summaryrefslogtreecommitdiff
path: root/geom.go
blob: cfa5531fd70a37594e5699ae4e11347f25d4b381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
}

/*
	Horizontal  means layout widgets like books on a bookshelf

	---------------------------------
	| W | W | W | W | W | W | W | W |
	| i | i | i | i | i | i | i | i |
	| d | d | d | d | d | d | d | d |
	| g | g | g | g | g | g | g | g |
	| e | e | e | e | e | e | e | e |
	| t | t | t | t | t | t | t | t |
	---------------------------------

	Vertical    means layout widgets like books in a stack
	----------
	| Widget |
	----------
	| Widget |
	----------
	| Widget |
	----------
	| Widget |
	----------
*/
type Orientation int

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"
}