From 47b15946de10a75cda026a7317a90d4857b453c8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 13 Jan 2024 22:02:12 -0600 Subject: work on hiding widgets When widgets are hidden, their state works exactly the same as normal, but updates are not sent to the toolkits Signed-off-by: Jeff Carr --- structs.go | 71 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 18 deletions(-) (limited to 'structs.go') diff --git a/structs.go b/structs.go index 079cb6f..7139cea 100644 --- a/structs.go +++ b/structs.go @@ -27,14 +27,15 @@ var me guiConfig // 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 Range struct { +type RangeMovedToWidget struct { Low int High int } -type List []string +// type List []string type guiConfig struct { + // a toolkit requirement. never allow more than one per program initOnce sync.Once // This is the master node. The Binary Tree starts here @@ -52,28 +53,69 @@ type guiConfig struct { resFS embed.FS // used to beautify logging to Stdout - depth int - prefix string +// depth int +// prefix string } -// The Node is a binary tree. This is how all GUI elements are stored -// simply the name and the size of whatever GUI element exists +/* + The Node is a binary tree. This is how all GUI elements are stored + simply the name and the size of whatever GUI element exists + + value : most widgets need 1 value. this is it. + For a window -- the title. For a button -- the name + + hidden : this means the widget is not displayed yet. In that + case, don't waste time trying to pass information to + the toolkits. This makes things efficient and fast if + the GUI does not have to display anything + + Custom() : if the user does something like click on a button, + this function will be called. (this should probably + be renamed Callback() + + progname : a short name to reference the widgets in the debugger + n.NewButton("click here to send it").SetProgName("SENT") + + parent, children : the binary tree + + pad, margin, expand : re-think these names and clarify + +*/ + type Node struct { id int // should be unique - hidden bool // Sierpinski Carpet mode. It's there, but you can't see it. - pad bool // the toolkit may use this. it's up to the toolkit - margin bool // the toolkit may use this. it's up to the toolkit - expand bool // the toolkit may use this. it's up to the toolkit + hidden bool // don't update the toolkits when it's hidden + changed bool // do we need to inform the toolkit something changed? + enabled bool // if false, then the the user can't click on it WidgetType widget.WidgetType - // the current widget value. + // most widgets need one value, this is current alue value any // this can programatically identify the widget // The name must be unique progname string // a name useful for debugging + // for widgets that a user select from a list of strings + strings []string + + // how to arrange widgets + direction widget.Orientation + + // this function is run when there are mouse or keyboard events + Custom func() + + parent *Node + children []*Node + + + // RETHINK EVERYTHING BELOW HERE + pad bool // the toolkit may use this. it's up to the toolkit + margin bool // the toolkit may use this. it's up to the toolkit + expand bool // the toolkit may use this. it's up to the toolkit + + // used for Windows in toolkits measured in pixels width int height int @@ -95,11 +137,4 @@ type Node struct { // if this widget is in a grid, this is the position of a widget AtW int AtH int - - - // this function is run when there are mouse or keyboard events - Custom func() - - parent *Node - children []*Node } -- cgit v1.2.3