2022-11-13 08:53:03 -06:00
|
|
|
package toolkit
|
2022-11-09 08:38:50 -06:00
|
|
|
|
|
|
|
// passes information between the toolkit library (plugin)
|
2023-02-25 14:05:25 -06:00
|
|
|
//
|
2022-11-09 08:38:50 -06:00
|
|
|
// All Toolkit interactions should be done via a channel or Queue()
|
2023-02-25 14:05:25 -06:00
|
|
|
// TODO: FIND THIS NOTE AND FIGURE OUT HOW TO IMPLEMENT IT
|
|
|
|
//
|
2022-11-09 08:38:50 -06:00
|
|
|
// This is the only thing that is passed between the toolkit plugin
|
2023-02-25 14:05:25 -06:00
|
|
|
//
|
2022-11-09 08:38:50 -06:00
|
|
|
// what names should be used? This is not part of [[Graphical Widget]]
|
|
|
|
// Event() seems like a good name.
|
|
|
|
// Could a protobuf be used here? (Can functions be passed?)
|
|
|
|
type Widget struct {
|
2023-03-01 11:35:36 -06:00
|
|
|
Name string // "New", "Delete", "Set", aka something to do
|
|
|
|
Action string // "New", "Delete", "Set", aka something to do
|
|
|
|
// Type string // after lots of back and forth, a simple string
|
|
|
|
Type WidgetType
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
S string // not safe to have 'S'
|
2023-02-25 14:05:25 -06:00
|
|
|
|
|
|
|
// 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)
|
2022-11-09 08:38:50 -06:00
|
|
|
Width int
|
|
|
|
Height int
|
2022-11-13 08:53:03 -06:00
|
|
|
X int
|
|
|
|
Y int
|
2022-11-09 08:38:50 -06:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
// Put space around elements to improve look & feel
|
|
|
|
Margin bool
|
2022-11-09 08:38:50 -06:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
// Make widgets fill up the space available
|
|
|
|
Expand bool
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
// latest attempt. seems to work so far (2023/02/28)
|
|
|
|
// Hopefully this will be the barrier between the goroutines
|
|
|
|
Custom func()
|
2022-11-13 08:53:03 -06:00
|
|
|
}
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
type WidgetType int
|
2022-11-09 08:38:50 -06:00
|
|
|
|
|
|
|
// https://ieftimov.com/post/golang-datastructures-trees/
|
|
|
|
const (
|
2023-03-01 11:35:36 -06:00
|
|
|
Unknown WidgetType = iota
|
2022-11-09 08:38:50 -06:00
|
|
|
Window
|
|
|
|
Tab
|
2023-03-01 11:35:36 -06:00
|
|
|
Group
|
2022-11-09 08:38:50 -06:00
|
|
|
Frame
|
2023-03-01 11:35:36 -06:00
|
|
|
Button
|
|
|
|
Checkbox
|
|
|
|
Dropdown
|
2022-11-09 08:38:50 -06:00
|
|
|
Label
|
2023-03-01 11:35:36 -06:00
|
|
|
Textbox
|
|
|
|
Slider
|
|
|
|
Spinner
|
2022-11-09 08:38:50 -06:00
|
|
|
)
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
func (s WidgetType) String() string {
|
2022-11-09 08:38:50 -06:00
|
|
|
switch s {
|
|
|
|
case Window:
|
|
|
|
return "Window"
|
|
|
|
case Tab:
|
|
|
|
return "Tab"
|
2023-03-01 11:35:36 -06:00
|
|
|
case Group:
|
|
|
|
return "Group"
|
2022-11-09 08:38:50 -06:00
|
|
|
case Frame:
|
|
|
|
return "Frame"
|
2023-03-01 11:35:36 -06:00
|
|
|
case Button:
|
|
|
|
return "Button"
|
|
|
|
case Checkbox:
|
|
|
|
return "Checkbox"
|
|
|
|
case Dropdown:
|
|
|
|
return "Dropdown"
|
2022-11-09 08:38:50 -06:00
|
|
|
case Label:
|
|
|
|
return "Label"
|
2023-03-01 11:35:36 -06:00
|
|
|
case Textbox:
|
|
|
|
return "Textbox"
|
|
|
|
case Slider:
|
|
|
|
return "Slider"
|
|
|
|
case Spinner:
|
|
|
|
return "Spinner"
|
|
|
|
case Unknown:
|
|
|
|
return "Unknown"
|
2022-11-09 08:38:50 -06:00
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
return "GuiToolkitTUndefinedType"
|
2022-11-09 08:38:50 -06:00
|
|
|
}
|