forked from wailsapp/wails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_webview_window.go
161 lines (119 loc) · 3.48 KB
/
options_webview_window.go
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package application
type WindowState int
const (
WindowStateNormal WindowState = iota
WindowStateMinimised
WindowStateMaximised
WindowStateFullscreen
)
type WebviewWindowOptions struct {
// Name is a unique identifier that can be given to a window.
Name string
// Title is the title of the window.
Title string
// Width is the starting width of the window.
Width int
// Height is the starting height of the window.
Height int
// AlwaysOnTop will make the window float above other windows.
AlwaysOnTop bool
// URL is the URL to load in the window.
URL string
// DisableResize will disable the ability to resize the window.
DisableResize bool
// Frameless will remove the window frame.
Frameless bool
// MinWidth is the minimum width of the window.
MinWidth int
// MinHeight is the minimum height of the window.
MinHeight int
// MaxWidth is the maximum width of the window.
MaxWidth int
// MaxHeight is the maximum height of the window.
MaxHeight int
// StartState indicates the state of the window when it is first shown.
// Default: WindowStateNormal
StartState WindowState
// Centered will center the window on the screen.
Centered bool
// BackgroundType is the type of background to use for the window.
// Default: BackgroundTypeSolid
BackgroundType BackgroundType
// BackgroundColour is the colour to use for the window background.
BackgroundColour RGBA
// HTML is the HTML to load in the window.
HTML string
// JS is the JavaScript to load in the window.
JS string
// CSS is the CSS to load in the window.
CSS string
// X is the starting X position of the window.
X int
// Y is the starting Y position of the window.
Y int
// TransparentTitlebar will make the titlebar transparent.
// TODO: Move to mac window options
FullscreenButtonEnabled bool
// Hidden will hide the window when it is first created.
Hidden bool
// Zoom is the zoom level of the window.
Zoom float64
// ZoomControlEnabled will enable the zoom control.
ZoomControlEnabled bool
// EnableDragAndDrop will enable drag and drop.
EnableDragAndDrop bool
// OpenInspectorOnStartup will open the inspector when the window is first shown.
OpenInspectorOnStartup bool
// Mac options
Mac MacWindow
// Windows options
Windows WindowsWindow
// ShouldClose is called when the window is about to close.
// Return true to allow the window to close, or false to prevent it from closing.
ShouldClose func(window *WebviewWindow) bool
// If true, the window's devtools will be available (default true in builds without the `production` build tag)
DevToolsEnabled bool
// If true, the window's default context menu will be disabled (default false)
DefaultContextMenuDisabled bool
// KeyBindings is a map of key bindings to functions
KeyBindings map[string]func(window *WebviewWindow)
// IgnoreMouseEvents will ignore mouse events in the window
IgnoreMouseEvents bool
}
var WebviewWindowDefaults = &WebviewWindowOptions{
Title: "",
Width: 800,
Height: 600,
URL: "",
BackgroundColour: RGBA{
Red: 255,
Green: 255,
Blue: 255,
Alpha: 255,
},
}
type RGBA struct {
Red, Green, Blue, Alpha uint8
}
func NewRGBA(red, green, blue, alpha uint8) RGBA {
return RGBA{
Red: red,
Green: green,
Blue: blue,
Alpha: alpha,
}
}
func NewRGB(red, green, blue uint8) RGBA {
return RGBA{
Red: red,
Green: green,
Blue: blue,
Alpha: 255,
}
}
type BackgroundType int
const (
BackgroundTypeSolid BackgroundType = iota
BackgroundTypeTransparent
BackgroundTypeTranslucent
)