5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 22:49:31 +08:00
wails/v2/pkg/runtime/window.go
ZanderCodes 70c484f603
Add Some WindowState (#1349)
* Add Check for WindowState IsMaximised, IsMinimized, IsNormal and IsFullscreen

Solve conflicts

# Conflicts:
#	v2/internal/frontend/desktop/darwin/WailsContext.m
#	v2/internal/frontend/desktop/darwin/frontend.go
#	v2/internal/frontend/desktop/linux/window.go
#	v2/internal/frontend/desktop/windows/window.go

* Add Check for WindowState IsMaximised, IsMinimized, IsNormal and IsFullscreen

Solve conflict
# Conflicts:
#	v2/pkg/runtime/window.go

* Forgot some function to use it

# Conflicts:
#	v2/internal/frontend/desktop/darwin/WailsContext.h
#	v2/internal/frontend/desktop/windows/win32/consts.go
#	v2/internal/frontend/desktop/windows/win32/window.go

* Modify the instructions

# Conflicts:
#	v2/internal/frontend/devserver/devserver.go

* Add Functions to DevServer

# Conflicts:
#	v2/internal/frontend/dispatcher/systemcalls.go
#	v2/internal/frontend/runtime/desktop/window.js
#	v2/internal/frontend/runtime/package-lock.json
#	v2/internal/frontend/runtime/runtime_prod_desktop.js
#	v2/internal/frontend/runtime/wrapper/runtime.d.ts
#	v2/internal/frontend/runtime/wrapper/runtime.js

* Add Callback and JavaScript Functions

# Conflicts:
#	v2/cmd/wails/internal/commands/initialise/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js
#	v2/internal/frontend/runtime/package-lock.json
#	v2/internal/frontend/runtime/runtime_dev_desktop.js

* Remove Merge lines

* Fix IsMaximised

* Add WindowState Docs

* Update docs

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-08-30 06:52:01 +10:00

176 lines
4.5 KiB
Go

package runtime
import (
"context"
"github.com/wailsapp/wails/v2/pkg/options"
)
// WindowSetTitle sets the title of the window
func WindowSetTitle(ctx context.Context, title string) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetTitle(title)
}
// WindowFullscreen makes the window fullscreen
func WindowFullscreen(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowFullscreen()
}
// WindowUnfullscreen makes the window UnFullscreen
func WindowUnfullscreen(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowUnfullscreen()
}
// WindowCenter the window on the current screen
func WindowCenter(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowCenter()
}
// WindowReload will reload the window contents
func WindowReload(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowReload()
}
// WindowReloadApp will reload the application
func WindowReloadApp(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowReloadApp()
}
func WindowSetSystemDefaultTheme(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetSystemDefaultTheme()
}
func WindowSetLightTheme(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetLightTheme()
}
func WindowSetDarkTheme(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetDarkTheme()
}
// WindowShow shows the window if hidden
func WindowShow(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowShow()
}
// WindowHide the window
func WindowHide(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowHide()
}
// WindowSetSize sets the size of the window
func WindowSetSize(ctx context.Context, width int, height int) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetSize(width, height)
}
func WindowGetSize(ctx context.Context) (int, int) {
appFrontend := getFrontend(ctx)
return appFrontend.WindowGetSize()
}
// WindowSetMinSize sets the minimum size of the window
func WindowSetMinSize(ctx context.Context, width int, height int) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetMinSize(width, height)
}
// WindowSetMaxSize sets the maximum size of the window
func WindowSetMaxSize(ctx context.Context, width int, height int) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetMaxSize(width, height)
}
// WindowSetAlwaysOnTop sets the window AlwaysOnTop or not on top
func WindowSetAlwaysOnTop(ctx context.Context, b bool) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetAlwaysOnTop(b)
}
// WindowSetPosition sets the position of the window
func WindowSetPosition(ctx context.Context, x int, y int) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetPosition(x, y)
}
func WindowGetPosition(ctx context.Context) (int, int) {
appFrontend := getFrontend(ctx)
return appFrontend.WindowGetPosition()
}
// WindowMaximise the window
func WindowMaximise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowMaximise()
}
// WindowToggleMaximise the window
func WindowToggleMaximise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowToggleMaximise()
}
// WindowUnmaximise the window
func WindowUnmaximise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowUnmaximise()
}
// WindowMinimise the window
func WindowMinimise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowMinimise()
}
// WindowUnminimise the window
func WindowUnminimise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowUnminimise()
}
// WindowIsFullscreen get the window state is window Fullscreen
func WindowIsFullscreen(ctx context.Context) bool {
appFrontend := getFrontend(ctx)
return appFrontend.WindowIsFullscreen()
}
// WindowIsMaximised get the window state is window Maximised
func WindowIsMaximised(ctx context.Context) bool {
appFrontend := getFrontend(ctx)
return appFrontend.WindowIsMaximised()
}
// WindowIsMinimised get the window state is window Minimised
func WindowIsMinimised(ctx context.Context) bool {
appFrontend := getFrontend(ctx)
return appFrontend.WindowIsMinimised()
}
// WindowIsNormal get the window state is window Normal
func WindowIsNormal(ctx context.Context) bool {
appFrontend := getFrontend(ctx)
return appFrontend.WindowIsNormal()
}
func WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8) {
appFrontend := getFrontend(ctx)
col := &options.RGBA{
R: R,
G: G,
B: B,
A: A,
}
appFrontend.WindowSetBackgroundColour(col)
}