2021-10-06 08:36:28 -05:00
|
|
|
package gui
|
|
|
|
|
2021-10-06 10:43:58 -05:00
|
|
|
import (
|
|
|
|
"log"
|
2021-10-06 08:36:28 -05:00
|
|
|
|
2021-10-06 10:43:58 -05:00
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
)
|
2021-10-06 08:36:28 -05:00
|
|
|
|
|
|
|
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
|
2021-10-06 10:43:58 -05:00
|
|
|
// other goroutines. This is due to the nature of how
|
2021-10-06 08:36:28 -05:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2021-10-06 10:43:58 -05:00
|
|
|
func ExampleWindow() {
|
|
|
|
log.Println("START gui.ExampleWindow()")
|
2021-10-06 08:36:28 -05:00
|
|
|
|
2021-10-06 10:43:58 -05:00
|
|
|
title := "Test Window"
|
2021-10-08 07:36:53 -05:00
|
|
|
node := InitWindow(nil, nil, title, 0)
|
|
|
|
box := node.box
|
2021-10-06 08:36:28 -05:00
|
|
|
window := box.Window
|
2021-10-06 10:43:58 -05:00
|
|
|
log.Println("box =", box)
|
|
|
|
log.Println("window =", window)
|
2021-10-09 19:25:52 -05:00
|
|
|
node.AddDebugTab("jcarr Debug")
|
2021-10-06 08:36:28 -05:00
|
|
|
|
|
|
|
window.UiWindow.Show()
|
|
|
|
}
|