Files

187 lines
4.8 KiB
Go
Raw Permalink Normal View History

2021-07-25 15:37:30 +10:00
package runtime
import (
"context"
2021-10-18 21:42:02 +11:00
2021-09-12 16:32:43 +10:00
"github.com/wailsapp/wails/v2/pkg/options"
)
2021-07-25 15:37:30 +10:00
// WindowSetTitle sets the title of the window
func WindowSetTitle(ctx context.Context, title string) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowSetTitle(title)
}
2021-07-25 15:37:30 +10:00
// WindowFullscreen makes the window fullscreen
func WindowFullscreen(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowFullscreen()
}
2022-02-19 20:29:55 +11:00
// WindowUnfullscreen makes the window UnFullscreen
func WindowUnfullscreen(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
2022-02-19 20:29:55 +11:00
appFrontend.WindowUnfullscreen()
}
2021-07-25 15:37:30 +10:00
// WindowCenter the window on the current screen
func WindowCenter(ctx context.Context) {
2021-08-15 21:07:34 +10:00
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()
}
2021-07-25 15:37:30 +10:00
// WindowShow shows the window if hidden
func WindowShow(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowShow()
}
2021-07-25 15:37:30 +10:00
// WindowHide the window
func WindowHide(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowHide()
}
2021-07-25 15:37:30 +10:00
// WindowSetSize sets the size of the window
func WindowSetSize(ctx context.Context, width int, height int) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowSetSize(width, height)
}
2021-10-18 21:42:02 +11:00
func WindowGetSize(ctx context.Context) (int, int) {
appFrontend := getFrontend(ctx)
return appFrontend.WindowGetSize()
}
2021-08-15 21:07:34 +10:00
// WindowSetMinSize sets the minimum size of the window
2021-07-25 15:37:30 +10:00
func WindowSetMinSize(ctx context.Context, width int, height int) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowSetMinSize(width, height)
}
2021-08-15 21:07:34 +10:00
// WindowSetMaxSize sets the maximum size of the window
2021-07-25 15:37:30 +10:00
func WindowSetMaxSize(ctx context.Context, width int, height int) {
2021-08-15 21:07:34 +10:00
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)
}
2021-07-25 15:37:30 +10:00
// WindowSetPosition sets the position of the window
func WindowSetPosition(ctx context.Context, x int, y int) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
2022-02-03 21:42:14 +11:00
appFrontend.WindowSetPosition(x, y)
}
2022-02-03 21:42:14 +11:00
func WindowGetPosition(ctx context.Context) (int, int) {
2021-10-18 21:42:02 +11:00
appFrontend := getFrontend(ctx)
2022-02-03 21:42:14 +11:00
return appFrontend.WindowGetPosition()
2021-10-18 21:42:02 +11:00
}
2021-07-25 15:37:30 +10:00
// WindowMaximise the window
func WindowMaximise(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowMaximise()
}
2022-02-18 20:28:16 +11:00
// WindowToggleMaximise the window
func WindowToggleMaximise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowToggleMaximise()
}
2021-07-25 15:37:30 +10:00
// WindowUnmaximise the window
func WindowUnmaximise(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowUnmaximise()
}
2021-07-25 15:37:30 +10:00
// WindowMinimise the window
func WindowMinimise(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowMinimise()
}
2021-07-25 15:37:30 +10:00
// WindowUnminimise the window
func WindowUnminimise(ctx context.Context) {
2021-08-15 21:07:34 +10:00
appFrontend := getFrontend(ctx)
appFrontend.WindowUnminimise()
}
2021-09-12 16:32:43 +10:00
2022-08-29 13:52:01 -07:00
// 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()
}
2022-10-05 08:44:23 +11:00
// WindowExecJS executes the given Js in the window
func WindowExecJS(ctx context.Context, js string) {
appFrontend := getFrontend(ctx)
appFrontend.ExecJS(js)
}
func WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8) {
2021-09-12 16:32:43 +10:00
appFrontend := getFrontend(ctx)
2022-02-19 20:29:55 +11:00
col := &options.RGBA{
R: R,
G: G,
B: B,
A: A,
}
appFrontend.WindowSetBackgroundColour(col)
2021-09-12 16:32:43 +10:00
}
2023-09-16 14:54:41 +10:00
func WindowPrint(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowPrint()
}