Look like production: icons, screenshots, title bar, Properties, task bar (#9209)

The port's window looks closer to production's VectorCraft (0.18 and its source), and the app's live screenshots work again.

Icons
- The app's icon and cursor sets are registered when the app is made (`VectorcraftApp::new`), so the web build, the tests and offscreen renders draw them, as the desktop app does.
- Each tool command carries its tool's icon, so the tool rail and its flyouts draw the tools instead of the "more" glyph.
- The hint bar's help icon is drawn (`dc-help`, a question mark in a circle, which no set had).

Screenshots
- `ui.screenshot` captures are issued from the app's kept UI passes, and the app repaints until they are issued; before, every capture timed out after 8 s. New test `tests::automation::a_screenshot_is_issued_by_the_apps_frames_and_written`.

Title bar and tabs
- Home is a bare icon toggle without the options-bar rule; the window title shows only beside the macOS menu bar.
- The Discord button is a soft neutral button with a border.
- Document tabs drop their own `*`, since the strip's modified mark shows it.

Properties panel
- Section headings in label text; form labels with colons beside fields that keep their own width; the Character section keeps its panel layout.
- Rotate and Shear show their icon and keep their own width; the Constrain Pie Angle link sits beside the pie angle fields.

Buttons and the Contextual Task Bar
- Push buttons have production's 4-point corners (the app's sizes set `radius.button`), so they are as narrow as production's.
- The task bar's actions are outlined push buttons.

Artboards panel
- Select All's keys select every artboard only while the list is drawn with the keys.

Checks: `vectorcraft-ui-egui` lib tests 3772 passed, 3 failed. The 3 failures also fail on `main` and need a newer craft-libs (Save for Web palette, two Select All tests). Clippy (`vectorcraft-ui-egui`, `vectorcraft`, all targets, `-D warnings`) and `cargo fmt --check` are clean.
This commit is contained in:
BFlat authored and GitHub committed 2026-11-24 11:43:22 +07:00
1 parent 3935fcb28c
commit 31508bf372
26 files changed
+214 -109

No files matched your search

