summaryrefslogtreecommitdiff
path: root/gadgets
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-01 15:43:50 -0600
committerJeff Carr <[email protected]>2024-01-01 15:43:50 -0600
commit4e7bbd89900a733593f0848778103c1cf1a7145d (patch)
tree22cd22124dd3ecba7c2a866b882d39aaf790d670 /gadgets
parent53ce3a8252090d5fb75d7fc1e3cd75a72c1415c6 (diff)
reorg to final resting place at go.wit.com/gui/guiv0.9.5
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'gadgets')
-rw-r--r--gadgets/README.md15
-rw-r--r--gadgets/basicCombobox.go79
-rw-r--r--gadgets/basicDropdown.go79
-rw-r--r--gadgets/basicEntry.go56
-rw-r--r--gadgets/basicLabel.go60
-rw-r--r--gadgets/durationSlider.go79
-rw-r--r--gadgets/logSettings.go72
-rw-r--r--gadgets/oneLiner.go56
8 files changed, 0 insertions, 496 deletions
diff --git a/gadgets/README.md b/gadgets/README.md
deleted file mode 100644
index 66c2a4f..0000000
--- a/gadgets/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# gadgets
-
-Package gadgets are special collections of widgets
-
-Things to avoid or keep in mind: Also Features these might enable:
-
-```go
-* These should never bypass the binary tree
-* Hide complexity internally here
-* These might require corresponding toolkit implementations?
-* These might allow unique/good corresponding toolkit implementations (date/time selection?)
-
-## Warning
-
-Doing this / adding these might be a really bad idea that I will regret later
diff --git a/gadgets/basicCombobox.go b/gadgets/basicCombobox.go
deleted file mode 100644
index f008eb0..0000000
--- a/gadgets/basicCombobox.go
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- A Labeled Combobox widget:
-
- -----------------------------
- | | |
- | Food: | <dropdown> |
- | | |
- -----------------------------
-
- The user can then edit the dropdown field and type anything into it
-*/
-package gadgets
-
-import (
- "go.wit.com/log"
- "go.wit.com/gui"
-)
-
-type BasicCombobox struct {
- ready bool
- name string
-
- parent *gui.Node // parent widget
- l *gui.Node // label widget
- d *gui.Node // dropdown widget
-
- value string
- label string
-
- Custom func()
-}
-
-func (d *BasicCombobox) Get() string {
- if ! d.Ready() {return ""}
- return d.value
-}
-
-// Returns true if the status is valid
-func (d *BasicCombobox) Ready() bool {
- if d == nil {return false}
- return d.ready
-}
-
-func (d *BasicCombobox) Add(value string) {
- if ! d.Ready() {return}
- log.Println("BasicCombobox.Add() =", value)
- d.d.AddDropdownName(value)
- return
-}
-
-func (d *BasicCombobox) Set(value string) bool {
- if ! d.Ready() {return false}
- log.Println("BasicCombobox.Set() =", value)
- d.d.SetText(value)
- d.value = value
- return true
-}
-
-func NewBasicCombobox(p *gui.Node, name string) *BasicCombobox {
- d := BasicCombobox {
- parent: p,
- name: name,
- ready: false,
- }
-
- // various timeout settings
- d.l = p.NewLabel(name)
- d.d = p.NewCombobox("")
- d.d.Custom = func() {
- d.value = d.Get()
- log.Println("BasicCombobox.Custom() user changed value to =", d.value)
- if d.Custom != nil {
- d.Custom()
- }
- }
-
- d.ready = true
- return &d
-}
diff --git a/gadgets/basicDropdown.go b/gadgets/basicDropdown.go
deleted file mode 100644
index d64aed7..0000000
--- a/gadgets/basicDropdown.go
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- A Labeled Dropdown widget:
-
- -----------------------------
- | | |
- | Food: | <dropdown> |
- | | |
- -----------------------------
-
- This being a 'Basic Dropdown', the dropdown names must be unique
-*/
-package gadgets
-
-import (
- "go.wit.com/log"
- "go.wit.com/gui"
-)
-
-type BasicDropdown struct {
- ready bool
- name string
-
- parent *gui.Node // parent widget
- l *gui.Node // label widget
- d *gui.Node // dropdown widget
-
- value string
- label string
-
- 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 {
- if d == nil {return false}
- return d.ready
-}
-
-func (d *BasicDropdown) Add(value string) {
- if ! d.Ready() {return}
- log.Println("BasicDropdown.Set() =", value)
- d.d.AddDropdownName(value)
- return
-}
-
-func (d *BasicDropdown) Set(value string) bool {
- if ! d.Ready() {return false}
- log.Println("BasicDropdown.Set() =", value)
- d.l.SetText(value)
- d.value = value
- return true
-}
-
-func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
- d := BasicDropdown {
- parent: p,
- name: name,
- ready: false,
- }
-
- // various timeout settings
- d.l = p.NewLabel(name)
- d.d = p.NewDropdown("")
- d.d.Custom = func() {
- d.value = d.Get()
- log.Println("BasicDropdown.Custom() user changed value to =", d.value)
- if d.Custom != nil {
- d.Custom()
- }
- }
-
- d.ready = true
- return &d
-}
diff --git a/gadgets/basicEntry.go b/gadgets/basicEntry.go
deleted file mode 100644
index 105347b..0000000
--- a/gadgets/basicEntry.go
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- A Labeled Single Line Entry widget:
-
- -----------------------------
- | | |
- | Food: | <type here> |
- | | |
- -----------------------------
-*/
-package gadgets
-
-import (
- "go.wit.com/log"
- "go.wit.com/gui"
-)
-
-type BasicEntry struct {
- parent *gui.Node // parent widget
- l *gui.Node // label widget
- v *gui.Node // value widget
-
- value string
- label string
-
- Custom func()
-}
-
-func (n *BasicEntry) Get() string {
- return n.value
-}
-
-func (n *BasicEntry) Set(value string) *BasicEntry {
- log.Println("BasicEntry.Set() =", value)
- if (n.v != nil) {
- n.v.Set(value)
- }
- n.value = value
- return n
-}
-
-func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
- d := BasicEntry {
- parent: p,
- value: "",
- }
-
- // various timeout settings
- d.l = p.NewLabel(name)
- d.v = p.NewEntryLine("")
- d.v.Custom = func() {
- d.value = d.v.S
- log.Println("BasicEntry.Custom() user changed value to =", d.value)
- }
-
- return &d
-}
diff --git a/gadgets/basicLabel.go b/gadgets/basicLabel.go
deleted file mode 100644
index a952912..0000000
--- a/gadgets/basicLabel.go
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- A Labeled label:
-
- -----------------------------
- | | |
- | Food: | Apple |
- | | |
- -----------------------------
-*/
-package gadgets
-
-import (
- "go.wit.com/log"
- "go.wit.com/gui"
-)
-
-type Node gui.Node
-
-type BasicLabel struct {
- p *gui.Node // parent widget
- l *gui.Node // label widget
- v *gui.Node // value widget
-
- value string
- label string
-
- Custom func()
-}
-
-func (n *BasicLabel) Get() string {
- return n.value
-}
-
-func (n *BasicLabel) Set(value string) *BasicLabel {
- log.Println("BasicLabel.Set() =", value)
- if (n.v != nil) {
- n.v.Set(value)
- }
- n.value = value
- return n
-}
-
-func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
- var n *gui.Node
- n = (*gui.Node)(ngui)
- d := BasicLabel {
- p: n,
- value: "",
- }
-
- // various timeout settings
- d.l = n.NewLabel(name)
- d.v = n.NewLabel("")
- d.v.Custom = func() {
- d.value = d.v.S
- log.Println("BasicLabel.Custom() user changed value to =", d.value)
- }
-
- return &d
-}
diff --git a/gadgets/durationSlider.go b/gadgets/durationSlider.go
deleted file mode 100644
index 6f81214..0000000
--- a/gadgets/durationSlider.go
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- A slider that goes between a High and Low time
-*/
-
-package gadgets
-
-import (
- "log"
- "fmt"
- "time"
-
- "go.wit.com/gui"
-)
-
-type Duration struct {
- p *gui.Node // parent widget
- l *gui.Node // label widget
- s *gui.Node // slider widget
-
- Label string
- Low time.Duration
- High time.Duration
- Duration time.Duration
-
- Custom func()
-}
-
-func (n *Duration) Set(d time.Duration) {
- var timeRange, step, offset time.Duration
-
- if (d > n.High) {
- d = n.High
- }
- if (d < n.Low) {
- d = n.Low
- }
-
- // set the duration
- n.Duration = d
-
- // figure out the integer offset for the Slider GUI Widget
- timeRange = n.High - n.Low
- step = timeRange / 1000
- if (step == 0) {
- log.Println("duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
- n.s.Set(0)
- return
- }
- offset = d - n.Low
- i := int(offset / step)
- log.Println("duration.Set() =", n.Low, n.High, d, "i =", i)
- n.s.I = i
- n.s.Set(i)
- n.s.Custom()
-}
-
-func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.Duration) *Duration {
- d := Duration {
- p: n,
- Label: label,
- High: high,
- Low: low,
- }
-
- // various timeout settings
- 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
- log.Println("d.Duration =", d.Duration)
- s := fmt.Sprintf("%s (%v)", d.Label, d.Duration)
- d.l.SetText(s)
- if (d.Custom != nil) {
- d.Custom()
- }
- }
-
- return &d
-}
diff --git a/gadgets/logSettings.go b/gadgets/logSettings.go
deleted file mode 100644
index 77c94a4..0000000
--- a/gadgets/logSettings.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package gadgets
-
-import (
- "go.wit.com/log"
- "go.wit.com/gui"
-)
-
-var myLogGui *LogSettings
-
-type LogSettings struct {
- ready bool
- hidden bool
- err error
-
- parent *gui.Node // should be the root of the 'gui' package binary tree
- window *gui.Node // our window for displaying the log package settings
- group *gui.Node //
- grid *gui.Node //
-
- // Primary Directives
- status *OneLiner
- summary *OneLiner
-}
-
-// This is initializes the main DO object
-// You can only have one of these
-func NewLogSettings(p *gui.Node) *LogSettings {
- if myLogGui != nil {return myLogGui}
- myLogGui = new(LogSettings)
- myLogGui.parent = p
-
- myLogGui.ready = false
-
- myLogGui.window = p.NewWindow("Log Settings")
-
- // make a group label and a grid
- myLogGui.group = myLogGui.window.NewGroup("droplets:").Pad()
- myLogGui.grid = myLogGui.group.NewGrid("grid", 2, 1).Pad()
-
- myLogGui.ready = true
- myLogGui.Hide()
- return myLogGui
-}
-
-// Returns true if the status is valid
-func (d *LogSettings) Ready() bool {
- if d == nil {return false}
- return d.ready
-}
-
-func (d *LogSettings) Show() {
- if ! d.Ready() {return}
- log.Info("LogSettings.Show() window")
- if d.hidden {
- d.window.Show()
- }
- d.hidden = false
-}
-
-func (d *LogSettings) Hide() {
- if ! d.Ready() {return}
- log.Info("LogSettings.Hide() window")
- if ! d.hidden {
- d.window.Hide()
- }
- d.hidden = true
-}
-
-func (d *LogSettings) Update() bool {
- if ! d.Ready() {return false}
- return true
-}
diff --git a/gadgets/oneLiner.go b/gadgets/oneLiner.go
deleted file mode 100644
index 529cec3..0000000
--- a/gadgets/oneLiner.go
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- A Labeled label:
-
- -----------------------------
- | | |
- | Food: | Apple |
- | | |
- -----------------------------
-*/
-package gadgets
-
-import (
- "go.wit.com/log"
- "go.wit.com/gui"
-)
-
-type OneLiner struct {
- p *gui.Node // parent widget
- 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) Set(value string) *OneLiner {
- log.Println("OneLiner.Set() =", value)
- if (n.v != nil) {
- n.v.Set(value)
- }
- n.value = value
- return n
-}
-
-func NewOneLiner(n *gui.Node, name string) *OneLiner {
- d := OneLiner {
- p: n,
- value: "",
- }
-
- // various timeout settings
- d.l = n.NewLabel(name)
- d.v = n.NewLabel("")
- d.v.Custom = func() {
- d.value = d.v.S
- log.Println("OneLiner.Custom() user changed value to =", d.value)
- }
-
- return &d
-}