move to SetPad(), SetMargin() and SetExpand()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e198e78096
commit
5a3f4a87dc
|
@ -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.
|
||||||
|
```
|
10
action.go
10
action.go
|
@ -16,6 +16,13 @@ type Action struct {
|
||||||
// how to arrange widgets
|
// how to arrange widgets
|
||||||
Direction Orientation
|
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)
|
// This is used for things like a slider(0,100)
|
||||||
X int
|
X int
|
||||||
Y int
|
Y int
|
||||||
|
@ -47,10 +54,13 @@ const (
|
||||||
Hide
|
Hide
|
||||||
Enable
|
Enable
|
||||||
Disable
|
Disable
|
||||||
|
SetMargin
|
||||||
Margin
|
Margin
|
||||||
Unmargin
|
Unmargin
|
||||||
|
SetPad
|
||||||
Pad
|
Pad
|
||||||
Unpad
|
Unpad
|
||||||
|
SetExpand
|
||||||
Append
|
Append
|
||||||
Move
|
Move
|
||||||
Dump
|
Dump
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
26
reflect.go
26
reflect.go
|
@ -1,10 +1,36 @@
|
||||||
package widget
|
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 (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"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 {
|
func GetString(A any) string {
|
||||||
if A == nil {
|
if A == nil {
|
||||||
// log.Warn("getString() got nil")
|
// log.Warn("getString() got nil")
|
||||||
|
|
Loading…
Reference in New Issue