lots of syntax changes
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
76d6da5505
commit
a8d95fef8d
|
@ -1,77 +1,97 @@
|
||||||
/*
|
/*
|
||||||
A Labeled Combobox widget:
|
A Labeled Combobox widget:
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
| | |
|
| | |
|
||||||
| Food: | <dropdown> |
|
| Food: | <dropdown> |
|
||||||
| | |
|
| | |
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
The user can then edit the dropdown field and type anything into it
|
The user can then edit the dropdown field and type anything into it
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BasicCombobox struct {
|
type BasicCombobox struct {
|
||||||
ready bool
|
ready bool
|
||||||
progname string
|
progname string
|
||||||
|
|
||||||
parent *gui.Node // parent widget
|
parent *gui.Node // parent widget
|
||||||
l *gui.Node // label widget
|
l *gui.Node // label widget
|
||||||
d *gui.Node // dropdown widget
|
d *gui.Node // dropdown widget
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicCombobox) String() string {
|
func (d *BasicCombobox) String() string {
|
||||||
if ! d.Ready() {return ""}
|
if !d.Ready() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return d.d.String()
|
return d.d.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicCombobox) SetText(s string) {
|
func (d *BasicCombobox) SetText(s string) {
|
||||||
if ! d.Ready() {return}
|
if !d.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
d.d.SetText(s)
|
d.d.SetText(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the status is valid
|
// Returns true if the status is valid
|
||||||
func (d *BasicCombobox) Ready() bool {
|
func (d *BasicCombobox) Ready() bool {
|
||||||
if d == nil {return false}
|
if d == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return d.ready
|
return d.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicCombobox) Enable() {
|
func (d *BasicCombobox) Enable() {
|
||||||
if d == nil {return}
|
if d == nil {
|
||||||
if d.d == nil {return}
|
return
|
||||||
|
}
|
||||||
|
if d.d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
d.d.Enable()
|
d.d.Enable()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicCombobox) Disable() {
|
func (d *BasicCombobox) Disable() {
|
||||||
if d == nil {return}
|
if d == nil {
|
||||||
if d.d == nil {return}
|
return
|
||||||
|
}
|
||||||
|
if d.d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
d.d.Disable()
|
d.d.Disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicCombobox) SetTitle(name string) {
|
func (d *BasicCombobox) SetTitle(name string) {
|
||||||
if d == nil {return}
|
if d == nil {
|
||||||
if d.d == nil {return}
|
return
|
||||||
|
}
|
||||||
|
if d.d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
d.d.SetText(name)
|
d.d.SetText(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicCombobox) AddText(s string) {
|
func (d *BasicCombobox) AddText(s string) {
|
||||||
if ! d.Ready() {return}
|
if !d.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(INFO, "BasicCombobox.Add() =", s)
|
log.Log(INFO, "BasicCombobox.Add() =", s)
|
||||||
d.d.AddText(s)
|
d.d.AddText(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBasicCombobox(p *gui.Node, label string) *BasicCombobox {
|
func NewBasicCombobox(p *gui.Node, label string) *BasicCombobox {
|
||||||
d := BasicCombobox {
|
d := BasicCombobox{
|
||||||
parent: p,
|
parent: p,
|
||||||
progname: label,
|
progname: label,
|
||||||
ready: false,
|
ready: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// various timeout settings
|
// various timeout settings
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
A Labeled Dropdown widget:
|
A Labeled Dropdown widget:
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
| | |
|
| | |
|
||||||
| Food: | <dropdown> |
|
| Food: | <dropdown> |
|
||||||
| | |
|
| | |
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
This being a 'Basic Dropdown', the dropdown names must be unique
|
This being a 'Basic Dropdown', the dropdown names must be unique
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BasicDropdown struct {
|
type BasicDropdown struct {
|
||||||
ready bool
|
ready bool
|
||||||
name string
|
name string
|
||||||
|
|
||||||
parent *gui.Node // parent widget
|
parent *gui.Node // parent widget
|
||||||
l *gui.Node // label widget
|
l *gui.Node // label widget
|
||||||
d *gui.Node // dropdown widget
|
d *gui.Node // dropdown widget
|
||||||
|
|
||||||
value string
|
value string
|
||||||
label string
|
label string
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
@ -39,36 +39,47 @@ func (d *BasicDropdown) Get() string {
|
||||||
|
|
||||||
// Returns true if the status is valid
|
// Returns true if the status is valid
|
||||||
func (d *BasicDropdown) Ready() bool {
|
func (d *BasicDropdown) Ready() bool {
|
||||||
if d == nil {return false}
|
if d == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return d.ready
|
return d.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicDropdown) AddText(s string) {
|
func (d *BasicDropdown) AddText(s string) {
|
||||||
if ! d.Ready() {return}
|
if !d.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(INFO, "BasicDropdown.AddText() =", s)
|
log.Log(INFO, "BasicDropdown.AddText() =", s)
|
||||||
d.d.AddText(s)
|
d.d.AddText(s)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicDropdown) SetText(s string) {
|
func (d *BasicDropdown) SetText(s string) {
|
||||||
if ! d.Ready() {return}
|
if !d.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(INFO, "BasicDropdown.SetText() =", s)
|
log.Log(INFO, "BasicDropdown.SetText() =", s)
|
||||||
d.d.SetText(s)
|
d.d.SetText(s)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicDropdown) String() string {
|
func (d *BasicDropdown) String() string {
|
||||||
if ! d.Ready() {return ""}
|
if !d.Ready() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
log.Log(INFO, "BasicDropdown.String()", d.d.String())
|
log.Log(INFO, "BasicDropdown.String()", d.d.String())
|
||||||
return d.d.String()
|
return d.d.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BasicDropdown) SetLabel(value string) bool {
|
func (d *BasicDropdown) SetLabel(value string) bool {
|
||||||
if ! d.Ready() {return false}
|
if !d.Ready() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
log.Log(INFO, "BasicDropdown.SetLabel() =", value)
|
log.Log(INFO, "BasicDropdown.SetLabel() =", value)
|
||||||
d.l.SetText(value)
|
d.l.SetText(value)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func (d *BasicDropdown) Set(value string) bool {
|
func (d *BasicDropdown) Set(value string) bool {
|
||||||
if ! d.Ready() {return false}
|
if ! d.Ready() {return false}
|
||||||
|
@ -80,10 +91,10 @@ func (d *BasicDropdown) Set(value string) bool {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
|
func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
|
||||||
d := BasicDropdown {
|
d := BasicDropdown{
|
||||||
parent: p,
|
parent: p,
|
||||||
name: name,
|
name: name,
|
||||||
ready: false,
|
ready: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// various timeout settings
|
// various timeout settings
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/*
|
/*
|
||||||
A Labeled Single Line Entry widget:
|
A Labeled Single Line Entry widget:
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
| | |
|
| | |
|
||||||
| Food: | <type here> |
|
| Food: | <type here> |
|
||||||
| | |
|
| | |
|
||||||
-----------------------------
|
-----------------------------
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BasicEntry struct {
|
type BasicEntry struct {
|
||||||
parent *gui.Node // parent widget
|
parent *gui.Node // parent widget
|
||||||
l *gui.Node // label widget
|
l *gui.Node // label widget
|
||||||
v *gui.Node // value widget
|
v *gui.Node // value widget
|
||||||
|
|
||||||
value string
|
value string
|
||||||
label string
|
label string
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@ func (n *BasicEntry) Set(value string) *BasicEntry {
|
||||||
|
|
||||||
func (n *BasicEntry) Enable() {
|
func (n *BasicEntry) Enable() {
|
||||||
log.Log(INFO, "BasicEntry.Enable()")
|
log.Log(INFO, "BasicEntry.Enable()")
|
||||||
if (n.v != nil) {
|
if n.v != nil {
|
||||||
n.v.Enable()
|
n.v.Enable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *BasicEntry) Disable() {
|
func (n *BasicEntry) Disable() {
|
||||||
log.Log(INFO, "BasicEntry.Disable()")
|
log.Log(INFO, "BasicEntry.Disable()")
|
||||||
if (n.v != nil) {
|
if n.v != nil {
|
||||||
n.v.Disable()
|
n.v.Disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,9 @@ func (n *BasicEntry) SetLabel(s string) *BasicEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
|
func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
|
||||||
d := BasicEntry {
|
d := BasicEntry{
|
||||||
parent: p,
|
parent: p,
|
||||||
value: "",
|
value: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
// various timeout settings
|
// various timeout settings
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
/*
|
/*
|
||||||
A Labeled label:
|
A Labeled label:
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
| | |
|
| | |
|
||||||
| Food: | Apple |
|
| Food: | Apple |
|
||||||
| | |
|
| | |
|
||||||
-----------------------------
|
-----------------------------
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Node gui.Node
|
type Node gui.Node
|
||||||
|
|
||||||
type BasicLabel struct {
|
type BasicLabel struct {
|
||||||
p *gui.Node // parent widget
|
p *gui.Node // parent widget
|
||||||
l *gui.Node // label widget
|
l *gui.Node // label widget
|
||||||
v *gui.Node // value widget
|
v *gui.Node // value widget
|
||||||
|
|
||||||
value string
|
value string
|
||||||
label string
|
label string
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ func (n *BasicLabel) Set(value string) *BasicLabel {
|
||||||
func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
|
func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
|
||||||
var n *gui.Node
|
var n *gui.Node
|
||||||
n = (*gui.Node)(ngui)
|
n = (*gui.Node)(ngui)
|
||||||
d := BasicLabel {
|
d := BasicLabel{
|
||||||
p: n,
|
p: n,
|
||||||
value: "",
|
value: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
A Standard Window
|
A Standard Window
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BasicWindow struct {
|
type BasicWindow struct {
|
||||||
ready bool
|
ready bool
|
||||||
hidden bool
|
hidden bool
|
||||||
vertical bool
|
vertical bool
|
||||||
title string
|
title string
|
||||||
|
|
||||||
parent *gui.Node
|
parent *gui.Node
|
||||||
win *gui.Node // window widget
|
win *gui.Node // window widget
|
||||||
box *gui.Node // box
|
box *gui.Node // box
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
|
func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
|
||||||
var w *BasicWindow
|
var w *BasicWindow
|
||||||
w = &BasicWindow {
|
w = &BasicWindow{
|
||||||
parent: parent,
|
parent: parent,
|
||||||
title: title,
|
title: title,
|
||||||
vertical: false,
|
vertical: false,
|
||||||
}
|
}
|
||||||
log.Warn("NewBasicWindow() END")
|
log.Warn("NewBasicWindow() END")
|
||||||
|
@ -34,21 +34,27 @@ func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Show() {
|
func (w *BasicWindow) Show() {
|
||||||
if ! w.Ready() {return}
|
if !w.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
w.win.Show()
|
w.win.Show()
|
||||||
w.hidden = false
|
w.hidden = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Hide() {
|
func (w *BasicWindow) Hide() {
|
||||||
if ! w.Ready() {return}
|
if !w.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
w.win.Hide()
|
w.win.Hide()
|
||||||
w.hidden = true
|
w.hidden = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Toggle() {
|
func (w *BasicWindow) Toggle() {
|
||||||
if ! w.Ready() {return}
|
if !w.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if w.hidden {
|
if w.hidden {
|
||||||
w.Show()
|
w.Show()
|
||||||
w.hidden = false
|
w.hidden = false
|
||||||
|
@ -60,14 +66,18 @@ func (w *BasicWindow) Toggle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Title(title string) {
|
func (w *BasicWindow) Title(title string) {
|
||||||
if ! w.Ready() {return}
|
if !w.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
w.win.SetText(title)
|
w.win.SetText(title)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets this window to run os.Exit()
|
// sets this window to run os.Exit()
|
||||||
func (w *BasicWindow) StandardExit() {
|
func (w *BasicWindow) StandardExit() {
|
||||||
if ! w.Ready() {return}
|
if !w.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
w.win.Custom = func() {
|
w.win.Custom = func() {
|
||||||
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
|
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
|
||||||
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
|
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
|
||||||
|
@ -81,21 +91,31 @@ func (w *BasicWindow) StandardExit() {
|
||||||
|
|
||||||
// Returns true if initialized
|
// Returns true if initialized
|
||||||
func (w *BasicWindow) Initialized() bool {
|
func (w *BasicWindow) Initialized() bool {
|
||||||
if w == nil {return false}
|
if w == nil {
|
||||||
if w.parent == nil {return false}
|
return false
|
||||||
|
}
|
||||||
|
if w.parent == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the status is valid
|
// Returns true if the status is valid
|
||||||
func (w *BasicWindow) Ready() bool {
|
func (w *BasicWindow) Ready() bool {
|
||||||
if ! w.Initialized() {return false}
|
if !w.Initialized() {
|
||||||
if ! w.parent.Ready() {return false}
|
return false
|
||||||
|
}
|
||||||
|
if !w.parent.Ready() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return w.ready
|
return w.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Box() *gui.Node {
|
func (w *BasicWindow) Box() *gui.Node {
|
||||||
if ! w.Initialized() {return nil}
|
if !w.Initialized() {
|
||||||
if (w.win == nil) {
|
return nil
|
||||||
|
}
|
||||||
|
if w.win == nil {
|
||||||
w.Draw()
|
w.Draw()
|
||||||
}
|
}
|
||||||
return w.box
|
return w.box
|
||||||
|
@ -103,20 +123,26 @@ func (w *BasicWindow) Box() *gui.Node {
|
||||||
|
|
||||||
func (w *BasicWindow) Vertical() {
|
func (w *BasicWindow) Vertical() {
|
||||||
log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
|
log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
|
||||||
if w == nil {return}
|
if w == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
w.vertical = true
|
w.vertical = true
|
||||||
log.Warn("BasicWindow() Vertical() END w.vertical =", w.vertical, w.title)
|
log.Warn("BasicWindow() Vertical() END w.vertical =", w.vertical, w.title)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Horizontal() {
|
func (w *BasicWindow) Horizontal() {
|
||||||
log.Warn("BasicWindow() Horizontal() START w.vertical =", w.vertical, w.title)
|
log.Warn("BasicWindow() Horizontal() START w.vertical =", w.vertical, w.title)
|
||||||
if w == nil {return}
|
if w == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
w.vertical = false
|
w.vertical = false
|
||||||
log.Warn("BasicWindow() Horizontal() END w.vertical =", w.vertical, w.title)
|
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
|
||||||
|
}
|
||||||
if w.win != nil {
|
if w.win != nil {
|
||||||
log.Warn("BasicWindow.Make() window was already created")
|
log.Warn("BasicWindow.Make() window was already created")
|
||||||
return
|
return
|
||||||
|
@ -148,7 +174,9 @@ func (w *BasicWindow) Make() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) TestDraw() {
|
func (w *BasicWindow) TestDraw() {
|
||||||
if ! w.Initialized() {return}
|
if !w.Initialized() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if w.win == nil {
|
if w.win == nil {
|
||||||
log.Warn("BasicWindow.TestDraw() can't draw on window == nil")
|
log.Warn("BasicWindow.TestDraw() can't draw on window == nil")
|
||||||
w.Make()
|
w.Make()
|
||||||
|
@ -158,7 +186,9 @@ func (w *BasicWindow) TestDraw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *BasicWindow) Draw() {
|
func (w *BasicWindow) Draw() {
|
||||||
if ! w.Initialized() {return}
|
if !w.Initialized() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if w.win != nil {
|
if w.win != nil {
|
||||||
log.Warn("BasicWindow.Draw() window was already created")
|
log.Warn("BasicWindow.Draw() window was already created")
|
||||||
w.Make()
|
w.Make()
|
||||||
|
|
|
@ -4,34 +4,34 @@
|
||||||
|
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Duration struct {
|
type Duration struct {
|
||||||
p *gui.Node // parent widget
|
p *gui.Node // parent widget
|
||||||
l *gui.Node // label widget
|
l *gui.Node // label widget
|
||||||
s *gui.Node // slider widget
|
s *gui.Node // slider widget
|
||||||
|
|
||||||
Label string
|
Label string
|
||||||
Low time.Duration
|
Low time.Duration
|
||||||
High time.Duration
|
High time.Duration
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Duration) Set(d time.Duration) {
|
func (n *Duration) Set(d time.Duration) {
|
||||||
var timeRange, step, offset time.Duration
|
var timeRange, step, offset time.Duration
|
||||||
|
|
||||||
if (d > n.High) {
|
if d > n.High {
|
||||||
d = n.High
|
d = n.High
|
||||||
}
|
}
|
||||||
if (d < n.Low) {
|
if d < n.Low {
|
||||||
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
|
// figure out the integer offset for the Slider GUI Widget
|
||||||
timeRange = n.High - n.Low
|
timeRange = n.High - n.Low
|
||||||
step = timeRange / 1000
|
step = timeRange / 1000
|
||||||
if (step == 0) {
|
if step == 0 {
|
||||||
log.Log(INFO, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
|
log.Log(INFO, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
|
||||||
n.s.Set(0)
|
n.s.Set(0)
|
||||||
return
|
return
|
||||||
|
@ -55,22 +55,22 @@ func (n *Duration) Set(d time.Duration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.Duration) *Duration {
|
func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.Duration) *Duration {
|
||||||
d := Duration {
|
d := Duration{
|
||||||
p: n,
|
p: n,
|
||||||
Label: label,
|
Label: label,
|
||||||
High: high,
|
High: high,
|
||||||
Low: low,
|
Low: low,
|
||||||
}
|
}
|
||||||
|
|
||||||
// various timeout settings
|
// various timeout settings
|
||||||
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.Int()) / 1000
|
d.Duration = low + (high-low)*time.Duration(d.s.Int())/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)
|
||||||
if (d.Custom != nil) {
|
if d.Custom != nil {
|
||||||
d.Custom()
|
d.Custom()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
logFlag.go
32
logFlag.go
|
@ -1,29 +1,29 @@
|
||||||
/*
|
/*
|
||||||
A log.Flag
|
A log.Flag
|
||||||
|
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
| | |
|
| | |
|
||||||
| [ X ] | INFO (controls log.Info() |
|
| [ X ] | INFO (controls log.Info() |
|
||||||
| | |
|
| | |
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type LogFlag struct {
|
type LogFlag struct {
|
||||||
p *gui.Node // parent widget
|
p *gui.Node // parent widget
|
||||||
c *gui.Node // checkbox widget
|
c *gui.Node // checkbox widget
|
||||||
lf *log.LogFlag
|
lf *log.LogFlag
|
||||||
|
|
||||||
Name string
|
Name string
|
||||||
Subsystem string
|
Subsystem string
|
||||||
Desc string
|
Desc string
|
||||||
Default bool
|
Default bool
|
||||||
b bool
|
b bool
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func (f *LogFlag) SetDefault() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
|
func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
|
||||||
f := LogFlag {
|
f := LogFlag{
|
||||||
p: n,
|
p: n,
|
||||||
}
|
}
|
||||||
f.Name = lf.GetName()
|
f.Name = lf.GetName()
|
||||||
|
|
30
oneLiner.go
30
oneLiner.go
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
A Labeled label:
|
A Labeled label:
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
| | |
|
| | |
|
||||||
| Food: | Apple |
|
| Food: | Apple |
|
||||||
| | |
|
| | |
|
||||||
-----------------------------
|
-----------------------------
|
||||||
*/
|
*/
|
||||||
package gadgets
|
package gadgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OneLiner struct {
|
type OneLiner struct {
|
||||||
p *gui.Node // parent widget
|
p *gui.Node // parent widget
|
||||||
l *gui.Node // label widget
|
l *gui.Node // label widget
|
||||||
v *gui.Node // value widget
|
v *gui.Node // value widget
|
||||||
|
|
||||||
Custom func()
|
Custom func()
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func (n *OneLiner) SetText(s string) *OneLiner {
|
||||||
|
|
||||||
func (n *OneLiner) SetLabel(value string) *OneLiner {
|
func (n *OneLiner) SetLabel(value string) *OneLiner {
|
||||||
log.Log(INFO, "OneLiner.SetLabel() =", value)
|
log.Log(INFO, "OneLiner.SetLabel() =", value)
|
||||||
if (n.l != nil) {
|
if n.l != nil {
|
||||||
n.l.Set(value)
|
n.l.Set(value)
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
|
@ -42,20 +42,20 @@ func (n *OneLiner) SetLabel(value string) *OneLiner {
|
||||||
|
|
||||||
func (n *OneLiner) Enable() {
|
func (n *OneLiner) Enable() {
|
||||||
log.Log(INFO, "OneLiner.Enable()")
|
log.Log(INFO, "OneLiner.Enable()")
|
||||||
if (n.v != nil) {
|
if n.v != nil {
|
||||||
n.v.Show()
|
n.v.Show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *OneLiner) Disable() {
|
func (n *OneLiner) Disable() {
|
||||||
log.Log(INFO, "OneLiner.Disable()")
|
log.Log(INFO, "OneLiner.Disable()")
|
||||||
if (n.v != nil) {
|
if n.v != nil {
|
||||||
n.v.Hide()
|
n.v.Hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOneLiner(n *gui.Node, label string) *OneLiner {
|
func NewOneLiner(n *gui.Node, label string) *OneLiner {
|
||||||
d := OneLiner {
|
d := OneLiner{
|
||||||
p: n,
|
p: n,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue