From 327e14f05154b1cfdb9af27b387cc3227cedca0d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 5 Jan 2024 13:30:00 -0600 Subject: [PATCH] andlabs compiles with 'go.wit.com/gui/widget' Signed-off-by: Jeff Carr --- andlabs/action.go | 126 ++++++++++++++++++++++---------------------- andlabs/add.go | 46 ++++++++-------- andlabs/debug.go | 4 +- andlabs/delete.go | 6 +-- andlabs/dropdown.go | 4 +- andlabs/main.go | 4 +- andlabs/setText.go | 58 ++++++++++---------- andlabs/tab.go | 6 +-- andlabs/widget.go | 6 +-- 9 files changed, 130 insertions(+), 130 deletions(-) diff --git a/andlabs/action.go b/andlabs/action.go index aedd8ae..57cbdba 100644 --- a/andlabs/action.go +++ b/andlabs/action.go @@ -3,7 +3,7 @@ package main import ( "strconv" "github.com/andlabs/ui" - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" ) func (n *node) show(b bool) { @@ -37,7 +37,7 @@ func (n *node) enable(b bool) { } } -func (n *node) pad(at toolkit.ActionType) { +func (n *node) pad(at widget.ActionType) { log(logInfo, "pad() on WidgetId =", n.WidgetId) t := n.tk @@ -47,62 +47,62 @@ func (n *node) pad(at toolkit.ActionType) { } switch n.WidgetType { - case toolkit.Group: + case widget.Group: switch at { - case toolkit.Margin: + case widget.Margin: t.uiGroup.SetMargined(true) - case toolkit.Unmargin: + case widget.Unmargin: t.uiGroup.SetMargined(false) - case toolkit.Pad: + case widget.Pad: t.uiGroup.SetMargined(true) - case toolkit.Unpad: + case widget.Unpad: t.uiGroup.SetMargined(false) } - case toolkit.Tab: + case widget.Tab: switch at { - case toolkit.Margin: + case widget.Margin: tabSetMargined(t.uiTab, true) - case toolkit.Unmargin: + case widget.Unmargin: tabSetMargined(t.uiTab, false) - case toolkit.Pad: + case widget.Pad: tabSetMargined(t.uiTab, true) - case toolkit.Unpad: + case widget.Unpad: tabSetMargined(t.uiTab, false) } - case toolkit.Window: + case widget.Window: switch at { - case toolkit.Margin: + case widget.Margin: t.uiWindow.SetMargined(true) - case toolkit.Unmargin: + case widget.Unmargin: t.uiWindow.SetMargined(false) - case toolkit.Pad: + case widget.Pad: t.uiWindow.SetBorderless(false) - case toolkit.Unpad: + case widget.Unpad: t.uiWindow.SetBorderless(true) } - case toolkit.Grid: + case widget.Grid: switch at { - case toolkit.Margin: + case widget.Margin: t.uiGrid.SetPadded(true) - case toolkit.Unmargin: + case widget.Unmargin: t.uiGrid.SetPadded(false) - case toolkit.Pad: + case widget.Pad: t.uiGrid.SetPadded(true) - case toolkit.Unpad: + case widget.Unpad: t.uiGrid.SetPadded(false) } - case toolkit.Box: + case widget.Box: switch at { - case toolkit.Margin: + case widget.Margin: t.uiBox.SetPadded(true) - case toolkit.Unmargin: + case widget.Unmargin: t.uiBox.SetPadded(false) - case toolkit.Pad: + case widget.Pad: t.uiBox.SetPadded(true) - case toolkit.Unpad: + case widget.Unpad: t.uiBox.SetPadded(false) } - case toolkit.Textbox: + case widget.Textbox: log(debugError, "TODO: implement ActionType =", at) default: log(debugError, "TODO: implement pad() for", at) @@ -113,14 +113,14 @@ func (n *node) move(newParent *node) { p := n.parent switch p.WidgetType { - case toolkit.Group: - case toolkit.Tab: + case widget.Group: + case widget.Tab: // tabSetMargined(tParent.uiTab, true) - case toolkit.Window: + case widget.Window: // t.uiWindow.SetBorderless(false) - case toolkit.Grid: + case widget.Grid: // t.uiGrid.SetPadded(true) - case toolkit.Box: + case widget.Box: log(logInfo, "TODO: move() where =", p.ParentId) log(logInfo, "TODO: move() for widget =", n.WidgetId) @@ -146,15 +146,15 @@ func (n *node) Delete() { log(debugNow, "uiDelete()", n.WidgetId, "to", p.WidgetId) switch p.WidgetType { - case toolkit.Group: + case widget.Group: // tParent.uiGroup.SetMargined(true) - case toolkit.Tab: + case widget.Tab: // tabSetMargined(tParent.uiTab, true) - case toolkit.Window: + case widget.Window: // t.uiWindow.SetBorderless(false) - case toolkit.Grid: + case widget.Grid: // t.uiGrid.SetPadded(true) - case toolkit.Box: + case widget.Box: log(debugNow, "tWidget.boxC =", p.Name) log(debugNow, "is there a tParent parent? =", p.parent) if (p.tk.boxC < 1) { @@ -174,11 +174,11 @@ func (n *node) Delete() { } } -func rawAction(a *toolkit.Action) { +func rawAction(a *widget.Action) { log(logInfo, "rawAction() START a.ActionType =", a.ActionType) log(logInfo, "rawAction() START a.S =", a.S) - if (a.ActionType == toolkit.InitToolkit) { + if (a.ActionType == widget.InitToolkit) { // TODO: make sure to only do this once // go uiMain.Do(func() { // ui.Main(demoUI) @@ -190,14 +190,14 @@ func rawAction(a *toolkit.Action) { log(logInfo, "rawAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId) switch a.WidgetType { - case toolkit.Flag: + case widget.Flag: flag(a) return } n := me.rootNode.findWidgetId(a.WidgetId) - if (a.ActionType == toolkit.Add) { + if (a.ActionType == widget.Add) { ui.QueueMain(func() { add(a) }) @@ -206,7 +206,7 @@ func rawAction(a *toolkit.Action) { return } - if (a.ActionType == toolkit.Dump) { + if (a.ActionType == widget.Dump) { log(debugNow, "rawAction() Dump =", a.ActionType, a.WidgetType, n.Name) me.rootNode.listChildren(true) return @@ -223,38 +223,38 @@ func rawAction(a *toolkit.Action) { } switch a.ActionType { - case toolkit.Show: + case widget.Show: n.show(true) - case toolkit.Hide: + case widget.Hide: n.show(false) - case toolkit.Enable: + case widget.Enable: n.enable(true) - case toolkit.Disable: + case widget.Disable: n.enable(false) - case toolkit.Get: + case widget.Get: n.setText(a) - case toolkit.GetText: + case widget.GetText: switch a.WidgetType { - case toolkit.Textbox: + case widget.Textbox: a.S = n.S } - case toolkit.Set: + case widget.Set: n.setText(a) - case toolkit.SetText: + case widget.SetText: n.setText(a) - case toolkit.AddText: + case widget.AddText: n.setText(a) - case toolkit.Margin: - n.pad(toolkit.Unmargin) - case toolkit.Unmargin: - n.pad(toolkit.Margin) - case toolkit.Pad: - n.pad(toolkit.Pad) - case toolkit.Unpad: - n.pad(toolkit.Unpad) - case toolkit.Delete: + case widget.Margin: + n.pad(widget.Unmargin) + case widget.Unmargin: + n.pad(widget.Margin) + case widget.Pad: + n.pad(widget.Pad) + case widget.Unpad: + n.pad(widget.Unpad) + case widget.Delete: n.Delete() - case toolkit.Move: + case widget.Move: log(debugNow, "rawAction() attempt to move() =", a.ActionType, a.WidgetType) newParent := me.rootNode.findWidgetId(a.ParentId) n.move(newParent) diff --git a/andlabs/add.go b/andlabs/add.go index a402955..a902608 100644 --- a/andlabs/add.go +++ b/andlabs/add.go @@ -4,10 +4,10 @@ import ( "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" ) -func actionDump(b bool, a *toolkit.Action) { +func actionDump(b bool, a *widget.Action) { log(b, "actionDump() Widget.Type =", a.ActionType) log(b, "actionDump() Widget.S =", a.S) log(b, "actionDump() Widget.I =", a.I) @@ -15,8 +15,8 @@ func actionDump(b bool, a *toolkit.Action) { log(b, "actionDump() ParentId =", a.ParentId) } -func add(a *toolkit.Action) { - if (a.WidgetType == toolkit.Root) { +func add(a *widget.Action) { + if (a.WidgetType == widget.Root) { me.rootNode = addNode(a) return } @@ -24,46 +24,46 @@ func add(a *toolkit.Action) { p := n.parent switch n.WidgetType { - case toolkit.Window: + case widget.Window: newWindow(n) return - case toolkit.Tab: + case widget.Tab: p.newTab(n) return - case toolkit.Label: + case widget.Label: p.newLabel(n) return - case toolkit.Button: + case widget.Button: p.newButton(n) return - case toolkit.Grid: + case widget.Grid: p.newGrid(n) return - case toolkit.Checkbox: + case widget.Checkbox: p.newCheckbox(n) return - case toolkit.Spinner: + case widget.Spinner: p.newSpinner(n) return - case toolkit.Slider: + case widget.Slider: p.newSlider(n) return - case toolkit.Dropdown: + case widget.Dropdown: p.newDropdown(n) return - case toolkit.Combobox: + case widget.Combobox: p.newCombobox(n) return - case toolkit.Textbox: + case widget.Textbox: p.newTextbox(n) return - case toolkit.Group: + case widget.Group: p.newGroup(n) return - case toolkit.Box: + case widget.Box: p.newBox(n) return - case toolkit.Image: + case widget.Image: p.newImage(n) return default: @@ -106,7 +106,7 @@ func (p *node) place(n *node) bool { log(logInfo, "place() switch", p.WidgetType) switch p.WidgetType { - case toolkit.Grid: + case widget.Grid: log(logInfo, "place() Grid try at Parent X,Y =", n.X, n.Y) n.tk.gridX = n.AtW - 1 n.tk.gridY = n.AtH - 1 @@ -116,7 +116,7 @@ func (p *node) place(n *node) bool { n.tk.gridX, n.tk.gridY, 1, 1, false, ui.AlignFill, false, ui.AlignFill) return true - case toolkit.Group: + case widget.Group: if (p.tk.uiBox == nil) { p.tk.uiGroup.SetChild(n.tk.uiControl) log(logInfo, "place() hack Group to use this as the box?", n.Name, n.WidgetType) @@ -125,7 +125,7 @@ func (p *node) place(n *node) bool { p.tk.uiBox.Append(n.tk.uiControl, stretchy) } return true - case toolkit.Tab: + case widget.Tab: if (p.tk.uiTab == nil) { log(logError, "p.tk.uiTab == nil for n.WidgetId =", n.WidgetId, "p.tk =", p.tk) panic("p.tk.uiTab == nil") @@ -141,13 +141,13 @@ func (p *node) place(n *node) bool { p.tk.uiTab.Append(n.Text, n.tk.uiControl) p.tk.boxC += 1 return true - case toolkit.Box: + case widget.Box: log(logInfo, "place() uiBox =", p.tk.uiBox) log(logInfo, "place() uiControl =", n.tk.uiControl) p.tk.uiBox.Append(n.tk.uiControl, stretchy) p.tk.boxC += 1 return true - case toolkit.Window: + case widget.Window: p.tk.uiWindow.SetChild(n.tk.uiControl) return true default: diff --git a/andlabs/debug.go b/andlabs/debug.go index 5e28dd0..d92739f 100644 --- a/andlabs/debug.go +++ b/andlabs/debug.go @@ -2,7 +2,7 @@ package main import ( "strconv" - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" ) var defaultBehavior bool = true @@ -92,7 +92,7 @@ func GetDebugToolkit () bool { } */ -func flag(a *toolkit.Action) { +func flag(a *widget.Action) { // should set the checkbox to this value switch a.S { case "Quiet": diff --git a/andlabs/delete.go b/andlabs/delete.go index 7b6c2da..c6fa6d2 100644 --- a/andlabs/delete.go +++ b/andlabs/delete.go @@ -2,7 +2,7 @@ package main // if you include more than just this import // then your plugin might be doing something un-ideal (just a guess from 2023/02/27) -import "go.wit.com/gui/toolkits" +import "go.wit.com/gui/widget" // delete the child widget from the parent // p = parent, c = child @@ -21,7 +21,7 @@ func (n *node) destroy() { } switch n.WidgetType { - case toolkit.Button: + case widget.Button: log(true, "Should delete Button here:", n.Name) log(true, "Parent:") pt.Dump(true) @@ -39,7 +39,7 @@ func (n *node) destroy() { ct.uiButton.Destroy() } - case toolkit.Window: + case widget.Window: log(true, "Should delete Window here:", n.Name) default: log(true, "Fuckit, let's destroy a button") diff --git a/andlabs/dropdown.go b/andlabs/dropdown.go index c7a11e2..f5dc295 100644 --- a/andlabs/dropdown.go +++ b/andlabs/dropdown.go @@ -4,7 +4,7 @@ import ( "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" ) func (p *node) newDropdown(n *node) { @@ -65,7 +65,7 @@ func (n *node) AddDropdownName(s string) { t.addDropdownName(s) } -func (n *node) SetDropdownName(a *toolkit.Action, s string) { +func (n *node) SetDropdownName(a *widget.Action, s string) { log(logInfo, "SetDropdown()", n.WidgetId, ",", s) t := n.tk diff --git a/andlabs/main.go b/andlabs/main.go index b135563..b9109b9 100644 --- a/andlabs/main.go +++ b/andlabs/main.go @@ -2,7 +2,7 @@ package main import ( "sync" - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" "github.com/andlabs/ui" // the _ means we only need this for the init() @@ -49,7 +49,7 @@ func init() { }) // andlabs = make(map[int]*andlabsT) - pluginChan = make(chan toolkit.Action, 1) + pluginChan = make(chan widget.Action, 1) log(logNow, "Init() start channel reciever") go catchActionChannel() diff --git a/andlabs/setText.go b/andlabs/setText.go index 2c7fb62..ecc1066 100644 --- a/andlabs/setText.go +++ b/andlabs/setText.go @@ -1,10 +1,10 @@ package main import ( - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" ) -func (n *node) setText(a *toolkit.Action) { +func (n *node) setText(a *widget.Action) { log(debugChange, "setText() START with a.S =", a.S) t := n.tk if (t == nil) { @@ -15,33 +15,33 @@ func (n *node) setText(a *toolkit.Action) { log(debugChange, "setText() Attempt on", n.WidgetType, "with", a.S) switch n.WidgetType { - case toolkit.Window: + case widget.Window: t.uiWindow.SetTitle(a.S) - case toolkit.Tab: - case toolkit.Group: + case widget.Tab: + case widget.Group: t.uiGroup.SetTitle(a.S) - case toolkit.Checkbox: + case widget.Checkbox: switch a.ActionType { - case toolkit.SetText: + case widget.SetText: t.uiCheckbox.SetText(a.S) - case toolkit.Get: + case widget.Get: n.B = t.uiCheckbox.Checked() - case toolkit.Set: + case widget.Set: // TODO: commented out while working on chan t.uiCheckbox.SetChecked(a.B) default: log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } - case toolkit.Textbox: + case widget.Textbox: switch a.ActionType { - case toolkit.Set: + case widget.Set: if (t.uiEntry != nil) { t.uiEntry.SetText(a.S) } if (t.uiMultilineEntry != nil) { t.uiMultilineEntry.SetText(a.S) } - case toolkit.SetText: + case widget.SetText: if (t.uiEntry != nil) { t.uiEntry.SetText(a.S) } @@ -51,33 +51,33 @@ func (n *node) setText(a *toolkit.Action) { default: log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } - case toolkit.Label: + case widget.Label: t.uiLabel.SetText(a.S) - case toolkit.Button: + case widget.Button: t.uiButton.SetText(a.S) - case toolkit.Slider: + case widget.Slider: switch a.ActionType { - case toolkit.Get: + case widget.Get: n.I = t.uiSlider.Value() - case toolkit.Set: + case widget.Set: t.uiSlider.SetValue(a.I) default: log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } - case toolkit.Spinner: + case widget.Spinner: switch a.ActionType { - case toolkit.Get: + case widget.Get: n.I = t.uiSpinbox.Value() - case toolkit.Set: + case widget.Set: t.uiSpinbox.SetValue(a.I) default: log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } - case toolkit.Dropdown: + case widget.Dropdown: switch a.ActionType { - case toolkit.AddText: + case widget.AddText: n.AddDropdownName(a.S) - case toolkit.Set: + case widget.Set: var orig int var i int = -1 var s string @@ -101,21 +101,21 @@ func (n *node) setText(a *toolkit.Action) { if (orig == -1) { t.uiCombobox.SetSelected(i) } - case toolkit.Get: + case widget.Get: // t.S = t.s - case toolkit.GetText: + case widget.GetText: // t.S = t.s default: log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } - case toolkit.Combobox: + case widget.Combobox: switch a.ActionType { - case toolkit.AddText: + case widget.AddText: t.AddComboboxName(a.S) - case toolkit.Set: + case widget.Set: t.uiEditableCombobox.SetText(a.S) n.S = a.S - case toolkit.SetText: + case widget.SetText: t.uiEditableCombobox.SetText(a.S) n.S = a.S default: diff --git a/andlabs/tab.go b/andlabs/tab.go index 34c3c0a..078ab40 100644 --- a/andlabs/tab.go +++ b/andlabs/tab.go @@ -1,7 +1,7 @@ package main import ( - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" @@ -25,7 +25,7 @@ func (p *node) newTab(n *node) { if (p == nil) { log(debugError, "newTab() p == nil. how the fuck does this happen?", n.WidgetId, n.ParentId) } - if (p.WidgetType != toolkit.Window) { + if (p.WidgetType != widget.Window) { log(debugError, "newTab() uiWindow == nil. I can't add a toolbar without window", n.WidgetId, n.ParentId) return } @@ -41,7 +41,7 @@ func (p *node) newTab(n *node) { } else { // this means you have to append a tab log(debugToolkit, "newTab() GOOD. This should be an additional tab:", n.WidgetId, n.ParentId) - if (n.WidgetType == toolkit.Tab) { + if (n.WidgetType == widget.Tab) { // andlabs doesn't have multiple tab widgets so make a fake one? // this makes a guiWidget internal structure with the parent values newt = new(guiWidget) diff --git a/andlabs/widget.go b/andlabs/widget.go index 71082a6..989634d 100644 --- a/andlabs/widget.go +++ b/andlabs/widget.go @@ -1,7 +1,7 @@ package main import ( - "go.wit.com/gui/toolkits" + "go.wit.com/gui/widget" ) // this is specific to the nocui toolkit @@ -10,14 +10,14 @@ func initWidget(n *node) *guiWidget { w = new(guiWidget) // Set(w, "default") - if n.WidgetType == toolkit.Root { + if n.WidgetType == widget.Root { log(logInfo, "setupWidget() FOUND ROOT w.id =", n.WidgetId) n.WidgetId = 0 me.rootNode = n return w } - if (n.WidgetType == toolkit.Box) { + if (n.WidgetType == widget.Box) { if (n.B) { n.horizontal = true } else {