gui api updates

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-11 20:37:39 -06:00
parent b6d0521996
commit 5351099972
6 changed files with 33 additions and 31 deletions

View File

@ -70,7 +70,7 @@ func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
d.l = p.NewLabel(name) d.l = p.NewLabel(name)
d.v = p.NewEntryLine("") d.v = p.NewEntryLine("")
d.v.Custom = func() { d.v.Custom = func() {
d.value = d.v.S d.value = d.v.GetText()
log.Log(INFO, "BasicEntry.Custom() user changed value to =", d.value) log.Log(INFO, "BasicEntry.Custom() user changed value to =", d.value)
if d.Custom != nil { if d.Custom != nil {
d.Custom() d.Custom()

View File

@ -52,7 +52,7 @@ func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
d.l = n.NewLabel(name) d.l = n.NewLabel(name)
d.v = n.NewLabel("") d.v = n.NewLabel("")
d.v.Custom = func() { d.v.Custom = func() {
d.value = d.v.S d.value = d.v.GetText()
log.Log(INFO, "BasicLabel.Custom() user changed value to =", d.value) log.Log(INFO, "BasicLabel.Custom() user changed value to =", d.value)
} }

View File

@ -12,7 +12,7 @@ type BasicWindow struct {
ready bool ready bool
hidden bool hidden bool
vertical bool vertical bool
name string title string
parent *gui.Node parent *gui.Node
win *gui.Node // window widget win *gui.Node // window widget
@ -76,32 +76,32 @@ func (w *BasicWindow) Box() *gui.Node {
} }
func (w *BasicWindow) Vertical() { func (w *BasicWindow) Vertical() {
log.Log(INFO, "BasicWindow() w.vertical =", w.vertical) log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
if ! w.Initialized() { if w == nil {return}
log.Warn("BasicWindow() not Initialized yet()")
return
}
if w.Ready() {
log.Warn("BasicWindow() is already created. You can not change it to Vertical now (TODO: fix this)")
return
}
w.vertical = true w.vertical = true
log.Log(INFO, "BasicWindow() w.vertical =", w.vertical) log.Warn("BasicWindow() Vertical() END w.vertical =", w.vertical, w.title)
}
func (w *BasicWindow) Horizontal() {
log.Warn("BasicWindow() Horizontal() START w.vertical =", w.vertical, w.title)
if w == nil {return}
w.vertical = false
log.Warn("BasicWindow() Horizontal() END w.vertical =", w.vertical, w.title)
} }
func (w *BasicWindow) Make() { func (w *BasicWindow) Make() {
if ! w.Initialized() {return} if ! w.Initialized() {return}
// various timeout settings // various timeout settings
w.win = w.parent.RawWindow(w.name) w.win = w.parent.RawWindow(w.title)
w.win.Custom = func() { w.win.Custom = func() {
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.name) log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
} }
if w.vertical { if w.vertical {
w.box = w.win.NewBox("bw vbox", false) w.box = w.win.NewVerticalBox("BW VBOX")
log.Log(INFO, "BasicWindow.Custom() made vbox") log.Log(INFO, "BasicWindow.Make() made NewVerticalBox", w.title)
} else { } else {
w.box = w.win.NewBox("bw hbox", true) w.box = w.win.NewHorizontalBox("BW HBOX")
log.Log(INFO, "BasicWindow.Custom() made hbox") log.Log(INFO, "BasicWindow.Make() made NewHorizontalBox", w.title)
} }
w.ready = true w.ready = true
@ -110,29 +110,31 @@ func (w *BasicWindow) Make() {
func (w *BasicWindow) Draw() { func (w *BasicWindow) Draw() {
if ! w.Initialized() {return} if ! w.Initialized() {return}
// various timeout settings // various timeout settings
w.win = w.parent.NewWindow(w.name) w.win = w.parent.NewWindow(w.title)
w.win.Custom = func() { w.win.Custom = func() {
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.name) log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
} }
log.Warn("BasicWindow.Draw() about to make a box vertical =", w.vertical, w.title)
if w.vertical { if w.vertical {
w.box = w.win.NewBox("bw vbox", false) w.box = w.win.NewVerticalBox("BW VBOX")
log.Log(INFO, "BasicWindow.Custom() made vbox") log.Log(INFO, "BasicWindow.Draw() made vbox title =", w.title)
} else { } else {
w.box = w.win.NewBox("bw hbox", true) w.box = w.win.NewHorizontalBox("BW HBOX")
log.Log(INFO, "BasicWindow.Custom() made hbox") log.Log(INFO, "BasicWindow.Draw() made hbox title =", w.title)
} }
w.ready = true w.ready = true
} }
func NewBasicWindow(parent *gui.Node, name string) *BasicWindow { func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
var w *BasicWindow var w *BasicWindow
w = &BasicWindow { w = &BasicWindow {
parent: parent, parent: parent,
name: name, title: title,
vertical: false, vertical: false,
} }
log.Warn("NewBasicWindow() END")
return w return w
} }

View File

@ -49,7 +49,7 @@ func (n *Duration) Set(d time.Duration) {
offset = d - n.Low offset = d - n.Low
i := int(offset / step) i := int(offset / step)
log.Log(INFO, "duration.Set() =", n.Low, n.High, d, "i =", i) log.Log(INFO, "duration.Set() =", n.Low, n.High, d, "i =", i)
n.s.I = i // n.s.I = i
n.s.Set(i) n.s.Set(i)
n.s.Custom() n.s.Custom()
} }
@ -66,7 +66,7 @@ func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.D
d.l = n.NewLabel(label) d.l = n.NewLabel(label)
d.s = n.NewSlider(label, 0, 1000) d.s = n.NewSlider(label, 0, 1000)
d.s.Custom = func () { d.s.Custom = func () {
d.Duration = low + (high - low) * time.Duration(d.s.I) / 1000 d.Duration = low + (high - low) * time.Duration(d.s.GetInt()) / 1000
log.Println("d.Duration =", d.Duration) log.Println("d.Duration =", d.Duration)
s := fmt.Sprintf("%s (%v)", d.Label, d.Duration) s := fmt.Sprintf("%s (%v)", d.Label, d.Duration)
d.l.SetText(s) d.l.SetText(s)

View File

@ -55,7 +55,7 @@ func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
// various timeout settings // various timeout settings
f.c = n.NewCheckbox(f.Name + ": " + f.Desc) f.c = n.NewCheckbox(f.Name + ": " + f.Desc)
f.c.Custom = func() { f.c.Custom = func() {
f.lf.Set(f.c.B) f.lf.Set(f.c.GetBool())
log.Info("LogFlag.Custom() user changed value to =", f.lf.Get()) log.Info("LogFlag.Custom() user changed value to =", f.lf.Get())
} }
f.c.Set(lf.Get()) f.c.Set(lf.Get())

View File

@ -70,7 +70,7 @@ func NewOneLiner(n *gui.Node, name string) *OneLiner {
d.l = n.NewLabel(name) d.l = n.NewLabel(name)
d.v = n.NewLabel("") d.v = n.NewLabel("")
d.v.Custom = func() { d.v.Custom = func() {
d.value = d.v.S d.value = d.v.GetText()
log.Log(INFO, "OneLiner.Custom() user changed value to =", d.value) log.Log(INFO, "OneLiner.Custom() user changed value to =", d.value)
} }