mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 03:48:12 +08:00
Refactor the WidgetLayout struct to remove SubLayout and avoid sending LayoutTarget to frontend
This commit is contained in:
@@ -2,14 +2,15 @@
|
||||
import { getContext, onMount } from "svelte";
|
||||
|
||||
import type { Editor } from "@graphite/editor";
|
||||
import { defaultWidgetLayout, patchWidgetLayout, UpdateStatusBarHintsLayout } from "@graphite/messages";
|
||||
import type { LayoutGroup } from "@graphite/messages";
|
||||
import { patchWidgetLayout, UpdateStatusBarHintsLayout } from "@graphite/messages";
|
||||
|
||||
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
|
||||
import WidgetLayout from "@graphite/components/widgets/WidgetLayout.svelte";
|
||||
|
||||
const editor = getContext<Editor>("editor");
|
||||
|
||||
let statusBarHintsLayout = defaultWidgetLayout();
|
||||
let statusBarHintsLayout: LayoutGroup[] = [];
|
||||
|
||||
onMount(() => {
|
||||
editor.subscriptions.subscribeJsMessage(UpdateStatusBarHintsLayout, (updateStatusBarHintsLayout) => {
|
||||
@@ -20,7 +21,7 @@
|
||||
</script>
|
||||
|
||||
<LayoutRow class="status-bar">
|
||||
<WidgetLayout class="hints" layout={statusBarHintsLayout} />
|
||||
<WidgetLayout class="hints" layout={statusBarHintsLayout} layoutTarget="StatusBarHints" />
|
||||
</LayoutRow>
|
||||
|
||||
<style lang="scss" global>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import { getContext, onMount } from "svelte";
|
||||
|
||||
import type { Editor } from "@graphite/editor";
|
||||
import { defaultWidgetLayout, patchWidgetLayout, UpdateMenuBarLayout } from "@graphite/messages";
|
||||
import type { LayoutGroup } from "@graphite/messages";
|
||||
import { patchWidgetLayout, UpdateMenuBarLayout } from "@graphite/messages";
|
||||
import type { AppWindowState } from "@graphite/state-providers/app-window";
|
||||
|
||||
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
|
||||
@@ -14,7 +15,7 @@
|
||||
const appWindow = getContext<AppWindowState>("appWindow");
|
||||
const editor = getContext<Editor>("editor");
|
||||
|
||||
let menuBarLayout = defaultWidgetLayout();
|
||||
let menuBarLayout: LayoutGroup[] = [];
|
||||
|
||||
onMount(() => {
|
||||
editor.subscriptions.subscribeJsMessage(UpdateMenuBarLayout, (updateMenuBarLayout) => {
|
||||
@@ -28,7 +29,7 @@
|
||||
<!-- Menu bar -->
|
||||
<LayoutRow>
|
||||
{#if $appWindow.platform !== "Mac"}
|
||||
<WidgetLayout layout={menuBarLayout} />
|
||||
<WidgetLayout layout={menuBarLayout} layoutTarget="MenuBar" />
|
||||
{/if}
|
||||
</LayoutRow>
|
||||
<!-- Spacer -->
|
||||
|
||||
Reference in New Issue
Block a user