mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 19:01:02 +08:00
[mac] Support min/max
This commit is contained in:
parent
fd5348d26d
commit
a88b3553ba
@ -56,7 +56,7 @@
|
||||
NSSize size = { minWidth, minHeight };
|
||||
|
||||
self.minSize = size;
|
||||
|
||||
|
||||
[self.mainWindow setMinSize:size];
|
||||
|
||||
[self adjustWindowSize];
|
||||
@ -73,7 +73,7 @@
|
||||
size.height = maxHeight > 0 ? maxHeight : FLT_MAX;
|
||||
|
||||
self.maxSize = size;
|
||||
|
||||
|
||||
[self.mainWindow setMinSize:size];
|
||||
|
||||
[self adjustWindowSize];
|
||||
@ -90,7 +90,7 @@
|
||||
if ( currentFrame.size.width < self.minSize.width ) currentFrame.size.width = self.minSize.width;
|
||||
if ( currentFrame.size.height > self.maxSize.height ) currentFrame.size.height = self.maxSize.height;
|
||||
if ( currentFrame.size.height < self.minSize.height ) currentFrame.size.height = self.minSize.height;
|
||||
|
||||
|
||||
[self.mainWindow setFrame:currentFrame display:TRUE animate:FALSE];
|
||||
|
||||
}
|
||||
|
@ -66,10 +66,6 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
|
||||
bindings: appBindings,
|
||||
dispatcher: dispatcher,
|
||||
ctx: ctx,
|
||||
minHeight: appoptions.MinHeight,
|
||||
minWidth: appoptions.MinWidth,
|
||||
maxHeight: appoptions.MaxHeight,
|
||||
maxWidth: appoptions.MaxWidth,
|
||||
}
|
||||
|
||||
// Check if we have been given a directory to serve assets from.
|
||||
|
@ -73,7 +73,9 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
||||
|
||||
appearance = c.String(string(mac.Appearance))
|
||||
}
|
||||
var context *C.WailsContext = C.Create(title, width, height, frameless, resizable, fullscreen, fullSizeContent, hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent, alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug)
|
||||
var context *C.WailsContext = C.Create(title, width, height, frameless, resizable, fullscreen, fullSizeContent,
|
||||
hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent,
|
||||
alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug)
|
||||
|
||||
// Create menu
|
||||
result := &Window{
|
||||
@ -100,6 +102,9 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
||||
result.SetApplicationMenu(frontendOptions.Menu)
|
||||
}
|
||||
|
||||
result.SetMinSize(frontendOptions.MinWidth, frontendOptions.MinHeight)
|
||||
result.SetMaxSize(frontendOptions.MaxWidth, frontendOptions.MaxHeight)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@ -156,10 +161,16 @@ func (w *Window) UnMinimise() {
|
||||
}
|
||||
|
||||
func (w *Window) SetMinSize(width int, height int) {
|
||||
if width == 0 && height == 0 {
|
||||
return
|
||||
}
|
||||
C.SetMinSize(w.context, C.int(width), C.int(height))
|
||||
}
|
||||
|
||||
func (w *Window) SetMaxSize(width int, height int) {
|
||||
if width == 0 && height == 0 {
|
||||
return
|
||||
}
|
||||
C.SetMaxSize(w.context, C.int(width), C.int(height))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user