works with new toolkit and gui changes

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-17 21:05:52 -06:00
parent 38595e75f2
commit d91e80a9ea
3 changed files with 74 additions and 3 deletions

View File

@ -7,6 +7,8 @@ type Action struct {
WidgetId int WidgetId int
ParentId int ParentId int
State State
// Text string // what is visable to the user // Text string // what is visable to the user
ProgName string // a name useful for programming ProgName string // a name useful for programming
@ -67,8 +69,11 @@ const (
Move Move
Dump Dump
User // the user did something (mouse, keyboard, etc) User // the user did something (mouse, keyboard, etc)
InitToolkit // initializes the toolkit ToolkitLoad // attempts to load a new toolkit
CloseToolkit // closes the toolkit ToolkitInit // initializes the toolkit
ToolkitClose // closes the toolkit
ToolkitPanic
CloseWindow
UserQuit // the user closed the GUI UserQuit // the user closed the GUI
EnableDebug // open the debugging window EnableDebug // open the debugging window
) )

View File

@ -106,7 +106,10 @@ func GetInt(A any) int {
return A.(int) return A.(int)
case reflect.String: case reflect.String:
tmp := A.(string) tmp := A.(string)
i, _ := strconv.Atoi(tmp) i, err := strconv.Atoi(tmp)
if err != nil {
return -1
}
return i return i
case reflect.Bool: case reflect.Bool:
if A.(bool) { if A.(bool) {

63
state.go Normal file
View File

@ -0,0 +1,63 @@
package widget
// This is the state of the widget
// The whole state of the widget is sent
// when the widget action is Add() or Show()
// Range(1, 10) includes the values 1 and 10
// almost all toolkits use integers so there doesn't
// seem to be a good idea to use 'type any' here as it
// just makes things more complicated for no good reason
type State struct {
// This is a unmodifiable string that is displayed to the user.
Label string
// most primitive widgets just store a single thing
// it is the default value
Value any
// how to arrange widgets
Direction Orientation
//
// This is complicated. We must send a list of all the widgets
// in the binary tree to the toolkits because some toolkits
// must make the widgets exist and then hide them.
//
// However, when a widget is not visable, no updates to the
// widget is sent to the toolkit and no events from the
// widget are valid back to the program
//
Visable bool
// if false, pack things as tightly as possible
Pad bool
// trys to fill up available space
Expand bool
// All the strings for things like dropdown menus
// They must be sent in display order
// These must be unique
Strings []string
// for widgets that use a range
Range RangeType
Geom Geom
Size Size
GridSize GridSize
GridOffset GridOffset
// This is for the grid size & widget position
W int
H int
AtW int
AtH int
// a name useful for programming and the debugger.
// It is not intended to be displayed to the user
ProgName string
}