mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 15:48:12 +08:00
Desktop: Fix window maximize and minimize (#3200)
Fix window maximize and minimize state
This commit is contained in:
@@ -302,9 +302,8 @@ export class UpdatePlatform extends JsMessage {
|
||||
readonly platform!: AppWindowPlatform;
|
||||
}
|
||||
|
||||
export class UpdateWindowState extends JsMessage {
|
||||
export class UpdateMaximized extends JsMessage {
|
||||
readonly maximized!: boolean;
|
||||
readonly minimized!: boolean;
|
||||
}
|
||||
|
||||
export class CloseWindow extends JsMessage {}
|
||||
@@ -1694,7 +1693,7 @@ export const messageMakers: Record<string, MessageMaker> = {
|
||||
UpdateLayersPanelControlBarLeftLayout,
|
||||
UpdateLayersPanelControlBarRightLayout,
|
||||
UpdateLayerWidths,
|
||||
UpdateWindowState,
|
||||
UpdateMaximized,
|
||||
UpdateMenuBarLayout,
|
||||
UpdateMouseCursor,
|
||||
UpdateNodeGraphControlBarLayout,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { type Editor } from "@graphite/editor";
|
||||
import { type AppWindowPlatform, UpdatePlatform, UpdateViewportHolePunch, UpdateWindowState } from "@graphite/messages";
|
||||
import { type AppWindowPlatform, UpdatePlatform, UpdateViewportHolePunch, UpdateMaximized as UpdateMaximized } from "@graphite/messages";
|
||||
|
||||
export function createAppWindowState(editor: Editor) {
|
||||
const { subscribe, update } = writable({
|
||||
@@ -17,9 +17,9 @@ export function createAppWindowState(editor: Editor) {
|
||||
return state;
|
||||
});
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateWindowState, (updateWindowState) => {
|
||||
editor.subscriptions.subscribeJsMessage(UpdateMaximized, (updateMaximized) => {
|
||||
update((state) => {
|
||||
state.maximized = updateWindowState.maximized;
|
||||
state.maximized = updateMaximized.maximized;
|
||||
return state;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -307,13 +307,6 @@ impl EditorHandle {
|
||||
}
|
||||
}
|
||||
|
||||
/// Minimizes the application window to the taskbar or dock
|
||||
#[wasm_bindgen(js_name = appWindowMinimize)]
|
||||
pub fn app_window_minimize(&self) {
|
||||
let message = AppWindowMessage::AppWindowMinimize;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = addPrimaryImport)]
|
||||
pub fn add_primary_import(&self) {
|
||||
self.dispatch(DocumentMessage::AddTransaction);
|
||||
@@ -338,6 +331,13 @@ impl EditorHandle {
|
||||
self.dispatch(NodeGraphMessage::AddSecondaryExport);
|
||||
}
|
||||
|
||||
/// Minimizes the application window to the taskbar or dock
|
||||
#[wasm_bindgen(js_name = appWindowMinimize)]
|
||||
pub fn app_window_minimize(&self) {
|
||||
let message = AppWindowMessage::AppWindowMinimize;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Toggles minimizing or restoring down the application window
|
||||
#[wasm_bindgen(js_name = appWindowMaximize)]
|
||||
pub fn app_window_maximize(&self) {
|
||||
|
||||
Reference in New Issue
Block a user