mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v3 windows] Add frameless resize
This commit is contained in:
+41
-3
@@ -52,7 +52,7 @@ Webview Window Interface Methods
|
||||
| setAlwaysOnTop(alwaysOnTop bool) | Y | | Y | |
|
||||
| setBackgroundColour(color RGBA) | Y | | Y | |
|
||||
| setFrameless(bool) | | | Y | |
|
||||
| setFullscreenButtonEnabled(enabled bool) | X | | Y | There is no fullscreen button in Windows |
|
||||
| setFullscreenButtonEnabled(enabled bool) | - | | Y | There is no fullscreen button in Windows |
|
||||
| setHTML(html string) | | | Y | |
|
||||
| setMaxSize(width, height int) | Y | | Y | |
|
||||
| setMinSize(width, height int) | Y | | Y | |
|
||||
@@ -148,6 +148,44 @@ Webview Window Interface Methods
|
||||
| SetZoom | | | Y | Set view scale |
|
||||
| Screen | | | Y | Get screen for window |
|
||||
|
||||
|
||||
### Window Options
|
||||
|
||||
A 'Y' in the table below indicates that the option has been tested and is applied when the window is created.
|
||||
An 'X' indicates that the option is not supported by the platform.
|
||||
|
||||
|
||||
| Feature | Windows | Linux | Mac | Notes |
|
||||
|---------------------------------|---------|-------|-----|--------------------------------------------|
|
||||
| Name | | | | |
|
||||
| Title | Y | | | |
|
||||
| Width | Y | | | |
|
||||
| Height | Y | | | |
|
||||
| AlwaysOnTop | Y | | | |
|
||||
| URL | | | | |
|
||||
| DisableResize | Y | | | |
|
||||
| Frameless | | | | |
|
||||
| MinWidth | Y | | | |
|
||||
| MinHeight | Y | | | |
|
||||
| MaxWidth | Y | | | |
|
||||
| MaxHeight | Y | | | |
|
||||
| StartState | Y | | | |
|
||||
| Mac | - | - | | |
|
||||
| BackgroundType | | | | Acrylic seems to work but the others don't |
|
||||
| BackgroundColour | Y | | | |
|
||||
| HTML | | | | |
|
||||
| JS | | | | |
|
||||
| CSS | | | | |
|
||||
| X | | | | |
|
||||
| Y | | | | |
|
||||
| HideOnClose | | | | |
|
||||
| FullscreenButtonEnabled | | | | |
|
||||
| Hidden | | | | |
|
||||
| EnableFraudulentWebsiteWarnings | | | | |
|
||||
| Zoom | | | | |
|
||||
| EnableDragAndDrop | | | | |
|
||||
| Windows | | - | - | |
|
||||
|
||||
### Log
|
||||
|
||||
To log or not to log? System logger vs custom logger.
|
||||
@@ -230,9 +268,9 @@ Built-in plugin support:
|
||||
| Icon Generation | | | Y | |
|
||||
| Icon Embedding | | | Y | |
|
||||
| Info.plist | | | Y | |
|
||||
| NSIS Installer | | | | |
|
||||
| NSIS Installer | | | - | |
|
||||
| Mac bundle | | | Y | |
|
||||
| Windows exe | | | | |
|
||||
| Windows exe | | | - | |
|
||||
|
||||
## Frameless Windows
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ const (
|
||||
type WebviewWindowOptions struct {
|
||||
Name string
|
||||
Title string
|
||||
Width, Height int
|
||||
Width int
|
||||
Height int
|
||||
AlwaysOnTop bool
|
||||
URL string
|
||||
DisableResize bool
|
||||
|
||||
@@ -662,6 +662,53 @@ func (w *windowsWebviewWindow) WndProc(msg uint32, wparam, lparam uintptr) uintp
|
||||
if w.framelessWithDecorations() {
|
||||
w32.ExtendFrameIntoClientArea(w.hwnd, true)
|
||||
}
|
||||
case w32.WM_NCHITTEST:
|
||||
// Get the cursor position
|
||||
x := int32(w32.LOWORD(uint32(lparam)))
|
||||
y := int32(w32.HIWORD(uint32(lparam)))
|
||||
ptCursor := w32.POINT{X: x, Y: y}
|
||||
|
||||
// Get the window rectangle
|
||||
rcWindow := w32.GetWindowRect(w.hwnd)
|
||||
|
||||
// Determine if the cursor is in a resize area
|
||||
bOnResizeBorder := false
|
||||
resizeBorderWidth := int32(5) // change this to adjust the resize border width
|
||||
if ptCursor.X >= rcWindow.Right-resizeBorderWidth {
|
||||
bOnResizeBorder = true // right edge
|
||||
}
|
||||
if ptCursor.Y >= rcWindow.Bottom-resizeBorderWidth {
|
||||
bOnResizeBorder = true // bottom edge
|
||||
}
|
||||
if ptCursor.X <= rcWindow.Left+resizeBorderWidth {
|
||||
bOnResizeBorder = true // left edge
|
||||
}
|
||||
if ptCursor.Y <= rcWindow.Top+resizeBorderWidth {
|
||||
bOnResizeBorder = true // top edge
|
||||
}
|
||||
|
||||
// Return the appropriate value
|
||||
if bOnResizeBorder {
|
||||
if ptCursor.X >= rcWindow.Right-resizeBorderWidth && ptCursor.Y >= rcWindow.Bottom-resizeBorderWidth {
|
||||
return w32.HTBOTTOMRIGHT
|
||||
} else if ptCursor.X <= rcWindow.Left+resizeBorderWidth && ptCursor.Y >= rcWindow.Bottom-resizeBorderWidth {
|
||||
return w32.HTBOTTOMLEFT
|
||||
} else if ptCursor.X >= rcWindow.Right-resizeBorderWidth && ptCursor.Y <= rcWindow.Top+resizeBorderWidth {
|
||||
return w32.HTTOPRIGHT
|
||||
} else if ptCursor.X <= rcWindow.Left+resizeBorderWidth && ptCursor.Y <= rcWindow.Top+resizeBorderWidth {
|
||||
return w32.HTTOPLEFT
|
||||
} else if ptCursor.X >= rcWindow.Right-resizeBorderWidth {
|
||||
return w32.HTRIGHT
|
||||
} else if ptCursor.Y >= rcWindow.Bottom-resizeBorderWidth {
|
||||
return w32.HTBOTTOM
|
||||
} else if ptCursor.X <= rcWindow.Left+resizeBorderWidth {
|
||||
return w32.HTLEFT
|
||||
} else if ptCursor.Y <= rcWindow.Top+resizeBorderWidth {
|
||||
return w32.HTTOP
|
||||
}
|
||||
}
|
||||
return w32.HTCLIENT
|
||||
|
||||
case w32.WM_NCCALCSIZE:
|
||||
// Disable the standard frame by allowing the client area to take the full
|
||||
// window size.
|
||||
|
||||
Reference in New Issue
Block a user