diff options
Diffstat (limited to 'toolkit')
| -rw-r--r-- | toolkit/andlabs/action.go | 4 | ||||
| -rw-r--r-- | toolkit/andlabs/add.go | 9 | ||||
| -rw-r--r-- | toolkit/andlabs/debug.go | 12 | ||||
| -rw-r--r-- | toolkit/andlabs/main.go | 11 | ||||
| -rw-r--r-- | toolkit/andlabs/updateui.go | 3 | ||||
| -rw-r--r-- | toolkit/gocui/debug.go | 3 | ||||
| -rw-r--r-- | toolkit/gocui/main.go | 2 | ||||
| -rw-r--r-- | toolkit/gocui/plugin.go | 38 | ||||
| -rw-r--r-- | toolkit/gocui/view.go | 53 |
9 files changed, 100 insertions, 35 deletions
diff --git a/toolkit/andlabs/action.go b/toolkit/andlabs/action.go index 29b797a..5352fc8 100644 --- a/toolkit/andlabs/action.go +++ b/toolkit/andlabs/action.go @@ -38,11 +38,11 @@ func (n *node) enable(b bool) { } func (n *node) pad(at toolkit.ActionType) { - log(debugError, "pad()") + log(logInfo, "pad() on WidgetId =", n.WidgetId) t := n.tk if (t == nil) { - log(debugError, "pad() toolkit struct == nil. for", n.WidgetId) + log(logError, "pad() toolkit struct == nil. for", n.WidgetId) return } diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go index 9963b79..82d962f 100644 --- a/toolkit/andlabs/add.go +++ b/toolkit/andlabs/add.go @@ -127,15 +127,16 @@ func (p *node) place(n *node) bool { return true case toolkit.Tab: if (p.tk.uiTab == nil) { - log(logError, "p.tk.uiTab == nil", p.tk) + log(logError, "p.tk.uiTab == nil for n.WidgetId =", n.WidgetId, "p.tk =", p.tk) panic("p.tk.uiTab == nil") } if (n.tk.uiControl == nil) { - log(logError, "n.tk.uiControl == nil", n.tk) + log(logError, "n.tk.uiControl == nil for n.WidgetId =", n.WidgetId, "n.tk =", n.tk) panic("n.tk.uiControl == nil") } - log(logError, "THIS SHOULD NEVER HAPPEN ??????? trying to place() node=", n.WidgetId, n.Name, n.Text, n.WidgetType) - log(logError, "THIS SHOULD NEVER HAPPEN ??????? trying to place() on parent=", p.WidgetId, p.Name, p.Text, p.WidgetType) + log(logError, "CHECK LOGIC ON THIS. APPENDING directly into a window without a tab") + // log(logError, "THIS SHOULD NEVER HAPPEN ??????? trying to place() node=", n.WidgetId, n.Name, n.Text, n.WidgetType) + // log(logError, "THIS SHOULD NEVER HAPPEN ??????? trying to place() on parent=", p.WidgetId, p.Name, p.Text, p.WidgetType) // panic("n.tk.uiControl == nil") p.tk.uiTab.Append(n.Text, n.tk.uiControl) p.tk.boxC += 1 diff --git a/toolkit/andlabs/debug.go b/toolkit/andlabs/debug.go index 33f8c44..d9f8e58 100644 --- a/toolkit/andlabs/debug.go +++ b/toolkit/andlabs/debug.go @@ -14,12 +14,12 @@ var stretchy bool // expand things like buttons to the maximum size var padded bool // add space between things like buttons var margin bool // add space around the frames of windows -var debugToolkit bool = true -var debugChange bool = true -var debugPlugin bool = true -var debugAction bool = true -var debugFlags bool = true -var debugGrid bool = true +var debugToolkit bool = false +var debugChange bool = false +var debugPlugin bool = false +var debugAction bool = false +var debugFlags bool = false +var debugGrid bool = false var debugNow bool = true var debugError bool = true diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go index e2d34a3..3430769 100644 --- a/toolkit/andlabs/main.go +++ b/toolkit/andlabs/main.go @@ -40,13 +40,18 @@ func init() { // log(debugToolkit, "init() Setting defaultBehavior = true") setDefaultBehavior(true) - // andlabs = make(map[int]*andlabsT) - pluginChan = make(chan toolkit.Action, 1) - log(logNow, "Init() start channel reciever") + // TODO: this is messed up. run ui.Main() from the first add? Initialize it with an empty thing first? + // fake out the OS toolkit by making a fake window. This is probably needed for macos & windows + // actually, this probably breaks the macos build go ui.Main(func() { demoUI() }) + + // andlabs = make(map[int]*andlabsT) + pluginChan = make(chan toolkit.Action, 1) + + log(logNow, "Init() start channel reciever") go catchActionChannel() log(logNow, "Init() END") } diff --git a/toolkit/andlabs/updateui.go b/toolkit/andlabs/updateui.go index 4752d67..c43e15f 100644 --- a/toolkit/andlabs/updateui.go +++ b/toolkit/andlabs/updateui.go @@ -86,7 +86,8 @@ func demoUI() { messageLabel.SetText("") }) - mainWindow.Show() + // this is messed up. + // mainWindow.Show() } /* diff --git a/toolkit/gocui/debug.go b/toolkit/gocui/debug.go index 7512c1e..2669067 100644 --- a/toolkit/gocui/debug.go +++ b/toolkit/gocui/debug.go @@ -45,7 +45,8 @@ func (n *node) showWidgetPlacement(b bool, s string) { s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH) } } - log(b, s1, s, n.WidgetType, ",", n.Name) // , "text=", w.text) + tmp := "." + n.Name + "." + log(b, s1, s, n.WidgetType, ",", tmp) // , "text=", w.text) } func (n *node) dumpWidget(pad string) { diff --git a/toolkit/gocui/main.go b/toolkit/gocui/main.go index 04e1255..11f525a 100644 --- a/toolkit/gocui/main.go +++ b/toolkit/gocui/main.go @@ -43,7 +43,7 @@ func catchActionChannel() { log(logError,"ERROR: console did not initialize") continue } - log(logNow, "catchActionChannel()", a.WidgetId, a.ActionType, a.WidgetType, a.Name) + log(logInfo, "catchActionChannel()", a.WidgetId, a.ActionType, a.WidgetType, a.Name) action(&a) } } diff --git a/toolkit/gocui/plugin.go b/toolkit/gocui/plugin.go index eae811d..18cb71f 100644 --- a/toolkit/gocui/plugin.go +++ b/toolkit/gocui/plugin.go @@ -51,8 +51,22 @@ func action(a *toolkit.Action) { case toolkit.CloseToolkit: log(logNow, "attempting to close the plugin and release stdout and stderr") standardExit() + case toolkit.Enable: + if n.Visible() { + // widget was already shown + } else { + log(logInfo, "Setting Visable to true", a.Name) + n.SetVisible(true) + } + case toolkit.Disable: + if n.Visible() { + log(logInfo, "Setting Visable to false", a.Name) + n.SetVisible(false) + } else { + // widget was already hidden + } default: - log(logError, "action() Unknown =", a.ActionType, a.WidgetType, a.Name) + log(logError, "action() ActionType =", a.ActionType, "WidgetType =", a.WidgetType, "Name =", a.Name) } log(logInfo, "action() END") } @@ -70,16 +84,28 @@ func (n *node) AddText(text string) { } func (n *node) SetText(text string) { + var changed bool = false if (n == nil) { log(logNow, "widget is nil") return } - n.S = text - n.Text = text + if (n.Text != text) { + n.Text = text + changed = true + } + if (n.S != text) { + n.S = text + changed = true + } + if (! changed) { + return + } - n.textResize() - n.deleteView() - n.showView() + if (n.Visible()) { + n.textResize() + n.deleteView() + n.showView() + } } func (n *node) Set(val any) { diff --git a/toolkit/gocui/view.go b/toolkit/gocui/view.go index e69bf7c..28b80e0 100644 --- a/toolkit/gocui/view.go +++ b/toolkit/gocui/view.go @@ -20,20 +20,30 @@ func splitLines(s string) []string { return lines } -func (n *node) textResize() { +func (n *node) textResize() bool { w := n.tk var width, height int = 0, 0 + var changed bool = false for i, s := range splitLines(n.Text) { - log(logNow, "textResize() len =", len(s), i, s) + log(logInfo, "textResize() len =", len(s), i, s) if (width < len(s)) { width = len(s) } height += 1 } - w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW - w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH - n.showWidgetPlacement(logNow, "textResize()") + if (w.gocuiSize.w1 != w.gocuiSize.w0 + width + me.FramePadW) { + w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW + changed = true + } + if (w.gocuiSize.h1 != w.gocuiSize.h0 + height + me.FramePadH) { + w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH + changed = true + } + if (changed) { + n.showWidgetPlacement(logNow, "textResize() changed") + } + return changed } func (n *node) hideView() { @@ -58,17 +68,38 @@ func (n *node) showView() { x0, y0, x1, y1, err := me.baseGui.ViewPosition(w.cuiName) log(logInfo, "showView() w.v already defined for widget", n.Name, err) + // n.smartGocuiSize() + changed := n.textResize() + + if (changed) { + log(logNow, "showView() textResize() changed. Should recreateView here wId =", w.cuiName) + } else { + log(logNow, "showView() Clear() and Fprint() here wId =", w.cuiName) + w.v.Clear() + fmt.Fprint(w.v, n.Text) + n.SetVisible(false) + n.SetVisible(true) + return + } + // if the gocui element has changed where it is supposed to be on the screen // recreate it - if (x0 != w.gocuiSize.w0) || (y0 != w.gocuiSize.h0) { - log(logError, "showView() w.v.w0 != x0", n.Name, w.gocuiSize.w0, x0) - log(logError, "showView() w.v.h0 != y0", n.Name, w.gocuiSize.h0, y0) + if (x0 != w.gocuiSize.w0) { + n.recreateView() + return + } + if (y0 != w.gocuiSize.h0) { + log(logError, "showView() start hight mismatch id=", w.cuiName, "gocui h vs computed h =", w.gocuiSize.h0, y0) + n.recreateView() + return + } + if (x1 != w.gocuiSize.w1) { + log(logError, "showView() too wide", w.cuiName, "w,w", w.gocuiSize.w1, x1) n.recreateView() return } - if (x1 != w.gocuiSize.w1) || (y1 != w.gocuiSize.h1) { - log(logError, "showView() w.v.w1 != x1", n.Name, w.gocuiSize.w1, x1) - log(logError, "showView() w.v.h1 != y1", n.Name, w.gocuiSize.h1, y1) + if (y1 != w.gocuiSize.h1) { + log(logError, "showView() too high", w.cuiName, "h,h", w.gocuiSize.h1, y1) n.recreateView() return } |
