lots of syntax changes
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
76d6da5505
commit
a8d95fef8d
|
@ -12,8 +12,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type BasicCombobox struct {
|
||||
|
@ -28,41 +28,61 @@ type BasicCombobox struct {
|
|||
}
|
||||
|
||||
func (d *BasicCombobox) String() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return d.d.String()
|
||||
}
|
||||
|
||||
func (d *BasicCombobox) SetText(s string) {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
d.d.SetText(s)
|
||||
}
|
||||
|
||||
// Returns true if the status is valid
|
||||
func (d *BasicCombobox) Ready() bool {
|
||||
if d == nil {return false}
|
||||
if d == nil {
|
||||
return false
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
func (d *BasicCombobox) Enable() {
|
||||
if d == nil {return}
|
||||
if d.d == nil {return}
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
if d.d == nil {
|
||||
return
|
||||
}
|
||||
d.d.Enable()
|
||||
}
|
||||
|
||||
func (d *BasicCombobox) Disable() {
|
||||
if d == nil {return}
|
||||
if d.d == nil {return}
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
if d.d == nil {
|
||||
return
|
||||
}
|
||||
d.d.Disable()
|
||||
}
|
||||
|
||||
func (d *BasicCombobox) SetTitle(name string) {
|
||||
if d == nil {return}
|
||||
if d.d == nil {return}
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
if d.d == nil {
|
||||
return
|
||||
}
|
||||
d.d.SetText(name)
|
||||
}
|
||||
|
||||
func (d *BasicCombobox) AddText(s string) {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Log(INFO, "BasicCombobox.Add() =", s)
|
||||
d.d.AddText(s)
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type BasicDropdown struct {
|
||||
|
@ -39,36 +39,47 @@ func (d *BasicDropdown) Get() string {
|
|||
|
||||
// Returns true if the status is valid
|
||||
func (d *BasicDropdown) Ready() bool {
|
||||
if d == nil {return false}
|
||||
if d == nil {
|
||||
return false
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
func (d *BasicDropdown) AddText(s string) {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Log(INFO, "BasicDropdown.AddText() =", s)
|
||||
d.d.AddText(s)
|
||||
return
|
||||
}
|
||||
|
||||
func (d *BasicDropdown) SetText(s string) {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Log(INFO, "BasicDropdown.SetText() =", s)
|
||||
d.d.SetText(s)
|
||||
return
|
||||
}
|
||||
|
||||
func (d *BasicDropdown) String() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
log.Log(INFO, "BasicDropdown.String()", d.d.String())
|
||||
return d.d.String()
|
||||
}
|
||||
|
||||
func (d *BasicDropdown) SetLabel(value string) bool {
|
||||
if ! d.Ready() {return false}
|
||||
if !d.Ready() {
|
||||
return false
|
||||
}
|
||||
log.Log(INFO, "BasicDropdown.SetLabel() =", value)
|
||||
d.l.SetText(value)
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
func (d *BasicDropdown) Set(value string) bool {
|
||||
if ! d.Ready() {return false}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type BasicEntry struct {
|
||||
|
@ -42,14 +42,14 @@ func (n *BasicEntry) Set(value string) *BasicEntry {
|
|||
|
||||
func (n *BasicEntry) Enable() {
|
||||
log.Log(INFO, "BasicEntry.Enable()")
|
||||
if (n.v != nil) {
|
||||
if n.v != nil {
|
||||
n.v.Enable()
|
||||
}
|
||||
}
|
||||
|
||||
func (n *BasicEntry) Disable() {
|
||||
log.Log(INFO, "BasicEntry.Disable()")
|
||||
if (n.v != nil) {
|
||||
if n.v != nil {
|
||||
n.v.Disable()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type Node gui.Node
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type BasicWindow struct {
|
||||
|
@ -34,21 +34,27 @@ func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
|
|||
}
|
||||
|
||||
func (w *BasicWindow) Show() {
|
||||
if ! w.Ready() {return}
|
||||
if !w.Ready() {
|
||||
return
|
||||
}
|
||||
w.win.Show()
|
||||
w.hidden = false
|
||||
return
|
||||
}
|
||||
|
||||
func (w *BasicWindow) Hide() {
|
||||
if ! w.Ready() {return}
|
||||
if !w.Ready() {
|
||||
return
|
||||
}
|
||||
w.win.Hide()
|
||||
w.hidden = true
|
||||
return
|
||||
}
|
||||
|
||||
func (w *BasicWindow) Toggle() {
|
||||
if ! w.Ready() {return}
|
||||
if !w.Ready() {
|
||||
return
|
||||
}
|
||||
if w.hidden {
|
||||
w.Show()
|
||||
w.hidden = false
|
||||
|
@ -60,14 +66,18 @@ func (w *BasicWindow) Toggle() {
|
|||
}
|
||||
|
||||
func (w *BasicWindow) Title(title string) {
|
||||
if ! w.Ready() {return}
|
||||
if !w.Ready() {
|
||||
return
|
||||
}
|
||||
w.win.SetText(title)
|
||||
return
|
||||
}
|
||||
|
||||
// sets this window to run os.Exit()
|
||||
func (w *BasicWindow) StandardExit() {
|
||||
if ! w.Ready() {return}
|
||||
if !w.Ready() {
|
||||
return
|
||||
}
|
||||
w.win.Custom = func() {
|
||||
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
|
||||
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
|
||||
|
@ -81,21 +91,31 @@ func (w *BasicWindow) StandardExit() {
|
|||
|
||||
// Returns true if initialized
|
||||
func (w *BasicWindow) Initialized() bool {
|
||||
if w == nil {return false}
|
||||
if w.parent == nil {return false}
|
||||
if w == nil {
|
||||
return false
|
||||
}
|
||||
if w.parent == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Returns true if the status is valid
|
||||
func (w *BasicWindow) Ready() bool {
|
||||
if ! w.Initialized() {return false}
|
||||
if ! w.parent.Ready() {return false}
|
||||
if !w.Initialized() {
|
||||
return false
|
||||
}
|
||||
if !w.parent.Ready() {
|
||||
return false
|
||||
}
|
||||
return w.ready
|
||||
}
|
||||
|
||||
func (w *BasicWindow) Box() *gui.Node {
|
||||
if ! w.Initialized() {return nil}
|
||||
if (w.win == nil) {
|
||||
if !w.Initialized() {
|
||||
return nil
|
||||
}
|
||||
if w.win == nil {
|
||||
w.Draw()
|
||||
}
|
||||
return w.box
|
||||
|
@ -103,20 +123,26 @@ func (w *BasicWindow) Box() *gui.Node {
|
|||
|
||||
func (w *BasicWindow) Vertical() {
|
||||
log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
|
||||
if w == nil {return}
|
||||
if w == nil {
|
||||
return
|
||||
}
|
||||
w.vertical = true
|
||||
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}
|
||||
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}
|
||||
if !w.Initialized() {
|
||||
return
|
||||
}
|
||||
if w.win != nil {
|
||||
log.Warn("BasicWindow.Make() window was already created")
|
||||
return
|
||||
|
@ -148,7 +174,9 @@ func (w *BasicWindow) Make() {
|
|||
}
|
||||
|
||||
func (w *BasicWindow) TestDraw() {
|
||||
if ! w.Initialized() {return}
|
||||
if !w.Initialized() {
|
||||
return
|
||||
}
|
||||
if w.win == nil {
|
||||
log.Warn("BasicWindow.TestDraw() can't draw on window == nil")
|
||||
w.Make()
|
||||
|
@ -158,7 +186,9 @@ func (w *BasicWindow) TestDraw() {
|
|||
}
|
||||
|
||||
func (w *BasicWindow) Draw() {
|
||||
if ! w.Initialized() {return}
|
||||
if !w.Initialized() {
|
||||
return
|
||||
}
|
||||
if w.win != nil {
|
||||
log.Warn("BasicWindow.Draw() window was already created")
|
||||
w.Make()
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type Duration struct {
|
||||
|
@ -28,10 +28,10 @@ type Duration struct {
|
|||
func (n *Duration) Set(d time.Duration) {
|
||||
var timeRange, step, offset time.Duration
|
||||
|
||||
if (d > n.High) {
|
||||
if d > n.High {
|
||||
d = n.High
|
||||
}
|
||||
if (d < n.Low) {
|
||||
if d < n.Low {
|
||||
d = n.Low
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ func (n *Duration) Set(d time.Duration) {
|
|||
// figure out the integer offset for the Slider GUI Widget
|
||||
timeRange = n.High - n.Low
|
||||
step = timeRange / 1000
|
||||
if (step == 0) {
|
||||
if step == 0 {
|
||||
log.Log(INFO, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
|
||||
n.s.Set(0)
|
||||
return
|
||||
|
@ -70,7 +70,7 @@ func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.D
|
|||
log.Println("d.Duration =", d.Duration)
|
||||
s := fmt.Sprintf("%s (%v)", d.Label, d.Duration)
|
||||
d.l.SetText(s)
|
||||
if (d.Custom != nil) {
|
||||
if d.Custom != nil {
|
||||
d.Custom()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type LogFlag struct {
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
package gadgets
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
type OneLiner struct {
|
||||
|
@ -34,7 +34,7 @@ func (n *OneLiner) SetText(s string) *OneLiner {
|
|||
|
||||
func (n *OneLiner) SetLabel(value string) *OneLiner {
|
||||
log.Log(INFO, "OneLiner.SetLabel() =", value)
|
||||
if (n.l != nil) {
|
||||
if n.l != nil {
|
||||
n.l.Set(value)
|
||||
}
|
||||
return n
|
||||
|
@ -42,14 +42,14 @@ func (n *OneLiner) SetLabel(value string) *OneLiner {
|
|||
|
||||
func (n *OneLiner) Enable() {
|
||||
log.Log(INFO, "OneLiner.Enable()")
|
||||
if (n.v != nil) {
|
||||
if n.v != nil {
|
||||
n.v.Show()
|
||||
}
|
||||
}
|
||||
|
||||
func (n *OneLiner) Disable() {
|
||||
log.Log(INFO, "OneLiner.Disable()")
|
||||
if (n.v != nil) {
|
||||
if n.v != nil {
|
||||
n.v.Hide()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue