summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/textbox.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-03-23 12:35:12 -0500
committerJeff Carr <[email protected]>2023-03-23 12:35:12 -0500
commitd4787a1ebdd08359746516dbb72f1feaf95be5b6 (patch)
treecb81756d61096ccf74af7c8cc9a15e4e00fe1da7 /toolkit/andlabs/textbox.go
parent6a848bf40474365cc1c0b4da9e2f7e3e10b4d627 (diff)
Squashed commit of the following:v0.7.3
boxes now exist and are tracked in the binary tree create for group and grid works gocui plugin no longer works. TODO: fix in next release converted everything from plugin to Action() can remove send() tab and window are now action() flags moved to action() ready for new release pad() margion() border() all work move worked! go.wit.com attept 578th try adds an early grid widget. won't work until chan andlabs/ui grid (X,Y) works right actually can put things in places in a grid Queue() means shit doesn't look right on grids lots of fucking around. why am I wasting time on image? wow. the crazy doAppend() thing is gone implement Action Show() and Hide() Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs/textbox.go')
-rw-r--r--toolkit/andlabs/textbox.go138
1 files changed, 17 insertions, 121 deletions
diff --git a/toolkit/andlabs/textbox.go b/toolkit/andlabs/textbox.go
index 9f7c3b4..cff61f2 100644
--- a/toolkit/andlabs/textbox.go
+++ b/toolkit/andlabs/textbox.go
@@ -7,142 +7,38 @@ import (
_ "github.com/andlabs/ui/winmanifest"
)
-func newTextbox(parentW *toolkit.Widget, w *toolkit.Widget) {
- log(debugToolkit, "NewTexbox()", w.Name)
-
- t := mapToolkits[parentW]
- if (t == nil) {
- listMap(debugError)
- log(debugError, "newTextbox() listMap()")
- log(debugError, "FFFFFFFFFFFF listMap()")
- log(debugError, "FFFFFFFFFFFF listMap()")
- }
-
- // t.NewTextbox(w)
-// func (t *andlabsT) NewTextbox(w *toolkit.Widget) *andlabsT {
- var newt *andlabsT
- newt = new(andlabsT)
-
- log(debugToolkit, "gui.Toolkit.NewTextbox()", w.Name)
- if t.broken() {
- return
- }
+// func newTextbox(a *toolkit.Action) {
+func (t *andlabsT) newTextbox(w *toolkit.Widget) *andlabsT {
+ var newt andlabsT
c := ui.NewNonWrappingMultilineEntry()
newt.uiMultilineEntry = c
+ newt.uiControl = c
- newt.uiBox = t.uiBox
newt.Name = w.Name
newt.tw = w
- if (defaultBehavior) {
- t.uiBox.Append(c, true)
- } else {
- t.uiBox.Append(c, stretchy)
- }
-
- /*
- // don't bother with "images" on andlabs/ui
- "image"
- "bytes"
- _ "image/png"
- "image/draw"
-
- if (w.Name == "image") {
- log(true, "NewTextbox() trying to add a new image")
- i := ui.NewImage(16, 16)
- img, _, err := image.Decode(bytes.NewReader(rawImage))
- if err != nil {
- panic(err)
- }
- nr, ok := img.(*image.RGBA)
- if !ok {
- i2 := image.NewRGBA(img.Bounds())
- draw.Draw(i2, i2.Bounds(), img, img.Bounds().Min, draw.Src)
- nr = i2
- }
- i.Append(nr)
- t.uiBox.Append(i, true)
-
- var img *ui.Image
- var icon []byte
- var imgA image.Image
-
- icon, _ = res.ReadFile("resources/ping6.working.png")
- // imgA, _, err := image.Decode(bytes.NewReader(b))
- imgA, _, _ = image.Decode(icon)
- img.Append(imgA)
- img.Append(icon)
- }
- */
c.OnChanged(func(spin *ui.MultilineEntry) {
- w.S = newt.uiMultilineEntry.Text()
+ t.s = spin.Text()
// this is still dangerous
// newt.commonChange(newt.tw)
log(debugChange, "Not yet safe to trigger on change for ui.MultilineEntry")
})
- mapWidgetsToolkits(w, newt)
+ return &newt
}
+func newTextbox(a *toolkit.Action) {
+ w := a.Widget
+ parentW := a.Where
+ log(debugToolkit, "newCombobox()", w.Name)
-func doTextbox(p *toolkit.Widget, c *toolkit.Widget) {
- if broken(c) {
- return
- }
- if (c.Action == "New") {
- newTextbox(p, c)
- return
- }
- ct := mapToolkits[c]
- if (ct == nil) {
- log(debugError, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
- return
- }
- if ct.broken() {
- log(debugError, "Textbox() ct.broken", ct)
- return
- }
- if (ct.uiMultilineEntry == nil) {
- log(debugError, "Textbox() uiMultilineEntry == nil", ct)
+ t := mapToolkits[parentW]
+ if (t == nil) {
+ log(debugToolkit, "newCombobox() toolkit struct == nil. name=", parentW.Name, w.Name)
+ listMap(debugToolkit)
return
}
- // the dns control panel isn't crashing anymore (?)
- Queue(ct.doSimpleAction)
-}
-
-func (t *andlabsT) doSimpleAction() {
- if (t.tw == nil) {
- log(true, "doSimpleAction() got an empty widget")
- log(true, "THIS SHOULD NEVER HAPPEN")
- panic("crap. panic. widget == nil")
- }
- log(debugChange, "Going to attempt:", t.tw.Action)
- switch t.tw.Action {
- case "Enable":
- if (t.uiEntry != nil) {
- t.uiEntry.Enable()
- } else if (t.uiMultilineEntry != nil) {
- t.uiMultilineEntry.Enable()
- } else {
- log(debugError, "don't know what to enable", t.Name)
- }
- case "Disable":
- if (t.uiEntry != nil) {
- t.uiEntry.Disable()
- } else if (t.uiMultilineEntry != nil) {
- t.uiMultilineEntry.Disable()
- } else {
- log(debugError, "don't know what to disable", t.Name)
- }
- case "Show":
- t.uiMultilineEntry.Show()
- case "Hide":
- t.uiMultilineEntry.Hide()
- case "SetText":
- t.uiMultilineEntry.SetText(t.tw.S)
- case "Set":
- t.uiMultilineEntry.SetText(t.tw.S)
- default:
- log(debugError, "Can't do", t.tw.Action, "to a Textbox")
- }
+ newt := t.newTextbox(w)
+ place(a, t, newt)
+ mapWidgetsToolkits(a, newt)
}