mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 07:58:11 +08:00
Save the layouts, even when in the welcome screen (#916)
This commit is contained in:
committed by
Keavon Chambers
parent
d742b05d3a
commit
559c05f2a9
@@ -0,0 +1,51 @@
|
||||
import { nextTick, reactive, readonly } from "vue";
|
||||
|
||||
import { type Editor } from "@/wasm-communication/editor";
|
||||
import {
|
||||
defaultWidgetLayout,
|
||||
patchWidgetLayout,
|
||||
UpdateDocumentBarLayout,
|
||||
UpdateDocumentModeLayout,
|
||||
UpdateToolOptionsLayout,
|
||||
UpdateToolShelfLayout,
|
||||
UpdateWorkingColorsLayout,
|
||||
} from "@/wasm-communication/messages";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export function createDocumentState(editor: Editor) {
|
||||
const state = reactive({
|
||||
// Layouts
|
||||
documentModeLayout: defaultWidgetLayout(),
|
||||
toolOptionsLayout: defaultWidgetLayout(),
|
||||
documentBarLayout: defaultWidgetLayout(),
|
||||
toolShelfLayout: defaultWidgetLayout(),
|
||||
workingColorsLayout: defaultWidgetLayout(),
|
||||
});
|
||||
|
||||
// Update layouts
|
||||
editor.subscriptions.subscribeJsMessage(UpdateDocumentModeLayout, async (updateDocumentModeLayout) => {
|
||||
await nextTick();
|
||||
patchWidgetLayout(state.documentModeLayout, updateDocumentModeLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateToolOptionsLayout, async (updateToolOptionsLayout) => {
|
||||
await nextTick();
|
||||
patchWidgetLayout(state.toolOptionsLayout, updateToolOptionsLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateDocumentBarLayout, async (updateDocumentBarLayout) => {
|
||||
await nextTick();
|
||||
patchWidgetLayout(state.documentBarLayout, updateDocumentBarLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateToolShelfLayout, async (updateToolShelfLayout) => {
|
||||
await nextTick();
|
||||
patchWidgetLayout(state.toolShelfLayout, updateToolShelfLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateWorkingColorsLayout, async (updateWorkingColorsLayout) => {
|
||||
await nextTick();
|
||||
patchWidgetLayout(state.workingColorsLayout, updateWorkingColorsLayout);
|
||||
});
|
||||
|
||||
return {
|
||||
state: readonly(state) as typeof state,
|
||||
};
|
||||
}
|
||||
export type DocumentState = ReturnType<typeof createDocumentState>;
|
||||
@@ -9,16 +9,11 @@ import {
|
||||
TriggerViewportResize,
|
||||
UpdateDocumentArtboards,
|
||||
UpdateDocumentArtwork,
|
||||
UpdateDocumentBarLayout,
|
||||
UpdateDocumentModeLayout,
|
||||
UpdateDocumentOverlays,
|
||||
UpdateDocumentRulers,
|
||||
UpdateDocumentScrollbars,
|
||||
UpdateEyedropperSamplingState,
|
||||
UpdateMouseCursor,
|
||||
UpdateToolOptionsLayout,
|
||||
UpdateToolShelfLayout,
|
||||
UpdateWorkingColorsLayout,
|
||||
} from "@/wasm-communication/messages";
|
||||
|
||||
import DocumentComponent from "@/components/panels/Document.vue";
|
||||
@@ -93,28 +88,6 @@ export function createPanelsState(editor: Editor) {
|
||||
state.documentPanel.displayRemoveEditableTextbox();
|
||||
});
|
||||
|
||||
// Update layouts
|
||||
editor.subscriptions.subscribeJsMessage(UpdateDocumentModeLayout, async (updateDocumentModeLayout) => {
|
||||
await nextTick();
|
||||
state.documentPanel.updateDocumentModeLayout(updateDocumentModeLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateToolOptionsLayout, async (updateToolOptionsLayout) => {
|
||||
await nextTick();
|
||||
state.documentPanel.updateToolOptionsLayout(updateToolOptionsLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateDocumentBarLayout, async (updateDocumentBarLayout) => {
|
||||
await nextTick();
|
||||
state.documentPanel.updateDocumentBarLayout(updateDocumentBarLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateToolShelfLayout, async (updateToolShelfLayout) => {
|
||||
await nextTick();
|
||||
state.documentPanel.updateToolShelfLayout(updateToolShelfLayout);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateWorkingColorsLayout, async (updateWorkingColorsLayout) => {
|
||||
await nextTick();
|
||||
state.documentPanel.updateWorkingColorsLayout(updateWorkingColorsLayout);
|
||||
});
|
||||
|
||||
// Resize elements to render the new viewport size
|
||||
editor.subscriptions.subscribeJsMessage(TriggerViewportResize, async () => {
|
||||
await nextTick();
|
||||
|
||||
Reference in New Issue
Block a user