diff options
| author | Jeff Carr <[email protected]> | 2025-02-04 09:40:51 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-04 09:40:51 -0600 |
| commit | 5a28806bdf79f360e43deb45f3e68623fb3e45a2 (patch) | |
| tree | f33fd3f3cc254f85866b16167c15206c306008b8 /treeDraw.go | |
| parent | d2c681f573a44c5cd572dc8e0d6f470c0cda10ff (diff) | |
getting closer on windows
Diffstat (limited to 'treeDraw.go')
| -rw-r--r-- | treeDraw.go | 140 |
1 files changed, 74 insertions, 66 deletions
diff --git a/treeDraw.go b/treeDraw.go index 7c42693..f2cca36 100644 --- a/treeDraw.go +++ b/treeDraw.go @@ -10,9 +10,80 @@ import ( "github.com/awesome-gocui/gocui" log "go.wit.com/log" + "go.wit.com/widget" ) -var toggle bool = true +// display's the text of the widget in gocui +// deletes the old view if it exists and recreates it +func (tk *guiWidget) drawView() { + var err error + log.Log(INFO, "drawView() START", tk.node.WidgetType, tk.String()) + if me.baseGui == nil { + log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", tk) + return + } + + if tk.cuiName == "" { + log.Log(ERROR, "drawView() tk.cuiName was not set for widget", tk) + tk.cuiName = strconv.Itoa(tk.node.WidgetId) + " TK" + } + log.Log(INFO, "drawView() labelN =", tk.labelN) + + // this deletes the button from gocui + me.baseGui.DeleteView(tk.cuiName) + tk.v = nil + + if tk.node.WidgetType == widget.Window { + if !tk.resize { + tk.resize = true + tk.textResize() // resize window only once + } + } else { + tk.textResize() // resize everything except windows + } + a := tk.gocuiSize.w0 + b := tk.gocuiSize.h0 + c := tk.gocuiSize.w1 + d := tk.gocuiSize.h1 + + tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0) + if err == nil { + tk.dumpWidget("drawView() err") + log.Log(ERROR, "drawView() internal plugin error err = nil") + return + } + if !errors.Is(err, gocui.ErrUnknownView) { + tk.dumpWidget("drawView() err") + log.Log(ERROR, "drawView() internal plugin error error.IS()", err) + return + } + + // this sets up the keybinding for the name of the window + // does this really need to be done? I think we probably already + // know everything about where all the widgets are so we could bypass + // the gocui package and just handle all the mouse events internally here (?) + // for now, the w.v.Name is a string "1", "2", "3", etc from the widgetId + + // set the binding for this gocui view now that it has been created + // gocui handles overlaps of views so it will run on the view that is clicked on + // me.baseGui.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click) + + // this actually sends the text to display to gocui + tk.v.Wrap = true + tk.v.Frame = tk.frame + tk.v.Clear() + fmt.Fprint(tk.v, tk.labelN) + + // if you don't do this here, it will be black & white only + if tk.color != nil { + tk.v.FrameColor = tk.color.frame + tk.v.FgColor = tk.color.fg + tk.v.BgColor = tk.color.bg + tk.v.SelFgColor = tk.color.selFg + tk.v.SelBgColor = tk.color.selBg + } + log.Log(INFO, "drawView() END") +} func (w *guiWidget) DrawAt(offsetW, offsetH int) { w.setColor(&colorActiveW) @@ -27,6 +98,8 @@ func (w *guiWidget) simpleDrawAt(offsetW, offsetH int) { w.dumpWidget("simpleDrawAt()") } +var toggle bool = true + func (w *guiWidget) toggleTree() { if toggle { w.drawTree(toggle) @@ -54,68 +127,3 @@ func (w *guiWidget) drawTree(draw bool) { child.drawTree(draw) } } - -// display's the text of the widget in gocui -// deletes the old view if it exists and recreates it -func (w *guiWidget) drawView() { - var err error - log.Log(INFO, "drawView() START", w.node.WidgetType, w.String()) - if me.baseGui == nil { - log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", w) - return - } - - if w.cuiName == "" { - log.Log(ERROR, "drawView() w.cuiName was not set for widget", w) - w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK" - } - log.Log(INFO, "drawView() labelN =", w.labelN) - - // this deletes the button from gocui - me.baseGui.DeleteView(w.cuiName) - w.v = nil - - w.textResize() - a := w.gocuiSize.w0 - b := w.gocuiSize.h0 - c := w.gocuiSize.w1 - d := w.gocuiSize.h1 - - w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0) - if err == nil { - w.dumpWidget("drawView() err") - log.Log(ERROR, "drawView() internal plugin error err = nil") - return - } - if !errors.Is(err, gocui.ErrUnknownView) { - w.dumpWidget("drawView() err") - log.Log(ERROR, "drawView() internal plugin error error.IS()", err) - return - } - - // this sets up the keybinding for the name of the window - // does this really need to be done? I think we probably already - // know everything about where all the widgets are so we could bypass - // the gocui package and just handle all the mouse events internally here (?) - // for now, the w.v.Name is a string "1", "2", "3", etc from the widgetId - - // set the binding for this gocui view now that it has been created - // gocui handles overlaps of views so it will run on the view that is clicked on - // me.baseGui.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click) - - // this actually sends the text to display to gocui - w.v.Wrap = true - w.v.Frame = w.frame - w.v.Clear() - fmt.Fprint(w.v, w.labelN) - - // if you don't do this here, it will be black & white only - if w.color != nil { - w.v.FrameColor = w.color.frame - w.v.FgColor = w.color.fg - w.v.BgColor = w.color.bg - w.v.SelFgColor = w.color.selFg - w.v.SelBgColor = w.color.selBg - } - log.Log(INFO, "drawView() END") -} |
