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.v = p.NewEntryLine("")
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)
if d.Custom != nil {
d.Custom()

View File

@ -52,7 +52,7 @@ func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
d.l = n.NewLabel(name)
d.v = n.NewLabel("")
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)
}

View File

@ -12,7 +12,7 @@ type BasicWindow struct {
ready bool
hidden bool
vertical bool
name string
title string
parent *gui.Node
win *gui.Node // window widget
@ -76,32 +76,32 @@ func (w *BasicWindow) Box() *gui.Node {
}
func (w *BasicWindow) Vertical() {
log.Log(INFO, "BasicWindow() w.vertical =", w.vertical)
if ! w.Initialized() {
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
}
log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
if w == nil {return}
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() {
if ! w.Initialized() {return}
// various timeout settings
w.win = w.parent.RawWindow(w.name)
w.win = w.parent.RawWindow(w.title)
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 {
w.box = w.win.NewBox("bw vbox", false)
log.Log(INFO, "BasicWindow.Custom() made vbox")
w.box = w.win.NewVerticalBox("BW VBOX")
log.Log(INFO, "BasicWindow.Make() made NewVerticalBox", w.title)
} else {
w.box = w.win.NewBox("bw hbox", true)
log.Log(INFO, "BasicWindow.Custom() made hbox")
w.box = w.win.NewHorizontalBox("BW HBOX")
log.Log(INFO, "BasicWindow.Make() made NewHorizontalBox", w.title)
}
w.ready = true
@ -110,29 +110,31 @@ func (w *BasicWindow) Make() {
func (w *BasicWindow) Draw() {
if ! w.Initialized() {return}
// various timeout settings
w.win = w.parent.NewWindow(w.name)
w.win = w.parent.NewWindow(w.title)
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 {
w.box = w.win.NewBox("bw vbox", false)
log.Log(INFO, "BasicWindow.Custom() made vbox")
w.box = w.win.NewVerticalBox("BW VBOX")
log.Log(INFO, "BasicWindow.Draw() made vbox title =", w.title)
} else {
w.box = w.win.NewBox("bw hbox", true)
log.Log(INFO, "BasicWindow.Custom() made hbox")
w.box = w.win.NewHorizontalBox("BW HBOX")
log.Log(INFO, "BasicWindow.Draw() made hbox title =", w.title)
}
w.ready = true
}
func NewBasicWindow(parent *gui.Node, name string) *BasicWindow {
func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
var w *BasicWindow
w = &BasicWindow {
parent: parent,
name: name,
title: title,
vertical: false,
}
log.Warn("NewBasicWindow() END")
return w
}

View File

@ -49,7 +49,7 @@ func (n *Duration) Set(d time.Duration) {
offset = d - n.Low
i := int(offset / step)
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.Custom()
}
@ -66,7 +66,7 @@ func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.D
d.l = n.NewLabel(label)
d.s = n.NewSlider(label, 0, 1000)
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)
s := fmt.Sprintf("%s (%v)", d.Label, d.Duration)
d.l.SetText(s)

View File

@ -55,7 +55,7 @@ func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
// various timeout settings
f.c = n.NewCheckbox(f.Name + ": " + f.Desc)
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())
}
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.v = n.NewLabel("")
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)
}