diff options
| -rw-r--r-- | eventBindings.go | 13 | ||||
| -rw-r--r-- | plugin.go | 23 | ||||
| -rw-r--r-- | structs.go | 1 | ||||
| -rw-r--r-- | treeDraw.go | 42 |
4 files changed, 74 insertions, 5 deletions
diff --git a/eventBindings.go b/eventBindings.go index cb80a0f..65296a7 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -71,6 +71,19 @@ func theSuperMouse(g *gocui.Gui, v *gocui.View) error { // use this to test code ideas // put whatever you want here and hit '2' to activate it func theNotsure(g *gocui.Gui, v *gocui.View) error { log.Info("got to theNotsure(). now what? dark =", me.dark) + if me.debug { + log.Info("debugging off") + me.debug = false + } else { + log.Info("debugging on") + me.debug = true + } + win := findWindowUnderMouse() + if win != nil { + win.dumpWidget("found() win. redrawing window:") + win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0) + } + return nil } @@ -99,12 +99,19 @@ func newaction(n *tree.Node, atype widget.ActionType) { w := n.TK.(*guiWidget) switch atype { case widget.Show: + if me.debug { + w.dumpWidget("Show()") + } + w.node.State.Hidden = false w.Show() case widget.Hide: + if me.debug { + w.dumpWidget("Hide()") + } if n.Hidden() { // already hidden } else { - log.Log(NOW, "attempt to hide() =", atype, n.WidgetId, n.WidgetType, n.ProgName()) + // log.Log(NOW, "attempt to hide() =", atype, n.WidgetId, n.WidgetType, n.ProgName()) w.node.State.Hidden = true w.Hide() } @@ -219,13 +226,16 @@ func (tk *guiWidget) Disable() { } tk.enable = false tk.node.State.Enable = false - log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) + // log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) switch tk.node.WidgetType { + case widget.Box: + log.Info("todo: blank out the window here") + return case widget.Button: tk.setColorDisable() return default: - log.Log(INFO, "don't know how to disable", tk.node.WidgetId, "w.name", tk.String()) + tk.dumpWidget("fixme: disable") } } @@ -236,12 +246,15 @@ func (tk *guiWidget) Enable() { } tk.enable = true tk.node.State.Enable = true - log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) + // log.Info("enable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) switch tk.node.WidgetType { + case widget.Box: + // log.Info("todo: blank out the window here") + return case widget.Button: tk.restoreEnableColor() return default: - log.Log(INFO, "don't know how to disable", tk.node.WidgetId, "w.name", tk.String()) + tk.dumpWidget("fixme: enable") } } @@ -74,6 +74,7 @@ type config struct { dark bool // use a 'dark' color palette mouse mouse // mouse settings showDebug bool // todo: move this into config struct + debug bool // todo: move this into config struct outf *os.File // hacks for capturing stdout } diff --git a/treeDraw.go b/treeDraw.go index 802e498..e9f9d20 100644 --- a/treeDraw.go +++ b/treeDraw.go @@ -13,6 +13,34 @@ import ( "go.wit.com/widget" ) +// don't draw widgets that are too far down the window +func (tk *guiWidget) doNotDraw() bool { + var check bool + switch tk.node.WidgetType { + case widget.Button: + check = true + case widget.Label: + check = true + default: + } + if !check { + return false + } + win := tk.findParentWindow() + if win == nil { + // don't draw anything if you can't find the parent window + return true + } + + h := tk.gocuiSize.h0 - win.gocuiSize.h0 + + if h > 20 { + return true + } + + return false +} + // display's the text of the widget in gocui // deletes the old view if it exists and recreates it func (tk *guiWidget) drawView() { @@ -33,11 +61,22 @@ func (tk *guiWidget) drawView() { me.baseGui.DeleteView(tk.cuiName) tk.v = nil + if tk.doNotDraw() { + return + } + a := tk.gocuiSize.w0 b := tk.gocuiSize.h0 c := tk.gocuiSize.w1 d := tk.gocuiSize.h1 + if tk.node.WidgetType == widget.Window || tk.node.WidgetType == widget.Flag { + if tk.gocuiSize.Height() > 30 { + tk.gocuiSize.h1 = tk.gocuiSize.h0 + 30 + d = tk.gocuiSize.h1 + } + } + // this is all terrible. This sets the title. kinda if tk.node.WidgetType == widget.Window { tk.textResize() @@ -139,6 +178,9 @@ func (w *guiWidget) Show() { // never show hidden widgets return } + if me.debug { + w.dumpWidget("drawView()") + } w.drawView() } |
