mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:39:30 +08:00
WIP
This commit is contained in:
parent
6eba8ec76f
commit
b07fd608b3
@ -173,7 +173,7 @@ func (f *Frontend) WindowFullscreen() {
|
|||||||
f.mainWindow.SetMaxSize(0, 0)
|
f.mainWindow.SetMaxSize(0, 0)
|
||||||
f.mainWindow.SetMinSize(0, 0)
|
f.mainWindow.SetMinSize(0, 0)
|
||||||
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
||||||
f.ExecJS("window.wails.flags.enableResize = false;")
|
f.ExecJS("window.wails.enableFramelessResize();")
|
||||||
}
|
}
|
||||||
f.mainWindow.Fullscreen()
|
f.mainWindow.Fullscreen()
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ func (f *Frontend) WindowFullscreen() {
|
|||||||
func (f *Frontend) WindowUnFullscreen() {
|
func (f *Frontend) WindowUnFullscreen() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
||||||
f.ExecJS("window.wails.flags.enableResize = true;")
|
f.ExecJS("window.wails.enableFramelessResize();")
|
||||||
}
|
}
|
||||||
f.mainWindow.UnFullscreen()
|
f.mainWindow.UnFullscreen()
|
||||||
f.mainWindow.SetMaxSize(f.maxWidth, f.maxHeight)
|
f.mainWindow.SetMaxSize(f.maxWidth, f.maxHeight)
|
||||||
@ -491,7 +491,7 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
||||||
f.ExecJS("window.wails.flags.enableResize = true;")
|
f.ExecJS("window.wails.enableFramelessResize();")
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.hasStarted {
|
if f.hasStarted {
|
||||||
|
@ -57,10 +57,10 @@ func NewWindow(parent winc.Controller, appoptions *options.App) *Window {
|
|||||||
result.SetText(appoptions.Title)
|
result.SetText(appoptions.Title)
|
||||||
if appoptions.Frameless == false && !appoptions.Fullscreen {
|
if appoptions.Frameless == false && !appoptions.Fullscreen {
|
||||||
result.EnableMaxButton(!appoptions.DisableResize)
|
result.EnableMaxButton(!appoptions.DisableResize)
|
||||||
|
result.EnableSizable(!appoptions.DisableResize)
|
||||||
result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight)
|
result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight)
|
||||||
result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight)
|
result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight)
|
||||||
}
|
}
|
||||||
result.EnableSizable(!appoptions.DisableResize)
|
|
||||||
|
|
||||||
if appoptions.Windows != nil {
|
if appoptions.Windows != nil {
|
||||||
if appoptions.Windows.WindowIsTranslucent {
|
if appoptions.Windows.WindowIsTranslucent {
|
||||||
|
@ -43,9 +43,11 @@ window.wails = {
|
|||||||
flags: {
|
flags: {
|
||||||
disableScrollbarDrag: false,
|
disableScrollbarDrag: false,
|
||||||
disableWailsDefaultContextMenu: false,
|
disableWailsDefaultContextMenu: false,
|
||||||
enableResize: false,
|
enableFramelessResize: false,
|
||||||
defaultCursor: null
|
defaultCursor: null
|
||||||
}
|
},
|
||||||
|
enableFramelessResize,
|
||||||
|
disableFramelessResize
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the bindings
|
// Set the bindings
|
||||||
@ -64,7 +66,7 @@ if (ENV === 0) {
|
|||||||
window.addEventListener('mousedown', (e) => {
|
window.addEventListener('mousedown', (e) => {
|
||||||
|
|
||||||
// Check for resizing
|
// Check for resizing
|
||||||
if (window.wails.flags.resizeEdge) {
|
if (window.wails.flags.enableFramelessResize && window.wails.flags.resizeEdge) {
|
||||||
window.WailsInvoke("resize:" + window.wails.flags.resizeEdge);
|
window.WailsInvoke("resize:" + window.wails.flags.resizeEdge);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
@ -95,7 +97,7 @@ function setResize(cursor) {
|
|||||||
window.wails.flags.resizeEdge = cursor;
|
window.wails.flags.resizeEdge = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('mousemove', function (e) {
|
function mouseHandler(e) {
|
||||||
if (!window.wails.flags.enableResize) {
|
if (!window.wails.flags.enableResize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -122,7 +124,17 @@ window.addEventListener('mousemove', function (e) {
|
|||||||
else if (bottomBorder) setResize("s-resize");
|
else if (bottomBorder) setResize("s-resize");
|
||||||
else if (rightBorder) setResize("e-resize");
|
else if (rightBorder) setResize("e-resize");
|
||||||
|
|
||||||
});
|
}
|
||||||
|
|
||||||
|
export function enableFramelessResize() {
|
||||||
|
window.wails.flags.enableFramelessResize = true;
|
||||||
|
window.addEventListener('mousemove', mouseHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function disableFramelessResize() {
|
||||||
|
window.wails.flags.enableFramelessResize = false;
|
||||||
|
window.removeEventListener('mousemove', mouseHandler);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup context menu hook
|
// Setup context menu hook
|
||||||
window.addEventListener('contextmenu', function (e) {
|
window.addEventListener('contextmenu', function (e) {
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user