mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-05 04:00:32 +08:00
[v3 Windows] Add Support for SetTitle, Center, Un/Minimise/Maximise, IsMin/Maximised, IsNormal, Show/Hide
This commit is contained in:
parent
17204bebd0
commit
1f6217c0d8
244
v3/STATUS.md
244
v3/STATUS.md
@ -8,19 +8,19 @@ Application interface methods
|
|||||||
|
|
||||||
| Method | Windows | Linux | Mac | Notes |
|
| Method | Windows | Linux | Mac | Notes |
|
||||||
|---------------------------------------------------------------|---------|-------|-----|-------|
|
|---------------------------------------------------------------|---------|-------|-----|-------|
|
||||||
| run() error | | | ✅ | |
|
| run() error | | | Y | |
|
||||||
| destroy() | | | ✅ | |
|
| destroy() | | | Y | |
|
||||||
| setApplicationMenu(menu *Menu) | | | ✅ | |
|
| setApplicationMenu(menu *Menu) | | | Y | |
|
||||||
| name() string | | | ✅ | |
|
| name() string | | | Y | |
|
||||||
| getCurrentWindowID() uint | | | ✅ | |
|
| getCurrentWindowID() uint | | | Y | |
|
||||||
| showAboutDialog(name string, description string, icon []byte) | | | ✅ | |
|
| showAboutDialog(name string, description string, icon []byte) | | | Y | |
|
||||||
| setIcon(icon []byte) | | | ✅ | |
|
| setIcon(icon []byte) | | | Y | |
|
||||||
| on(id uint) | | | ✅ | |
|
| on(id uint) | | | Y | |
|
||||||
| dispatchOnMainThread(id uint) | | | ✅ | |
|
| dispatchOnMainThread(fn func()) | Y | | Y | |
|
||||||
| hide() | | | ✅ | |
|
| hide() | | | Y | |
|
||||||
| show() | | | ✅ | |
|
| show() | | | Y | |
|
||||||
| getPrimaryScreen() (*Screen, error) | | | ✅ | |
|
| getPrimaryScreen() (*Screen, error) | | | Y | |
|
||||||
| getScreens() ([]*Screen, error) | | | ✅ | |
|
| getScreens() ([]*Screen, error) | | | Y | |
|
||||||
|
|
||||||
## Webview Window
|
## Webview Window
|
||||||
|
|
||||||
@ -28,52 +28,53 @@ Webview Window Interface Methods
|
|||||||
|
|
||||||
| Method | Windows | Linux | Mac | Notes |
|
| Method | Windows | Linux | Mac | Notes |
|
||||||
|----------------------------------------------------|---------|-------|-----|-------|
|
|----------------------------------------------------|---------|-------|-----|-------|
|
||||||
| setTitle(title string) | | | ✅ | |
|
| setTitle(title string) | Y | | Y | |
|
||||||
| setSize(width, height int) | | | ✅ | |
|
| setSize(width, height int) | Y | | Y | |
|
||||||
| setAlwaysOnTop(alwaysOnTop bool) | | | ✅ | |
|
| setAlwaysOnTop(alwaysOnTop bool) | Y | | Y | |
|
||||||
| setURL(url string) | | | ✅ | |
|
| setURL(url string) | | | Y | |
|
||||||
| setResizable(resizable bool) | | | ✅ | |
|
| setResizable(resizable bool) | Y | | Y | |
|
||||||
| setMinSize(width, height int) | | | ✅ | |
|
| setMinSize(width, height int) | | | Y | |
|
||||||
| setMaxSize(width, height int) | | | ✅ | |
|
| setMaxSize(width, height int) | | | Y | |
|
||||||
| execJS(js string) | | | ✅ | |
|
| execJS(js string) | | | Y | |
|
||||||
| restore() | | | ✅ | |
|
| restore() | | | Y | |
|
||||||
| setBackgroundColour(color *RGBA) | | | ✅ | |
|
| setBackgroundColour(color RGBA) | Y | | Y | |
|
||||||
| run() | | | ✅ | |
|
| run() | Y | | Y | |
|
||||||
| center() | | | ✅ | |
|
| center() | Y | | Y | |
|
||||||
| size() (int, int) | | | ✅ | |
|
| size() (int, int) | | | Y | |
|
||||||
| width() int | | | ✅ | |
|
| width() int | Y | | Y | |
|
||||||
| height() int | | | ✅ | |
|
| height() int | Y | | Y | |
|
||||||
| position() (int, int) | | | ✅ | |
|
| position() (int, int) | Y | | Y | |
|
||||||
| destroy() | | | ✅ | |
|
| destroy() | | | Y | |
|
||||||
| reload() | | | ✅ | |
|
| reload() | | | Y | |
|
||||||
| forceReload() | | | ✅ | |
|
| forceReload() | | | Y | |
|
||||||
| toggleDevTools() | | | ✅ | |
|
| toggleDevTools() | | | Y | |
|
||||||
| zoomReset() | | | ✅ | |
|
| zoomReset() | | | Y | |
|
||||||
| zoomIn() | | | ✅ | |
|
| zoomIn() | | | Y | |
|
||||||
| zoomOut() | | | ✅ | |
|
| zoomOut() | | | Y | |
|
||||||
| getZoom() float64 | | | ✅ | |
|
| getZoom() float64 | | | Y | |
|
||||||
| setZoom(zoom float64) | | | ✅ | |
|
| setZoom(zoom float64) | | | Y | |
|
||||||
| close() | | | ✅ | |
|
| close() | | | Y | |
|
||||||
| zoom() | | | ✅ | |
|
| zoom() | | | Y | |
|
||||||
| setHTML(html string) | | | ✅ | |
|
| setHTML(html string) | | | Y | |
|
||||||
| setPosition(x int, y int) | | | ✅ | |
|
| setPosition(x int, y int) | | | Y | |
|
||||||
| on(eventID uint) | | | ✅ | |
|
| on(eventID uint) | | | Y | |
|
||||||
| minimise() | | | ✅ | |
|
| minimise() | Y | | Y | |
|
||||||
| unminimise() | | | ✅ | |
|
| unminimise() | Y | | Y | |
|
||||||
| maximise() | | | ✅ | |
|
| maximise() | Y | | Y | |
|
||||||
| unmaximise() | | | ✅ | |
|
| unmaximise() | Y | | Y | |
|
||||||
| fullscreen() | | | ✅ | |
|
| fullscreen() | | | Y | |
|
||||||
| unfullscreen() | | | ✅ | |
|
| unfullscreen() | | | Y | |
|
||||||
| isMinimised() bool | | | ✅ | |
|
| isMinimised() bool | Y | | Y | |
|
||||||
| isMaximised() bool | | | ✅ | |
|
| isMaximised() bool | Y | | Y | |
|
||||||
| isFullscreen() bool | | | ✅ | |
|
| isFullscreen() bool | | | Y | |
|
||||||
| disableSizeConstraints() | | | ✅ | |
|
| disableSizeConstraints() | | | Y | |
|
||||||
| setFullscreenButtonEnabled(enabled bool) | | | ✅ | |
|
| setFullscreenButtonEnabled(enabled bool) | | | Y | |
|
||||||
| show() | | | ✅ | |
|
| show() | Y | | Y | |
|
||||||
| hide() | | | ✅ | |
|
| hide() | Y | | Y | |
|
||||||
| getScreen() (*Screen, error) | | | ✅ | |
|
| getScreen() (*Screen, error) | | | Y | |
|
||||||
| setFrameless(bool) | | | ✅ | |
|
| setFrameless(bool) | | | Y | |
|
||||||
| openContextMenu(menu *Menu, data *ContextMenuData) | | | ✅ | |
|
| openContextMenu(menu *Menu, data *ContextMenuData) | | | Y | |
|
||||||
|
| nativeWindowHandle() (uintptr, error) | Y | | | |
|
||||||
|
|
||||||
## Runtime
|
## Runtime
|
||||||
|
|
||||||
@ -81,73 +82,73 @@ Webview Window Interface Methods
|
|||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|---------|---------|-------|-----|-------|
|
|---------|---------|-------|-----|-------|
|
||||||
| Quit | | | ✅ | |
|
| Quit | | | Y | |
|
||||||
| Hide | | | ✅ | |
|
| Hide | | | Y | |
|
||||||
| Show | | | ✅ | |
|
| Show | | | Y | |
|
||||||
|
|
||||||
### Dialogs
|
### Dialogs
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|----------|---------|-------|-----|-------|
|
|----------|---------|-------|-----|-------|
|
||||||
| Info | | | ✅ | |
|
| Info | | | Y | |
|
||||||
| Warning | | | ✅ | |
|
| Warning | | | Y | |
|
||||||
| Error | | | ✅ | |
|
| Error | | | Y | |
|
||||||
| Question | | | ✅ | |
|
| Question | | | Y | |
|
||||||
| OpenFile | | | ✅ | |
|
| OpenFile | | | Y | |
|
||||||
| SaveFile | | | ✅ | |
|
| SaveFile | | | Y | |
|
||||||
|
|
||||||
### Clipboard
|
### Clipboard
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|---------|---------|-------|-----|-------|
|
|---------|---------|-------|-----|-------|
|
||||||
| SetText | | | ✅ | |
|
| SetText | | | Y | |
|
||||||
| Text | | | ✅ | |
|
| Text | | | Y | |
|
||||||
|
|
||||||
### ContextMenu
|
### ContextMenu
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|-----------------|---------|-------|-----|-------|
|
|-----------------|---------|-------|-----|-------|
|
||||||
| OpenContextMenu | | | ✅ | |
|
| OpenContextMenu | | | Y | |
|
||||||
|
|
||||||
### Screens
|
### Screens
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|------------|---------|-------|-----|-------|
|
|------------|---------|-------|-----|-------|
|
||||||
| GetAll | | | ✅ | |
|
| GetAll | | | Y | |
|
||||||
| GetPrimary | | | ✅ | |
|
| GetPrimary | | | Y | |
|
||||||
| GetCurrent | | | ✅ | |
|
| GetCurrent | | | Y | |
|
||||||
|
|
||||||
### Window
|
### Window
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|---------------------|---------|-------|-----|--------------------------------------------------------------------------------------|
|
|---------------------|---------|-------|-----|--------------------------------------------------------------------------------------|
|
||||||
| SetTitle | | | ✅ | |
|
| SetTitle | | | Y | |
|
||||||
| SetSize | | | ✅ | |
|
| SetSize | | | Y | |
|
||||||
| Size | | | ✅ | |
|
| Size | | | Y | |
|
||||||
| SetPosition | | | ✅ | |
|
| SetPosition | | | Y | |
|
||||||
| Position | | | ✅ | |
|
| Position | | | Y | |
|
||||||
| FullScreen | | | ✅ | |
|
| FullScreen | | | Y | |
|
||||||
| UnFullscreen | | | ✅ | |
|
| UnFullscreen | | | Y | |
|
||||||
| Minimise | | | ✅ | |
|
| Minimise | | | Y | |
|
||||||
| UnMinimise | | | ✅ | |
|
| UnMinimise | | | Y | |
|
||||||
| Maximise | | | ✅ | |
|
| Maximise | | | Y | |
|
||||||
| UnMaximise | | | ✅ | |
|
| UnMaximise | | | Y | |
|
||||||
| Show | | | ✅ | |
|
| Show | | | Y | |
|
||||||
| Hide | | | ✅ | |
|
| Hide | | | Y | |
|
||||||
| Center | | | ✅ | |
|
| Center | | | Y | |
|
||||||
| SetBackgroundColour | | | ✅ | https://github.com/MicrosoftEdge/WebView2Feedback/issues/1621#issuecomment-938234294 |
|
| SetBackgroundColour | | | Y | https://github.com/MicrosoftEdge/WebView2Feedback/issues/1621#issuecomment-938234294 |
|
||||||
| SetAlwaysOnTop | | | ✅ | |
|
| SetAlwaysOnTop | | | Y | |
|
||||||
| SetResizable | | | ✅ | |
|
| SetResizable | | | Y | |
|
||||||
| SetMinSize | | | ✅ | |
|
| SetMinSize | | | Y | |
|
||||||
| SetMaxSize | | | ✅ | |
|
| SetMaxSize | | | Y | |
|
||||||
| Width | | | ✅ | |
|
| Width | | | Y | |
|
||||||
| Height | | | ✅ | |
|
| Height | | | Y | |
|
||||||
| ZoomIn | | | ✅ | Increase view scale |
|
| ZoomIn | | | Y | Increase view scale |
|
||||||
| ZoomOut | | | ✅ | Decrease view scale |
|
| ZoomOut | | | Y | Decrease view scale |
|
||||||
| ZoomReset | | | ✅ | Reset view scale |
|
| ZoomReset | | | Y | Reset view scale |
|
||||||
| GetZoom | | | ✅ | Get current view scale |
|
| GetZoom | | | Y | Get current view scale |
|
||||||
| SetZoom | | | ✅ | Set view scale |
|
| SetZoom | | | Y | Set view scale |
|
||||||
| Screen | | | ✅ | Get screen for window |
|
| Screen | | | Y | Get screen for window |
|
||||||
|
|
||||||
### Log
|
### Log
|
||||||
|
|
||||||
@ -157,16 +158,16 @@ To log or not to log? System logger vs custom logger.
|
|||||||
|
|
||||||
| Event | Windows | Linux | Mac | Notes |
|
| Event | Windows | Linux | Mac | Notes |
|
||||||
|--------------------------|---------|-------|-----|-------|
|
|--------------------------|---------|-------|-----|-------|
|
||||||
| Default Application Menu | | | ✅ | |
|
| Default Application Menu | | | Y | |
|
||||||
|
|
||||||
## Tray Menus
|
## Tray Menus
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|--------------------|---------|-------|-----|-------|
|
|--------------------|---------|-------|-----|-------|
|
||||||
| Icon | | | ✅ | |
|
| Icon | | | Y | |
|
||||||
| Label | | | ✅ | |
|
| Label | | | Y | |
|
||||||
| Label (ANSI Codes) | | | | |
|
| Label (ANSI Codes) | | | | |
|
||||||
| Menu | | | ✅ | |
|
| Menu | | | Y | |
|
||||||
|
|
||||||
## Cross Platform Events
|
## Cross Platform Events
|
||||||
|
|
||||||
@ -197,10 +198,10 @@ TBD
|
|||||||
## Theme
|
## Theme
|
||||||
|
|
||||||
| Plugin | Windows | Linux | Mac | Notes |
|
| Plugin | Windows | Linux | Mac | Notes |
|
||||||
|-----------------|---------|-------|-----|-------|
|
|--------|---------|-------|-----|-------|
|
||||||
| Dark | | | | |
|
| Dark | Y | | | |
|
||||||
| Light | | | | |
|
| Light | Y | | | |
|
||||||
| System | | | | |
|
| System | Y | | | |
|
||||||
|
|
||||||
## NSIS Installer
|
## NSIS Installer
|
||||||
|
|
||||||
@ -216,29 +217,29 @@ Built-in plugin support:
|
|||||||
|
|
||||||
| Plugin | Windows | Linux | Mac | Notes |
|
| Plugin | Windows | Linux | Mac | Notes |
|
||||||
|-----------------|---------|-------|-----|-------|
|
|-----------------|---------|-------|-----|-------|
|
||||||
| Browser | | | ✅ | |
|
| Browser | | | Y | |
|
||||||
| KV Store | | | ✅ | |
|
| KV Store | | | Y | |
|
||||||
| Log | | | ✅ | |
|
| Log | | | Y | |
|
||||||
| Single Instance | | | ✅ | |
|
| Single Instance | | | Y | |
|
||||||
| SQLite | | | ✅ | |
|
| SQLite | | | Y | |
|
||||||
| Start at login | | | ✅ | |
|
| Start at login | | | Y | |
|
||||||
| Server | | | | |
|
| Server | | | | |
|
||||||
|
|
||||||
## Packaging
|
## Packaging
|
||||||
|
|
||||||
| | Windows | Linux | Mac | Notes |
|
| | Windows | Linux | Mac | Notes |
|
||||||
|-----------------|---------|-------|-----|-------|
|
|-----------------|---------|-------|-----|-------|
|
||||||
| Icon Generation | | | ✅ | |
|
| Icon Generation | | | Y | |
|
||||||
| Icon Embedding | | | ✅ | |
|
| Icon Embedding | | | Y | |
|
||||||
| Info.plist | | | ✅ | |
|
| Info.plist | | | Y | |
|
||||||
| NSIS Installer | | | | |
|
| NSIS Installer | | | | |
|
||||||
| Mac bundle | | | ✅ | |
|
| Mac bundle | | | Y | |
|
||||||
| Windows exe | | | | |
|
| Windows exe | | | | |
|
||||||
|
|
||||||
## Frameless Windows
|
## Frameless Windows
|
||||||
|
|
||||||
| Feature | Windows | Linux | Mac | Notes |
|
| Feature | Windows | Linux | Mac | Notes |
|
||||||
|---------|---------|-------|----|-------|
|
|---------|---------|-------|-----|-------|
|
||||||
| Resize | | | | |
|
| Resize | | | | |
|
||||||
| Drag | | | | |
|
| Drag | | | | |
|
||||||
|
|
||||||
@ -248,4 +249,7 @@ Built-in plugin support:
|
|||||||
|
|
||||||
## Windows Specific
|
## Windows Specific
|
||||||
|
|
||||||
|
- [x] Translucency
|
||||||
|
- [x] Custom Themes
|
||||||
|
|
||||||
## Linux Specific
|
## Linux Specific
|
||||||
|
@ -22,7 +22,6 @@ type (
|
|||||||
setMinSize(width, height int)
|
setMinSize(width, height int)
|
||||||
setMaxSize(width, height int)
|
setMaxSize(width, height int)
|
||||||
execJS(js string)
|
execJS(js string)
|
||||||
restore()
|
|
||||||
setBackgroundColour(color RGBA)
|
setBackgroundColour(color RGBA)
|
||||||
run()
|
run()
|
||||||
center()
|
center()
|
||||||
@ -53,6 +52,7 @@ type (
|
|||||||
isMinimised() bool
|
isMinimised() bool
|
||||||
isMaximised() bool
|
isMaximised() bool
|
||||||
isFullscreen() bool
|
isFullscreen() bool
|
||||||
|
isNormal() bool
|
||||||
disableSizeConstraints()
|
disableSizeConstraints()
|
||||||
setFullscreenButtonEnabled(enabled bool)
|
setFullscreenButtonEnabled(enabled bool)
|
||||||
show()
|
show()
|
||||||
@ -102,6 +102,7 @@ func (w *WebviewWindow) onApplicationEvent(eventType events.ApplicationEventType
|
|||||||
w.addCancellationFunction(cancelFn)
|
w.addCancellationFunction(cancelFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewWindow creates a new window with the given options
|
||||||
func NewWindow(options *WebviewWindowOptions) *WebviewWindow {
|
func NewWindow(options *WebviewWindowOptions) *WebviewWindow {
|
||||||
if options.Width == 0 {
|
if options.Width == 0 {
|
||||||
options.Width = 800
|
options.Width = 800
|
||||||
@ -129,6 +130,7 @@ func (w *WebviewWindow) addCancellationFunction(canceller func()) {
|
|||||||
w.cancellers = append(w.cancellers, canceller)
|
w.cancellers = append(w.cancellers, canceller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTitle sets the title of the window
|
||||||
func (w *WebviewWindow) SetTitle(title string) *WebviewWindow {
|
func (w *WebviewWindow) SetTitle(title string) *WebviewWindow {
|
||||||
w.implLock.RLock()
|
w.implLock.RLock()
|
||||||
defer w.implLock.RUnlock()
|
defer w.implLock.RUnlock()
|
||||||
@ -139,10 +141,12 @@ func (w *WebviewWindow) SetTitle(title string) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the name of the window
|
||||||
func (w *WebviewWindow) Name() string {
|
func (w *WebviewWindow) Name() string {
|
||||||
return w.options.Name
|
return w.options.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetSize sets the size of the window
|
||||||
func (w *WebviewWindow) SetSize(width, height int) *WebviewWindow {
|
func (w *WebviewWindow) SetSize(width, height int) *WebviewWindow {
|
||||||
// Don't set size if fullscreen
|
// Don't set size if fullscreen
|
||||||
if w.IsFullscreen() {
|
if w.IsFullscreen() {
|
||||||
@ -193,6 +197,7 @@ func (w *WebviewWindow) run() {
|
|||||||
w.impl.run()
|
w.impl.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetAlwaysOnTop sets the window to be always on top.
|
||||||
func (w *WebviewWindow) SetAlwaysOnTop(b bool) *WebviewWindow {
|
func (w *WebviewWindow) SetAlwaysOnTop(b bool) *WebviewWindow {
|
||||||
w.options.AlwaysOnTop = b
|
w.options.AlwaysOnTop = b
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -201,6 +206,7 @@ func (w *WebviewWindow) SetAlwaysOnTop(b bool) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show shows the window.
|
||||||
func (w *WebviewWindow) Show() *WebviewWindow {
|
func (w *WebviewWindow) Show() *WebviewWindow {
|
||||||
if globalApplication.impl == nil {
|
if globalApplication.impl == nil {
|
||||||
return w
|
return w
|
||||||
@ -212,6 +218,8 @@ func (w *WebviewWindow) Show() *WebviewWindow {
|
|||||||
w.impl.show()
|
w.impl.show()
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide hides the window.
|
||||||
func (w *WebviewWindow) Hide() *WebviewWindow {
|
func (w *WebviewWindow) Hide() *WebviewWindow {
|
||||||
w.options.Hidden = true
|
w.options.Hidden = true
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -228,6 +236,7 @@ func (w *WebviewWindow) SetURL(s string) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetZoom sets the zoom level of the window.
|
||||||
func (w *WebviewWindow) SetZoom(magnification float64) *WebviewWindow {
|
func (w *WebviewWindow) SetZoom(magnification float64) *WebviewWindow {
|
||||||
w.options.Zoom = magnification
|
w.options.Zoom = magnification
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -236,6 +245,7 @@ func (w *WebviewWindow) SetZoom(magnification float64) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetZoom returns the current zoom level of the window.
|
||||||
func (w *WebviewWindow) GetZoom() float64 {
|
func (w *WebviewWindow) GetZoom() float64 {
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
return w.impl.getZoom()
|
return w.impl.getZoom()
|
||||||
@ -243,6 +253,7 @@ func (w *WebviewWindow) GetZoom() float64 {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetResizable sets whether the window is resizable.
|
||||||
func (w *WebviewWindow) SetResizable(b bool) *WebviewWindow {
|
func (w *WebviewWindow) SetResizable(b bool) *WebviewWindow {
|
||||||
w.options.DisableResize = !b
|
w.options.DisableResize = !b
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -251,10 +262,12 @@ func (w *WebviewWindow) SetResizable(b bool) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resizable returns true if the window is resizable.
|
||||||
func (w *WebviewWindow) Resizable() bool {
|
func (w *WebviewWindow) Resizable() bool {
|
||||||
return !w.options.DisableResize
|
return !w.options.DisableResize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMinSize sets the minimum size of the window.
|
||||||
func (w *WebviewWindow) SetMinSize(minWidth, minHeight int) *WebviewWindow {
|
func (w *WebviewWindow) SetMinSize(minWidth, minHeight int) *WebviewWindow {
|
||||||
w.options.MinWidth = minWidth
|
w.options.MinWidth = minWidth
|
||||||
w.options.MinHeight = minHeight
|
w.options.MinHeight = minHeight
|
||||||
@ -282,6 +295,7 @@ func (w *WebviewWindow) SetMinSize(minWidth, minHeight int) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMaxSize sets the maximum size of the window.
|
||||||
func (w *WebviewWindow) SetMaxSize(maxWidth, maxHeight int) *WebviewWindow {
|
func (w *WebviewWindow) SetMaxSize(maxWidth, maxHeight int) *WebviewWindow {
|
||||||
w.options.MaxWidth = maxWidth
|
w.options.MaxWidth = maxWidth
|
||||||
w.options.MaxHeight = maxHeight
|
w.options.MaxHeight = maxHeight
|
||||||
@ -309,6 +323,7 @@ func (w *WebviewWindow) SetMaxSize(maxWidth, maxHeight int) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExecJS executes the given javascript in the context of the window.
|
||||||
func (w *WebviewWindow) ExecJS(js string) {
|
func (w *WebviewWindow) ExecJS(js string) {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -316,6 +331,7 @@ func (w *WebviewWindow) ExecJS(js string) {
|
|||||||
w.impl.execJS(js)
|
w.impl.execJS(js)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fullscreen sets the window to fullscreen mode. Min/Max size constraints are disabled.
|
||||||
func (w *WebviewWindow) Fullscreen() *WebviewWindow {
|
func (w *WebviewWindow) Fullscreen() *WebviewWindow {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
w.options.StartState = WindowStateFullscreen
|
w.options.StartState = WindowStateFullscreen
|
||||||
@ -370,6 +386,7 @@ func (w *WebviewWindow) IsFullscreen() bool {
|
|||||||
return w.impl.isFullscreen()
|
return w.impl.isFullscreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetBackgroundColour sets the background colour of the window
|
||||||
func (w *WebviewWindow) SetBackgroundColour(colour RGBA) *WebviewWindow {
|
func (w *WebviewWindow) SetBackgroundColour(colour RGBA) *WebviewWindow {
|
||||||
w.options.BackgroundColour = colour
|
w.options.BackgroundColour = colour
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -388,6 +405,7 @@ func (w *WebviewWindow) handleMessage(message string) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Center centers the window on the screen
|
||||||
func (w *WebviewWindow) Center() {
|
func (w *WebviewWindow) Center() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -395,6 +413,7 @@ func (w *WebviewWindow) Center() {
|
|||||||
w.impl.center()
|
w.impl.center()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On registers a callback for the given window event
|
||||||
func (w *WebviewWindow) On(eventType events.WindowEventType, callback func(ctx *WindowEventContext)) func() {
|
func (w *WebviewWindow) On(eventType events.WindowEventType, callback func(ctx *WindowEventContext)) func() {
|
||||||
eventID := uint(eventType)
|
eventID := uint(eventType)
|
||||||
w.eventListenersLock.Lock()
|
w.eventListenersLock.Lock()
|
||||||
@ -423,6 +442,7 @@ func (w *WebviewWindow) handleWindowEvent(id uint) {
|
|||||||
w.eventListenersLock.RUnlock()
|
w.eventListenersLock.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Width returns the width of the window
|
||||||
func (w *WebviewWindow) Width() int {
|
func (w *WebviewWindow) Width() int {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return 0
|
return 0
|
||||||
@ -430,6 +450,7 @@ func (w *WebviewWindow) Width() int {
|
|||||||
return w.impl.width()
|
return w.impl.width()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Height returns the height of the window
|
||||||
func (w *WebviewWindow) Height() int {
|
func (w *WebviewWindow) Height() int {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return 0
|
return 0
|
||||||
@ -437,6 +458,7 @@ func (w *WebviewWindow) Height() int {
|
|||||||
return w.impl.height()
|
return w.impl.height()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Position returns the position of the window
|
||||||
func (w *WebviewWindow) Position() (int, int) {
|
func (w *WebviewWindow) Position() (int, int) {
|
||||||
w.implLock.RLock()
|
w.implLock.RLock()
|
||||||
defer w.implLock.RUnlock()
|
defer w.implLock.RUnlock()
|
||||||
@ -457,6 +479,7 @@ func (w *WebviewWindow) Destroy() {
|
|||||||
w.impl.destroy()
|
w.impl.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reload reloads the page assets
|
||||||
func (w *WebviewWindow) Reload() {
|
func (w *WebviewWindow) Reload() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -464,6 +487,7 @@ func (w *WebviewWindow) Reload() {
|
|||||||
w.impl.reload()
|
w.impl.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ForceReload forces the window to reload the page assets
|
||||||
func (w *WebviewWindow) ForceReload() {
|
func (w *WebviewWindow) ForceReload() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -471,6 +495,7 @@ func (w *WebviewWindow) ForceReload() {
|
|||||||
w.impl.forceReload()
|
w.impl.forceReload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToggleFullscreen toggles the window between fullscreen and normal
|
||||||
func (w *WebviewWindow) ToggleFullscreen() {
|
func (w *WebviewWindow) ToggleFullscreen() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -489,6 +514,7 @@ func (w *WebviewWindow) ToggleDevTools() {
|
|||||||
w.impl.toggleDevTools()
|
w.impl.toggleDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ZoomReset resets the zoom level of the webview content to 100%
|
||||||
func (w *WebviewWindow) ZoomReset() *WebviewWindow {
|
func (w *WebviewWindow) ZoomReset() *WebviewWindow {
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
w.impl.zoomReset()
|
w.impl.zoomReset()
|
||||||
@ -497,6 +523,7 @@ func (w *WebviewWindow) ZoomReset() *WebviewWindow {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ZoomIn increases the zoom level of the webview content
|
||||||
func (w *WebviewWindow) ZoomIn() {
|
func (w *WebviewWindow) ZoomIn() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -504,6 +531,7 @@ func (w *WebviewWindow) ZoomIn() {
|
|||||||
w.impl.zoomIn()
|
w.impl.zoomIn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ZoomOut decreases the zoom level of the webview content
|
||||||
func (w *WebviewWindow) ZoomOut() {
|
func (w *WebviewWindow) ZoomOut() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -511,6 +539,7 @@ func (w *WebviewWindow) ZoomOut() {
|
|||||||
w.impl.zoomOut()
|
w.impl.zoomOut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the window
|
||||||
func (w *WebviewWindow) Close() {
|
func (w *WebviewWindow) Close() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -518,13 +547,6 @@ func (w *WebviewWindow) Close() {
|
|||||||
w.impl.close()
|
w.impl.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WebviewWindow) Minimize() {
|
|
||||||
if w.impl == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.impl.minimise()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *WebviewWindow) Zoom() {
|
func (w *WebviewWindow) Zoom() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -532,6 +554,7 @@ func (w *WebviewWindow) Zoom() {
|
|||||||
w.impl.zoom()
|
w.impl.zoom()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetHTML sets the HTML of the window to the given html string.
|
||||||
func (w *WebviewWindow) SetHTML(html string) *WebviewWindow {
|
func (w *WebviewWindow) SetHTML(html string) *WebviewWindow {
|
||||||
w.options.HTML = html
|
w.options.HTML = html
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -540,6 +563,7 @@ func (w *WebviewWindow) SetHTML(html string) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetPosition sets the position of the window.
|
||||||
func (w *WebviewWindow) SetPosition(x, y int) *WebviewWindow {
|
func (w *WebviewWindow) SetPosition(x, y int) *WebviewWindow {
|
||||||
w.options.X = x
|
w.options.X = x
|
||||||
w.options.Y = y
|
w.options.Y = y
|
||||||
@ -549,6 +573,7 @@ func (w *WebviewWindow) SetPosition(x, y int) *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Minimise minimises the window.
|
||||||
func (w *WebviewWindow) Minimise() *WebviewWindow {
|
func (w *WebviewWindow) Minimise() *WebviewWindow {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
w.options.StartState = WindowStateMinimised
|
w.options.StartState = WindowStateMinimised
|
||||||
@ -560,6 +585,7 @@ func (w *WebviewWindow) Minimise() *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maximise maximises the window. Min/Max size constraints are disabled.
|
||||||
func (w *WebviewWindow) Maximise() *WebviewWindow {
|
func (w *WebviewWindow) Maximise() *WebviewWindow {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
w.options.StartState = WindowStateMaximised
|
w.options.StartState = WindowStateMaximised
|
||||||
@ -572,29 +598,39 @@ func (w *WebviewWindow) Maximise() *WebviewWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnMinimise un-minimises the window. Min/Max size constraints are re-enabled.
|
||||||
func (w *WebviewWindow) UnMinimise() {
|
func (w *WebviewWindow) UnMinimise() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.IsMinimised() {
|
||||||
w.impl.unminimise()
|
w.impl.unminimise()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnMaximise un-maximises the window.
|
||||||
func (w *WebviewWindow) UnMaximise() {
|
func (w *WebviewWindow) UnMaximise() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.IsMaximised() {
|
||||||
w.enableSizeConstraints()
|
w.enableSizeConstraints()
|
||||||
w.impl.unmaximise()
|
w.impl.unmaximise()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnFullscreen un-fullscreens the window.
|
||||||
func (w *WebviewWindow) UnFullscreen() {
|
func (w *WebviewWindow) UnFullscreen() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.IsFullscreen() {
|
||||||
w.enableSizeConstraints()
|
w.enableSizeConstraints()
|
||||||
w.impl.unfullscreen()
|
w.impl.unfullscreen()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore restores the window to its previous state if it was previously minimised, maximised or fullscreen.
|
||||||
func (w *WebviewWindow) Restore() {
|
func (w *WebviewWindow) Restore() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
@ -612,18 +648,27 @@ func (w *WebviewWindow) disableSizeConstraints() {
|
|||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.options.MinWidth > 0 && w.options.MinHeight > 0 {
|
||||||
w.impl.setMinSize(0, 0)
|
w.impl.setMinSize(0, 0)
|
||||||
|
}
|
||||||
|
if w.options.MaxWidth > 0 && w.options.MaxHeight > 0 {
|
||||||
w.impl.setMaxSize(0, 0)
|
w.impl.setMaxSize(0, 0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (w *WebviewWindow) enableSizeConstraints() {
|
func (w *WebviewWindow) enableSizeConstraints() {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.options.MinWidth > 0 && w.options.MinHeight > 0 {
|
||||||
w.SetMinSize(w.options.MinWidth, w.options.MinHeight)
|
w.SetMinSize(w.options.MinWidth, w.options.MinHeight)
|
||||||
|
}
|
||||||
|
if w.options.MaxWidth > 0 && w.options.MaxHeight > 0 {
|
||||||
w.SetMaxSize(w.options.MaxWidth, w.options.MaxHeight)
|
w.SetMaxSize(w.options.MaxWidth, w.options.MaxHeight)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetScreen returns the screen that the window is on
|
||||||
func (w *WebviewWindow) GetScreen() (*Screen, error) {
|
func (w *WebviewWindow) GetScreen() (*Screen, error) {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -631,6 +676,7 @@ func (w *WebviewWindow) GetScreen() (*Screen, error) {
|
|||||||
return w.impl.getScreen()
|
return w.impl.getScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetFrameless removes the window frame and title bar
|
||||||
func (w *WebviewWindow) SetFrameless(frameless bool) *WebviewWindow {
|
func (w *WebviewWindow) SetFrameless(frameless bool) *WebviewWindow {
|
||||||
w.options.Frameless = frameless
|
w.options.Frameless = frameless
|
||||||
if w.impl != nil {
|
if w.impl != nil {
|
||||||
@ -690,12 +736,14 @@ func (w *WebviewWindow) openContextMenu(data *ContextMenuData) {
|
|||||||
w.impl.openContextMenu(menu, data)
|
w.impl.openContextMenu(menu, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterContextMenu registers a context menu and assigns it the given name.
|
||||||
func (w *WebviewWindow) RegisterContextMenu(name string, menu *Menu) {
|
func (w *WebviewWindow) RegisterContextMenu(name string, menu *Menu) {
|
||||||
w.contextMenusLock.Lock()
|
w.contextMenusLock.Lock()
|
||||||
defer w.contextMenusLock.Unlock()
|
defer w.contextMenusLock.Unlock()
|
||||||
w.contextMenus[name] = menu
|
w.contextMenus[name] = menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NativeWindowHandle returns the platform native window handle for the window.
|
||||||
func (w *WebviewWindow) NativeWindowHandle() (uintptr, error) {
|
func (w *WebviewWindow) NativeWindowHandle() (uintptr, error) {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
return 0, errors.New("native handle unavailable as window is not running")
|
return 0, errors.New("native handle unavailable as window is not running")
|
||||||
|
@ -26,12 +26,12 @@ func (w *windowsWebviewWindow) nativeWindowHandle() uintptr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) setTitle(title string) {
|
func (w *windowsWebviewWindow) setTitle(title string) {
|
||||||
//TODO implement me
|
w32.SetWindowText(w.hwnd, title)
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) setSize(width, height int) {
|
func (w *windowsWebviewWindow) setSize(width, height int) {
|
||||||
x, y := w.position()
|
x, y := w.position()
|
||||||
|
// TODO: Take scaling/DPI into consideration
|
||||||
w32.MoveWindow(w.hwnd, x, y, width, height, true)
|
w32.MoveWindow(w.hwnd, x, y, width, height, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +71,6 @@ func (w *windowsWebviewWindow) execJS(js string) {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) restore() {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) setBackgroundColour(color RGBA) {
|
func (w *windowsWebviewWindow) setBackgroundColour(color RGBA) {
|
||||||
w32.SetBackgroundColour(w.hwnd, color.Red, color.Green, color.Blue)
|
w32.SetBackgroundColour(w.hwnd, color.Red, color.Green, color.Blue)
|
||||||
}
|
}
|
||||||
@ -161,8 +156,7 @@ func (w *windowsWebviewWindow) _run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) center() {
|
func (w *windowsWebviewWindow) center() {
|
||||||
//TODO implement me
|
w32.CenterWindow(w.hwnd)
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) size() (int, int) {
|
func (w *windowsWebviewWindow) size() (int, int) {
|
||||||
@ -264,23 +258,29 @@ func (w *windowsWebviewWindow) on(eventID uint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) minimise() {
|
func (w *windowsWebviewWindow) minimise() {
|
||||||
//TODO implement me
|
globalApplication.dispatchOnMainThread(func() {
|
||||||
panic("implement me")
|
w32.ShowWindow(w.hwnd, w32.SW_MINIMIZE)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) unminimise() {
|
func (w *windowsWebviewWindow) unminimise() {
|
||||||
//TODO implement me
|
w.restore()
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) maximise() {
|
func (w *windowsWebviewWindow) maximise() {
|
||||||
//TODO implement me
|
globalApplication.dispatchOnMainThread(func() {
|
||||||
panic("implement me")
|
w32.ShowWindow(w.hwnd, w32.SW_MAXIMIZE)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) unmaximise() {
|
func (w *windowsWebviewWindow) unmaximise() {
|
||||||
//TODO implement me
|
w.restore()
|
||||||
panic("implement me")
|
}
|
||||||
|
|
||||||
|
func (w *windowsWebviewWindow) restore() {
|
||||||
|
globalApplication.dispatchOnMainThread(func() {
|
||||||
|
w32.ShowWindow(w.hwnd, w32.SW_RESTORE)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) fullscreen() {
|
func (w *windowsWebviewWindow) fullscreen() {
|
||||||
@ -294,13 +294,13 @@ func (w *windowsWebviewWindow) unfullscreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) isMinimised() bool {
|
func (w *windowsWebviewWindow) isMinimised() bool {
|
||||||
//TODO implement me
|
style := uint32(w32.GetWindowLong(w.hwnd, w32.GWL_STYLE))
|
||||||
panic("implement me")
|
return style&w32.WS_MINIMIZE != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) isMaximised() bool {
|
func (w *windowsWebviewWindow) isMaximised() bool {
|
||||||
//TODO implement me
|
style := uint32(w32.GetWindowLong(w.hwnd, w32.GWL_STYLE))
|
||||||
panic("implement me")
|
return style&w32.WS_MAXIMIZE != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) isFullscreen() bool {
|
func (w *windowsWebviewWindow) isFullscreen() bool {
|
||||||
@ -308,6 +308,10 @@ func (w *windowsWebviewWindow) isFullscreen() bool {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *windowsWebviewWindow) isNormal() bool {
|
||||||
|
return !w.isMinimised() && !w.isMaximised() && !w.isFullscreen()
|
||||||
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) disableSizeConstraints() {
|
func (w *windowsWebviewWindow) disableSizeConstraints() {
|
||||||
//TODO implement me
|
//TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
@ -319,12 +323,15 @@ func (w *windowsWebviewWindow) setFullscreenButtonEnabled(enabled bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) show() {
|
func (w *windowsWebviewWindow) show() {
|
||||||
|
globalApplication.dispatchOnMainThread(func() {
|
||||||
w32.ShowWindow(w.hwnd, w32.SW_SHOW)
|
w32.ShowWindow(w.hwnd, w32.SW_SHOW)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) hide() {
|
func (w *windowsWebviewWindow) hide() {
|
||||||
//TODO implement me
|
globalApplication.dispatchOnMainThread(func() {
|
||||||
panic("implement me")
|
w32.ShowWindow(w.hwnd, w32.SW_HIDE)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) getScreen() (*Screen, error) {
|
func (w *windowsWebviewWindow) getScreen() (*Screen, error) {
|
||||||
@ -404,7 +411,6 @@ func (w *windowsWebviewWindow) setIcon(icon w32.HICON) {
|
|||||||
func (w *windowsWebviewWindow) disableIcon() {
|
func (w *windowsWebviewWindow) disableIcon() {
|
||||||
|
|
||||||
// TODO: If frameless, return
|
// TODO: If frameless, return
|
||||||
|
|
||||||
exStyle := w32.GetWindowLong(w.hwnd, w32.GWL_EXSTYLE)
|
exStyle := w32.GetWindowLong(w.hwnd, w32.GWL_EXSTYLE)
|
||||||
w32.SetWindowLong(w.hwnd, w32.GWL_EXSTYLE, uint32(exStyle|w32.WS_EX_DLGMODALFRAME))
|
w32.SetWindowLong(w.hwnd, w32.GWL_EXSTYLE, uint32(exStyle|w32.WS_EX_DLGMODALFRAME))
|
||||||
w32.SetWindowPos(w.hwnd, 0, 0, 0, 0, 0,
|
w32.SetWindowPos(w.hwnd, 0, 0, 0, 0, 0,
|
||||||
|
@ -135,3 +135,39 @@ func MustUTF16FromString(input string) []uint16 {
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CenterWindow(hwnd HWND) {
|
||||||
|
windowInfo := getWindowInfo(hwnd)
|
||||||
|
frameless := windowInfo.IsPopup()
|
||||||
|
|
||||||
|
info := getMonitorInfo(hwnd)
|
||||||
|
workRect := info.RcWork
|
||||||
|
screenMiddleW := workRect.Left + (workRect.Right-workRect.Left)/2
|
||||||
|
screenMiddleH := workRect.Top + (workRect.Bottom-workRect.Top)/2
|
||||||
|
var winRect *RECT
|
||||||
|
if !frameless {
|
||||||
|
winRect = GetWindowRect(hwnd)
|
||||||
|
} else {
|
||||||
|
winRect = GetClientRect(hwnd)
|
||||||
|
}
|
||||||
|
winWidth := winRect.Right - winRect.Left
|
||||||
|
winHeight := winRect.Bottom - winRect.Top
|
||||||
|
windowX := screenMiddleW - (winWidth / 2)
|
||||||
|
windowY := screenMiddleH - (winHeight / 2)
|
||||||
|
SetWindowPos(hwnd, HWND_TOP, int(windowX), int(windowY), int(winWidth), int(winHeight), SWP_NOSIZE)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getWindowInfo(hwnd HWND) *WINDOWINFO {
|
||||||
|
var info WINDOWINFO
|
||||||
|
info.CbSize = uint32(unsafe.Sizeof(info))
|
||||||
|
GetWindowInfo(hwnd, &info)
|
||||||
|
return &info
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMonitorInfo(hwnd HWND) *MONITORINFO {
|
||||||
|
currentMonitor := MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)
|
||||||
|
var info MONITORINFO
|
||||||
|
info.CbSize = uint32(unsafe.Sizeof(info))
|
||||||
|
GetMonitorInfo(currentMonitor, &info)
|
||||||
|
return &info
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user