+1
View File
@@ -196,6 +196,7 @@ Generated-in-code art is original and has no file to list. This covers the defau
| `assets/icons/dc-graphic-styles.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-grid-view.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-group-select.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-help.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a question mark in a circle) | MIT OR Apache-2.0 | |
| `assets/icons/dc-join-bevel.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-join-miter.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-join-round.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
-2
View File
@@ -614,8 +614,6 @@ fn main() -> std::process::ExitCode {
};
embed::install(ctx, spec, &vectorcraft_ui_egui::ui_fonts()).map_err(|e| e.to_string())?;
egui_extras::install_image_loaders(ctx);
craft::ui::primitives::register_app_icons(&vectorcraft_ui_egui::icons::APP_ICONS);
craft::ui::primitives::register_app_icons(&vectorcraft_ui_egui::cursors::CURSOR_ICONS);
let folders = settings.lock().get().ui.last_folders.clone();
let wake = {
let ctx = ctx.clone();
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6v.6M12 17h.01"/></svg>

After

Width:  |  Height:  |  Size: 293 B

+8 -3
View File
@@ -48,9 +48,12 @@ fn now_secs() -> f64 {
impl VectorcraftApp {
/// The app around `session`, reaching the platform through `services` (the clipboard, files
/// and the like). It starts cataloguing the installed fonts at once, gives Data Recovery the
/// host's store and makes a view for each open document.
/// and the like). It registers the app's icon sets, starts cataloguing the installed fonts at
/// once, gives Data Recovery the host's store and makes a view for each open document.
pub fn new(mut session: Session, mut services: Services) -> Self {
// Every entry point (desktop, web, tests) makes the app before its first pass.
craft::ui::primitives::register_app_icons(&super::icons::APP_ICONS);
craft::ui::primitives::register_app_icons(&super::cursors::CURSOR_ICONS);
// The font menus and the first file opened need the installed fonts: catalog them now.
vectorcraft_text::FontDb::global().scan_in_background();
if let Some(store) = &services.recovery_store {
@@ -634,9 +637,10 @@ impl VectorcraftApp {
self.flush_clipboard_out();
crate::cursors::request_busy(self, &ctx);
// A pass egui will discard and rerun is not a presented frame: it must not become the
// frame-time sample.
// frame-time sample, and it must not issue a capture of what it drew.
if !ctx.will_discard() {
self.perf.frame_ms = monotonic_ms() - t0;
self.issue_captures(&ctx);
// A hidden window's pass shows nothing, so the step waits for a pass the user sees.
if step_held && !self.viewport_hidden(&ctx) {
crate::panels::actions::playback_shown(self, ctx.cumulative_frame_nr());
@@ -655,6 +659,7 @@ pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32) -> Ro
// A hand-edited preferences file must not scale the interface to nothing.
let scaling = if prefs.ui_scaling.is_finite() && prefs.ui_scaling > 0.0 { prefs.ui_scaling as f32 } else { 1.0 };
let mut root = RootEnv::new().theme(theme).mode(mode).accent(accent).scale(Scale::new(scaling)).tooltips(prefs.show_tool_tips);
root.sizes = theme::app_sizes();
root.values.set(view::zoom_scheme(prefs, native_ppp));
root.values.set(if prefs.scrub_numeric_fields { ScrubDrags::LabelOnly } else { ScrubDrags::Off });
// A bare Tab on the canvas, or with nothing focused, toggles the panels (`window.dock`) instead of moving focus.
+19
View File
@@ -74,9 +74,28 @@ impl VectorcraftApp {
channel.settle(req, reply, document, settle);
}
}
// A capture is issued only after passes settle it, and an idle window runs none; a hidden
// one runs only this logic unless asked to paint.
if self.channel.as_ref().is_some_and(|channel| channel.captures.any_unissued()) {
if self.viewport_hidden(ctx) {
host.paint_while_hidden();
}
ctx.request_repaint();
}
self.answer_pointer_waits(ctx);
}
/// The UI phase of a pass egui keeps: counts it for settling and issues the captures that are
/// due, answering those that expired or lost their window meanwhile.
pub(crate) fn issue_captures(&mut self, ctx: &egui::Context) {
let document = self.document_identity();
let finished = self.channel.as_mut().map_or_else(Vec::new, |channel| {
channel.captures.note_pass();
channel.captures.issue(&WindowHost::of(ctx), motion::now(), document)
});
self.finish_captures(finished);
}
/// Answers the requests that waited for injected input once the window host has run it, or
/// fails them when it withdrew the input. Called at the end of a pass, after its UI, or between
/// passes: called earlier in a pass, it would count the step the pass carries as run, and the
+1 -2
View File
@@ -11,7 +11,6 @@ use craft::ui::popover::Popover;
use craft::ui::primitives::IconSpec;
use craft::ui::runtime::commands::{CommandRef, CommandState, CommandStates};
use craft::ui::runtime::env::Label;
use craft::ui::style::Variant;
use vectorcraft_doc::NodeKind;
use vectorcraft_doc::text::TextKind;
use vectorcraft_geom::{Point, Rect};
@@ -470,7 +469,7 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpac
run = Some(("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": x}})));
}
}
} else if Button::new(*label).icon(IconSpec::svg(IconId::new(icon))).variant(Variant::GHOST).show(ui).clicked() {
} else if Button::new(*label).icon(IconSpec::svg(IconId::new(icon))).show(ui).clicked() {
run = Some((*cmd, params.clone()));
}
}
+13 -10
View File
@@ -6,8 +6,7 @@ use std::cell::RefCell;
use craft::behavior::IconId;
use craft::behavior::fit::{FitItem, FitKeep, fit_items};
use craft::menu::MenuBarUi;
use craft::ui::bars::BarHome;
use craft::ui::buttons::{Button, ButtonChord, IconButton, PopupMark};
use craft::ui::buttons::{Button, ButtonChord, IconButton, PopupMark, ToggleButton};
use craft::ui::contract::{Bind, BodyCx, Props, Show, ShowContainer, Trigger};
use craft::ui::display::{Divider, Picture};
use craft::ui::layout::measure_slot;
@@ -160,7 +159,8 @@ fn leading(ui: &mut Ui, app: &mut VectorcraftApp) {
}
let mut home = menus::home_showing(app);
let before = home;
BarHome::new(tl!("Home"), Bind::bound(&mut home)).show(ui);
// The title bar's Home has no rule after it, as an options bar's `BarHome` does.
ToggleButton::new(tl!("Home"), Bind::bound(&mut home)).icon(IconSpec::svg(IconId::new("home"))).icon_only().show(ui);
if home != before {
app.run("app.home", json!({})).ok();
}
@@ -198,16 +198,19 @@ fn trailing(ui: &mut Ui, app: &mut VectorcraftApp) {
/// The application bar, the body of the shell's title bar: brand mark, Home and menus, then Discord,
/// tutorials, Arrange Documents, search and the workspace switcher at the end. The title bar draws
/// the caption buttons, drags the window and shows the title.
/// the caption buttons and drags the window; it shows the title only while the menus are in the macOS
/// menu bar, where the bar has the room the menus leave.
pub fn app_bar(ui: &mut Ui, _cx: &mut BodyCx<'_>, app: &mut VectorcraftApp) {
let titled = app.services.native_menu.is_some();
let app = RefCell::new(app);
// Both closures need the app; the bar runs them one after the other.
let _ = TitleBar::new().show_titled(
ui,
Title::new(tl!("VectorCraft")),
|ui, _| leading(ui, &mut app.borrow_mut()),
|ui, _| trailing(ui, &mut app.borrow_mut()),
);
let start = |ui: &mut Ui, _: &mut BodyCx<'_>| leading(ui, &mut app.borrow_mut());
let end = |ui: &mut Ui, _: &mut BodyCx<'_>| trailing(ui, &mut app.borrow_mut());
let _ = if titled {
TitleBar::new().show_titled(ui, Title::new(tl!("VectorCraft")), start, end)
} else {
TitleBar::new().trailing(end).show(ui, start).output
};
}
/// The OS window title: the active document's name suffixed with the app name (a `*` prefix
+1 -2
View File
@@ -257,8 +257,7 @@ pub fn hint_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
}
};
Bar::new(tl!("Help Bar"), BarKind::Status).show(ui, |ui, _| {
// PLAN: assumed the framework icon "help" (document-panels-w1).
Icon::new(IconSpec::svg(IconId::new("help"))).show(ui);
Icon::new(IconSpec::svg(IconId::new("dc-help"))).show(ui);
let spans = segments
.iter()
.map(|(text, bold)| {
+18 -15
View File
@@ -10,41 +10,42 @@ use craft::ui::tabs::{DocumentTab, DocumentTabs, DocumentTabsEvent};
/// [`view_tab_title`] for a document with one view.
#[cfg(test)]
pub(super) fn tab_title(d: &vectorcraft_engine::DocState, zoom: f64, outline: bool, display_print_size: bool) -> String {
view_tab_title(d, None, zoom, outline, display_print_size)
view_tab_title(d, None, true, zoom, outline, display_print_size)
}
/// A document tab's title: "Name* @ 66.67 % (RGB/Preview)", or while an opacity mask is edited
/// "Name* @ 66.67 % (<Opacity Mask>/Opacity Mask)". For a view of a document with more than one
/// view, the view's `number` follows the name: "Name:2* @ 66.67 % (RGB/Preview)".
fn view_tab_title(d: &vectorcraft_engine::DocState, number: Option<u32>, zoom: f64, outline: bool, display_print_size: bool) -> String {
/// view, the view's `number` follows the name: "Name:2* @ 66.67 % (RGB/Preview)". The `*` of unsaved changes shows
/// when `marked`; a document tab shows its own modified mark instead.
fn view_tab_title(d: &vectorcraft_engine::DocState, number: Option<u32>, marked: bool, zoom: f64, outline: bool, display_print_size: bool) -> String {
let mode = if d.doc.mask_edit.is_some() {
format!("<{0}>/{0}", tl!("Opacity Mask"))
} else {
let color = if d.doc.color_mode == vectorcraft_doc::ColorMode::Cmyk { "CMYK" } else { "RGB" };
format!("{color}/{}", if outline { tl!("Outline") } else { tl!("Preview") })
};
format!("{} @ {} ({mode})", view_tab_name(d, number), zoom_label(zoom, display_print_size).replace('%', " %"))
format!("{} @ {} ({mode})", view_tab_name(d, number, marked), zoom_label(zoom, display_print_size).replace('%', " %"))
}
/// The start of [`view_tab_title`], which an inactive document tab shows alone (#8582): "Name*",
/// or for a view of a document with more than one view, "Name:2*".
fn view_tab_name(d: &vectorcraft_engine::DocState, number: Option<u32>) -> String {
/// or for a view of a document with more than one view, "Name:2*"; the `*` only when `marked`.
fn view_tab_name(d: &vectorcraft_engine::DocState, number: Option<u32>, marked: bool) -> String {
let number = number.map(|n| format!(":{n}")).unwrap_or_default();
format!("{}{number}{}", d.title(), if d.is_dirty() { "*" } else { "" })
format!("{}{number}{}", d.title(), if marked && d.is_dirty() { "*" } else { "" })
}
/// The title of window `w`, a view of document `d`: with the view's zoom and Outline or Preview,
/// and the view's number while the document has more than one view.
fn window_tab_title(app: &VectorcraftApp, w: crate::doc_windows::Win, d: &vectorcraft_engine::DocState) -> String {
/// and the view's number while the document has more than one view; `marked` as in [`view_tab_title`].
fn window_tab_title(app: &VectorcraftApp, w: crate::doc_windows::Win, d: &vectorcraft_engine::DocState, marked: bool) -> String {
let view = crate::doc_windows::view(app, w);
let zoom = view.map_or(1.0, |v| v.zoom);
view_tab_title(d, crate::doc_windows::label(app, w), zoom, view.is_some_and(|v| v.outline), app.session.prefs.display_print_size)
view_tab_title(d, crate::doc_windows::label(app, w), marked, zoom, view.is_some_and(|v| v.outline), app.session.prefs.display_print_size)
}
/// The title of window `w`'s tab and floating window ([`crate::doc_windows`]).
pub(crate) fn document_window_title(app: &VectorcraftApp, w: crate::doc_windows::Win) -> Option<String> {
let d = app.session.documents().get(w.0)?;
Some(window_tab_title(app, w, d))
Some(window_tab_title(app, w, d, true))
}
/// Runs command `id`, reporting its failure in the status line.
@@ -66,8 +67,9 @@ pub(super) fn reorder_target(app: &VectorcraftApp, from: usize, before: Option<W
if from < gap { gap - 1 } else { gap }
}
/// Document tab strip: the current window's tab shows "Name* @ 66.67 % (RGB/Preview)", each other
/// tab "Name*" alone with the whole title as its tooltip (#8582). Each view Window › New Window
/// Document tab strip: the current window's tab shows "Name @ 66.67 % (RGB/Preview)", each other
/// tab "Name" alone with the whole title as its tooltip (#8582), and the tab of a document with
/// unsaved changes the strip's modified mark. Each view Window › New Window
/// opened has a tab of its own; floating windows have none ([`crate::doc_windows`]). A tab dragged
/// along the strip moves its document (`document.move`, #5663); one released over no strip floats
/// its view in a window; one from a floating window's strip docks here. A middle click closes a tab
@@ -78,11 +80,12 @@ pub fn doc_tabs(app: &mut VectorcraftApp, ui: &mut Ui) {
.into_iter()
.filter_map(|w| {
let d = app.session.documents().get(w.0)?;
let whole = window_tab_title(app, w, d);
// The tab's modified mark shows unsaved changes, so its text has no `*`.
let whole = window_tab_title(app, w, d, false);
let tab = if Some(w) == shown {
DocumentTab::new(w, whole)
} else {
DocumentTab::new(w, view_tab_name(d, doc_windows::label(app, w))).tooltip(whole)
DocumentTab::new(w, view_tab_name(d, doc_windows::label(app, w), false)).tooltip(whole)
};
Some(tab.modified(d.is_dirty()))
})
+4 -2
View File
@@ -3,6 +3,8 @@
//! on Discord's colour with the word "Discord".
use craft::behavior::IconId;
use craft::theme::Emphasis;
use craft::theme::variant::Tone;
use craft::ui::buttons::Button;
use craft::ui::contract::{Props, Show};
use craft::ui::primitives::IconSpec;
@@ -14,12 +16,12 @@ use crate::VectorcraftApp;
/// Discord's brand colour (a colour, not a logo).
const DISCORD: Color32 = Color32::from_rgb(0x58, 0x65, 0xF2);
/// The Discord button: quiet, with Discord's colour on its icon alone. It opens the community link.
/// The Discord button: a soft neutral button, with Discord's colour on its icon alone. It opens the community link.
pub fn discord_button(app: &mut VectorcraftApp, ui: &mut Ui) {
let icon = IconSpec::svg(IconId::new("message-circle")).data_color(DataColor::new(DISCORD));
let shown = Button::new(tl!("Discord"))
.icon(icon)
.variant(Variant::GHOST)
.variant(Variant::look(Emphasis::Soft, Tone::Neutral))
.tooltip(tl!("Join the ArtCraft community on Discord (discord.gg/artcraft)"))
.show(ui);
if shown.clicks > 0 {
+1
View File
@@ -108,6 +108,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
("dc-graphic-styles", include_bytes!("../../../assets/icons/dc-graphic-styles.svg")),
("dc-grid-view", include_bytes!("../../../assets/icons/dc-grid-view.svg")),
("dc-group-select", include_bytes!("../../../assets/icons/dc-group-select.svg")),
("dc-help", include_bytes!("../../../assets/icons/dc-help.svg")),
("dc-join", include_bytes!("../../../assets/icons/dc-join.svg")),
("dc-join-bevel", include_bytes!("../../../assets/icons/dc-join-bevel.svg")),
("dc-join-miter", include_bytes!("../../../assets/icons/dc-join-miter.svg")),
+4 -1
View File
@@ -246,9 +246,12 @@ pub(crate) fn corner_radius_field(app: &mut VectorcraftApp, ui: &mut Ui, n: &Nod
/// The icon the command catalog gives command `id`: the Align panel's align, distribute and Align
/// To buttons' and the Pathfinder panel's, so a bar or menu row of the command shows the panel's
/// glyph. `None` for every other command.
/// glyph, and each tool's, which the tool rail and its flyouts show. `None` for every other command.
pub(crate) fn command_icon(id: &str) -> Option<&'static str> {
use align::{AlignTo, Button};
if let Some(tool) = id.strip_prefix("tool:") {
return vectorcraft_tools::tool_info(tool).map(|t| crate::icons::tool_icon(t.icon));
}
if let Some(op) = id.strip_prefix("object.pathfinder.") {
return pathfinder::SHAPE_MODES.iter().chain(&pathfinder::PATHFINDERS).find(|(_, _, o)| *o == op).map(|(icon, _, _)| *icon);
}
+12 -6
View File
@@ -41,8 +41,9 @@ pub struct ArtboardsUi {
pub anchor: Option<(u64, usize)>,
/// The row whose name field opens at the list's next pass (the panel menu's Rename); taken by [`show`].
pub rename: Option<usize>,
/// Whether key focus is in the list: Select All's keys then select every artboard ([`selects_all`]).
pub focused: bool,
/// The window and its pass in which key focus was last in the list: while the list keeps it, Select All's keys
/// select every artboard ([`selects_all`]).
pub focused_pass: Option<(egui::ViewportId, u64)>,
/// The row whose context menu is open.
pub menu: Option<usize>,
}
@@ -420,9 +421,11 @@ pub(crate) fn toggle(app: &mut VectorcraftApp, i: usize, n: usize) {
}
/// Whether Select All's shortcut selects every artboard ([`select_all`]) instead of the art: the list has
/// key focus and the Artboard tool is in use.
pub(crate) fn selects_all(app: &VectorcraftApp) -> bool {
app.session.tool_id() == "artboard" && app.ui.artboards_ui.focused
/// key focus and the Artboard tool is in use. The list keeps the keys only while its window draws it in every pass, so
/// a closed panel gives them back to the art; the fired commands run after the frame, a pass after the list's last.
pub(crate) fn selects_all(app: &VectorcraftApp, ctx: &egui::Context) -> bool {
app.session.tool_id() == "artboard"
&& app.ui.artboards_ui.focused_pass.is_some_and(|(window, pass)| ctx.cumulative_pass_nr_for(window) <= pass + 1)
}
/// Ctrl/Cmd+A while [`selects_all`]: the Artboard tool selects every artboard, and the active
@@ -508,7 +511,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
list = list.start_rename(row);
}
let output = list.show(ui);
app.ui.artboards_ui.focused = output.focused;
// A measuring run of the panel has no focus.
if !craft::ui::runtime::measure::active(ui.ctx()) {
app.ui.artboards_ui.focused_pass = output.focused.then(|| (ui.ctx().viewport_id(), ui.ctx().cumulative_pass_nr()));
}
if let Some(row) = picked.anchor {
app.ui.artboards_ui.anchor = Some((uid, row));
}
+25 -17
View File
@@ -2,12 +2,12 @@
use craft::behavior::{ColumnWidth, IconId};
use craft::ui::buttons::{Button, IconButton};
use craft::ui::contract::{Props as _, Show as _, ShowContainer as _};
use craft::ui::layout_components::{Grid, Row};
use craft::ui::contract::{LabelScheme, Props as _, Show as _, ShowContainer as _};
use craft::ui::layout_components::{Grid, Row, Stack};
use craft::ui::patterns::panels::Inspector;
use craft::ui::runtime::commands::CommandRef;
use craft::ui::sections::Section;
use craft::ui::sections::{HeaderStrength, Section};
use egui::Ui;
use serde_json::json;
use vectorcraft_doc::{LiveShape, Node, NodeKind};
@@ -52,19 +52,27 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let guides = super::transform::selected_guides(app);
let header = heading(first.as_deref(), n_sel, editing_artboards, guides.is_some());
inspector.target(key).header(header).show(ui, |ui, _| {
if editing_artboards {
artboard_sections::artboard_sections(app, ui);
} else if first.is_none() {
match guides {
Some(guides) => transform_section::guide_sections(app, ui, guides),
None => document_sections::document_sections(app, ui),
// The reference panel's labels end in a colon beside fields that keep their own width.
Stack::new().fill_width().labels(LabelScheme::Form).show(ui, |ui, _| {
if editing_artboards {
artboard_sections::artboard_sections(app, ui);
} else if first.is_none() {
match guides {
Some(guides) => transform_section::guide_sections(app, ui, guides),
None => document_sections::document_sections(app, ui),
}
} else {
body(app, ui, first.as_deref(), n_sel, anchors);
}
} else {
body(app, ui, first.as_deref(), n_sel, anchors);
}
});
});
}
/// A section of the panel under its heading in label text, as the reference panel's section headings are.
fn section<'a>(title: &'static str) -> Section<'a> {
Section::fixed(title).strength(HeaderStrength::Normal)
}
/// The document's uid: production's field ids do not change with the selection, so neither does the key and the
/// scroll position stays.
fn target_key(app: &VectorcraftApp) -> Option<u64> {
@@ -89,7 +97,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
transform_section::corner_rows(app, ui);
// The Gradient tool: the gradient's type and, for a freeform one, how clicks add points (#921).
if app.session.tool_id() == "gradient" {
Section::fixed(tl!("Gradient")).show(ui, |ui, _| {
section(tl!("Gradient")).show(ui, |ui, _| {
super::gradient::type_row(app, ui);
super::gradient::draw_radios(app, ui);
});
@@ -112,7 +120,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
crate::dialogs::dimension::properties_section(app, ui);
}
appearance_section::appearance_section(app, ui);
Section::fixed(tl!("Align")).show(ui, |ui, _| {
section(tl!("Align")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
super::align::align_buttons(app, ui);
// The rest (Distribute Objects, Distribute Spacing, Align To) is the Align panel's.
@@ -120,7 +128,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
});
});
if n_sel > 1 {
Section::fixed(tl!("Pathfinder")).show(ui, |ui, _| {
section(tl!("Pathfinder")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
for (icon, tip, op) in [
("squares-unite", tl!("Unite"), "unite"),
@@ -135,10 +143,10 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
});
}
if anchors != crate::chrome::AnchorControls::None {
Section::fixed(tl!("Anchor Point")).show(ui, |ui, _| crate::chrome::anchor_buttons(app, ui, anchors));
section(tl!("Anchor Point")).show(ui, |ui, _| crate::chrome::anchor_buttons(app, ui, anchors));
}
let actions = quick_actions(app);
Section::fixed(tl!("Quick Actions")).show(ui, |ui, _| {
section(tl!("Quick Actions")).show(ui, |ui, _| {
if is_image {
crate::panels::image_trace::trace_button(app, ui);
}
@@ -5,13 +5,12 @@ use craft::behavior::IconId;
use craft::keymap::CommandRef;
use craft::ui::buttons::{Button, IconButton};
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _, Trigger, clicked};
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, clicked};
use craft::ui::display::{Elide, Shade, Text};
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::menu::Menu;
use craft::ui::popover::Popover;
use craft::ui::sections::Section;
use craft::ui::style::TypeRole;
use craft::ui::text::{NumberField, TextField};
use egui::{Response, Ui};
@@ -27,7 +26,7 @@ use crate::panels::{self, appearance, first_selected, stroke};
/// profile, Opacity and the effect controls.
pub(super) fn appearance_section(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(n) = first_selected(app) else { return };
Section::fixed(tl!("Appearance")).show(ui, |ui, _| {
super::section(tl!("Appearance")).show(ui, |ui, _| {
fill_stroke_rows(app, ui);
width_profile_row(app, ui);
opacity_row(app, ui, &n);
@@ -45,6 +44,7 @@ fn opacity_row(app: &mut VectorcraftApp, ui: &mut Ui, n: &Node) {
Row::new().show(ui, |ui, _| {
let shown = Some(n.opacity as f64 * 100.0);
let out = Field::new(tl!("Opacity"))
.sizing(Sizing::Content)
.show(ui, |ui, _| NumberField::new(tl!("Opacity"), Bind::given(shown)).range(0.0..=100.0).unit("%").fixed_decimals(0).show(ui))
.inner;
if let Some(out) = out {
@@ -135,8 +135,8 @@ pub(super) fn global_edit_row(app: &mut VectorcraftApp, ui: &mut Ui) {
// A copy, so the popover's flag does not borrow `app` while its body runs commands.
let mut open = app.ui.properties_panel.global_edit_open;
Row::new().show(ui, |ui, _| {
// The command's own state gives its title: Start or Stop Global Edit.
Button::command("select.globalEdit").show(ui);
// The command's own state gives its title: Start or Stop Global Edit. It takes the row up to the options.
Button::command("select.globalEdit").sizing(Sizing::FillWidth).show(ui);
let options = IconButton::new(IconId::new("chevron-down")).label(tl!("Global Edit Options")).enabled(!on).show(ui);
global_edit_popover(app, ui, &options.response, &mut open);
});
@@ -13,7 +13,6 @@ use craft::ui::layout_components::{Grid, Row};
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::pickers::Select;
use craft::ui::primitives::IconSpec;
use craft::ui::sections::Section;
use craft::ui::text::TextField;
use egui::Ui;
use serde_json::json;
@@ -36,13 +35,13 @@ pub(super) fn artboard_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
let i = artboards::selected(app, n);
let ab = app.session.active().and_then(|d| d.doc.artboards.get(i)).cloned();
if let Some(ab) = &ab {
Section::fixed(tl!("Transform")).show(ui, |ui, _| {
super::section(tl!("Transform")).show(ui, |ui, _| {
transform::artboard_fields(app, ui, i, ab.rect);
artboard_size_row(app, ui, i, ab.rect.width(), ab.rect.height());
artboards::art_options(app, ui);
});
}
Section::fixed(tl!("Artboards")).show(ui, |ui, _| {
super::section(tl!("Artboards")).show(ui, |ui, _| {
if let Some(ab) = &ab {
Field::new(tl!("Name:")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
@@ -72,7 +71,7 @@ pub(super) fn artboard_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
});
Section::fixed(tl!("Quick Actions")).show(ui, |ui, _| {
super::section(tl!("Quick Actions")).show(ui, |ui, _| {
Grid::new(&HALVES).show(ui, |ui, _| {
rearrange_button(ui, n);
Button::command(CommandRef::with_params("tool.select", json!({ "tool": "selection" })))
@@ -9,7 +9,6 @@ use craft::ui::form::Field;
use craft::ui::layout_components::{Grid, Row};
use craft::ui::pickers::Select;
use craft::ui::runtime::env::LengthUnits;
use craft::ui::sections::Section;
use craft::ui::text::NumberField;
use egui::Ui;
use serde_json::json;
@@ -26,7 +25,7 @@ use crate::panels::transform;
pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
let units = app.session.general_unit();
let artboards = app.session.active().map_or(0, |d| d.doc.artboards.len());
Section::fixed(tl!("Document")).show(ui, |ui, _| {
super::section(tl!("Document")).show(ui, |ui, _| {
Field::new(tl!("Units")).show(ui, |ui, _| {
let entries: Vec<Entry<Unit>> = Unit::ALL.iter().map(|u| Entry::new(*u, u.label())).collect();
let out = Select::new(tl!("Units"), Bind::given(units), &entries).show(ui);
@@ -45,8 +44,8 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
});
Section::fixed(tl!("Appearance")).show(ui, |ui, _| super::appearance_section::fill_stroke_rows(app, ui));
Section::fixed(tl!("Rulers & Grids")).show(ui, |ui, _| {
super::section(tl!("Appearance")).show(ui, |ui, _| super::appearance_section::fill_stroke_rows(app, ui));
super::section(tl!("Rulers & Grids")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
// The checked and enabled states and the tooltips come from the commands (Trim View turns the grid off).
for (command, icon) in [("view.rulers", "ruler"), ("view.grid", "grid-3x3"), ("view.transparencyGrid", "square-dashed")] {
@@ -54,14 +53,14 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
});
Section::fixed(tl!("Guides")).show(ui, |ui, _| {
super::section(tl!("Guides")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
for (command, icon) in [("view.guides", "layout-grid"), ("view.smartGuides", "sparkles")] {
ToggleButton::command(CommandRef::new(command)).icon(IconId::new(icon)).icon_only().show(ui);
}
});
});
Section::fixed(tl!("Snap Options")).show(ui, |ui, _| {
super::section(tl!("Snap Options")).show(ui, |ui, _| {
let (point, grid) = (app.ui.view.snap_to_point, app.ui.view.snap_to_grid);
for (command, label, on) in [("view.snapToPoint", tl!("Snap to Point"), point), ("view.snapToGrid", tl!("Snap to Grid"), grid)] {
if Checkbox::new(Bind::given(on)).label(label).show(ui).value().is_some() {
@@ -69,7 +68,7 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
}
});
Section::fixed(tl!("Preferences")).show(ui, |ui, _| {
super::section(tl!("Preferences")).show(ui, |ui, _| {
Field::new(tl!("Keyboard Increment")).show(ui, |ui, _| {
// PLAN: assumed `canvas::rulers::general_lengths(app) -> LengthUnits` (cv.B5b)
let lengths: LengthUnits = crate::canvas::rulers::general_lengths(app);
@@ -89,7 +88,7 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
transform::set_pref(app, "scaleStrokes", on);
}
});
Section::fixed(tl!("Quick Actions")).show(ui, |ui, _| {
super::section(tl!("Quick Actions")).show(ui, |ui, _| {
Grid::new(&HALVES).show(ui, |ui, _| {
for command in ["file.documentSetup", "edit.preferences"] {
Button::command(CommandRef::new(command)).sizing(Sizing::FillWidth).show(ui);
@@ -8,7 +8,6 @@
use craft::ui::buttons::Button;
use craft::ui::contract::{Props as _, Show as _, ShowContainer as _};
use craft::ui::layout_components::Row;
use craft::ui::sections::Section;
use egui::Ui;
use vectorcraft_doc::{Document, GraphKind, MAX_GRAPH_SERIES, NodeId};
@@ -79,7 +78,7 @@ fn series_of(doc: &Document, graph: NodeId, id: NodeId) -> Option<usize> {
/// The Graph section for the selection; nothing without a graph.
pub(crate) fn section(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(s) = shown(app) else { return };
Section::fixed(tl!("Graph")).show(ui, |ui, _| {
super::section(tl!("Graph")).show(ui, |ui, _| {
Row::new().wrap(true).show(ui, |ui, _| {
Button::command("graph.setType").label(tl!("Graph Type…")).show(ui);
Button::command("graph.setData").label(tl!("Graph Data…")).show(ui);
@@ -10,7 +10,6 @@ use craft::ui::form::Field;
use craft::ui::layout_components::Grid;
use craft::ui::pickers::{ReferencePoint, ReferencePointLook};
use craft::ui::runtime::env::UnitKind;
use craft::ui::sections::Section;
use craft::ui::style::TypeRole;
use craft::ui::text::{NumberField, NumberPick};
use egui::Ui;
@@ -28,7 +27,7 @@ pub(super) fn image_section(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(i) = crate::place::selected_image_info(app) else { return };
let (name, details) = crate::place::image_summary(i);
let (Some(id), linked) = (i["id"].as_u64(), i["linked"] == true) else { return };
Section::fixed(if linked { tl!("Linked File") } else { tl!("Embedded Image") }).show(ui, |ui, _| {
super::section(if linked { tl!("Linked File") } else { tl!("Embedded Image") }).show(ui, |ui, _| {
Text::new(name.clone()).elide(Elide::Middle).role(TypeRole::BodyStrong).show(ui);
Text::new(details.clone()).shade(Shade::Muted).show(ui);
Grid::new(&HALVES).show(ui, |ui, _| {
@@ -52,7 +51,7 @@ pub(super) fn image_section(app: &mut VectorcraftApp, ui: &mut Ui) {
/// The one selected Image Trace object: its preset (choosing another traces it again with that
/// one), view, a button to reveal the tracing controls, Expand and Release.
pub(super) fn trace_section(app: &mut VectorcraftApp, ui: &mut Ui, preset: &str, view: vectorcraft_doc::TraceView) {
Section::fixed(tl!("Image Trace")).show(ui, |ui, _| {
super::section(tl!("Image Trace")).show(ui, |ui, _| {
Field::new(tl!("Preset")).show(ui, |ui, _| crate::panels::image_trace::preset_dropdown(app, ui, preset));
crate::panels::image_trace::view_row(app, ui, view);
crate::panels::image_trace::split_row(app, ui);
@@ -118,7 +117,7 @@ pub(super) fn objects_on_path_section(app: &mut VectorcraftApp, ui: &mut Ui, oop
app.status(e);
}
};
Section::fixed(tl!("Objects on Path Options")).show(ui, |ui, _| {
super::section(tl!("Objects on Path Options")).show(ui, |ui, _| {
Field::new(tl!("Pivot")).show(ui, |ui, _| {
// Mixed while the groups' pivots differ: no square is chosen.
let shown = oop.pivot.map_or(Mixed::Mixed, |p| Mixed::Same(Anchor9::ALL.get(usize::from(p)).copied()));
@@ -12,7 +12,6 @@ use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::pickers::Select;
use craft::ui::popover::Popover;
use craft::ui::sections::Section;
use egui::Ui;
use serde_json::json;
use vectorcraft_doc::{LiveCorners, LiveShape, NodeKind};
@@ -31,7 +30,7 @@ pub fn transform_section(app: &mut VectorcraftApp, ui: &mut Ui) {
Text::new(tl!("No Selection")).shade(Shade::Muted).show(ui);
return;
}
Section::fixed(tl!("Transform")).show(ui, |ui, _| {
super::section(tl!("Transform")).show(ui, |ui, _| {
let mut groups = TransformGroups::NONE;
groups.reference = true;
groups.position = true;
@@ -107,5 +106,5 @@ pub(super) fn corner_rows(app: &mut VectorcraftApp, ui: &mut Ui) {
/// Ruler guides selected on their own: a Transform section with the X of the vertical ones and
/// the Y of the horizontal ones, which move them, as the Transform panel shows them (#1597).
pub(super) fn guide_sections(app: &mut VectorcraftApp, ui: &mut Ui, guides: (Option<f64>, Option<f64>)) {
Section::fixed(tl!("Transform")).show(ui, |ui, _| transform::guide_fields(app, ui, guides));
super::section(tl!("Transform")).show(ui, |ui, _| transform::guide_fields(app, ui, guides));
}
@@ -1,10 +1,9 @@
//! The Properties panel's Character and Paragraph sections for the selected text.
use craft::text::ui::character::CharacterRows;
use craft::ui::contract::{Show as _, ShowContainer as _};
use craft::ui::contract::{LabelScheme, Show as _, ShowContainer as _};
use craft::ui::display::{Shade, Text};
use craft::ui::layout_components::Row;
use craft::ui::sections::Section;
use craft::ui::layout_components::{Row, Stack};
use egui::Ui;
use vectorcraft_doc::NodeKind;
@@ -23,8 +22,11 @@ pub fn type_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
if character::text_style(app).is_none() {
return;
}
Section::fixed(tl!("Character")).show(ui, |ui, _| character::controls(app, ui, CharacterRows::PROPERTIES));
Section::fixed(tl!("Paragraph")).show(ui, |ui, _| {
// The Character panel's controls as that panel lays them out: the font pickers and the metrics fill the row.
super::section(tl!("Character")).show(ui, |ui, _| {
Stack::new().fill_width().labels(LabelScheme::Inspector).show(ui, |ui, _| character::controls(app, ui, CharacterRows::PROPERTIES));
});
super::section(tl!("Paragraph")).show(ui, |ui, _| {
// As in the Paragraph panel: the seven alignments and Hyphenate (#775), and area type's vertical alignment
// (#3759); the rest is there.
Row::new().show(ui, |ui, _| {
+5 -3
View File
@@ -15,7 +15,7 @@ use craft::draw::ui::transform::{
use craft::keymap::CommandRef;
use craft::ui::buttons::{IconButton, Link};
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Entry, LabelPress, Props, Show, ShowContainer, SideLabel};
use craft::ui::contract::{Bind, Entry, GlyphLabel, LabelKind, LabelPress, Props, Show, ShowContainer, SideLabel, Sizing};
use craft::ui::display::{Shade, Text};
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
@@ -419,7 +419,8 @@ pub(crate) fn object_bar_fields(app: &mut VectorcraftApp, ui: &mut Ui) -> Option
Some(out)
}
/// A field of an angle: its icon as a scrubbing label, the value in degrees and the presets on a ladder of stops.
/// A field of an angle: its icon in place of its label, which scrubs it, the value in degrees and the presets on a
/// ladder of stops.
fn angle_field(
ui: &mut Ui,
label: &'static str,
@@ -431,7 +432,8 @@ fn angle_field(
) -> Option<NumberOutput> {
let entries: Vec<Entry<NumberPick>> = presets.iter().map(|v| Entry::new(NumberPick::Number(*v), format!("{v}°"))).collect();
Field::new(label)
.side(SideLabel::new().icon(IconId::new(icon)).scrub(true))
.sizing(Sizing::Content)
.side(SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::icon(IconId::new(icon)))).tooltip(label).scrub(true))
.enabled(enabled)
.show(ui, |ui, _| {
NumberField::new(label, Bind::given(Some(shown)))
+14 -13
View File
@@ -3,8 +3,9 @@
use craft::behavior::Mixed;
use craft::ui::buttons::Button;
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _};
use craft::ui::contract::{Bind, Bracket, Props as _, Show as _, ShowContainer as _};
use craft::ui::form::Field;
use craft::ui::layout_components::{Row, Stack};
use craft::ui::pickers::Select;
use craft::ui::sections::{HeaderStrength, Section};
use craft::ui::text::{NumberField, link_toggle};
@@ -152,21 +153,21 @@ fn line_rows(app: &mut VectorcraftApp, ui: &mut Ui, live: &LiveShape) -> bool {
}
/// An ellipse's Pie Start and End Angle (degrees, counterclockwise from 3 o'clock; 0 to 360 is the whole
/// ellipse), the Constrain Pie Angle link after them, and Invert Pie, which shows the other part of it. With the
/// ellipse), the Constrain Pie Angle link beside them, and Invert Pie, which shows the other part of it. With the
/// link on, a typed angle moves the other one by as much, so each selected ellipse keeps its span.
fn pie_rows(app: &mut VectorcraftApp, ui: &mut Ui, pie: (f64, f64)) {
let constrain = app.ui.constrain_pie_angle;
for (label, key, v) in [(tl!("Pie Start Angle"), "pieStart", pie.0), (tl!("Pie End Angle"), "pieEnd", pie.1)] {
number_row(
app,
ui,
label,
Some(v),
Quantity::Degrees,
|a| if constrain { json!({ key: a, "constrainPie": true }) } else { json!({ key: a }) },
);
}
link_toggle(tl!("Constrain Pie Angle"), Bind::bound(&mut app.ui.constrain_pie_angle)).show(ui);
// The link sits halfway between the two fields, with no bracket drawn to them.
Row::new().bracket(Bracket::Unlinked).show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
for (label, key, v) in [(tl!("Pie Start Angle"), "pieStart", pie.0), (tl!("Pie End Angle"), "pieEnd", pie.1)] {
number_row(app, ui, label, Some(v), Quantity::Degrees, |a| {
if constrain { json!({ key: a, "constrainPie": true }) } else { json!({ key: a }) }
});
}
});
link_toggle(tl!("Constrain Pie Angle"), Bind::bound(&mut app.ui.constrain_pie_angle)).show(ui);
});
if Button::new(tl!("Invert Pie")).show(ui).clicked() {
set_live_shape(app, json!({"invertPie": true}));
}
+1 -1
View File
@@ -104,7 +104,7 @@ pub(crate) fn run_fired(app: &mut VectorcraftApp, ctx: &egui::Context, fired: &F
}
return;
}
if command.id == "select.all" && crate::panels::artboards::selects_all(app) {
if command.id == "select.all" && crate::panels::artboards::selects_all(app, ctx) {
// With the Artboard tool, Select All's keys after a click on an Artboards panel row select every artboard
// instead of the art.
crate::panels::artboards::select_all(app);
+39
View File
@@ -1103,6 +1103,45 @@ fn a_screenshot_reply_hides_paths_like_any_reply() {
let _ = std::fs::remove_dir_all(base);
}
/// `ui.screenshot` is answered from the app's own frames: once the request settles, a kept pass sends
/// the window's screenshot command, and the image the window gives back is written where the request
/// asked.
#[test]
fn a_screenshot_is_issued_by_the_apps_frames_and_written() {
let (mut app, tx, base) = confined("screenshot-frames");
let ctx = app.ui_ctx.clone().unwrap();
let size = egui::vec2(800.0, 600.0);
let raw = || {
let mut raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), ..Default::default() };
let root = raw.viewports.entry(egui::ViewportId::ROOT).or_default();
root.inner_rect = raw.screen_rect;
root.native_pixels_per_point = Some(1.0);
raw
};
let path = base.join("out/shot.png");
let (req, reply) = ControlRequest::new("ui.screenshot", json!({"path": s(path.clone()), "focus": false}));
tx.send(req).unwrap();
// The settle delay runs on the wall clock: frames come until it is over, as an idle window's do.
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
let callback = loop {
let out = crate::testing::app_frame(&mut app, &ctx, raw());
let sent = out.viewport_output.get(&egui::ViewportId::ROOT).and_then(|root| {
root.commands.iter().find_map(|c| if let egui::ViewportCommand::Screenshot(callback) = c { Some(callback.clone()) } else { None })
});
if let Some(callback) = sent {
break callback;
}
assert!(reply.try_recv().is_err(), "the screenshot was answered before it was taken");
assert!(std::time::Instant::now() < deadline, "no frame issued the screenshot");
};
callback.complete(std::sync::Arc::new(egui::ColorImage::filled([800, 600], egui::Color32::WHITE)));
crate::testing::app_frame(&mut app, &ctx, raw());
let r = reply.try_recv().expect("the frame after the image answers");
assert_eq!(r["ok"], true, "{r}");
assert!(std::fs::metadata(&path).is_ok_and(|m| m.len() > 0), "the PNG was written");
let _ = std::fs::remove_dir_all(base);
}
/// A reply whose only trace of a hidden library's path is a `file:` URL with every separator escaped
/// shows the file name alone.
#[test]
+19 -1
View File
@@ -1,8 +1,9 @@
//! The user's interface choices (brightness, accent, colour scheme) and how they select the root theme.
use craft::theme::{ModeChoice, Rgba, ThemeId};
use craft::theme::{AppSizes, ModeChoice, Rgba, ThemeId};
use egui::{FontFamily, FontId};
use serde::{Deserialize, Serialize};
use std::sync::{Arc, LazyLock};
use vectorcraft_engine::Prefs;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
@@ -144,6 +145,17 @@ pub fn root_theme(prefs: &Prefs) -> (ThemeId, ModeChoice, Option<Rgba>) {
}
}
/// The app's sizes over the framework's size sets (`sizes.json`): push buttons have the app's 4-point corners
/// where the sets give pills.
const SIZES: &[u8] = br#"{"all": {"radius.button": 4}}"#;
/// The app's sizes ([`SIZES`]) as one shared value: the token cache tells a change of sizes by its pointer, so a
/// new value each frame would resolve the tokens again each frame.
pub fn app_sizes() -> Arc<AppSizes> {
static SHARED: LazyLock<Arc<AppSizes>> = LazyLock::new(|| Arc::new(AppSizes::parse_or_default(SIZES)));
Arc::clone(&SHARED)
}
pub fn semibold(size: f32) -> FontId {
FontId::new(size, FontFamily::Name(craft::ui::fonts::SEMIBOLD.into()))
}
@@ -163,4 +175,10 @@ mod tests {
assert_eq!(Brightness::parse(b.label()), Some(b));
}
}
/// A size `app_sizes` cannot read is only logged and dropped, which brings the pill buttons back unnoticed.
#[test]
fn the_app_sizes_are_read_whole() {
assert!(AppSizes::parse(SIZES).is_ok_and(|sizes| !sizes.is_empty()));
}
}