@@ -16,6 +16,7 @@ type config struct {
16
16
windowInitializerDeprecated func (* glfw.Window ) error
17
17
windowIconProvider func () ([]image.Image , error )
18
18
windowInitialDimensions windowDimensions
19
+ windowDimensionLimits windowDimensionLimits
19
20
20
21
forcePixelRatio float64
21
22
keyboardLayout KeyboardShortcuts
@@ -27,16 +28,23 @@ type config struct {
27
28
}
28
29
29
30
type windowDimensions struct {
30
- x int
31
- y int
31
+ width int
32
+ height int
33
+ }
34
+
35
+ type windowDimensionLimits struct {
36
+ minWidth int
37
+ minHeight int
38
+ maxWidth int
39
+ maxHeight int
32
40
}
33
41
34
42
// defaultApplicationConfig define the default configuration values for a new
35
43
// Application. These values may be changed at any time.
36
44
var defaultApplicationConfig = config {
37
45
windowInitialDimensions : windowDimensions {
38
- x : 800 ,
39
- y : 600 ,
46
+ width : 800 ,
47
+ height : 600 ,
40
48
},
41
49
keyboardLayout : KeyboardQwertyLayout ,
42
50
windowMode : WindowModeDefault ,
@@ -96,19 +104,47 @@ func ApplicationWindowDimension(x, y int) Option {
96
104
}
97
105
98
106
// WindowInitialDimensions specify the startup's dimension of the window.
99
- func WindowInitialDimensions (x , y int ) Option {
100
- if x < 1 {
107
+ func WindowInitialDimensions (width , height int ) Option {
108
+ if width < 1 {
101
109
fmt .Println ("go-flutter: invalid initial value for width, must be 1 or greater." )
102
110
os .Exit (1 )
103
111
}
104
- if y < 1 {
112
+ if height < 1 {
105
113
fmt .Println ("go-flutter: invalid initial value for height, must be 1 or greater." )
106
114
os .Exit (1 )
107
115
}
108
116
109
117
return func (c * config ) {
110
- c .windowInitialDimensions .x = x
111
- c .windowInitialDimensions .y = y
118
+ c .windowInitialDimensions .width = width
119
+ c .windowInitialDimensions .height = height
120
+ }
121
+ }
122
+
123
+ // WindowDimensionLimits specify the dimension limits of the window.
124
+ // Does not work when the window is fullscreen or not resizable.
125
+ func WindowDimensionLimits (minWidth , minHeight , maxWidth , maxHeight int ) Option {
126
+ if minWidth < 1 {
127
+ fmt .Println ("go-flutter: invalid initial value for minWidth, must be 1 or greater." )
128
+ os .Exit (1 )
129
+ }
130
+ if minHeight < 1 {
131
+ fmt .Println ("go-flutter: invalid initial value for minHeight, must be 1 or greater." )
132
+ os .Exit (1 )
133
+ }
134
+ if maxWidth < minWidth {
135
+ fmt .Println ("go-flutter: invalid initial value for maxWidth, must be greater or equal to minWidth." )
136
+ os .Exit (1 )
137
+ }
138
+ if maxHeight < minHeight {
139
+ fmt .Println ("go-flutter: invalid initial value for maxHeight, must be greater or equal to minHeight." )
140
+ os .Exit (1 )
141
+ }
142
+
143
+ return func (c * config ) {
144
+ c .windowDimensionLimits .minWidth = minWidth
145
+ c .windowDimensionLimits .minHeight = minHeight
146
+ c .windowDimensionLimits .maxWidth = maxWidth
147
+ c .windowDimensionLimits .maxHeight = maxHeight
112
148
}
113
149
}
114
150
0 commit comments