blob: 3020c83f5ea284f52220872502bcff2cf7d75cee (
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
88
|
package main
import (
// "github.com/awesome-gocui/gocui"
"git.wit.org/wit/gui/toolkit"
)
// TODO: make these defaults in config struct definition
var fakeStartWidth int = me.DevelOffsetW
var fakeStartHeight int = me.TabH + me.FramePadH
func (w *cuiWidget) setFake() {
w.isFake = true
t := len(w.name)
// setup fake labels for non-visable things off screen
w.gocuiSize.w0 = fakeStartWidth
w.gocuiSize.h0 = fakeStartHeight
w.gocuiSize.w1 = w.gocuiSize.w0 + t + me.PadW
w.gocuiSize.h1 = w.gocuiSize.h0 + me.DefaultHeight + me.PadH
w.realWidth = w.gocuiSize.Width() + me.FramePadW
w.realHeight = w.gocuiSize.Height() + me.FramePadH
fakeStartHeight += w.realHeight
// TODO: use the actual max hight of the terminal window
if (fakeStartHeight > 24) {
fakeStartHeight = me.TabH + me.FramePadH
fakeStartWidth += me.DevelOffsetW
}
if (logInfo) {
w.showView()
}
}
// set the widget start width & height
func (w *cuiWidget) addWidget() {
log(logInfo, "setStartWH() w.id =", w.id, "w.name", w.name)
switch w.widgetType {
case toolkit.Root:
log(logInfo, "setStartWH() rootNode w.id =", w.id, "w.name", w.name)
w.setFake()
return
case toolkit.Flag:
w.setFake()
return
case toolkit.Window:
me.current = w
updateCurrentTabs()
setCurrentWindow(w)
return
case toolkit.Tab:
// if this is the first tab, set it to the current one and stay here
if (me.current != nil) {
// there is already a current tab. just redraw the tabs
updateCurrentTabs()
return
}
setCurrentTab(w)
return
case toolkit.Box:
w.isFake = true
w.setFake()
w.startW = w.parent.startW
w.startH = w.parent.startH
return
case toolkit.Grid:
w.isFake = true
w.setFake()
w.startW = w.parent.startW
w.startH = w.parent.startH
return
case toolkit.Group:
w.startW = w.parent.startW + 4
w.startH = w.parent.startH + me.DefaultHeight + me.FramePadH
t := len(w.text)
w.gocuiSize.w1 = w.gocuiSize.w0 + t + me.FramePadW
w.gocuiSize.h1 = w.gocuiSize.h0 + me.DefaultHeight + me.FramePadH
return
default:
w.startW = w.parent.startW
w.startH = w.parent.startH
if w.IsCurrent() {
w.updateCurrent()
}
}
w.showWidgetPlacement(logInfo, "addWidget()")
}
|