mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3 windows] Support irregular shaped windows. Centered option.
This commit is contained in:
parent
647982de1a
commit
42b1807c36
4 changed files with 13 additions and 3 deletions
|
|
@ -23,7 +23,7 @@ type WebviewWindowOptions struct {
|
|||
MaxWidth int
|
||||
MaxHeight int
|
||||
StartState WindowState
|
||||
Mac MacWindow
|
||||
Centered bool
|
||||
BackgroundType BackgroundType
|
||||
BackgroundColour RGBA
|
||||
HTML string
|
||||
|
|
@ -37,6 +37,7 @@ type WebviewWindowOptions struct {
|
|||
EnableFraudulentWebsiteWarnings bool
|
||||
Zoom float64
|
||||
EnableDragAndDrop bool
|
||||
Mac MacWindow
|
||||
Windows WindowsWindow
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ type WindowsWindow struct {
|
|||
DisableFramelessWindowDecorations bool
|
||||
|
||||
// WindowMask is used to set the window shape. Use a PNG with an alpha channel to create a custom shape.
|
||||
WindowMask []byte
|
||||
WindowMask []byte
|
||||
WindowMaskDraggable bool
|
||||
}
|
||||
|
||||
type Theme int
|
||||
|
|
|
|||
|
|
@ -446,6 +446,7 @@ func (w *WebviewWindow) handleMessage(message string) {
|
|||
// Center centers the window on the screen
|
||||
func (w *WebviewWindow) Center() {
|
||||
if w.impl == nil {
|
||||
w.options.Centered = true
|
||||
return
|
||||
}
|
||||
invokeSync(w.impl.center)
|
||||
|
|
|
|||
|
|
@ -185,6 +185,10 @@ func (w *windowsWebviewWindow) run() {
|
|||
w.setWindowMask(options.Windows.WindowMask)
|
||||
}
|
||||
|
||||
if options.Centered {
|
||||
w.center()
|
||||
}
|
||||
|
||||
w.setForeground()
|
||||
|
||||
if !options.Hidden {
|
||||
|
|
@ -649,7 +653,10 @@ func (w *windowsWebviewWindow) WndProc(msg uint32, wparam, lparam uintptr) uintp
|
|||
if w.parent.options.Windows.WindowMask != nil {
|
||||
switch msg {
|
||||
case w32.WM_NCHITTEST:
|
||||
return w32.HTCAPTION
|
||||
if w.parent.options.Windows.WindowMaskDraggable {
|
||||
return w32.HTCAPTION
|
||||
}
|
||||
return w32.HTCLIENT
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue