2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-17 22:39:03 -05:00
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
)
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
func newGroup(parentW *toolkit.Widget, w *toolkit.Widget) {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugToolkit, "NewGroup()", w.Name)
|
2022-11-14 14:30:28 -06:00
|
|
|
|
|
|
|
t := mapToolkits[parentW]
|
|
|
|
if (t == nil) {
|
2023-03-03 14:41:38 -06:00
|
|
|
log(debugToolkit, "NewGroup() toolkit struct == nil. name=", parentW.Name, w.Name)
|
2023-03-01 11:35:36 -06:00
|
|
|
listMap(debugToolkit)
|
2022-11-14 14:30:28 -06:00
|
|
|
}
|
2023-03-03 14:41:38 -06:00
|
|
|
newt := t.rawGroup(w.Name)
|
2022-11-14 14:30:28 -06:00
|
|
|
mapWidgetsToolkits(w, newt)
|
|
|
|
}
|
2022-10-17 22:39:03 -05:00
|
|
|
|
|
|
|
// make new Group here
|
2023-03-03 14:41:38 -06:00
|
|
|
func (t *andlabsT) rawGroup(title string) *andlabsT {
|
2022-11-14 14:30:28 -06:00
|
|
|
var newt andlabsT
|
2023-03-03 14:41:38 -06:00
|
|
|
newt.Name = title
|
2022-10-19 13:23:22 -05:00
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
log(debugToolkit, "NewGroup() create", newt.Name)
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
g := ui.NewGroup(newt.Name)
|
2022-10-21 11:40:08 -05:00
|
|
|
g.SetMargined(margin)
|
2023-03-03 14:41:38 -06:00
|
|
|
newt.uiGroup = g
|
2022-11-06 12:59:24 -06:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
t.doAppend(toolkit.Group, &newt, nil)
|
2022-10-17 22:39:03 -05:00
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
hbox := ui.NewVerticalBox()
|
2022-10-21 11:40:08 -05:00
|
|
|
hbox.SetPadded(padded)
|
2022-10-19 13:23:22 -05:00
|
|
|
g.SetChild(hbox)
|
2022-10-17 22:39:03 -05:00
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
newt.uiBox = hbox
|
2022-11-06 12:59:24 -06:00
|
|
|
newt.uiWindow = t.uiWindow
|
2023-03-03 14:41:38 -06:00
|
|
|
newt.uiTab = t.uiTab
|
2022-10-17 22:39:03 -05:00
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
return &newt
|
2022-10-17 22:39:03 -05:00
|
|
|
}
|
2023-03-12 08:47:16 -05:00
|
|
|
|
|
|
|
// This routine is very specific to this toolkit
|
|
|
|
// It's annoying and has to be copied to each widget when there are changes
|
|
|
|
// it could be 'simplfied' maybe or made to be more generic, but this is as far as I've gotten
|
|
|
|
// it's probably not worth working much more on this toolkit, the andlabs/ui has been great and got me here!
|
|
|
|
// but it's time to write direct GTK, QT, macos and windows toolkit plugins
|
|
|
|
// -- jcarr 2023/03/09
|
|
|
|
|
|
|
|
func doGroup(p *toolkit.Widget, c *toolkit.Widget) {
|
|
|
|
if broken(c) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log(debugChange, "Going to attempt:", c.Action)
|
|
|
|
if (c.Action == "New") {
|
|
|
|
newGroup(p, c)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ct := mapToolkits[c]
|
|
|
|
if (ct == nil) {
|
|
|
|
log(debugError, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if ct.broken() {
|
|
|
|
log(debugError, "Group() ct.broken", ct)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (ct.uiGroup == nil) {
|
|
|
|
log(debugError, "Label() uiGroup == nil", ct)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
switch c.Action {
|
|
|
|
case "Enable":
|
|
|
|
ct.uiGroup.Enable()
|
|
|
|
case "Disable":
|
|
|
|
ct.uiGroup.Disable()
|
|
|
|
case "Show":
|
|
|
|
ct.uiGroup.Show()
|
|
|
|
case "Hide":
|
|
|
|
ct.uiGroup.Hide()
|
|
|
|
case "Get":
|
|
|
|
c.S = ct.uiGroup.Title()
|
|
|
|
case "Set":
|
|
|
|
ct.uiGroup.SetTitle(c.S)
|
|
|
|
case "SetText":
|
|
|
|
ct.uiGroup.SetTitle(c.S)
|
|
|
|
case "SetMargin":
|
|
|
|
ct.uiGroup.SetMargined(c.B)
|
|
|
|
case "Destroy":
|
|
|
|
ct.uiGroup.Destroy()
|
|
|
|
default:
|
|
|
|
log(debugError, "Can't do", c.Action, "to a Group")
|
|
|
|
}
|
|
|
|
}
|