Skip to content

Commit 0571bc3

Browse files
authored
Merge branch 'master' into fix-breadcrumb-ui-scaling
2 parents 3619882 + 6616d1b commit 0571bc3

14 files changed

Lines changed: 176 additions & 236 deletions

.nix/pkgs/graphite.nix

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,20 @@ deps.crane.lib.buildPackage (
109109
}
110110
else
111111
{ }
112-
);
112+
) // {
113+
GRAPHITE_GIT_COMMIT_HASH = inputs.self.rev or "unknown";
114+
GRAPHITE_GIT_COMMIT_DATE = inputs.self.lastModified or "unknown";
115+
};
113116

114117
postUnpack = ''
115118
mkdir ./branding
116119
cp -r ${branding}/* ./branding
117120
'';
118121

122+
preBuild = if inputs.self ? rev then ''
123+
export GRAPHITE_GIT_COMMIT_DATE="$(date -u -d "@$GRAPHITE_GIT_COMMIT_DATE" +"%Y-%m-%dT%H:%M:%SZ")"
124+
'' else "";
125+
119126
installPhase = ''
120127
mkdir -p $out/bin
121128
cp target/${if dev then "debug" else "release"}/graphite $out/bin/graphite
@@ -125,6 +132,12 @@ deps.crane.lib.buildPackage (
125132
126133
mkdir -p $out/share/icons/hicolor/scalable/apps
127134
cp ${branding}/app-icons/graphite.svg $out/share/icons/hicolor/scalable/apps/art.graphite.Graphite.svg
135+
mkdir -p $out/share/icons/hicolor/512x512/apps
136+
cp ${branding}/app-icons/graphite-512.png $out/share/icons/hicolor/512x512/apps/art.graphite.Graphite.png
137+
mkdir -p $out/share/icons/hicolor/256x256/apps
138+
cp ${branding}/app-icons/graphite-256.png $out/share/icons/hicolor/256x256/apps/art.graphite.Graphite.png
139+
mkdir -p $out/share/icons/hicolor/128x128/apps
140+
cp ${branding}/app-icons/graphite-128.png $out/share/icons/hicolor/128x128/apps/art.graphite.Graphite.png
128141
'';
129142

130143
postFixup = ''

editor/build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ fn main() {
1818
if !gh.trim().is_empty() {
1919
gh.trim().to_string()
2020
} else {
21-
git_or_unknown(&["rev-parse", "--abbrev-ref", "HEAD"])
21+
git(&["rev-parse", "--abbrev-ref", "HEAD"]).unwrap_or_default()
2222
}
2323
});
2424

2525
// Instruct Cargo to set environment variables for compile time.
2626
// They are accessed with the `env!("GRAPHITE_*")` macro in the codebase.
27-
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_DATE={commit_date}");
28-
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_HASH={commit_hash}");
29-
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_BRANCH={commit_branch}");
3027
println!("cargo:rustc-env=GRAPHITE_RELEASE_SERIES={GRAPHITE_RELEASE_SERIES}");
28+
if !commit_branch.is_empty() {
29+
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_BRANCH={commit_branch}");
30+
}
31+
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_HASH={commit_hash}");
32+
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_DATE={commit_date}");
3133
}
3234

3335
/// Get an environment variable, or if it is not set or empty, use the provided fallback function. Returns a string with trimmed whitespace.

editor/src/application.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,17 @@ impl Default for Editor {
3939
}
4040

4141
pub const GRAPHITE_RELEASE_SERIES: &str = env!("GRAPHITE_RELEASE_SERIES");
42-
pub const GRAPHITE_GIT_COMMIT_DATE: &str = env!("GRAPHITE_GIT_COMMIT_DATE");
42+
pub const GRAPHITE_GIT_COMMIT_BRANCH: Option<&str> = option_env!("GRAPHITE_GIT_COMMIT_BRANCH");
4343
pub const GRAPHITE_GIT_COMMIT_HASH: &str = env!("GRAPHITE_GIT_COMMIT_HASH");
44-
pub const GRAPHITE_GIT_COMMIT_BRANCH: &str = env!("GRAPHITE_GIT_COMMIT_BRANCH");
44+
pub const GRAPHITE_GIT_COMMIT_DATE: &str = env!("GRAPHITE_GIT_COMMIT_DATE");
4545

4646
pub fn commit_info_localized(localized_commit_date: &str) -> String {
47-
format!(
48-
"Release Series: {}\n\
49-
Branch: {}\n\
50-
Commit: {}\n\
51-
{}",
52-
GRAPHITE_RELEASE_SERIES,
53-
GRAPHITE_GIT_COMMIT_BRANCH,
54-
GRAPHITE_GIT_COMMIT_HASH.get(..8).unwrap_or(GRAPHITE_GIT_COMMIT_HASH),
55-
localized_commit_date
56-
)
47+
let mut info = String::new();
48+
info.push_str(&format!("Release Series: {GRAPHITE_RELEASE_SERIES}\n"));
49+
if let Some(branch) = GRAPHITE_GIT_COMMIT_BRANCH {
50+
info.push_str(&format!("Branch: {branch}\n"));
51+
}
52+
info.push_str(&format!("Commit: {}\n", GRAPHITE_GIT_COMMIT_HASH.get(..8).unwrap_or(GRAPHITE_GIT_COMMIT_HASH)));
53+
info.push_str(localized_commit_date);
54+
info
5755
}

editor/src/messages/dialog/dialog_message_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::simple_dialogs::{self, AboutGraphiteDialog, DemoArtworkDialog, LicensesDialog};
2+
use crate::application::GRAPHITE_GIT_COMMIT_DATE;
23
use crate::messages::dialog::simple_dialogs::LicensesThirdPartyDialog;
34
use crate::messages::layout::utility_types::widget_prelude::*;
45
use crate::messages::prelude::*;
@@ -48,7 +49,7 @@ impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHa
4849
}
4950
DialogMessage::RequestAboutGraphiteDialog => {
5051
responses.add(FrontendMessage::TriggerAboutGraphiteLocalizedCommitDate {
51-
commit_date: env!("GRAPHITE_GIT_COMMIT_DATE").into(),
52+
commit_date: GRAPHITE_GIT_COMMIT_DATE.into(),
5253
});
5354
}
5455
DialogMessage::RequestAboutGraphiteDialogWithLocalizedCommitDate {

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
964964
}
965965
PortfolioMessage::RequestStatusBarInfoLayout => {
966966
#[cfg(not(target_family = "wasm"))]
967-
let widgets = vec![TextLabel::new("Graphite (beta) 1.0.0-RC2").disabled(true).widget_instance()];
967+
let widgets = vec![TextLabel::new("Graphite 1.0.0-RC2").disabled(true).widget_instance()];
968968
#[cfg(target_family = "wasm")]
969969
let widgets = vec![];
970970

frontend/src/components/window/MainWindow.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import Tooltip from "@graphite/components/floating-menus/Tooltip.svelte";
1111
import LayoutCol from "@graphite/components/layout/LayoutCol.svelte";
1212
import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte";
13-
import StatusBar from "@graphite/components/window/status-bar/StatusBar.svelte";
14-
import TitleBar from "@graphite/components/window/title-bar/TitleBar.svelte";
15-
import Workspace from "@graphite/components/window/workspace/Workspace.svelte";
13+
import StatusBar from "@graphite/components/window/StatusBar.svelte";
14+
import TitleBar from "@graphite/components/window/TitleBar.svelte";
15+
import Workspace from "@graphite/components/window/Workspace.svelte";
1616
1717
const dialog = getContext<DialogState>("dialog");
1818
const tooltip = getContext<TooltipState>("tooltip");
File renamed without changes.
File renamed without changes.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<script lang="ts">
2+
import { getContext, onMount } from "svelte";
3+
4+
import type { Editor } from "@graphite/editor";
5+
import type { Layout } from "@graphite/messages";
6+
import { patchLayout, UpdateMenuBarLayout } from "@graphite/messages";
7+
import type { AppWindowState } from "@graphite/state-providers/app-window";
8+
import type { FullscreenState } from "@graphite/state-providers/fullscreen";
9+
import type { TooltipState } from "@graphite/state-providers/tooltip";
10+
11+
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
12+
import IconLabel from "@graphite/components/widgets/labels/IconLabel.svelte";
13+
import WidgetLayout from "@graphite/components/widgets/WidgetLayout.svelte";
14+
15+
const appWindow = getContext<AppWindowState>("appWindow");
16+
const editor = getContext<Editor>("editor");
17+
const fullscreen = getContext<FullscreenState>("fullscreen");
18+
const tooltip = getContext<TooltipState>("tooltip");
19+
20+
let menuBarLayout: Layout = [];
21+
22+
$: showFullscreenButton = $appWindow.platform === "Web" || $fullscreen.windowFullscreen;
23+
// On Mac, the menu bar height needs to be scaled by the inverse of the UI scale to fit its native window buttons
24+
$: height = $appWindow.platform === "Mac" ? 28 * (1 / $appWindow.uiScale) : 28;
25+
26+
onMount(() => {
27+
editor.subscriptions.subscribeJsMessage(UpdateMenuBarLayout, (data) => {
28+
patchLayout(menuBarLayout, data);
29+
menuBarLayout = menuBarLayout;
30+
});
31+
});
32+
</script>
33+
34+
<LayoutRow class="title-bar" styles={{ height: height + "px" }}>
35+
<!-- Menu bar -->
36+
<LayoutRow class="menu-bar">
37+
{#if $appWindow.platform !== "Mac"}
38+
<WidgetLayout layout={menuBarLayout} layoutTarget="MenuBar" />
39+
{/if}
40+
</LayoutRow>
41+
<!-- Window frame -->
42+
<LayoutRow class="window-frame" on:mousedown={() => editor.handle.appWindowDrag()} on:dblclick={() => editor.handle.appWindowMaximize()} />
43+
<!-- Window buttons -->
44+
<LayoutRow class="window-buttons" classes={{ fullscreen: showFullscreenButton, windows: $appWindow.platform === "Windows", linux: $appWindow.platform === "Linux" }}>
45+
{#if $appWindow.platform !== "Mac"}
46+
{#if showFullscreenButton}
47+
<LayoutRow
48+
tooltipLabel={$fullscreen.windowFullscreen ? "Exit Fullscreen" : "Enter Fullscreen"}
49+
tooltipDescription={$appWindow.platform === "Web" && $fullscreen.keyboardLockApiSupported
50+
? "While fullscreen, keyboard shortcuts normally reserved by the browser become available."
51+
: undefined}
52+
tooltipShortcut={$tooltip.f11Shortcut}
53+
on:click={() => ($fullscreen.windowFullscreen ? fullscreen.exitFullscreen : fullscreen.enterFullscreen)()}
54+
>
55+
<IconLabel icon={$fullscreen.windowFullscreen ? "FullscreenExit" : "FullscreenEnter"} />
56+
</LayoutRow>
57+
{:else}
58+
<LayoutRow tooltipLabel="Minimize" on:click={() => editor.handle.appWindowMinimize()}>
59+
<IconLabel icon="WindowButtonWinMinimize" />
60+
</LayoutRow>
61+
<LayoutRow tooltipLabel={$appWindow.maximized ? ($appWindow.platform === "Windows" ? "Restore Down" : "Unmaximize") : "Maximize"} on:click={() => editor.handle.appWindowMaximize()}>
62+
<IconLabel icon={$appWindow.maximized ? "WindowButtonWinRestoreDown" : "WindowButtonWinMaximize"} />
63+
</LayoutRow>
64+
<LayoutRow tooltipLabel="Close" on:click={() => editor.handle.appWindowClose()}>
65+
<IconLabel icon="WindowButtonWinClose" />
66+
</LayoutRow>
67+
{/if}
68+
{/if}
69+
</LayoutRow>
70+
</LayoutRow>
71+
72+
<style lang="scss" global>
73+
.title-bar {
74+
flex: 0 0 auto;
75+
76+
> .layout-row {
77+
flex: 0 0 auto;
78+
79+
> .widget-span {
80+
--row-height: 28px;
81+
82+
> * {
83+
--widget-height: 28px;
84+
}
85+
}
86+
87+
&.window-frame {
88+
flex: 1 1 100%;
89+
}
90+
91+
.text-button {
92+
height: 100%;
93+
}
94+
}
95+
96+
.window-buttons {
97+
> .layout-row {
98+
flex: 0 0 auto;
99+
align-items: center;
100+
101+
svg {
102+
fill: var(--color-e-nearwhite);
103+
}
104+
105+
&:hover {
106+
background: var(--color-6-lowergray);
107+
108+
svg {
109+
fill: var(--color-f-white);
110+
}
111+
}
112+
}
113+
114+
&.fullscreen > .layout-row {
115+
padding: 0 8px;
116+
}
117+
118+
&.windows > .layout-row {
119+
padding: 0 17px;
120+
121+
&:hover {
122+
background: #2d2d2d;
123+
}
124+
125+
&:last-of-type:hover {
126+
background: #c42b1c;
127+
}
128+
}
129+
130+
&.linux > .layout-row {
131+
padding: 0 12px;
132+
133+
&:hover {
134+
border-radius: 2px;
135+
}
136+
}
137+
}
138+
}
139+
</style>

frontend/src/components/window/workspace/Workspace.svelte renamed to frontend/src/components/window/Workspace.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
import LayoutCol from "@graphite/components/layout/LayoutCol.svelte";
99
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
10-
import Panel from "@graphite/components/window/workspace/Panel.svelte";
10+
import Panel from "@graphite/components/window/Panel.svelte";
1111
1212
const MIN_PANEL_SIZE = 100;
1313
const PANEL_SIZES = {

0 commit comments

Comments
 (0)