|
3 | 3 |
|
4 | 4 | import type { Editor } from "@graphite/editor"; |
5 | 5 | import { type KeyRaw, type LayoutKeysGroup, type MenuBarEntry, type MenuListEntry, type AppWindowPlatform, UpdateMenuBarLayout } from "@graphite/messages"; |
6 | | - import type { PortfolioState } from "@graphite/state-providers/portfolio"; |
7 | 6 | import { platformIsMac } from "@graphite/utility-functions/platform"; |
8 | 7 |
|
9 | 8 | import LayoutRow from "@graphite/components/layout/LayoutRow.svelte"; |
10 | 9 | import TextButton from "@graphite/components/widgets/buttons/TextButton.svelte"; |
11 | 10 | import WindowButtonsLinux from "@graphite/components/window/title-bar/WindowButtonsLinux.svelte"; |
12 | | - import WindowButtonsMac from "@graphite/components/window/title-bar/WindowButtonsMac.svelte"; |
13 | 11 | import WindowButtonsWeb from "@graphite/components/window/title-bar/WindowButtonsWeb.svelte"; |
14 | 12 | import WindowButtonsWindows from "@graphite/components/window/title-bar/WindowButtonsWindows.svelte"; |
15 | | - import WindowTitle from "@graphite/components/window/title-bar/WindowTitle.svelte"; |
16 | 13 |
|
17 | 14 | export let platform: AppWindowPlatform; |
18 | 15 | export let maximized: boolean; |
19 | 16 |
|
20 | 17 | const editor = getContext<Editor>("editor"); |
21 | | - const portfolio = getContext<PortfolioState>("portfolio"); |
22 | 18 |
|
23 | 19 | // TODO: Apparently, Safari does not support the Keyboard.lock() API but does relax its authority over certain keyboard shortcuts in fullscreen mode, which we should take advantage of |
24 | 20 | const ACCEL_KEY = platformIsMac() ? "Command" : "Control"; |
|
32 | 28 |
|
33 | 29 | let entries: MenuListEntry[] = []; |
34 | 30 |
|
35 | | - $: docIndex = $portfolio.activeDocumentIndex; |
36 | | - $: displayName = $portfolio.documents[docIndex]?.displayName || ""; |
37 | | - $: windowTitle = `${displayName}${displayName && " - "}Graphite`; |
38 | | -
|
39 | 31 | onMount(() => { |
40 | 32 | const arraysEqual = (a: KeyRaw[], b: KeyRaw[]): boolean => a.length === b.length && a.every((aValue, i) => aValue === b[i]); |
41 | 33 | const shortcutRequiresLock = (shortcut: LayoutKeysGroup): boolean => { |
|
67 | 59 | </script> |
68 | 60 |
|
69 | 61 | <LayoutRow class="title-bar"> |
70 | | - <!-- Menu bar (or on Mac: window buttons) --> |
71 | | - <LayoutRow class="left"> |
72 | | - {#if platform === "Mac"} |
73 | | - <WindowButtonsMac /> |
74 | | - {:else} |
| 62 | + {#if platform !== "Mac"} |
| 63 | + <!-- Menu bar --> |
| 64 | + <LayoutRow> |
75 | 65 | {#each entries as entry} |
76 | 66 | <TextButton label={entry.label} icon={entry.icon} menuListChildren={entry.children} action={entry.action} flush={true} /> |
77 | 67 | {/each} |
78 | | - {/if} |
79 | | - <LayoutRow on:mousedown={() => editor.handle.appWindowDrag()} on:dblclick={() => editor.handle.appWindowMaximize()} /> |
80 | | - </LayoutRow> |
81 | | - <!-- Document title --> |
82 | | - <LayoutRow class="center" on:mousedown={() => editor.handle.appWindowDrag()} on:dblclick={() => editor.handle.appWindowMaximize()}> |
83 | | - <WindowTitle text={windowTitle} /> |
84 | | - </LayoutRow> |
85 | | - <!-- Window buttons (except on Mac) --> |
86 | | - <LayoutRow class="right"> |
87 | | - <LayoutRow on:mousedown={() => editor.handle.appWindowDrag()} on:dblclick={() => editor.handle.appWindowMaximize()} /> |
88 | | - {#if platform === "Windows"} |
89 | | - <WindowButtonsWindows {maximized} /> |
90 | | - {:else if platform === "Linux"} |
91 | | - <WindowButtonsLinux {maximized} /> |
92 | | - {:else if platform === "Web"} |
93 | | - <WindowButtonsWeb /> |
94 | | - {/if} |
95 | | - </LayoutRow> |
| 68 | + </LayoutRow> |
| 69 | + <!-- Spacer --> |
| 70 | + <LayoutRow class="spacer" on:mousedown={() => editor.handle.appWindowDrag()} on:dblclick={() => editor.handle.appWindowMaximize()} /> |
| 71 | + <!-- Window buttons --> |
| 72 | + <LayoutRow> |
| 73 | + {#if platform === "Web"} |
| 74 | + <WindowButtonsWeb /> |
| 75 | + {:else if platform === "Windows"} |
| 76 | + <WindowButtonsWindows {maximized} /> |
| 77 | + {:else if platform === "Linux"} |
| 78 | + <WindowButtonsLinux {maximized} /> |
| 79 | + {/if} |
| 80 | + </LayoutRow> |
| 81 | + {/if} |
96 | 82 | </LayoutRow> |
97 | 83 |
|
98 | 84 | <style lang="scss" global> |
|
101 | 87 | flex: 0 0 auto; |
102 | 88 |
|
103 | 89 | > .layout-row { |
104 | | - flex: 1 1 100%; |
105 | | -
|
106 | | - &.left { |
107 | | - justify-content: flex-start; |
108 | | - } |
| 90 | + flex: 0 0 auto; |
109 | 91 |
|
110 | | - &.center { |
111 | | - justify-content: center; |
| 92 | + &.spacer { |
| 93 | + flex: 1 1 100%; |
112 | 94 | } |
113 | 95 |
|
114 | | - &.right { |
115 | | - justify-content: flex-end; |
| 96 | + .text-button { |
| 97 | + height: 100%; |
116 | 98 | } |
117 | 99 | } |
118 | | -
|
119 | | - .text-button { |
120 | | - height: 28px; |
121 | | - } |
122 | 100 | } |
123 | 101 | </style> |
0 commit comments