From a15aea03ea4d0bc73d3773f7c77b380caa57153c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 5 Feb 2024 03:19:08 -0600 Subject: [PATCH] rename to drawView() Signed-off-by: Jeff Carr --- color.go | 2 +- draw.go | 22 ++++++++++------------ view.go | 4 +++- widget.go | 8 ++++---- window.go | 5 ++--- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/color.go b/color.go index 2201690..5e777f0 100644 --- a/color.go +++ b/color.go @@ -131,7 +131,7 @@ func (tk *guiWidget) setColor(newColor *colorT) { tk.color = &colorNone } log.Log(NOW, "Set the node to color =", tk.color.name) - tk.recreateView() + tk.Show() } func (w *guiWidget) disableColor() { diff --git a/draw.go b/draw.go index 0e485d6..5b92d9e 100644 --- a/draw.go +++ b/draw.go @@ -47,22 +47,20 @@ func (w *guiWidget) drawTree(draw bool) { } // display's the text of the widget in gocui -// create or recreate the gocui widget visible -// will create a new gocui view if there isn't one or if it has been moved // deletes the old view if it exists and recreates it -func (w *guiWidget) recreateView() { +func (w *guiWidget) drawView() { var err error - log.Log(INFO, "recreateView() START", w.WidgetType, w.String()) + log.Log(INFO, "drawView() START", w.WidgetType, w.String()) if me.baseGui == nil { - log.Log(ERROR, "recreateView() ERROR: me.baseGui == nil", w) + log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", w) return } if w.cuiName == "" { - log.Log(ERROR, "recreateView() w.cuiName was not set for widget", w) + log.Log(ERROR, "drawView() w.cuiName was not set for widget", w) w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK" } - log.Log(INFO, "recreateView() labelN =", w.labelN) + log.Log(INFO, "drawView() labelN =", w.labelN) // this deletes the button from gocui me.baseGui.DeleteView(w.cuiName) @@ -76,13 +74,13 @@ func (w *guiWidget) recreateView() { w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0) if err == nil { - w.showWidgetPlacement("recreateView()") - log.Log(ERROR, "recreateView() internal plugin error err = nil") + w.showWidgetPlacement("drawView()") + log.Log(ERROR, "drawView() internal plugin error err = nil") return } if !errors.Is(err, gocui.ErrUnknownView) { - w.showWidgetPlacement("recreateView()") - log.Log(ERROR, "recreateView() internal plugin error error.IS()", err) + w.showWidgetPlacement("drawView()") + log.Log(ERROR, "drawView() internal plugin error error.IS()", err) return } @@ -110,5 +108,5 @@ func (w *guiWidget) recreateView() { w.v.SelFgColor = w.color.selFg w.v.SelBgColor = w.color.selBg } - log.Log(INFO, "recreateView() END") + log.Log(INFO, "drawView() END") } diff --git a/view.go b/view.go index afbc1f7..6de283c 100644 --- a/view.go +++ b/view.go @@ -83,9 +83,11 @@ func (w *guiWidget) hideFake() { } } +// shows the 'fake' widgets for widgets that +// are not normally displayed (like a grid widget) func (w *guiWidget) showFake() { if w.isFake { - w.recreateView() + w.drawView() w.showWidgetPlacement("showFake:") } for _, child := range w.children { diff --git a/widget.go b/widget.go index 923032b..8da42b6 100644 --- a/widget.go +++ b/widget.go @@ -104,7 +104,7 @@ func (tk *guiWidget) Visible() bool { func (w *guiWidget) Show() { // always should the dropdown widget if w == me.dropdownV { - me.dropdownV.recreateView() + me.dropdownV.drawView() return } @@ -116,13 +116,13 @@ func (w *guiWidget) Show() { // if this isn't in the binary tree // it's some internal widget so always display those if w.node == nil { - w.recreateView() + w.drawView() return } // always show window titles if w.node.WidgetType != widget.Window { - w.recreateView() + w.drawView() return } @@ -143,7 +143,7 @@ func (w *guiWidget) Show() { } // okay, if you made it this far, then display the widget - w.recreateView() + w.drawView() } func (tk *guiWidget) Hide() { diff --git a/window.go b/window.go index 789a355..5e1b6ec 100644 --- a/window.go +++ b/window.go @@ -4,6 +4,7 @@ import ( "go.wit.com/widget" ) +// re-draws the buttons for each of the windows func (w *guiWidget) redoWindows(nextW int, nextH int) { var startW int = nextW var startH int = nextH @@ -19,9 +20,7 @@ func (w *guiWidget) redoWindows(nextW int, nextH int) { child.gocuiSetWH(nextW, nextH) child.Hide() - // use the direct method recreateView() to - // bypass sanity checks here (fix this?) - child.recreateView() + child.drawView() sizeW := child.gocuiSize.Width() nextW += sizeW + 4 child.redoWindows(startW+3, startH+2)