diff options
| author | Jeff Carr <[email protected]> | 2024-01-13 13:31:35 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-13 13:31:35 -0600 |
| commit | 5a3f4a87dc19195c1ad232b6fc83e2ee31d4d475 (patch) | |
| tree | 79a68d9a42589cfbc017024443b8e5af4f442f19 | |
| parent | e198e7809671e06f6cbc5bd3618b741c04d48e4d (diff) | |
move to SetPad(), SetMargin() and SetExpand()v1.1.2
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | action.go | 10 | ||||
| -rw-r--r-- | range.go | 10 | ||||
| -rw-r--r-- | reflect.go | 26 |
4 files changed, 57 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..12b5c9f --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# widget + +Package gui/widget defines the widgets and actions that can be performed on them + +Principles: + +```go +* Make code using this package simple to use +* Widget names should try to match [Wikipedia Graphical widget] +* It's ok to guess. Try to do something sensible. +``` @@ -16,6 +16,13 @@ type Action struct { // how to arrange widgets Direction Orientation + // All the strings for things like dropdown menus + // They must be sent in display order + // These must be unique + Strings []string + + Range RangeType + // This is used for things like a slider(0,100) X int Y int @@ -47,10 +54,13 @@ const ( Hide Enable Disable + SetMargin Margin Unmargin + SetPad Pad Unpad + SetExpand Append Move Dump diff --git a/range.go b/range.go new file mode 100644 index 0000000..b110cb8 --- /dev/null +++ b/range.go @@ -0,0 +1,10 @@ +package widget + +// 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 RangeType struct { + Low int + High int +} @@ -1,10 +1,36 @@ package widget +/* + widget is a low level package that just defines the gui package + interaction with the toolkits. + + For simplicity, it seems to make sense to put type conversion functions + here for now +*/ + import ( "reflect" "strconv" ) +/* +// TODO: this syntax or the other syntax? + +func convertString(val any) string { + switch v := val.(type) { + case bool: + n.B = val.(bool) + case string: + n.label = val.(string) + n.S = val.(string) + case int: + n.I = val.(int) + default: + log.Error(errors.New("Set() unknown type"), "v =", v) + } +} +*/ + func GetString(A any) string { if A == nil { // log.Warn("getString() got nil") |
