use treeNode.Hidden()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
825be13ee9
commit
cf72809e26
2
click.go
2
click.go
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
func (w *guiWidget) doWidgetClick() {
|
func (w *guiWidget) doWidgetClick() {
|
||||||
switch w.WidgetType {
|
switch w.WidgetType {
|
||||||
|
/*
|
||||||
case widget.Root:
|
case widget.Root:
|
||||||
// THIS IS THE BEGINING OF THE LAYOUT
|
// THIS IS THE BEGINING OF THE LAYOUT
|
||||||
log.Log(NOW, "doWidgetClick()", w.String())
|
log.Log(NOW, "doWidgetClick()", w.String())
|
||||||
|
@ -18,6 +19,7 @@ func (w *guiWidget) doWidgetClick() {
|
||||||
case widget.Flag:
|
case widget.Flag:
|
||||||
log.Log(NOW, "doWidgetClick() FLAG widget name =", w.String())
|
log.Log(NOW, "doWidgetClick() FLAG widget name =", w.String())
|
||||||
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
||||||
|
*/
|
||||||
case widget.Window:
|
case widget.Window:
|
||||||
log.Log(NOW, "doWidgetClick() START on window", w.String())
|
log.Log(NOW, "doWidgetClick() START on window", w.String())
|
||||||
// if the user clicked on the current window, do nothing
|
// if the user clicked on the current window, do nothing
|
||||||
|
|
1
main.go
1
main.go
|
@ -27,6 +27,7 @@ func init() {
|
||||||
me.myTree = tree.New()
|
me.myTree = tree.New()
|
||||||
me.myTree.PluginName = "gocui"
|
me.myTree.PluginName = "gocui"
|
||||||
me.myTree.ActionFromChannel = action
|
me.myTree.ActionFromChannel = action
|
||||||
|
// me.myTree.NodeAction = nodeaction
|
||||||
|
|
||||||
// pluginChan = make(chan widget.Action)
|
// pluginChan = make(chan widget.Action)
|
||||||
|
|
||||||
|
|
31
plugin.go
31
plugin.go
|
@ -7,6 +7,13 @@ import (
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
func newaction(n *tree.Node, atype widget.ActionType) {
|
||||||
|
switch a.ActionType {
|
||||||
|
case widget.Add:
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func action(a widget.Action) {
|
func action(a widget.Action) {
|
||||||
log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
||||||
// n := me.rootNode.findWidgetId(a.WidgetId)
|
// n := me.rootNode.findWidgetId(a.WidgetId)
|
||||||
|
@ -34,9 +41,7 @@ func action(a widget.Action) {
|
||||||
} else {
|
} else {
|
||||||
w.setColor(&colorDisabled)
|
w.setColor(&colorDisabled)
|
||||||
}
|
}
|
||||||
if w.hidden {
|
w.Show()
|
||||||
w.SetVisible(false)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// this is done to protect the plugin being 'refreshed' with the
|
// this is done to protect the plugin being 'refreshed' with the
|
||||||
// widget binary tree. TODO: find a way to keep them in sync
|
// widget binary tree. TODO: find a way to keep them in sync
|
||||||
|
@ -44,23 +49,11 @@ func action(a widget.Action) {
|
||||||
a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
||||||
}
|
}
|
||||||
case widget.Show:
|
case widget.Show:
|
||||||
w.node.State.Hidden = false
|
log.Log(NOW, "Show() HERE. a.Hidden() was =", a.State.Hidden)
|
||||||
if w.Visible() {
|
w.Show()
|
||||||
// widget was already shown
|
|
||||||
} else {
|
|
||||||
log.Log(INFO, "Setting Visible to true", a.ProgName)
|
|
||||||
w.SetVisible(true)
|
|
||||||
}
|
|
||||||
case widget.Hide:
|
case widget.Hide:
|
||||||
w.node.State.Hidden = true
|
log.Log(NOW, "Hide() HERE. a.State.Hidden was =", a.State.Hidden)
|
||||||
log.Log(NOW, "HIDE HERE. a.State.Hidden =", a.State.Hidden)
|
w.Hide()
|
||||||
log.Log(NOW, "HIDE HERE. w.hidden =", w.hidden)
|
|
||||||
if w.Visible() {
|
|
||||||
log.Log(INFO, "Setting Visible to false", a.ProgName)
|
|
||||||
w.SetVisible(false)
|
|
||||||
} else {
|
|
||||||
// widget was already hidden
|
|
||||||
}
|
|
||||||
case widget.Set:
|
case widget.Set:
|
||||||
if a.WidgetType == widget.Flag {
|
if a.WidgetType == widget.Flag {
|
||||||
log.Log(NOW, "TODO: set flag here", a.ActionType, a.WidgetType, a.ProgName)
|
log.Log(NOW, "TODO: set flag here", a.ActionType, a.WidgetType, a.ProgName)
|
||||||
|
|
14
size.go
14
size.go
|
@ -13,7 +13,7 @@ func (tk *guiWidget) Size() (int, int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't count hidden widgets in size calculations
|
// don't count hidden widgets in size calculations
|
||||||
if tk.hidden {
|
if tk.node.Hidden() {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ func (tk *guiWidget) Size() (int, int) {
|
||||||
var maxH int = 0
|
var maxH int = 0
|
||||||
var maxW int = 0
|
var maxW int = 0
|
||||||
for _, child := range tk.children {
|
for _, child := range tk.children {
|
||||||
if tk.hidden {
|
if tk.node.Hidden() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sizeW, sizeH := child.Size()
|
sizeW, sizeH := child.Size()
|
||||||
|
@ -43,7 +43,7 @@ func (tk *guiWidget) Size() (int, int) {
|
||||||
maxH := tk.gocuiSize.Height()
|
maxH := tk.gocuiSize.Height()
|
||||||
|
|
||||||
for _, child := range tk.children {
|
for _, child := range tk.children {
|
||||||
if tk.hidden {
|
if tk.node.Hidden() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sizeW, sizeH := child.Size()
|
sizeW, sizeH := child.Size()
|
||||||
|
@ -67,13 +67,13 @@ func (tk *guiWidget) Size() (int, int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *guiWidget) sizeGrid() (int, int) {
|
func (w *guiWidget) sizeGrid() (int, int) {
|
||||||
if w.hidden {
|
if w.node.Hidden() {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// first compute the max sizes of the rows and columns
|
// first compute the max sizes of the rows and columns
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
if w.hidden {
|
if w.node.Hidden() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sizeW, sizeH := child.Size()
|
sizeW, sizeH := child.Size()
|
||||||
|
@ -105,14 +105,14 @@ func (w *guiWidget) sizeBox() (int, int) {
|
||||||
if w.WidgetType != widget.Box {
|
if w.WidgetType != widget.Box {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
if w.hidden {
|
if w.node.Hidden() {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
var maxW int = 0
|
var maxW int = 0
|
||||||
var maxH int = 0
|
var maxH int = 0
|
||||||
|
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
if w.hidden {
|
if w.node.Hidden() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sizeW, sizeH := child.Size()
|
sizeW, sizeH := child.Size()
|
||||||
|
|
|
@ -150,7 +150,7 @@ type guiWidget struct {
|
||||||
enable bool
|
enable bool
|
||||||
defaultColor *colorT // store the color to go back to
|
defaultColor *colorT // store the color to go back to
|
||||||
|
|
||||||
hidden bool
|
// hidden bool
|
||||||
|
|
||||||
// AtW int
|
// AtW int
|
||||||
// AtH int
|
// AtH int
|
||||||
|
|
|
@ -22,7 +22,6 @@ func initWidget(n *tree.Node) *guiWidget {
|
||||||
w.labelN = n.GetProgName()
|
w.labelN = n.GetProgName()
|
||||||
}
|
}
|
||||||
w.frame = true
|
w.frame = true
|
||||||
w.hidden = n.State.Hidden
|
|
||||||
w.enable = n.State.Enable
|
w.enable = n.State.Enable
|
||||||
|
|
||||||
if n.WidgetType == widget.Root {
|
if n.WidgetType == widget.Root {
|
||||||
|
@ -121,7 +120,7 @@ func (w *guiWidget) Show() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// always show window titles
|
// always show window titles
|
||||||
if w.node.WidgetType != widget.Window {
|
if w.node.WidgetType == widget.Window {
|
||||||
w.drawView()
|
w.drawView()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -137,7 +136,7 @@ func (w *guiWidget) Show() {
|
||||||
log.Log(NOW, "Show() drawing", w.cuiName, w.String())
|
log.Log(NOW, "Show() drawing", w.cuiName, w.String())
|
||||||
|
|
||||||
// finally, check if the widget State is hidden or not
|
// finally, check if the widget State is hidden or not
|
||||||
if w.node.State.Hidden {
|
if w.node.Hidden() {
|
||||||
// don't display hidden widgets
|
// don't display hidden widgets
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue