diff options
| author | Jeff Carr <[email protected]> | 2023-03-23 12:35:12 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-03-23 12:35:12 -0500 |
| commit | d4787a1ebdd08359746516dbb72f1feaf95be5b6 (patch) | |
| tree | cb81756d61096ccf74af7c8cc9a15e4e00fe1da7 /toolkit/widget.go | |
| parent | 6a848bf40474365cc1c0b4da9e2f7e3e10b4d627 (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/widget.go')
| -rw-r--r-- | toolkit/widget.go | 163 |
1 files changed, 143 insertions, 20 deletions
diff --git a/toolkit/widget.go b/toolkit/widget.go index 30169ba..450cd8b 100644 --- a/toolkit/widget.go +++ b/toolkit/widget.go @@ -1,18 +1,24 @@ package toolkit +type WidgetType int +type ActionType int + // passes information between the toolkit library (plugin) // // All Toolkit interactions should be done via a channel or Queue() -// TODO: FIND THIS NOTE AND FIGURE OUT HOW TO IMPLEMENT IT +// TODO: FIGURE OUT HOW TO IMPLEMENT THIS // // 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() 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]] // Could a protobuf be used here? (Can functions be passed?) type Widget struct { Name string - Action string // "New", "Delete", "Set", aka something to do + // Action string // "New", "Delete", "Set", aka something to do Type WidgetType // This function is how you interact with the toolkit @@ -20,6 +26,7 @@ type Widget struct { // Hopefully this will be the barrier between the goroutines // TODO: move this interaction to channels Custom func() + Callback func() // re-adding an id to test channels id int @@ -48,26 +55,88 @@ type Widget struct { Expand bool } -type WidgetType int +type Action struct { + Type ActionType + + // this should be the widget + // if the action is New, Hide, Enable, etc + Widget *Widget + + // this is the widget + // where the other one should be put on New, Move, etc + Where *Widget + + // This is how the values are passed back and forth + // values from things like checkboxes & dropdown's + // The string is also used to set the button name + B bool + I int + // maybe safe if there is correctly working Custom() between goroutines? + // (still probably not, almost certainly not. not possible. layer violation?) + S string // not safe to have 'S' + + // This GUI is intended for simple things + // We are not laying out PDF's here + // This is used for things like a slider(0,100) + Width int + Height int + X int + Y int + + // Put space around elements to improve look & feel + Margin bool + + // Make widgets fill up the space available + Expand bool +} + // https://ieftimov.com/post/golang-datastructures-trees/ +// TODO: protobuf ? const ( Unknown WidgetType = iota Window - Tab - Group - Frame + Tab // internally, this should be a window (?) + Frame // should windows and tab's be frames (?) + Grid // a grid of frames ? + Group // internally, this should be a grid (?) + Box // internally, this should be a grid (?) Button Checkbox Dropdown - Combobox + Combobox // dropdown with edit=true (?) Label - Textbox + Textbox // is this a Label with edit=true? Slider Spinner - Grid - Box Image + Area + Form + Font + Color + Dialog +) + +const ( + Add ActionType = iota + Delete + Get + Set + SetFlag + GetText + SetText + AddText + Show + Hide + Enable + Disable + Margin + Unmargin + Pad + Unpad + Append + Move + Dump Flag ) @@ -77,10 +146,14 @@ func (s WidgetType) String() string { return "Window" case Tab: return "Tab" - case Group: - return "Group" case Frame: return "Frame" + case Grid: + return "Grid" + case Group: + return "Group" + case Box: + return "Box" case Button: return "Button" case Checkbox: @@ -97,18 +170,68 @@ func (s WidgetType) String() string { return "Slider" case Spinner: return "Spinner" - case Grid: - return "Grid" - case Box: - return "Box" case Image: return "Image" - case Flag: - return "Flag" + case Area: + return "Area" + case Form: + return "Form" + case Font: + return "Font" + case Color: + return "Color" + case Dialog: + return "Dialog" case Unknown: return "Unknown" } - return "GuiToolkitTUndefinedType" + return "Widget.Type.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 SetFlag: + return "SetFlag" + 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 Flag: + return "Flag" + case Dump: + return "Dump" + } + return "Action.Type.String() Error" } // this is hopefully just used in a very few places for |
