mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +02:00
feat(window): add option to disable controls (#406)
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
This commit is contained in:
committed by
GitHub
parent
83abea3cae
commit
a79d6d94bd
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"window-js": "minor:feat"
|
||||
---
|
||||
|
||||
Added the `maximizable`, `minimizable` and `closable` fields on `WindowOptions`.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"window": "minor:feat"
|
||||
"window-js": "minor:feat"
|
||||
---
|
||||
|
||||
Added the `setMaximizable`, `setMinimizable`, `setClosable`, `isMaximizable`, `isMinimizable` and `isClosable` methods.
|
||||
Generated
+2
-2
@@ -3814,9 +3814,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.60"
|
||||
version = "1.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
|
||||
checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
@@ -78,6 +78,9 @@
|
||||
|
||||
let urlValue = "https://tauri.app";
|
||||
let resizable = true;
|
||||
let maximizable = true;
|
||||
let minimizable = true;
|
||||
let closable = true;
|
||||
let maximized = false;
|
||||
let decorations = true;
|
||||
let alwaysOnTop = false;
|
||||
@@ -231,6 +234,9 @@
|
||||
loadWindowSize();
|
||||
}
|
||||
$: windowMap[selectedWindow]?.setResizable(resizable);
|
||||
$: windowMap[selectedWindow]?.setMaximizable(maximizable);
|
||||
$: windowMap[selectedWindow]?.setMinimizable(minimizable);
|
||||
$: windowMap[selectedWindow]?.setClosable(closable);
|
||||
$: maximized
|
||||
? windowMap[selectedWindow]?.maximize()
|
||||
: windowMap[selectedWindow]?.unmaximize();
|
||||
@@ -333,6 +339,18 @@
|
||||
Resizable
|
||||
<input type="checkbox" bind:checked={resizable} />
|
||||
</label>
|
||||
<label>
|
||||
Maximizable
|
||||
<input type="checkbox" bind:checked={maximizable} />
|
||||
</label>
|
||||
<label>
|
||||
Minimizable
|
||||
<input type="checkbox" bind:checked={minimizable} />
|
||||
</label>
|
||||
<label>
|
||||
Closable
|
||||
<input type="checkbox" bind:checked={closable} />
|
||||
</label>
|
||||
<label>
|
||||
Has decorations
|
||||
<input type="checkbox" bind:checked={decorations} />
|
||||
|
||||
@@ -617,6 +617,69 @@ class WindowManager extends WebviewWindowHandle {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the window’s native maximize button state.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux / iOS / Android:** Unsupported.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/plugin-window';
|
||||
* const maximizable = await appWindow.isMaximizable();
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window's native maximize button is enabled or not.
|
||||
* */
|
||||
async isMaximizable(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_maximizable", {
|
||||
label: this.label,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the window’s native minimize button state.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux / iOS / Android:** Unsupported.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/plugin-window';
|
||||
* const minimizable = await appWindow.isMinimizable();
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window's native minimize button is enabled or not.
|
||||
* */
|
||||
async isMinimizable(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_minimizable", {
|
||||
label: this.label,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the window’s native close button state.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **iOS / Android:** Unsupported.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/plugin-window';
|
||||
* const closable = await appWindow.isClosable();
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window's native close button is enabled or not.
|
||||
* */
|
||||
async isClosable(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_closable", {
|
||||
label: this.label,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the window's current visible state.
|
||||
* @example
|
||||
@@ -713,7 +776,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* await appWindow.requestUserAttention();
|
||||
* ```
|
||||
*
|
||||
* @param resizable
|
||||
* @param requestType
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
@@ -756,6 +819,78 @@ class WindowManager extends WebviewWindowHandle {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the window's native maximize button is enabled or not.
|
||||
* If resizable is set to false, this setting is ignored.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
|
||||
* - **Linux / iOS / Android:** Unsupported.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/plugin-window';
|
||||
* await appWindow.setMaximizable(false);
|
||||
* ```
|
||||
*
|
||||
* @param maximizable
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setMaximizable(maximizable: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_maximizable", {
|
||||
label: this.label,
|
||||
value: maximizable,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the window's native minimize button is enabled or not.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux / iOS / Android:** Unsupported.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/plugin-window';
|
||||
* await appWindow.setMinimizable(false);
|
||||
* ```
|
||||
*
|
||||
* @param minimizable
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setMinimizable(minimizable: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_minimizable", {
|
||||
label: this.label,
|
||||
value: minimizable,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the window's native close button is enabled or not.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible
|
||||
* - **iOS / Android:** Unsupported.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/plugin-window';
|
||||
* await appWindow.setClosable(false);
|
||||
* ```
|
||||
*
|
||||
* @param closable
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setClosable(closable: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_closable", {
|
||||
label: this.label,
|
||||
value: closable,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the window title.
|
||||
* @example
|
||||
@@ -2123,6 +2258,18 @@ interface WindowOptions {
|
||||
* - **Android:** Unsupported.
|
||||
*/
|
||||
incognito?: boolean;
|
||||
/**
|
||||
* Whether the window's native maximize button is enabled or not. Defaults to `true`.
|
||||
*/
|
||||
maximizable?: boolean;
|
||||
/**
|
||||
* Whether the window's native minimize button is enabled or not. Defaults to `true`.
|
||||
*/
|
||||
minimizable?: boolean;
|
||||
/**
|
||||
* Whether the window's native close button is enabled or not. Defaults to `true`.
|
||||
*/
|
||||
closable?: boolean;
|
||||
}
|
||||
|
||||
function mapMonitor(m: Monitor | null): Monitor | null {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -115,6 +115,9 @@ getter!(is_maximized, bool);
|
||||
getter!(is_focused, bool);
|
||||
getter!(is_decorated, bool);
|
||||
getter!(is_resizable, bool);
|
||||
getter!(is_maximizable, bool);
|
||||
getter!(is_minimizable, bool);
|
||||
getter!(is_closable, bool);
|
||||
getter!(is_visible, bool);
|
||||
getter!(title, String);
|
||||
getter!(current_monitor, Option<Monitor>);
|
||||
@@ -125,6 +128,9 @@ getter!(theme, Theme);
|
||||
setter!(center);
|
||||
setter!(request_user_attention, Option<UserAttentionType>);
|
||||
setter!(set_resizable, bool);
|
||||
setter!(set_maximizable, bool);
|
||||
setter!(set_minimizable, bool);
|
||||
setter!(set_closable, bool);
|
||||
setter!(set_title, &str);
|
||||
setter!(maximize);
|
||||
setter!(unmaximize);
|
||||
|
||||
@@ -43,6 +43,9 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
desktop_commands::is_focused,
|
||||
desktop_commands::is_decorated,
|
||||
desktop_commands::is_resizable,
|
||||
desktop_commands::is_maximizable,
|
||||
desktop_commands::is_minimizable,
|
||||
desktop_commands::is_closable,
|
||||
desktop_commands::is_visible,
|
||||
desktop_commands::title,
|
||||
desktop_commands::current_monitor,
|
||||
@@ -53,6 +56,9 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
desktop_commands::center,
|
||||
desktop_commands::request_user_attention,
|
||||
desktop_commands::set_resizable,
|
||||
desktop_commands::set_maximizable,
|
||||
desktop_commands::set_minimizable,
|
||||
desktop_commands::set_closable,
|
||||
desktop_commands::set_title,
|
||||
desktop_commands::maximize,
|
||||
desktop_commands::unmaximize,
|
||||
|
||||
Reference in New Issue
Block a user