-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.go
More file actions
123 lines (103 loc) · 3.2 KB
/
window.go
File metadata and controls
123 lines (103 loc) · 3.2 KB
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
package tool
import (
"flag"
"github.com/caothu159/grunt"
"github.com/caothu159/hosts"
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
"github.com/google/gxui/themes/light"
)
var _defaultScaleFactor float32
var _flagTheme string
func init() {
flagTheme := flag.String("theme", "dark", "Theme to use {dark|light}.")
defaultScaleFactor := flag.Float64("scaling", 1.0, "Adjusts the scaling of UI rendering")
flag.Parse()
_defaultScaleFactor = float32(*defaultScaleFactor)
_flagTheme = *flagTheme
}
func CreateTheme(driver gxui.Driver) gxui.Theme {
if _flagTheme == "light" {
return light.CreateTheme(driver)
}
return dark.CreateTheme(driver)
}
func panelHolder(name string, panel gxui.LinearLayout, theme gxui.Theme) gxui.PanelHolder {
holder := theme.CreatePanelHolder()
holder.AddPanel(panel, name)
return holder
}
func appMain(driver gxui.Driver) {
theme := CreateTheme(driver)
label := func(text string) gxui.LinearLayout {
label := theme.CreateLabel()
label.SetText(text)
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.LeftToRight)
layout.AddChild(label)
return layout
}
// ┌───────┐║┌───────┐
// │ │║│ │
// │ A │║│ B │
// │ │║│ │
// │ │║└───────┘
// │ │║═════════
// │ │║┌───────┐
// │ │║│ │
// │ │║│ D │
// │ │║│ │
// └───────┘║└───────┘
// Left
leftPanelHolder := theme.CreatePanelHolder()
leftPanelHolder.AddPanel(label("A content"), "A")
splitterLeft := theme.CreateSplitterLayout()
splitterLeft.SetOrientation(gxui.Vertical)
splitterLeft.AddChild(leftPanelHolder)
// Right
rightBPanelHolder := theme.CreatePanelHolder()
rightBPanelHolder.AddPanel(label("B 1 content"), "B 1")
rightBPanelHolder.AddPanel(label("B 2 content"), "B 2")
rightDPanelHolder := theme.CreatePanelHolder()
rightDPanelHolder.AddPanel(label("D 1 content"), "D 1")
rightDPanelHolder.AddPanel(label("D 2 content"), "D 2")
rightDPanelHolder.AddPanel(label("D 3 content"), "D 3")
splitterRight := theme.CreateSplitterLayout()
splitterRight.SetOrientation(gxui.Vertical)
splitterRight.AddChild(rightBPanelHolder)
splitterRight.AddChild(rightDPanelHolder)
splitter := theme.CreateSplitterLayout()
splitter.SetOrientation(gxui.Horizontal)
splitter.AddChild(splitterLeft)
splitter.AddChild(splitterRight)
// Main Panel
mainPanelHolder := theme.CreatePanelHolder()
mainPanelHolder.AddPanel(grunt.CreateGrunt(theme), "Grunt")
mainPanelHolder.AddPanel(hosts.CreateHosts(theme), "Hosts")
mainPanelHolder.AddPanel(splitter, "In Feature Developing")
window := theme.CreateWindow(800, 600, "Code tools")
window.SetScale(_defaultScaleFactor)
window.SetPadding(math.Spacing{
//left
L: 10,
//right
R: 10,
//bottom
B: 10,
//top
T: 10,
})
window.OnClose(driver.Terminate)
window.AddChild(mainPanelHolder)
}
func CreateWindow() {
gl.StartDriver(appMain)
}
func Main() {
CreateWindow()
}
func main() {
Main()
}