summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basicCombobox.go102
-rw-r--r--basicDropdown.go27
-rw-r--r--basicEntry.go16
-rw-r--r--basicLabel.go4
-rw-r--r--durationSlider.go2
-rw-r--r--go.mod6
-rw-r--r--go.sum12
-rw-r--r--logFlag.go2
-rw-r--r--oneLiner.go24
9 files changed, 70 insertions, 125 deletions
diff --git a/basicCombobox.go b/basicCombobox.go
index 4ca27bc..aacf612 100644
--- a/basicCombobox.go
+++ b/basicCombobox.go
@@ -12,32 +12,29 @@
package gadgets
import (
- "reflect"
- "strconv"
-
"go.wit.com/log"
"go.wit.com/gui/gui"
)
type BasicCombobox struct {
ready bool
- name string
+ progname string
parent *gui.Node // parent widget
l *gui.Node // label widget
d *gui.Node // dropdown widget
- value string
- label string
-
- values map[string]string
-
Custom func()
}
-func (d *BasicCombobox) Get() string {
+func (d *BasicCombobox) String() string {
if ! d.Ready() {return ""}
- return d.value
+ return d.d.String()
+}
+
+func (d *BasicCombobox) SetText(s string) {
+ if ! d.Ready() {return}
+ d.d.SetText(s)
}
// Returns true if the status is valid
@@ -64,95 +61,28 @@ func (d *BasicCombobox) SetTitle(name string) {
d.d.SetText(name)
}
-func (d *BasicCombobox) Add(value any) {
+func (d *BasicCombobox) AddText(s string) {
if ! d.Ready() {return}
- log.Log(INFO, "BasicCombobox.Add() =", value)
-
- var b reflect.Kind
- b = reflect.TypeOf(value).Kind()
-
- switch b {
- case reflect.Int:
- var i int
- i = value.(int)
- s := strconv.Itoa(i)
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- case reflect.String:
- s := value.(string)
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- case reflect.Bool:
- if value.(bool) == true {
- s := "true"
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- } else {
- s := "false"
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- }
- default:
- }
-}
-
-func (d *BasicCombobox) Set(value any) bool {
- if ! d.Ready() {return false}
- log.Log(INFO, "BasicCombobox.Set() =", value)
-
- var b reflect.Kind
- b = reflect.TypeOf(value).Kind()
-
- switch b {
- case reflect.Int:
- var i int
- i = value.(int)
- s := strconv.Itoa(i)
- d.d.SetText(s)
- d.value = s
- case reflect.String:
- d.d.SetText(value.(string))
- d.value = value.(string)
- case reflect.Bool:
- if value.(bool) == true {
- d.d.SetText("true")
- d.value = "true"
- } else {
- d.d.SetText("false")
- d.value = "false"
- }
- default:
- return false
- }
- return true
+ log.Log(INFO, "BasicCombobox.Add() =", s)
+ d.d.AddText(s)
}
-func NewBasicCombobox(p *gui.Node, name string) *BasicCombobox {
+func NewBasicCombobox(p *gui.Node, label string) *BasicCombobox {
d := BasicCombobox {
parent: p,
- name: name,
+ progname: label,
ready: false,
}
// various timeout settings
- d.l = p.NewLabel(name)
- d.d = p.NewCombobox("")
+ d.l = p.NewLabel(label)
+ d.d = p.NewCombobox()
d.d.Custom = func() {
- d.value = d.d.GetText()
- log.Warn("BasicCombobox.Custom() user changed value to =", d.value)
+ log.Warn("BasicCombobox.Custom() user changed value to =", d.d.String())
if d.Custom != nil {
d.Custom()
}
}
- d.values = make(map[string]string)
d.ready = true
return &d
}
diff --git a/basicDropdown.go b/basicDropdown.go
index 78af8bd..fbc5137 100644
--- a/basicDropdown.go
+++ b/basicDropdown.go
@@ -30,10 +30,12 @@ type BasicDropdown struct {
Custom func()
}
+/*
func (d *BasicDropdown) Get() string {
if ! d.Ready() {return ""}
return d.d.GetText()
}
+*/
// Returns true if the status is valid
func (d *BasicDropdown) Ready() bool {
@@ -41,19 +43,33 @@ func (d *BasicDropdown) Ready() bool {
return d.ready
}
-func (d *BasicDropdown) Add(value string) {
+func (d *BasicDropdown) AddText(s string) {
if ! d.Ready() {return}
- log.Log(INFO, "BasicDropdown.Set() =", value)
- d.d.AddDropdownName(value)
+ log.Log(INFO, "BasicDropdown.AddText() =", s)
+ d.d.AddText(s)
+ return
+}
+
+func (d *BasicDropdown) SetText(s string) {
+ if ! d.Ready() {return}
+ log.Log(INFO, "BasicDropdown.SetText() =", s)
+ d.d.SetText(s)
return
}
+func (d *BasicDropdown) String() string {
+ 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}
log.Log(INFO, "BasicDropdown.SetLabel() =", value)
d.l.SetText(value)
return true
}
+/*
func (d *BasicDropdown) Set(value string) bool {
if ! d.Ready() {return false}
log.Log(INFO, "BasicDropdown.Set() =", value)
@@ -61,6 +77,7 @@ func (d *BasicDropdown) Set(value string) bool {
d.value = value
return true
}
+*/
func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
d := BasicDropdown {
@@ -71,9 +88,9 @@ func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
// various timeout settings
d.l = p.NewLabel(name)
- d.d = p.NewDropdown("")
+ d.d = p.NewDropdown()
d.d.Custom = func() {
- d.value = d.Get()
+ d.value = d.d.String()
log.Log(INFO, "BasicDropdown.Custom() user changed value to =", d.value)
if d.Custom != nil {
d.Custom()
diff --git a/basicEntry.go b/basicEntry.go
index 6dab1dc..29a0dd8 100644
--- a/basicEntry.go
+++ b/basicEntry.go
@@ -25,6 +25,7 @@ type BasicEntry struct {
Custom func()
}
+/*
func (n *BasicEntry) Get() string {
return n.value
}
@@ -37,6 +38,7 @@ func (n *BasicEntry) Set(value string) *BasicEntry {
n.value = value
return n
}
+*/
func (n *BasicEntry) Enable() {
log.Log(INFO, "BasicEntry.Enable()")
@@ -52,11 +54,13 @@ func (n *BasicEntry) Disable() {
}
}
-func (n *BasicEntry) SetLabel(value string) *BasicEntry {
- log.Log(INFO, "BasicEntry.SetLabel() =", value)
- if (n.l != nil) {
- n.l.Set(value)
- }
+func (n *BasicEntry) String() string {
+ log.Log(INFO, "BasicEntry.SetLabel() =", n.v.String())
+ return n.v.String()
+}
+
+func (n *BasicEntry) SetLabel(s string) *BasicEntry {
+ n.l.SetText(s)
return n
}
@@ -70,7 +74,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.GetText()
+ d.value = d.v.String()
log.Log(INFO, "BasicEntry.Custom() user changed value to =", d.value)
if d.Custom != nil {
d.Custom()
diff --git a/basicLabel.go b/basicLabel.go
index fc410d3..468c44e 100644
--- a/basicLabel.go
+++ b/basicLabel.go
@@ -27,6 +27,7 @@ type BasicLabel struct {
Custom func()
}
+/*
func (n *BasicLabel) Get() string {
return n.value
}
@@ -39,6 +40,7 @@ func (n *BasicLabel) Set(value string) *BasicLabel {
n.value = value
return n
}
+*/
func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
var n *gui.Node
@@ -52,7 +54,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.GetText()
+ d.value = d.v.String()
log.Log(INFO, "BasicLabel.Custom() user changed value to =", d.value)
}
diff --git a/durationSlider.go b/durationSlider.go
index 819fe50..cceb65b 100644
--- a/durationSlider.go
+++ b/durationSlider.go
@@ -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.GetInt()) / 1000
+ d.Duration = low + (high - low) * time.Duration(d.s.Int()) / 1000
log.Println("d.Duration =", d.Duration)
s := fmt.Sprintf("%s (%v)", d.Label, d.Duration)
d.l.SetText(s)
diff --git a/go.mod b/go.mod
index 0c23bf4..814ce49 100644
--- a/go.mod
+++ b/go.mod
@@ -3,13 +3,13 @@ module go.wit.com/gui/gadgets
go 1.21.4
require (
- go.wit.com/gui/gui v0.12.8
- go.wit.com/log v0.5.3
+ go.wit.com/gui/gui v0.12.10
+ go.wit.com/log v0.5.5
)
require (
go.wit.com/dev/alexflint/arg v1.4.5 // indirect
go.wit.com/dev/alexflint/scalar v1.2.1 // indirect
- go.wit.com/dev/davecgh/spew v1.1.3 // indirect
+ go.wit.com/dev/davecgh/spew v1.1.4 // indirect
go.wit.com/gui/widget v1.1.3 // indirect
)
diff --git a/go.sum b/go.sum
index c71e41f..c37fec5 100644
--- a/go.sum
+++ b/go.sum
@@ -2,11 +2,11 @@ go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfM
go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0=
go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
-go.wit.com/dev/davecgh/spew v1.1.3 h1:hqnB5qsPgC2cLZaJXqQJspQ5n/Ugry9kyL3tLk0hVzQ=
-go.wit.com/dev/davecgh/spew v1.1.3/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
-go.wit.com/gui/gui v0.12.8 h1:YJ7YjdP9+vwWYVvMakaJPPpfPt9g33Iw0xfuwNQZkmA=
-go.wit.com/gui/gui v0.12.8/go.mod h1:iALRA0qw7mn82MX21wrU0FOq/vR9l27If7ObNdOSlNE=
+go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
+go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
+go.wit.com/gui/gui v0.12.10 h1:52wFdTqB/GpsFKYFTUvSbHQWNEXz114lhvTfMVrXpYM=
+go.wit.com/gui/gui v0.12.10/go.mod h1:YgbFWxsGqZb45oLGaHim2GukPzPgMLQcVRRI0QkrGS8=
go.wit.com/gui/widget v1.1.3 h1:GvLzGSOF9tfmoh6HNbFdN+NSlBo2qeS/Ba2TnQQ1A1U=
go.wit.com/gui/widget v1.1.3/go.mod h1:A6/FaiFQtAHTjgo7c4FrokXe6bXX1Cowo35b2Lgi31E=
-go.wit.com/log v0.5.3 h1:/zHkniOPusPEuX1R401rMny9uwSO/nSU/QOMx6qoEnE=
-go.wit.com/log v0.5.3/go.mod h1:LzIzVxc2xJQxWQBtV9VbV605P4TOxmYDCl+BZF38yGE=
+go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
+go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
diff --git a/logFlag.go b/logFlag.go
index 80453c3..9aa9d54 100644
--- a/logFlag.go
+++ b/logFlag.go
@@ -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.GetBool())
+ f.lf.Set(f.c.Bool())
log.Info("LogFlag.Custom() user changed value to =", f.lf.Get())
}
f.c.Set(lf.Get())
diff --git a/oneLiner.go b/oneLiner.go
index b75842a..81e2a8b 100644
--- a/oneLiner.go
+++ b/oneLiner.go
@@ -19,22 +19,16 @@ type OneLiner struct {
l *gui.Node // label widget
v *gui.Node // value widget
- value string
- label string
-
Custom func()
}
-func (n *OneLiner) Get() string {
- return n.value
+func (n *OneLiner) String() string {
+ return n.v.String()
}
-func (n *OneLiner) Set(value string) *OneLiner {
- log.Log(INFO, "OneLiner.Set() =", value)
- if (n.v != nil) {
- n.v.Set(value)
- }
- n.value = value
+func (n *OneLiner) SetText(s string) *OneLiner {
+ log.Log(INFO, "OneLiner.Set() =", s)
+ n.v.SetText(s)
return n
}
@@ -60,18 +54,16 @@ func (n *OneLiner) Disable() {
}
}
-func NewOneLiner(n *gui.Node, name string) *OneLiner {
+func NewOneLiner(n *gui.Node, label string) *OneLiner {
d := OneLiner {
p: n,
- value: "",
}
// various timeout settings
- d.l = n.NewLabel(name)
+ d.l = n.NewLabel(label)
d.v = n.NewLabel("")
d.v.Custom = func() {
- 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.v.String())
}
return &d