65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
|
package widget
|
||
|
|
||
|
/*
|
||
|
2D geometry values
|
||
|
|
||
|
There are lots of issues when supporting multiple toolkit plugin
|
||
|
geometries. The geometries vary widely especially between the
|
||
|
graphical displays and the serial console ones.
|
||
|
|
||
|
To simplyfy this, we stick to using the concepts:
|
||
|
|
||
|
------------------------------ ^
|
||
|
| top | |
|
||
|
| | |
|
||
|
| left right | height
|
||
|
| | |
|
||
|
| bottom | |
|
||
|
------------------------------ v
|
||
|
|
||
|
<----------- width ---------->
|
||
|
|
||
|
This way, width & height are always positive numbers.
|
||
|
|
||
|
The qustion of (top,bottom) & (left,right) becomes problematic.
|
||
|
|
||
|
In almost every toolkit, right > left. However, top & bottom
|
||
|
vary and a choice can not be made easily. Luckily, we maybe do
|
||
|
not have to make that decision here and can pass that determination
|
||
|
to the toolkits. So, we use excusively:
|
||
|
|
||
|
geom(left, right, top, bottom)
|
||
|
size(width, height)
|
||
|
*/
|
||
|
|
||
|
type Geom struct {
|
||
|
Left any
|
||
|
Right any
|
||
|
Top any
|
||
|
Bottom any
|
||
|
}
|
||
|
|
||
|
type Size struct {
|
||
|
Width any
|
||
|
Height any
|
||
|
}
|
||
|
|
||
|
type Orientation int // Add, SetText, Click, Hide, Append, Delete, etc
|
||
|
|
||
|
const (
|
||
|
Horizontal Orientation = iota
|
||
|
Vertical
|
||
|
)
|
||
|
|
||
|
func (s Orientation) String() string {
|
||
|
switch s {
|
||
|
case Horizontal:
|
||
|
return "Horizontal"
|
||
|
case Vertical:
|
||
|
return "Vertical"
|
||
|
default:
|
||
|
return "Horizontal"
|
||
|
}
|
||
|
return "Horizontal"
|
||
|
}
|