diff --git a/click.go b/click.go index a08f60b..6d2614b 100644 --- a/click.go +++ b/click.go @@ -10,6 +10,7 @@ import ( func (w *guiWidget) doWidgetClick() { switch w.WidgetType { + /* case widget.Root: // THIS IS THE BEGINING OF THE LAYOUT log.Log(NOW, "doWidgetClick()", w.String()) @@ -18,6 +19,7 @@ func (w *guiWidget) doWidgetClick() { case widget.Flag: log.Log(NOW, "doWidgetClick() FLAG widget name =", w.String()) log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?") + */ case widget.Window: log.Log(NOW, "doWidgetClick() START on window", w.String()) // if the user clicked on the current window, do nothing diff --git a/main.go b/main.go index c6ec435..0a73e49 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,7 @@ func init() { me.myTree = tree.New() me.myTree.PluginName = "gocui" me.myTree.ActionFromChannel = action + // me.myTree.NodeAction = nodeaction // pluginChan = make(chan widget.Action) diff --git a/plugin.go b/plugin.go index 4c84323..673f184 100644 --- a/plugin.go +++ b/plugin.go @@ -7,6 +7,13 @@ import ( "go.wit.com/widget" ) +/* +func newaction(n *tree.Node, atype widget.ActionType) { + switch a.ActionType { + case widget.Add: +} +*/ + func action(a widget.Action) { log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName) // n := me.rootNode.findWidgetId(a.WidgetId) @@ -34,9 +41,7 @@ func action(a widget.Action) { } else { w.setColor(&colorDisabled) } - if w.hidden { - w.SetVisible(false) - } + w.Show() } else { // this is done to protect the plugin being 'refreshed' with the // 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) } case widget.Show: - w.node.State.Hidden = false - if w.Visible() { - // widget was already shown - } else { - log.Log(INFO, "Setting Visible to true", a.ProgName) - w.SetVisible(true) - } + log.Log(NOW, "Show() HERE. a.Hidden() was =", a.State.Hidden) + w.Show() case widget.Hide: - w.node.State.Hidden = true - log.Log(NOW, "HIDE HERE. a.State.Hidden =", a.State.Hidden) - 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 - } + log.Log(NOW, "Hide() HERE. a.State.Hidden was =", a.State.Hidden) + w.Hide() case widget.Set: if a.WidgetType == widget.Flag { log.Log(NOW, "TODO: set flag here", a.ActionType, a.WidgetType, a.ProgName) diff --git a/size.go b/size.go index a7581e2..cc09118 100644 --- a/size.go +++ b/size.go @@ -13,7 +13,7 @@ func (tk *guiWidget) Size() (int, int) { } // don't count hidden widgets in size calculations - if tk.hidden { + if tk.node.Hidden() { return 0, 0 } @@ -22,7 +22,7 @@ func (tk *guiWidget) Size() (int, int) { var maxH int = 0 var maxW int = 0 for _, child := range tk.children { - if tk.hidden { + if tk.node.Hidden() { continue } sizeW, sizeH := child.Size() @@ -43,7 +43,7 @@ func (tk *guiWidget) Size() (int, int) { maxH := tk.gocuiSize.Height() for _, child := range tk.children { - if tk.hidden { + if tk.node.Hidden() { continue } sizeW, sizeH := child.Size() @@ -67,13 +67,13 @@ func (tk *guiWidget) Size() (int, int) { } func (w *guiWidget) sizeGrid() (int, int) { - if w.hidden { + if w.node.Hidden() { return 0, 0 } // first compute the max sizes of the rows and columns for _, child := range w.children { - if w.hidden { + if w.node.Hidden() { continue } sizeW, sizeH := child.Size() @@ -105,14 +105,14 @@ func (w *guiWidget) sizeBox() (int, int) { if w.WidgetType != widget.Box { return 0, 0 } - if w.hidden { + if w.node.Hidden() { return 0, 0 } var maxW int = 0 var maxH int = 0 for _, child := range w.children { - if w.hidden { + if w.node.Hidden() { continue } sizeW, sizeH := child.Size() diff --git a/structs.go b/structs.go index 4a3cd50..4fc2df1 100644 --- a/structs.go +++ b/structs.go @@ -150,7 +150,7 @@ type guiWidget struct { enable bool defaultColor *colorT // store the color to go back to - hidden bool + // hidden bool // AtW int // AtH int diff --git a/widget.go b/widget.go index 8da42b6..a7747e8 100644 --- a/widget.go +++ b/widget.go @@ -22,7 +22,6 @@ func initWidget(n *tree.Node) *guiWidget { w.labelN = n.GetProgName() } w.frame = true - w.hidden = n.State.Hidden w.enable = n.State.Enable if n.WidgetType == widget.Root { @@ -121,7 +120,7 @@ func (w *guiWidget) Show() { } // always show window titles - if w.node.WidgetType != widget.Window { + if w.node.WidgetType == widget.Window { w.drawView() return } @@ -137,7 +136,7 @@ func (w *guiWidget) Show() { log.Log(NOW, "Show() drawing", w.cuiName, w.String()) // finally, check if the widget State is hidden or not - if w.node.State.Hidden { + if w.node.Hidden() { // don't display hidden widgets return }