2019-06-02 13:02:14 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
2019-06-03 02:20:28 -05:00
|
|
|
// import "reflect"
|
2019-06-02 13:02:14 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-06-03 02:20:28 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2019-06-02 13:02:14 -05:00
|
|
|
// add(nil, newbox, "") // use this when the Window is created. Always called 'MAINBOX'
|
|
|
|
// add(gw.BoxMap["MAINBOX"], newbox, name) // use this to add a box off the main box
|
|
|
|
// add(gw.BoxMap["BUTTONBOX"], newbox, name) // use this to add something to the box called 'BUTTONBOX'
|
|
|
|
// add(box, newbox, name) // add 'newbox' to 'box' and call it 'name'
|
|
|
|
func add(box *GuiBox, newbox *GuiBox) {
|
|
|
|
log.Println("gui.add() START box =", box)
|
|
|
|
log.Println("gui.add() START newbox =", newbox)
|
|
|
|
if (box == nil) {
|
|
|
|
log.Println("\tgui.add() add to Window as MAINBOX")
|
|
|
|
if (newbox.Window.UiTab != nil) {
|
2019-06-02 13:40:44 -05:00
|
|
|
// create a new tab here
|
|
|
|
// add the box to it as MAINBOX
|
2019-06-02 13:02:14 -05:00
|
|
|
log.Println("\tgui.add() add to Window as a UiTab")
|
2019-06-02 21:54:46 -05:00
|
|
|
// TODO: allow passing where to append
|
|
|
|
// newbox.Window.UiTab.InsertAt(newbox.Name, 0, newbox.UiBox)
|
|
|
|
newbox.Window.UiTab.Append(newbox.Name, newbox.UiBox)
|
2019-06-04 16:09:17 -05:00
|
|
|
// newbox.Window.UiTab.SetMargined(0, true)
|
2019-06-02 13:40:44 -05:00
|
|
|
|
|
|
|
// TODO: figure out how to make a new Tab/Window/Box here
|
|
|
|
// window := InitGuiWindow(Data.Config, newbox.Name, gw.MakeWindow, gw.UiWindow, gw.UiTab)
|
|
|
|
// window.UiTab.Delete(0)
|
|
|
|
// window.MakeWindow(window)
|
|
|
|
// newbox.Window = window
|
|
|
|
|
|
|
|
newbox.Window.BoxMap["MAINBOX"] = newbox
|
|
|
|
log.Println("gui.add() END")
|
|
|
|
return
|
2019-06-02 13:02:14 -05:00
|
|
|
} else {
|
2019-06-02 13:40:44 -05:00
|
|
|
log.Println("\tgui.add() ERROR DONT KNOW HOW TO ADD TO A RAW WINDOW YET")
|
2019-06-02 13:02:14 -05:00
|
|
|
// add this to the window
|
|
|
|
}
|
2019-06-02 13:40:44 -05:00
|
|
|
log.Println("\tgui.add() ERROR DON'T KNOW HOW TO add to Window as MAINBOX DONE")
|
2019-06-02 13:02:14 -05:00
|
|
|
log.Println("gui.add() END")
|
|
|
|
return
|
|
|
|
}
|
2019-06-02 14:38:29 -05:00
|
|
|
log.Println("\tgui.add() adding", newbox.Name, "to", box.Name)
|
2019-06-02 13:02:14 -05:00
|
|
|
// copy the box settings over
|
|
|
|
newbox.Window = box.Window
|
2019-06-03 02:20:28 -05:00
|
|
|
if (box.UiBox == nil) {
|
|
|
|
log.Println("\tgui.add() ERROR box.UiBox == nil")
|
|
|
|
panic("crap")
|
|
|
|
}
|
|
|
|
if (newbox.UiBox == nil) {
|
|
|
|
log.Println("\tgui.add() ERROR newbox.UiBox == nil")
|
|
|
|
panic("crap")
|
|
|
|
}
|
|
|
|
// log.Println("\tgui.add() newbox.UiBox == ", newbox.UiBox.GetParent())
|
|
|
|
// spew.Dump(newbox.UiBox)
|
2019-06-02 13:02:14 -05:00
|
|
|
box.UiBox.Append(newbox.UiBox, false)
|
|
|
|
|
|
|
|
// add the newbox to the Window.BoxMap[]
|
|
|
|
box.Window.BoxMap[newbox.Name] = newbox
|
|
|
|
log.Println("gui.add() END")
|
|
|
|
}
|
|
|
|
|
2019-06-03 02:50:05 -05:00
|
|
|
func NewBox(box *GuiBox, axis int, name string) *GuiBox {
|
2019-06-03 02:20:28 -05:00
|
|
|
log.Println("VerticalBox START")
|
|
|
|
var newbox *GuiBox
|
|
|
|
newbox = new(GuiBox)
|
|
|
|
newbox.Window = box.Window
|
|
|
|
newbox.Name = name
|
|
|
|
|
2019-06-03 02:50:05 -05:00
|
|
|
var uiBox *ui.Box
|
|
|
|
if (axis == Xaxis) {
|
|
|
|
uiBox = ui.NewHorizontalBox()
|
|
|
|
} else {
|
|
|
|
uiBox = ui.NewVerticalBox()
|
|
|
|
}
|
|
|
|
uiBox.SetPadded(true)
|
|
|
|
newbox.UiBox = uiBox
|
2019-06-03 02:20:28 -05:00
|
|
|
add(box, newbox)
|
|
|
|
return newbox
|
|
|
|
}
|
|
|
|
|
2019-06-03 02:50:05 -05:00
|
|
|
func HardBox(gw *GuiWindow, axis int, name string) *GuiBox {
|
2019-06-03 02:20:28 -05:00
|
|
|
log.Println("HardBox() START axis =", axis)
|
|
|
|
|
|
|
|
// add a Vertical Seperator if there is already a box
|
|
|
|
// Is this right?
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
if (box != nil) {
|
|
|
|
if (axis == Xaxis) {
|
|
|
|
VerticalBreak(box)
|
|
|
|
} else {
|
|
|
|
HorizontalBreak(box)
|
|
|
|
}
|
2019-06-02 13:02:14 -05:00
|
|
|
}
|
|
|
|
|
2019-06-03 02:20:28 -05:00
|
|
|
// make the new vbox
|
|
|
|
var uiBox *ui.Box
|
|
|
|
if (axis == Xaxis) {
|
|
|
|
uiBox = ui.NewHorizontalBox()
|
|
|
|
} else {
|
|
|
|
uiBox = ui.NewVerticalBox()
|
|
|
|
}
|
|
|
|
uiBox.SetPadded(true)
|
2019-06-02 13:02:14 -05:00
|
|
|
|
2019-06-03 02:20:28 -05:00
|
|
|
// Init a new GuiBox
|
|
|
|
newbox := new(GuiBox)
|
|
|
|
newbox.Window = gw
|
|
|
|
newbox.UiBox = uiBox
|
2019-06-03 02:50:05 -05:00
|
|
|
newbox.Name = name
|
2019-06-03 02:20:28 -05:00
|
|
|
|
|
|
|
add(gw.BoxMap["MAINBOX"], newbox)
|
|
|
|
|
2019-06-13 16:17:05 -05:00
|
|
|
log.Println("HardBox END")
|
2019-06-03 02:20:28 -05:00
|
|
|
return newbox
|
2019-06-02 13:02:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func HorizontalBreak(box *GuiBox) {
|
2019-06-03 02:20:28 -05:00
|
|
|
log.Println("VerticalSeparator added to box =", box.Name)
|
2019-06-02 13:02:14 -05:00
|
|
|
tmp := ui.NewHorizontalSeparator()
|
|
|
|
box.UiBox.Append(tmp, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func VerticalBreak(box *GuiBox) {
|
2019-06-03 02:20:28 -05:00
|
|
|
log.Println("VerticalSeparator added to box =", box.Name)
|
2019-06-02 13:02:14 -05:00
|
|
|
tmp := ui.NewVerticalSeparator()
|
|
|
|
box.UiBox.Append(tmp, false)
|
|
|
|
}
|