CODE: start a general code refactor

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-10-06 08:36:28 -05:00
parent cabdb12495
commit b4a11c0aa1
4 changed files with 77 additions and 1 deletions

46
main.go Normal file
View File

@ -0,0 +1,46 @@
package gui
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func Main(f func()) {
log.Println("Starting gui.Main() (using gtk via andlabs/ui)")
ui.Main(f)
}
// Other goroutines must use this
//
// You can not acess / process the GUI thread directly from
// other goroutines. This is due to the nature of how
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
// For example: gui.Queue(addNewTabForColorSelection())
func Queue(f func()) {
log.Println("Sending function to gui.Main() (using gtk via andlabs/ui)")
ui.QueueMain(f)
}
// gui.Main(
// gui.MainExample()
// )
func MainExample() {
name := "jcarr"
log.Println("gui.initUI() inside ui.Main()")
box := InitWindow(nil, "StartNewWindow" + name, 0)
window := box.Window
log.Println("StartNewWindow() box =", box)
window.UiWindow.Show()
}
func TestExample() {
log.Println("gui.initUI() inside ui.Main()")
box := InitWindow(nil, "test", 0)
window := box.Window
log.Println("StartNewWindow() box =", box)
window.UiWindow.Show()
}

29
new-structs.go Normal file
View File

@ -0,0 +1,29 @@
package gui
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
type Node struct {
Name string
tag string
Width int
Height int
uiType *ui.Control
Children []*Node
}
func (n Node) SetName(name string) {
// n.uiType.SetName(name)
log.Println("n.uiType =", n.uiType)
return
}
func (n Node) Append(child Node) {
// if (n.UiBox == nil) {
// return
// }
// n.uiType.Append(child, x)
}

View File

@ -42,6 +42,7 @@ type GuiData struct {
// andlabs/ui & andlabs/libui work
AllButtons []*GuiButton
buttonMap map[*ui.Button]*GuiButton
Nodes *Node
}
type GuiTab struct {

View File

@ -18,7 +18,7 @@ func makeWindowDebug() ui.Control {
vbox.Append(pbar, false)
/////////////////////////////////////////////////////
vbox = addGroup(hbox, "WindowMap")
vbox = addGroup(hbox, "WindowMap 2")
cbox := ui.NewCombobox()
for name, _ := range Data.WindowMap {