Support for minimum and maximum window sizes (#612)

* add support for minimum and maximum window sizes

* attempt to fix windows

* bug fixes

* support min/max window sizes on Linux and Windows

* fix min/max window sizes on Linux

* formatting and comments

* fixes Windows DPI issue, clamps width/height values to min/max

* App can't go into full screen when max size is set for Mac

* fixed Linux maximum width/height on window maximize

* Revert "fixed Linux maximum width/height on window maximize"

This reverts commit 3f7ba8b26435392116df3c9fe66ef11536e30c59.

The fix glitches on PopOS

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
RH12503
2021-04-02 13:14:09 +08:00
committed by GitHub
parent 2b6860b6c3
commit a1bd1013cb
10 changed files with 299 additions and 5 deletions

View File

@@ -31,6 +31,18 @@ type AppConfig struct {
// Indicates whether your app should be resizable
Resizable bool
// Minimum width of a resizable window. If set, MinHeight should also be set.
MinWidth int
// Minimum height of a resizable window. If set, MinWidth should also be set.
MinHeight int
// Maximum width of a resizable window. If set, MaxHeight should also be set.
MaxWidth int
// Maximum height of a resizable window. If set, MaxWidth should also be set.
MaxHeight int
// Indicated if the devtools should be disabled
DisableInspector bool
}
@@ -65,6 +77,26 @@ func (a *AppConfig) GetResizable() bool {
return a.Resizable
}
// GetMinWidth returns the minimum width of the window
func (a *AppConfig) GetMinWidth() int {
return a.MinWidth
}
// GetMinHeight returns the minimum height of the window
func (a *AppConfig) GetMinHeight() int {
return a.MinHeight
}
// GetMaxWidth returns the maximum width of the window
func (a *AppConfig) GetMaxWidth() int {
return a.MaxWidth
}
// GetMaxHeight returns the maximum height of the window
func (a *AppConfig) GetMaxHeight() int {
return a.MaxHeight
}
// GetDisableInspector returns true if the inspector should be disabled
func (a *AppConfig) GetDisableInspector() bool {
return a.DisableInspector
@@ -115,6 +147,23 @@ func (a *AppConfig) merge(in *AppConfig) error {
if in.Height != 0 {
a.Height = in.Height
}
if in.MinWidth != 0 {
a.MinWidth = in.MinWidth
}
if in.MinHeight != 0 {
a.MinHeight = in.MinHeight
}
if in.MaxWidth != 0 {
a.MaxWidth = in.MaxWidth
}
if in.MaxHeight != 0 {
a.MaxHeight = in.MaxHeight
}
a.Resizable = in.Resizable
a.DisableInspector = in.DisableInspector
@@ -127,6 +176,10 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
Width: 800,
Height: 600,
Resizable: true,
MinWidth: -1,
MinHeight: -1,
MaxWidth: -1,
MaxHeight: -1,
Title: "My Wails App",
Colour: "#FFF", // White by default
HTML: defaultHTML,