github.com/secoba/wails/v2@v2.6.4/internal/frontend/runtime/desktop/window.js (about) 1 /* 2 _ __ _ __ 3 | | / /___ _(_) /____ 4 | | /| / / __ `/ / / ___/ 5 | |/ |/ / /_/ / / (__ ) 6 |__/|__/\__,_/_/_/____/ 7 The electron alternative for Go 8 (c) Lea Anthony 2019-present 9 */ 10 11 /* jshint esversion: 9 */ 12 13 14 import {Call} from "./calls"; 15 16 export function WindowReload() { 17 window.location.reload(); 18 } 19 20 export function WindowReloadApp() { 21 window.WailsInvoke('WR'); 22 } 23 24 export function WindowSetSystemDefaultTheme() { 25 window.WailsInvoke('WASDT'); 26 } 27 28 export function WindowSetLightTheme() { 29 window.WailsInvoke('WALT'); 30 } 31 32 export function WindowSetDarkTheme() { 33 window.WailsInvoke('WADT'); 34 } 35 36 /** 37 * Place the window in the center of the screen 38 * 39 * @export 40 */ 41 export function WindowCenter() { 42 window.WailsInvoke('Wc'); 43 } 44 45 /** 46 * Sets the window title 47 * 48 * @param {string} title 49 * @export 50 */ 51 export function WindowSetTitle(title) { 52 window.WailsInvoke('WT' + title); 53 } 54 55 /** 56 * Makes the window go fullscreen 57 * 58 * @export 59 */ 60 export function WindowFullscreen() { 61 window.WailsInvoke('WF'); 62 } 63 64 /** 65 * Reverts the window from fullscreen 66 * 67 * @export 68 */ 69 export function WindowUnfullscreen() { 70 window.WailsInvoke('Wf'); 71 } 72 73 /** 74 * Returns the state of the window, i.e. whether the window is in full screen mode or not. 75 * 76 * @export 77 * @return {Promise<boolean>} The state of the window 78 */ 79 export function WindowIsFullscreen() { 80 return Call(":wails:WindowIsFullscreen"); 81 } 82 83 /** 84 * Set the Size of the window 85 * 86 * @export 87 * @param {number} width 88 * @param {number} height 89 */ 90 export function WindowSetSize(width, height) { 91 window.WailsInvoke('Ws:' + width + ':' + height); 92 } 93 94 /** 95 * Get the Size of the window 96 * 97 * @export 98 * @return {Promise<{w: number, h: number}>} The size of the window 99 100 */ 101 export function WindowGetSize() { 102 return Call(":wails:WindowGetSize"); 103 } 104 105 /** 106 * Set the maximum size of the window 107 * 108 * @export 109 * @param {number} width 110 * @param {number} height 111 */ 112 export function WindowSetMaxSize(width, height) { 113 window.WailsInvoke('WZ:' + width + ':' + height); 114 } 115 116 /** 117 * Set the minimum size of the window 118 * 119 * @export 120 * @param {number} width 121 * @param {number} height 122 */ 123 export function WindowSetMinSize(width, height) { 124 window.WailsInvoke('Wz:' + width + ':' + height); 125 } 126 127 128 129 /** 130 * Set the window AlwaysOnTop or not on top 131 * 132 * @export 133 */ 134 export function WindowSetAlwaysOnTop(b) { 135 136 window.WailsInvoke('WATP:' + (b ? '1' : '0')); 137 } 138 139 140 141 142 /** 143 * Set the Position of the window 144 * 145 * @export 146 * @param {number} x 147 * @param {number} y 148 */ 149 export function WindowSetPosition(x, y) { 150 window.WailsInvoke('Wp:' + x + ':' + y); 151 } 152 153 /** 154 * Get the Position of the window 155 * 156 * @export 157 * @return {Promise<{x: number, y: number}>} The position of the window 158 */ 159 export function WindowGetPosition() { 160 return Call(":wails:WindowGetPos"); 161 } 162 163 /** 164 * Hide the Window 165 * 166 * @export 167 */ 168 export function WindowHide() { 169 window.WailsInvoke('WH'); 170 } 171 172 /** 173 * Show the Window 174 * 175 * @export 176 */ 177 export function WindowShow() { 178 window.WailsInvoke('WS'); 179 } 180 181 /** 182 * Maximise the Window 183 * 184 * @export 185 */ 186 export function WindowMaximise() { 187 window.WailsInvoke('WM'); 188 } 189 190 /** 191 * Toggle the Maximise of the Window 192 * 193 * @export 194 */ 195 export function WindowToggleMaximise() { 196 window.WailsInvoke('Wt'); 197 } 198 199 /** 200 * Unmaximise the Window 201 * 202 * @export 203 */ 204 export function WindowUnmaximise() { 205 window.WailsInvoke('WU'); 206 } 207 208 /** 209 * Returns the state of the window, i.e. whether the window is maximised or not. 210 * 211 * @export 212 * @return {Promise<boolean>} The state of the window 213 */ 214 export function WindowIsMaximised() { 215 return Call(":wails:WindowIsMaximised"); 216 } 217 218 /** 219 * Minimise the Window 220 * 221 * @export 222 */ 223 export function WindowMinimise() { 224 window.WailsInvoke('Wm'); 225 } 226 227 /** 228 * Unminimise the Window 229 * 230 * @export 231 */ 232 export function WindowUnminimise() { 233 window.WailsInvoke('Wu'); 234 } 235 236 /** 237 * Returns the state of the window, i.e. whether the window is minimised or not. 238 * 239 * @export 240 * @return {Promise<boolean>} The state of the window 241 */ 242 export function WindowIsMinimised() { 243 return Call(":wails:WindowIsMinimised"); 244 } 245 246 /** 247 * Returns the state of the window, i.e. whether the window is normal or not. 248 * 249 * @export 250 * @return {Promise<boolean>} The state of the window 251 */ 252 export function WindowIsNormal() { 253 return Call(":wails:WindowIsNormal"); 254 } 255 256 /** 257 * Sets the background colour of the window 258 * 259 * @export 260 * @param {number} R Red 261 * @param {number} G Green 262 * @param {number} B Blue 263 * @param {number} A Alpha 264 */ 265 export function WindowSetBackgroundColour(R, G, B, A) { 266 let rgba = JSON.stringify({r: R || 0, g: G || 0, b: B || 0, a: A || 255}); 267 window.WailsInvoke('Wr:' + rgba); 268 } 269