function rename

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-05 03:05:37 -06:00
parent 2ee37e5c20
commit 063c40accd
9 changed files with 51 additions and 63 deletions

View File

@ -26,6 +26,6 @@ func (w *guiWidget) setCheckbox() {
// t := len(w.labelN) + 3
// w.gocuiSize.w1 = w.gocuiSize.w0 + t
w.deleteView()
w.Hide()
w.Show()
}

View File

@ -223,11 +223,5 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
tk.gocuiSize.h0 = newR.h0
tk.gocuiSize.w1 = newR.w1
tk.gocuiSize.h1 = newR.h1
if tk.Visible() {
// me.ctrlDown.hideView()
} else {
// me.ctrlDown.showView()
}
// me.ctrlDown.showWidgetPlacement("ctrlDown:")
return nil
}

View File

@ -145,10 +145,6 @@ func (w *guiWidget) enableColor() {
w.setColor(w.defaultColor)
}
func (w *guiWidget) setDefaultWidgetColor() {
w.showView()
}
func (w *guiWidget) setDefaultHighlight() {
if w.v == nil {
log.Log(ERROR, "SetColor() failed on view == nil")
@ -172,7 +168,8 @@ func (w *guiWidget) redoColor(draw bool) {
log.Sleep(.05)
w.setDefaultHighlight()
w.setDefaultWidgetColor()
// w.setDefaultWidgetColor()
w.Show()
for _, child := range w.children {
child.redoColor(draw)

View File

@ -27,9 +27,9 @@ func (w *guiWidget) drawTree(draw bool) {
w.showWidgetPlacement("drawTree()")
if draw {
// w.textResize()
w.showView()
w.Show()
} else {
w.deleteView()
w.Hide()
}
for _, child := range w.children {

View File

@ -32,8 +32,6 @@ var helpText []string = []string{"KEYBINDINGS",
func hidehelplayout() {
me.baseGui.DeleteView("help")
// n.deleteView()
// child.hideFake()
}
func helplayout() error {

View File

@ -160,8 +160,8 @@ func (w *guiWidget) SetText(text string) {
if w.Visible() {
w.textResize()
w.deleteView()
w.showView()
w.Hide()
w.Show()
}
}

42
view.go
View File

@ -48,23 +48,9 @@ func (w *guiWidget) textResize() bool {
return changed
}
func (w *guiWidget) hideView() {
w.deleteView()
}
// display's the text of the widget in gocui
// will create a new gocui view if there isn't one or if it has been moved
func (w *guiWidget) showView() {
if w.cuiName == "" {
log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
}
log.Log(INFO, "showView() labelN =", w.labelN)
w.recreateView()
}
// 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() {
var err error
@ -74,6 +60,12 @@ func (w *guiWidget) recreateView() {
return
}
if w.cuiName == "" {
log.Log(ERROR, "recreateView() w.cuiName was not set for widget", w)
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
}
log.Log(INFO, "recreateView() labelN =", w.labelN)
// this deletes the button from gocui
me.baseGui.DeleteView(w.cuiName)
w.v = nil
@ -111,8 +103,6 @@ func (w *guiWidget) recreateView() {
w.v.Frame = w.frame
w.v.Clear()
fmt.Fprint(w.v, w.labelN)
// n.showWidgetPlacement("n.String()=" + n.String() + " n.tk.label=" + n.tk.label + " " + w.cuiName)
// n.dumpWidget("jwc 2")
// if you don't do this here, it will be black & white only
if w.color != nil {
@ -137,7 +127,7 @@ func (w *guiWidget) hideWidgets() {
case widget.Box:
case widget.Grid:
default:
w.hideView()
w.Hide()
}
for _, child := range w.children {
child.hideWidgets()
@ -158,7 +148,7 @@ func showFake() {
func (w *guiWidget) hideFake() {
if w.isFake {
w.hideView()
w.Hide()
}
for _, child := range w.children {
child.hideFake()
@ -167,8 +157,7 @@ func (w *guiWidget) hideFake() {
func (w *guiWidget) showFake() {
if w.isFake {
// w.setFake()
w.showView()
w.recreateView()
w.showWidgetPlacement("showFake:")
}
for _, child := range w.children {
@ -177,15 +166,8 @@ func (w *guiWidget) showFake() {
}
func (w *guiWidget) showWidgets() {
if w.isFake {
// don't display by default
} else {
if w.node.State.Hidden {
// don't display hidden views
} else {
w.showView()
}
}
w.Show()
for _, child := range w.children {
child.showWidgets()
}

View File

@ -101,35 +101,49 @@ func (tk *guiWidget) Visible() bool {
return true
}
func (tk *guiWidget) Show() {
func (w *guiWidget) Show() {
// always should the dropdown widget
if tk == me.dropdownV {
me.dropdownV.showView()
if w== me.dropdownV {
me.dropdownV.recreateView()
return
}
// don't display fake widgets
if w.isFake {
return
}
// if this isn't in the binary tree
// it's some internal widget so always display those
if tk.node == nil {
tk.showView()
if w.node == nil {
w.recreateView()
return
}
// always show window titles
if w.node.WidgetType != widget.Window {
w.recreateView()
return
}
// if the widget is not in the current displayed windo
// then ignore it
log.Log(NOW, "Show() tk =", tk.cuiName, tk.String())
log.Log(NOW, "Show() tk.IsCurrent() returned", tk.IsCurrent())
if ! tk.IsCurrent() {
log.Log(NOW, "Show() NOT drawing", tk.cuiName, tk.String())
log.Log(NOW, "Show() widget =", w.cuiName, w.String())
log.Log(NOW, "Show() w.IsCurrent() returned", w.IsCurrent())
if ! w.IsCurrent() {
log.Log(NOW, "Show() NOT drawing", w.cuiName, w.String())
return
}
log.Log(NOW, "Show() drawing", tk.cuiName, tk.String())
log.Log(NOW, "Show() drawing", w.cuiName, w.String())
// finally, check if the widget State is hidden or not
if tk.node.State.Hidden {
if w.node.State.Hidden {
// don't display hidden widgets
} else {
tk.showView()
return
}
// okay, if you made it this far, then display the widget
w.recreateView()
}
func (tk *guiWidget) Hide() {

View File

@ -17,8 +17,11 @@ func (w *guiWidget) redoWindows(nextW int, nextH int) {
child.hasTabs = false
child.gocuiSetWH(nextW, nextH)
child.deleteView()
child.showView()
child.Hide()
// use the direct method recreateView() to
// bypass sanity checks here (fix this?)
child.recreateView()
sizeW := child.gocuiSize.Width()
nextW += sizeW + 4
child.redoWindows(startW+3, startH+2)