move widget.go in this archive
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b54d697173
commit
38a4e969be
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) show(b bool) {
|
func (n *node) show(b bool) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
_ "github.com/andlabs/ui/winmanifest"
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func actionDump(b bool, a *toolkit.Action) {
|
func actionDump(b bool, a *toolkit.Action) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultBehavior bool = true
|
var defaultBehavior bool = true
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
// if you include more than just this import
|
// if you include more than just this import
|
||||||
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
||||||
import "go.wit.com/gui/gui/toolkit"
|
import "go.wit.com/gui/toolkits"
|
||||||
|
|
||||||
// delete the child widget from the parent
|
// delete the child widget from the parent
|
||||||
// p = parent, c = child
|
// p = parent, c = child
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
_ "github.com/andlabs/ui/winmanifest"
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *node) newDropdown(n *node) {
|
func (p *node) newDropdown(n *node) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
|
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
// the _ means we only need this for the init()
|
// the _ means we only need this for the init()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) setText(a *toolkit.Action) {
|
func (n *node) setText(a *toolkit.Action) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
|
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
_ "github.com/andlabs/ui/winmanifest"
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this is specific to the nocui toolkit
|
// this is specific to the nocui toolkit
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fakeStartWidth int = me.FakeW
|
var fakeStartWidth int = me.FakeW
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "github.com/awesome-gocui/gocui"
|
// "github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) setCheckbox(b bool) {
|
func (n *node) setCheckbox(b bool) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// set isCurrent = false everywhere
|
// set isCurrent = false everywhere
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) dumpTree(draw bool) {
|
func (n *node) dumpTree(draw bool) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultKeybindings(g *gocui.Gui) error {
|
func defaultKeybindings(g *gocui.Gui) error {
|
||||||
|
|
|
@ -6,7 +6,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sets defaults and establishes communication
|
// sets defaults and establishes communication
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) placeBox(startW int, startH int) {
|
func (n *node) placeBox(startW int, startH int) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
// if you include more than just this import
|
// if you include more than just this import
|
||||||
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func action(a *toolkit.Action) {
|
func action(a *toolkit.Action) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
var outputW int = 180
|
var outputW int = 180
|
||||||
|
|
|
@ -4,7 +4,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *guiWidget) Width() int {
|
func (w *guiWidget) Width() int {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func splitLines(s string) []string {
|
func splitLines(s string) []string {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initWidget(n *node) *guiWidget {
|
func initWidget(n *node) *guiWidget {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) show(b bool) {
|
func (n *node) show(b bool) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ package main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this is the channel we send user events like
|
// this is the channel we send user events like
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) doWidgetClick() {
|
func (n *node) doWidgetClick() {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
var muAction sync.Mutex
|
var muAction sync.Mutex
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func simpleStdin() {
|
func simpleStdin() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this is specific to the nocui toolkit
|
// this is specific to the nocui toolkit
|
||||||
|
|
|
@ -0,0 +1,204 @@
|
||||||
|
package toolkit
|
||||||
|
|
||||||
|
// passes information between the toolkit library (plugin)
|
||||||
|
//
|
||||||
|
// This is the only thing that is passed between the toolkit plugin
|
||||||
|
//
|
||||||
|
// what names should be used? This is not part of [[Graphical Widget]]
|
||||||
|
// Event() seems like a good name.
|
||||||
|
// Event is used too much: web dev, cloud, etc
|
||||||
|
// I'm using "Action". Maybe it should really be
|
||||||
|
// "Interaction" as per wikipedia [[User interface]]
|
||||||
|
//
|
||||||
|
// TODO: convert this to a protobuf (?)
|
||||||
|
//
|
||||||
|
|
||||||
|
type WidgetType int // Button, Menu, Checkbox, etc.
|
||||||
|
type ActionType int // Add, SetText, Click, Hide, Append, Delete, etc
|
||||||
|
|
||||||
|
type Action struct {
|
||||||
|
ActionType ActionType
|
||||||
|
WidgetType WidgetType
|
||||||
|
|
||||||
|
WidgetId int
|
||||||
|
ParentId int
|
||||||
|
|
||||||
|
Text string // what is visable to the user
|
||||||
|
Name string // a name useful for programming
|
||||||
|
|
||||||
|
// This is how the values are passed back and forth
|
||||||
|
// values from things like checkboxes & dropdown's
|
||||||
|
B bool
|
||||||
|
I int
|
||||||
|
S string
|
||||||
|
|
||||||
|
// This is used for things like a slider(0,100)
|
||||||
|
X int
|
||||||
|
Y int
|
||||||
|
|
||||||
|
// This is for the grid size & widget position
|
||||||
|
W int
|
||||||
|
H int
|
||||||
|
AtW int
|
||||||
|
AtH int
|
||||||
|
|
||||||
|
// Put space around elements to improve look & feel
|
||||||
|
Margin bool
|
||||||
|
|
||||||
|
// Make widgets fill up the space available
|
||||||
|
Expand bool
|
||||||
|
|
||||||
|
A any // switch to this or deprecate this? pros/cons?
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
Unknown WidgetType = iota
|
||||||
|
Root // the master 'root' node of the binary tree
|
||||||
|
Flag // used to send configuration values to plugins
|
||||||
|
Window // in certain gui's (ncurses), these are tabs
|
||||||
|
Tab // internally, this is a window
|
||||||
|
Frame // deprecate?
|
||||||
|
Grid // like drawers in a chest
|
||||||
|
Group // like the 'Appetizers' section on a menu
|
||||||
|
Box // a vertical or horizontal stack of widgets
|
||||||
|
Button
|
||||||
|
Checkbox // select 'on' or 'off'
|
||||||
|
Dropdown
|
||||||
|
Combobox // dropdown with edit=true
|
||||||
|
Label
|
||||||
|
Textbox // is this a Label with edit=true
|
||||||
|
Slider // like a progress bar
|
||||||
|
Spinner // like setting the oven temperature
|
||||||
|
Separator // TODO
|
||||||
|
Image // TODO
|
||||||
|
Area // TODO
|
||||||
|
Form // TODO
|
||||||
|
Font // TODO
|
||||||
|
Color // TODO
|
||||||
|
Dialog // TODO
|
||||||
|
Stdout // can be used to capture and display log output
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Add ActionType = iota
|
||||||
|
Delete
|
||||||
|
Get
|
||||||
|
Set
|
||||||
|
GetText
|
||||||
|
SetText
|
||||||
|
AddText
|
||||||
|
Show
|
||||||
|
Hide
|
||||||
|
Enable
|
||||||
|
Disable
|
||||||
|
Margin
|
||||||
|
Unmargin
|
||||||
|
Pad
|
||||||
|
Unpad
|
||||||
|
Append
|
||||||
|
Move
|
||||||
|
Dump
|
||||||
|
User // the user did something (mouse, keyboard, etc)
|
||||||
|
InitToolkit // initializes the toolkit
|
||||||
|
CloseToolkit // closes the toolkit
|
||||||
|
UserQuit // the user closed the GUI
|
||||||
|
EnableDebug // open the debugging window
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s WidgetType) String() string {
|
||||||
|
switch s {
|
||||||
|
case Root:
|
||||||
|
return "Root"
|
||||||
|
case Flag:
|
||||||
|
return "Flag"
|
||||||
|
case Window:
|
||||||
|
return "Window"
|
||||||
|
case Tab:
|
||||||
|
return "Tab"
|
||||||
|
case Frame:
|
||||||
|
return "Frame"
|
||||||
|
case Grid:
|
||||||
|
return "Grid"
|
||||||
|
case Group:
|
||||||
|
return "Group"
|
||||||
|
case Box:
|
||||||
|
return "Box"
|
||||||
|
case Button:
|
||||||
|
return "Button"
|
||||||
|
case Checkbox:
|
||||||
|
return "Checkbox"
|
||||||
|
case Dropdown:
|
||||||
|
return "Dropdown"
|
||||||
|
case Combobox:
|
||||||
|
return "Combobox"
|
||||||
|
case Label:
|
||||||
|
return "Label"
|
||||||
|
case Textbox:
|
||||||
|
return "Textbox"
|
||||||
|
case Slider:
|
||||||
|
return "Slider"
|
||||||
|
case Spinner:
|
||||||
|
return "Spinner"
|
||||||
|
case Separator:
|
||||||
|
return "Separator"
|
||||||
|
case Image:
|
||||||
|
return "Image"
|
||||||
|
case Area:
|
||||||
|
return "Area"
|
||||||
|
case Form:
|
||||||
|
return "Form"
|
||||||
|
case Font:
|
||||||
|
return "Font"
|
||||||
|
case Color:
|
||||||
|
return "Color"
|
||||||
|
case Dialog:
|
||||||
|
return "Dialog"
|
||||||
|
case Stdout:
|
||||||
|
return "Stdout"
|
||||||
|
case Unknown:
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
return "WidgetType.String() Error"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ActionType) String() string {
|
||||||
|
switch s {
|
||||||
|
case Add:
|
||||||
|
return "Add"
|
||||||
|
case Delete:
|
||||||
|
return "Delete"
|
||||||
|
case Get:
|
||||||
|
return "Get"
|
||||||
|
case Set:
|
||||||
|
return "Set"
|
||||||
|
case GetText:
|
||||||
|
return "GetText"
|
||||||
|
case SetText:
|
||||||
|
return "SetText"
|
||||||
|
case AddText:
|
||||||
|
return "AddText"
|
||||||
|
case Show:
|
||||||
|
return "Show"
|
||||||
|
case Hide:
|
||||||
|
return "Hide"
|
||||||
|
case Enable:
|
||||||
|
return "Enable"
|
||||||
|
case Disable:
|
||||||
|
return "Disable"
|
||||||
|
case Margin:
|
||||||
|
return "Margin"
|
||||||
|
case Unmargin:
|
||||||
|
return "Unmargin"
|
||||||
|
case Pad:
|
||||||
|
return "Pad"
|
||||||
|
case Unpad:
|
||||||
|
return "Unpad"
|
||||||
|
case Append:
|
||||||
|
return "Append"
|
||||||
|
case Move:
|
||||||
|
return "Move"
|
||||||
|
case Dump:
|
||||||
|
return "Dump"
|
||||||
|
}
|
||||||
|
return "ActionType.String() Error"
|
||||||
|
}
|
Loading…
Reference in New Issue