blob: 8ce298c5b07659d8ec6661cfc0e659877e8c2630 (
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
package main
// implements widgets 'Window' and 'Tab'
import (
"git.wit.org/wit/gui/toolkit"
// "github.com/awesome-gocui/gocui"
)
func (w *cuiWidget) hideWidgets() {
w.isCurrent = false
switch w.widgetType {
case toolkit.Root:
case toolkit.Flag:
case toolkit.Window:
// case toolkit.Tab:
case toolkit.Box:
case toolkit.Grid:
default:
w.deleteView()
}
for _, child := range w.children {
child.hideWidgets()
}
}
func (w *cuiWidget) hideFake() {
if (w.isFake) {
w.deleteView()
}
for _, child := range w.children {
child.hideFake()
}
}
func (w *cuiWidget) showFake() {
if (w.isFake) {
w.setFake()
w.showWidgetPlacement(logNow, "showFake:")
w.showView()
}
for _, child := range w.children {
child.showFake()
}
}
func (w *cuiWidget) showWidgets() {
if (w.isFake) {
// don't display by default
} else {
if w.IsCurrent() {
w.showWidgetPlacement(logNow, "current:")
w.showView()
} else {
w.showWidgetPlacement(logNow, "not:")
// w.drawView()
}
}
for _, child := range w.children {
child.showWidgets()
}
}
func (w *cuiWidget) setWindowWH() {
w.gocuiSize.w0 = me.rootNode.nextW
w.gocuiSize.h0 = me.WindowH
t := len(w.text)
w.gocuiSize.w1 = w.gocuiSize.w0 + t + me.PadW
w.gocuiSize.h1 = w.gocuiSize.h0 + me.DefaultHeight + me.PadH
w.realWidth = w.gocuiSize.Width()
w.realHeight = w.gocuiSize.Height()
// move the rootNode width over for the next window
me.rootNode.nextW += w.realWidth + me.WindowPadW
w.nextW = 4
w.nextH = 2
w.showWidgetPlacement(logNow, "setWindowWH:")
}
func (w *cuiWidget) setTabWH() {
// set the start and size of the tab gocui button
w.gocuiSize.w0 = w.parent.nextW
w.gocuiSize.h0 = me.TabH
t := len(w.text)
w.gocuiSize.w1 = w.gocuiSize.w0 + t + me.PadW
w.gocuiSize.h1 = w.gocuiSize.h0 + me.DefaultHeight + me.PadH
w.realWidth = w.gocuiSize.Width()
w.realHeight = w.gocuiSize.Height()
w.realWidth += me.FramePadW
w.realHeight += me.FramePadH
w.parent.nextW += w.realWidth + me.TabPadW
w.showWidgetPlacement(logNow, "setTabWH:")
}
func (w *cuiWidget) redoTabs(draw bool) {
if (w.widgetType == toolkit.Window) {
var tabs bool = false
// figure out if the window is just a bunch of tabs
for _, child := range w.children {
if (child.widgetType == toolkit.Tab) {
tabs = true
}
}
if (tabs) {
// window is tabs. Don't show it as a standard button
w.frame = false
w.hasTabs = true
} else {
w.frame = true
w.hasTabs = false
}
w.setWindowWH()
w.deleteView()
w.showView()
}
if (w.widgetType == toolkit.Tab) {
w.setTabWH()
w.deleteView()
// show all the tabs for the current window
if w.parent.isCurrent {
w.showView()
}
}
for _, child := range w.children {
child.redoTabs(draw)
}
}
|