2021-08-24 23:48:03 +10:00
|
|
|
/*
|
|
|
|
|
_ __ _ __
|
|
|
|
|
| | / /___ _(_) /____
|
|
|
|
|
| | /| / / __ `/ / / ___/
|
|
|
|
|
| |/ |/ / /_/ / / (__ )
|
|
|
|
|
|__/|__/\__,_/_/_/____/
|
2021-08-27 21:11:03 +10:00
|
|
|
The electron alternative for Go
|
2021-08-24 23:48:03 +10:00
|
|
|
(c) Lea Anthony 2019-present
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* jshint esversion: 9 */
|
|
|
|
|
|
2021-09-09 20:10:18 +10:00
|
|
|
|
2022-06-29 22:31:49 +10:00
|
|
|
import {Call} from "./calls";
|
2021-09-09 20:10:18 +10:00
|
|
|
|
2021-08-24 23:48:03 +10:00
|
|
|
export function WindowReload() {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
}
|
2021-09-09 20:10:18 +10:00
|
|
|
|
2022-04-20 20:28:41 +10:00
|
|
|
export function WindowReloadApp() {
|
|
|
|
|
window.WailsInvoke('WR');
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-31 11:04:14 +02:00
|
|
|
export function WindowSetSystemDefaultTheme() {
|
2022-04-20 20:28:41 +10:00
|
|
|
window.WailsInvoke('WASDT');
|
2022-03-31 11:04:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function WindowSetLightTheme() {
|
2022-04-20 20:28:41 +10:00
|
|
|
window.WailsInvoke('WALT');
|
2022-03-31 11:04:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function WindowSetDarkTheme() {
|
2022-04-20 20:28:41 +10:00
|
|
|
window.WailsInvoke('WADT');
|
2022-03-31 11:04:14 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-09 20:10:18 +10:00
|
|
|
/**
|
|
|
|
|
* Place the window in the center of the screen
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowCenter() {
|
|
|
|
|
window.WailsInvoke('Wc');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the window title
|
|
|
|
|
*
|
|
|
|
|
* @param {string} title
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowSetTitle(title) {
|
|
|
|
|
window.WailsInvoke('WT' + title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Makes the window go fullscreen
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowFullscreen() {
|
|
|
|
|
window.WailsInvoke('WF');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverts the window from fullscreen
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
2022-02-19 20:29:55 +11:00
|
|
|
export function WindowUnfullscreen() {
|
2021-09-09 20:10:18 +10:00
|
|
|
window.WailsInvoke('Wf');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-29 13:52:01 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the state of the window, i.e. whether the window is in full screen mode or not.
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @return {Promise<boolean>} The state of the window
|
|
|
|
|
*/
|
|
|
|
|
export function WindowIsFullscreen() {
|
|
|
|
|
return Call(":wails:WindowIsFullscreen");
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 20:10:18 +10:00
|
|
|
/**
|
|
|
|
|
* Set the Size of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @param {number} width
|
|
|
|
|
* @param {number} height
|
|
|
|
|
*/
|
|
|
|
|
export function WindowSetSize(width, height) {
|
|
|
|
|
window.WailsInvoke('Ws:' + width + ':' + height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the Size of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @return {Promise<{w: number, h: number}>} The size of the window
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
export function WindowGetSize() {
|
|
|
|
|
return Call(":wails:WindowGetSize");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the maximum size of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @param {number} width
|
|
|
|
|
* @param {number} height
|
|
|
|
|
*/
|
|
|
|
|
export function WindowSetMaxSize(width, height) {
|
|
|
|
|
window.WailsInvoke('WZ:' + width + ':' + height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the minimum size of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @param {number} width
|
|
|
|
|
* @param {number} height
|
|
|
|
|
*/
|
|
|
|
|
export function WindowSetMinSize(width, height) {
|
|
|
|
|
window.WailsInvoke('Wz:' + width + ':' + height);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-22 18:55:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the window AlwaysOnTop or not on top
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowSetAlwaysOnTop(b) {
|
|
|
|
|
|
|
|
|
|
window.WailsInvoke('WATP:' + (b ? '1' : '0'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-09 20:10:18 +10:00
|
|
|
/**
|
|
|
|
|
* Set the Position of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @param {number} x
|
|
|
|
|
* @param {number} y
|
|
|
|
|
*/
|
|
|
|
|
export function WindowSetPosition(x, y) {
|
|
|
|
|
window.WailsInvoke('Wp:' + x + ':' + y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the Position of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @return {Promise<{x: number, y: number}>} The position of the window
|
|
|
|
|
*/
|
|
|
|
|
export function WindowGetPosition() {
|
|
|
|
|
return Call(":wails:WindowGetPos");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hide the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowHide() {
|
|
|
|
|
window.WailsInvoke('WH');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowShow() {
|
|
|
|
|
window.WailsInvoke('WS');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maximise the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowMaximise() {
|
|
|
|
|
window.WailsInvoke('WM');
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-18 20:28:16 +11:00
|
|
|
/**
|
|
|
|
|
* Toggle the Maximise of the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowToggleMaximise() {
|
|
|
|
|
window.WailsInvoke('Wt');
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 20:10:18 +10:00
|
|
|
/**
|
|
|
|
|
* Unmaximise the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowUnmaximise() {
|
|
|
|
|
window.WailsInvoke('WU');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-29 13:52:01 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the state of the window, i.e. whether the window is maximised or not.
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @return {Promise<boolean>} The state of the window
|
|
|
|
|
*/
|
|
|
|
|
export function WindowIsMaximised() {
|
|
|
|
|
return Call(":wails:WindowIsMaximised");
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 20:10:18 +10:00
|
|
|
/**
|
|
|
|
|
* Minimise the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowMinimise() {
|
|
|
|
|
window.WailsInvoke('Wm');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unminimise the Window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
*/
|
|
|
|
|
export function WindowUnminimise() {
|
|
|
|
|
window.WailsInvoke('Wu');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-29 13:52:01 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the state of the window, i.e. whether the window is minimised or not.
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @return {Promise<boolean>} The state of the window
|
|
|
|
|
*/
|
|
|
|
|
export function WindowIsMinimised() {
|
|
|
|
|
return Call(":wails:WindowIsMinimised");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the state of the window, i.e. whether the window is normal or not.
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @return {Promise<boolean>} The state of the window
|
|
|
|
|
*/
|
|
|
|
|
export function WindowIsNormal() {
|
|
|
|
|
return Call(":wails:WindowIsNormal");
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-12 16:32:43 +10:00
|
|
|
/**
|
|
|
|
|
* Sets the background colour of the window
|
|
|
|
|
*
|
|
|
|
|
* @export
|
2022-02-19 20:29:55 +11:00
|
|
|
* @param {number} R Red
|
|
|
|
|
* @param {number} G Green
|
|
|
|
|
* @param {number} B Blue
|
|
|
|
|
* @param {number} A Alpha
|
2021-09-12 16:32:43 +10:00
|
|
|
*/
|
2022-06-29 22:31:49 +10:00
|
|
|
export function WindowSetBackgroundColour(R, G, B, A) {
|
|
|
|
|
let rgba = JSON.stringify({r: R || 0, g: G || 0, b: B || 0, a: A || 255});
|
2021-09-12 16:32:43 +10:00
|
|
|
window.WailsInvoke('Wr:' + rgba);
|
|
|
|
|
}
|
|
|
|
|
|