mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:20:48 +08:00
[mac] Support min/max
This commit is contained in:
parent
fd5348d26d
commit
a88b3553ba
@ -56,7 +56,7 @@
|
|||||||
NSSize size = { minWidth, minHeight };
|
NSSize size = { minWidth, minHeight };
|
||||||
|
|
||||||
self.minSize = size;
|
self.minSize = size;
|
||||||
|
|
||||||
[self.mainWindow setMinSize:size];
|
[self.mainWindow setMinSize:size];
|
||||||
|
|
||||||
[self adjustWindowSize];
|
[self adjustWindowSize];
|
||||||
@ -73,7 +73,7 @@
|
|||||||
size.height = maxHeight > 0 ? maxHeight : FLT_MAX;
|
size.height = maxHeight > 0 ? maxHeight : FLT_MAX;
|
||||||
|
|
||||||
self.maxSize = size;
|
self.maxSize = size;
|
||||||
|
|
||||||
[self.mainWindow setMinSize:size];
|
[self.mainWindow setMinSize:size];
|
||||||
|
|
||||||
[self adjustWindowSize];
|
[self adjustWindowSize];
|
||||||
@ -90,7 +90,7 @@
|
|||||||
if ( currentFrame.size.width < self.minSize.width ) currentFrame.size.width = self.minSize.width;
|
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.maxSize.height ) currentFrame.size.height = self.maxSize.height;
|
||||||
if ( currentFrame.size.height < self.minSize.height ) currentFrame.size.height = self.minSize.height;
|
if ( currentFrame.size.height < self.minSize.height ) currentFrame.size.height = self.minSize.height;
|
||||||
|
|
||||||
[self.mainWindow setFrame:currentFrame display:TRUE animate:FALSE];
|
[self.mainWindow setFrame:currentFrame display:TRUE animate:FALSE];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,10 +66,6 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
|
|||||||
bindings: appBindings,
|
bindings: appBindings,
|
||||||
dispatcher: dispatcher,
|
dispatcher: dispatcher,
|
||||||
ctx: ctx,
|
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.
|
// 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))
|
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
|
// Create menu
|
||||||
result := &Window{
|
result := &Window{
|
||||||
@ -100,6 +102,9 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
|||||||
result.SetApplicationMenu(frontendOptions.Menu)
|
result.SetApplicationMenu(frontendOptions.Menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.SetMinSize(frontendOptions.MinWidth, frontendOptions.MinHeight)
|
||||||
|
result.SetMaxSize(frontendOptions.MaxWidth, frontendOptions.MaxHeight)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +161,16 @@ func (w *Window) UnMinimise() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetMinSize(width int, height int) {
|
func (w *Window) SetMinSize(width int, height int) {
|
||||||
|
if width == 0 && height == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
C.SetMinSize(w.context, C.int(width), C.int(height))
|
C.SetMinSize(w.context, C.int(width), C.int(height))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetMaxSize(width int, height int) {
|
func (w *Window) SetMaxSize(width int, height int) {
|
||||||
|
if width == 0 && height == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
C.SetMaxSize(w.context, C.int(width), C.int(height))
|
C.SetMaxSize(w.context, C.int(width), C.int(height))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user