Look like production: section headings, compact tool rail, missing icons (#9210)

More of the port's look matches production's VectorCraft, in the parts the app owns.

- Section headings (dialogs, Align, Pathfinder, Separations, …) are regular label text, as production drew them, through one helper instead of per site.
- The Tools rail takes the chrome's Compact density, production's 36×29 cells, so the whole tool column fits again.
- Icons for the names no set had: Fold Preview, the Links panel's status marks, the swatch kinds and Cycle Display Sizes.
- The app catalog leaves Undo, Redo, Cut, Copy, Paste and the panels toggles to the framework's command sets, keeping Cut, Copy and Paste's extra F2/F3/F4 keys outside macOS. This removes the start-up warnings about duplicate definitions.
- Properties: Document Setup and Preferences buttons read without the menu's ellipsis.
- The Control bar and Properties draw the align buttons with the Lucide align glyphs, as production did.

Checks: `vectorcraft-ui-egui` lib tests 3772 passed, 3 failed. The 3 also fail on `main` and are fixed by the coming craft-libs update. Clippy (`vectorcraft-ui-egui`, all targets, `-D warnings`) and `cargo fmt --check` are clean.
This commit is contained in:
BFlat authored and GitHub committed 2026-11-24 14:10:00 +07:00
1 parent 31508bf372
commit 66ed2eec39
28 files changed
+139 -96

No files matched your search

+4
View File
@@ -157,6 +157,7 @@ Generated-in-code art is original and has no file to list. This covers the defau
| `assets/icons/dc-crystallize.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-cube.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-curvature-circle.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (an arch with the circle that touches it at its top, and that circle's center) | MIT OR Apache-2.0 | |
| `assets/icons/dc-cycle-sizes.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (two stacked triangles, a panel's Cycle Display Sizes control) | MIT OR Apache-2.0 | |
| `assets/icons/dc-dash-align.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-dash-exact.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-dimension.svg` | Osama Amin | Original work, drawn for VectorCraft: a dimension line with arrowheads between two extension lines | MIT OR Apache-2.0 | |
@@ -268,7 +269,10 @@ Generated-in-code art is original and has no file to list. This covers the defau
| `assets/icons/dc-stroke-outside.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-stroke.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-swap.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-swatch-global.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a square with a filled corner, a global process color) | MIT OR Apache-2.0 | |
| `assets/icons/dc-swatch-kinds.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-swatch-process.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a square, a process color) | MIT OR Apache-2.0 | |
| `assets/icons/dc-swatch-spot.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a dot in a ring, a spot color) | MIT OR Apache-2.0 | |
| `assets/icons/dc-symbol-sprayer.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-touch-type.svg` | VectorCraft contributors (designed by ham9zah) | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-transform-panel.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
+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="butt" stroke-linejoin="miter"><path d="M5 9H19L12 2Z M5 15H19L12 22Z" fill="currentColor" stroke="none"/></svg>

After

Width:  |  Height:  |  Size: 264 B

+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="butt" stroke-linejoin="miter"><rect x="4.75" y="4.75" width="14.5" height="14.5"/><path d="M20 10V20H10Z" fill="currentColor" stroke="none"/></svg>

After

Width:  |  Height:  |  Size: 300 B

+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="butt" stroke-linejoin="miter"><rect x="4.75" y="4.75" width="14.5" height="14.5"/></svg>

After

Width:  |  Height:  |  Size: 241 B

+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="butt" stroke-linejoin="miter"><circle cx="12" cy="12" r="8.25"/><circle cx="12" cy="12" r="3.25" fill="currentColor" stroke="none"/></svg>

After

Width:  |  Height:  |  Size: 291 B

+1 -2
View File
@@ -15,7 +15,6 @@ use craft::ui::buttons::Button;
use craft::ui::contract::{Bind, Entry, Show as _, ShowContainer as _};
use craft::ui::form::{Field, FieldGroup};
use craft::ui::pickers::Select;
use craft::ui::sections::Section;
use egui::Ui;
use serde_json::{Map, Value, json};
@@ -193,7 +192,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
});
// Inks: Duotone's and Print Ink Fixes' dialogs, as their menu items open them.
let mut ink = None;
Section::fixed(tl!("Inks").to_string()).show(ui, |ui, _| {
crate::panels::section(tl!("Inks").to_string()).show(ui, |ui, _| {
for item in [duotone(), print_fixes()] {
if Button::new(tl!(item.0).to_string()).show(ui).clicked() {
ink = Some(item);
@@ -620,7 +620,7 @@ fn status(blanks: usize, folded: Option<(&Blank, &Folded)>, errors: bool) -> Vec
/// Shows the Fold Preview window: the toolbar, the folded blank, the status lines and the sliders.
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(st) = app.session.active() else {
crate::panels::empty_state(ui, "box", tl!("No document"), tl!("Open a document to preview its folded shape."));
crate::panels::empty_state(ui, "dc-cube", tl!("No document"), tl!("Open a document to preview its folded shape."));
return;
};
let (uid, revision, doc) = (st.uid, st.revision, st.doc.clone());
+1 -2
View File
@@ -9,7 +9,6 @@ use craft::ui::buttons::Button;
use craft::ui::choice::Segmented;
use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _};
use craft::ui::display::{Shade, Text};
use craft::ui::sections::Section;
use egui::Ui;
use serde_json::{Value, json};
use vectorcraft_tools::addons::smart_pen;
@@ -48,7 +47,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let mut curved = shown;
let mut action: Option<(&str, Value)> = None;
let segments = [Entry::new(false, tl!("Straight")).icon(IconId::new("dc-line")), Entry::new(true, tl!("Curved")).icon(IconId::new("spline"))];
Section::fixed(tl!("Next Segment")).show(ui, |ui, _| {
crate::panels::section(tl!("Next Segment")).show(ui, |ui, _| {
Segmented::new(tl!("Next Segment"), Bind::bound(&mut curved), &segments).show(ui);
});
if curved != shown {
+1 -2
View File
@@ -18,7 +18,6 @@ use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _};
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::runtime::env::{LengthUnits, UnitKind};
use craft::ui::sections::Section;
use craft::ui::text::NumberField;
use egui::Ui;
use serde_json::json;
@@ -183,7 +182,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let mut side = conv.side;
let (mut read, mut set) = (false, false);
Section::fixed(tl!("Selection")).show(ui, |ui, _| {
crate::panels::section(tl!("Selection")).show(ui, |ui, _| {
RadioGroup::new(tl!("Side"), Bind::bound(&mut side)).nav(NavShape::Spatial).show(ui, |ui, _| {
Radio::new(Side::Width).label(tl!("Width")).show(ui);
Radio::new(Side::Height).label(tl!("Height")).show(ui);
+4 -4
View File
@@ -27,7 +27,7 @@ use craft::ui::runtime::env::Label;
use craft::ui::runtime::measure;
use craft::ui::runtime::overlay::CloseReason;
use craft::ui::runtime::requests::{ColorRequest, HostAnswer};
use craft::ui::sections::{GroupBox, Section};
use craft::ui::sections::GroupBox;
use craft::ui::style::TypeRole;
use craft::ui::text::{NumberField, TextField};
use egui::{Rect, Ui};
@@ -689,13 +689,13 @@ pub fn properties_section(app: &mut VectorcraftApp, ui: &mut Ui) {
let mut next = o.clone();
let mut edited = Edited::default();
let e = &mut edited;
Section::fixed(tl!("Dimension")).show(ui, |ui, _| {
crate::panels::section(tl!("Dimension")).show(ui, |ui, _| {
units_row(ui, &mut next, e);
precision_row(ui, &mut next, e);
line_row(ui, &mut next, e, Line::Dimension, false);
arrow_style_row(ui, &mut next, e);
Section::fixed(tl!("Extension Lines")).show(ui, |ui, _| line_row(ui, &mut next, e, Line::Extension, false));
Section::fixed(tl!("Dimension Text")).show(ui, |ui, _| text_rows(ui, &mut next, e, false));
crate::panels::section(tl!("Extension Lines")).show(ui, |ui, _| line_row(ui, &mut next, e, Line::Extension, false));
crate::panels::section(tl!("Dimension Text")).show(ui, |ui, _| text_rows(ui, &mut next, e, false));
});
if edited.set {
update(app, id, &next);
@@ -45,7 +45,6 @@ use craft::ui::list::{List, ListRow, ThumbAspect, ThumbSize, ToggleCell, ToggleS
use craft::ui::patterns::form_dialogs::{FormDialog, PathRow};
use craft::ui::primitives::ContentPainterCx;
use craft::ui::runtime::env::Label;
use craft::ui::sections::Section;
use craft::ui::tabs::{Tab, TabKind, TabStrip};
use craft::ui::text::TextField;
use craft::ui::tile_grid::{Tile, TileGrid, TilePartEvent};
@@ -674,10 +673,10 @@ impl ExportForScreensDialog {
}
if text(fields, "tab") != "assets" {
let n = self.doc.as_ref().map_or(0, |s| s.doc.artboards.len());
Section::fixed(tl!("Select:")).show(ui, |ui, _| select_options(ui, fields, n));
crate::panels::section(tl!("Select:")).show(ui, |ui, _| select_options(ui, fields, n));
}
let web = self.web;
Section::fixed(tl!("Export to:")).show(ui, |ui, _| destination(ui, fields, web));
crate::panels::section(tl!("Export to:")).show(ui, |ui, _| destination(ui, fields, web));
pdf_mode(ui, fields);
let presets = self.presets.as_array().map_or(&[][..], Vec::as_slice);
let mut picked = None;
+6 -7
View File
@@ -31,7 +31,6 @@ use craft::ui::patterns::form_dialogs::FormDialog;
use craft::ui::pickers::Select;
use craft::ui::primitives::{Glyph, IconSpec};
use craft::ui::runtime::env::Label;
use craft::ui::sections::Section;
use craft::ui::style::UiTokens;
use craft::ui::text::{NumberField, TextField};
use egui::{Context, Ui};
@@ -810,7 +809,7 @@ fn text_row(ui: &mut Ui, v: &mut GraphTypeValues, key: &str, label: &'static str
fn options_page(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject) {
let kind = graph_kind(v, s);
Section::fixed(tl!("Type")).show(ui, |ui, _| {
crate::panels::section(tl!("Type")).show(ui, |ui, _| {
type_row(ui, v, s);
let sides: &[(&str, &str)] = if s.series.is_empty() { &SIDES } else { &SERIES_SIDES };
let enabled = active(v, s, "valueAxis");
@@ -818,7 +817,7 @@ fn options_page(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject) {
let enabled = active(v, s, "separateScales");
check(ui, v, "separateScales", tl!("Separate Scales"), enabled);
});
Section::fixed(tl!("Style")).show(ui, |ui, _| {
crate::panels::section(tl!("Style")).show(ui, |ui, _| {
Grid::new(TWO).show(ui, |ui, _| {
let rows = [
("dropShadow", tl!("Add Drop Shadow")),
@@ -844,7 +843,7 @@ fn type_options(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject, kind: Gr
if !(columns || lines || pie) {
return;
}
Section::fixed(tl!("Options")).show(ui, |ui, _| {
crate::panels::section(tl!("Options")).show(ui, |ui, _| {
if columns {
let width = if matches!(kind, GraphKind::Bar | GraphKind::StackedBar) { tl!("Bar Width") } else { tl!("Column Width") };
for (key, label) in [("columnWidth", width), ("clusterWidth", tl!("Cluster Width"))] {
@@ -884,7 +883,7 @@ fn type_options(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject, kind: Gr
fn value_page(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject, right: bool) {
let (scale, side) = page_axes(v, s, right);
let own_scale = scale_used(v, s, right);
Section::fixed(tl!("Tick Values")).show(ui, |ui, _| {
crate::panels::section(tl!("Tick Values")).show(ui, |ui, _| {
let (drawn, (lo, hi), count) = shown_scale(v, s, right);
check(ui, v, drawn.overridden, tl!("Override Calculated Values"), own_scale);
let enabled = own_scale && v.bool(scale.overridden);
@@ -893,7 +892,7 @@ fn value_page(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject, right: boo
number_row(ui, v, scale.ticks, tl!("Divisions"), count as f64, &DIVISION_COUNT, enabled);
});
tick_marks(ui, v, side.length, side.marks);
Section::fixed(tl!("Add Labels")).show(ui, |ui, _| {
crate::panels::section(tl!("Add Labels")).show(ui, |ui, _| {
text_row(ui, v, side.prefix, tl!("Prefix"));
text_row(ui, v, side.suffix, tl!("Suffix"));
});
@@ -928,7 +927,7 @@ fn category_page(ui: &mut Ui, v: &mut GraphTypeValues, s: &GraphSubject) {
/// Tick Marks: the length, and the tick marks per division while there are tick marks to draw.
fn tick_marks(ui: &mut Ui, v: &mut GraphTypeValues, length: &str, marks: &str) {
Section::fixed(tl!("Tick Marks")).show(ui, |ui, _| {
crate::panels::section(tl!("Tick Marks")).show(ui, |ui, _| {
choice(ui, v, length, tl!("Length"), &TICK_LENGTHS, true);
let shown = number(v, marks).unwrap_or(1.0);
let enabled = v.str(length) != "none";
@@ -28,7 +28,6 @@ use craft::ui::patterns::presets::{PresetPicker, PresetRow, PresetSource, Preset
use craft::ui::pickers::Select;
use craft::ui::runtime::env::{Label, LengthUnits, UnitKind};
use craft::ui::runtime::overlay::CloseReason;
use craft::ui::sections::Section;
use craft::ui::style::TypeRole;
use craft::ui::text::{NumberField, TextField};
use serde_json::{Value, json};
@@ -263,8 +262,8 @@ impl Pass<'_> {
/// The rows; whether the draft can be accepted. `save` is set when Save Preset… was pressed.
fn body(&self, ui: &mut egui::Ui, draft: &mut GridDraft, picker: &mut PresetState<String>, save: &mut bool) -> bool {
self.name(ui, draft, picker, save);
Section::fixed(word("Perspective Grid Settings")).id_salt("settings").show(ui, |ui, _| self.settings(ui, draft));
Section::fixed(word("Grid Color & Opacity")).id_salt("colors").show(ui, |ui, _| colors(ui, draft));
crate::panels::section(word("Perspective Grid Settings")).id_salt("settings").show(ui, |ui, _| self.settings(ui, draft));
crate::panels::section(word("Grid Color & Opacity")).id_salt("colors").show(ui, |ui, _| colors(ui, draft));
let valid = draft.def.validate();
if let Err(why) = &valid {
Text::new(why.clone()).role(TypeRole::Caption).tone(Tone::Bad).show(ui);
+6 -6
View File
@@ -47,7 +47,7 @@ use craft::ui::notices::{Notice, NoticeLayout};
use craft::ui::patterns::form_dialogs::{FormDialog, ResetFooter, ResetPick};
use craft::ui::runtime::env::{Label, LengthUnits};
use craft::ui::runtime::overlay::CloseReason;
use craft::ui::sections::{DialogRole, FooterButton, Section};
use craft::ui::sections::{DialogRole, FooterButton};
use craft::ui::text::{NumberField, link_toggle};
use serde_json::{Value, json};
use vectorcraft_doc::{Unit, WidthProfile};
@@ -449,9 +449,9 @@ fn body(ui: &mut egui::Ui, form: &mut Form, lengths: LengthUnits, refusal: Optio
};
match out {
Some((_, out)) => {
Section::fixed(titles[0].clone()).show(ui, |ui, _| rows(ui, &titles[0], sides));
Section::fixed(titles[1].clone()).show(ui, |ui, _| rows(ui, &titles[1], out));
Section::fixed(word(tl!("Single Width Only"))).show(ui, |ui, _| {
crate::panels::section(titles[0].clone()).show(ui, |ui, _| rows(ui, &titles[0], sides));
crate::panels::section(titles[1].clone()).show(ui, |ui, _| rows(ui, &titles[1], out));
crate::panels::section(word(tl!("Single Width Only"))).show(ui, |ui, _| {
RadioGroup::new(word(tl!("Single Width Only")), Bind::bound(single)).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
for (choice, text) in
@@ -477,8 +477,8 @@ fn body(ui: &mut egui::Ui, form: &mut Form, lengths: LengthUnits, refusal: Optio
}
};
if *discontinuous {
Section::fixed(titles[0].clone()).show(ui, |ui, _| rows(ui, 0));
Section::fixed(titles[1].clone()).show(ui, |ui, _| rows(ui, 1));
crate::panels::section(titles[0].clone()).show(ui, |ui, _| rows(ui, 0));
crate::panels::section(titles[1].clone()).show(ui, |ui, _| rows(ui, 1));
} else {
rows(ui, 0);
}
+3 -3
View File
@@ -20,7 +20,7 @@ use craft::ui::layout_components::Stack;
use craft::ui::list::{List, ListRow};
use craft::ui::pickers::Select;
use craft::ui::primitives::IconSpec;
use craft::ui::sections::{DialogRole, FooterButton, HeaderStrength, Section};
use craft::ui::sections::{DialogRole, FooterButton};
use craft::ui::text::TextField;
use egui::{Context, Ui};
use serde_json::{Value, json};
@@ -513,7 +513,7 @@ impl StackDialog for FindFontDialog {
let row_text = |at: usize| shown.get(at).and_then(|&i| rows.get(i)).map_or_else(String::new, |r| row_label(&r.family, &r.style));
let out = Dialog::new(tl!("Find Font").to_string()).buttons(buttons).show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
Section::fixed(heading.clone()).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(heading.clone()).show(ui, |ui, _| {
let docs = Lines { len: count, text: &doc_text };
List::<usize>::new(tl!("Fonts in Document").to_string())
.select(SelectMode::Single)
@@ -526,7 +526,7 @@ impl StackDialog for FindFontDialog {
if offer_folder {
folder = clicked(&Button::new(tl!("Find in Folder…").to_string()).show(ui));
}
Section::fixed(tl!("Replace With Font").to_string()).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Replace With Font").to_string()).show(ui, |ui, _| {
Field::new(tl!("Replace With Font From").to_string()).show(ui, |ui, _| {
let edit = Select::new(tl!("Replace With Font From").to_string(), Bind::given(source), &source_entries).show(ui);
new_source = edit.events.value().copied();
+4
View File
@@ -69,6 +69,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
("dc-crystallize", include_bytes!("../../../assets/icons/dc-crystallize.svg")),
("dc-cube", include_bytes!("../../../assets/icons/dc-cube.svg")),
("dc-curvature-circle", include_bytes!("../../../assets/icons/dc-curvature-circle.svg")),
("dc-cycle-sizes", include_bytes!("../../../assets/icons/dc-cycle-sizes.svg")),
("dc-dash-align", include_bytes!("../../../assets/icons/dc-dash-align.svg")),
("dc-dash-exact", include_bytes!("../../../assets/icons/dc-dash-exact.svg")),
("dc-dimension", include_bytes!("../../../assets/icons/dc-dimension.svg")),
@@ -180,7 +181,10 @@ pub static ICONS: &[(&str, &[u8])] = &[
("dc-stroke-inside", include_bytes!("../../../assets/icons/dc-stroke-inside.svg")),
("dc-stroke-outside", include_bytes!("../../../assets/icons/dc-stroke-outside.svg")),
("dc-swap", include_bytes!("../../../assets/icons/dc-swap.svg")),
("dc-swatch-global", include_bytes!("../../../assets/icons/dc-swatch-global.svg")),
("dc-swatch-kinds", include_bytes!("../../../assets/icons/dc-swatch-kinds.svg")),
("dc-swatch-process", include_bytes!("../../../assets/icons/dc-swatch-process.svg")),
("dc-swatch-spot", include_bytes!("../../../assets/icons/dc-swatch-spot.svg")),
("dc-symbol-sprayer", include_bytes!("../../../assets/icons/dc-symbol-sprayer.svg")),
("dc-touch-type", include_bytes!("../../../assets/icons/dc-touch-type.svg")),
("dc-transform-panel", include_bytes!("../../../assets/icons/dc-transform-panel.svg")),
+37 -1
View File
@@ -11,7 +11,9 @@ use craft::menu::{Item, LayoutOptions, Menu, MenuBar, MenuRole, Node, Target, la
use craft::tracked::Tracked;
use craft::ui::list::ThumbAspect;
use craft::ui::menu::Alternate;
use craft::ui::runtime::commands::{AppCatalog, CommandGate, CommandInput, CommandState, CommandStates};
use craft::ui::runtime::commands::{
AppCatalog, ChromeCommand, CommandGate, CommandInput, CommandSet as _, CommandState, CommandStates, EditCommands,
};
use craft::ui::runtime::windows::WindowHost;
use serde_json::{Value, json};
@@ -243,11 +245,13 @@ fn rebuild(app: &mut VectorcraftApp, target: Target) {
let options = LayoutOptions::new(APP_NAME).label(&translate_label);
let laid = layout(&bar, target, &options).bar;
let type_keys = crate::type_editing::app_keys(&defs, &app.shortcut_overrides);
let (defs, linked_keys) = without_linked(defs);
match AppCatalog::new(defs, generation(&listed, &crate::panels::actions::function_keys(&app.ui.actions), &type_keys)) {
Ok(catalog) => {
// While a text field has the keys no shortcut runs, as in production; the text-editing chords still edit it,
// and the Type tool's commands run while it types.
let catalog = catalog.typing_rule(TypingRule::AllWait);
let catalog = linked_keys.into_iter().fold(catalog, |catalog, (id, keys)| catalog.replace_defaults(id, keys));
let catalog = UNROUTED.iter().fold(catalog, |catalog, id| catalog.replace_defaults(id.as_str(), Vec::new()));
app.menus.catalog = Some(type_keys.into_iter().fold(catalog, |catalog, (id, keys)| catalog.replace_defaults(id, keys)));
}
@@ -306,6 +310,38 @@ fn catalog_defs(app: &VectorcraftApp, refs: &[(CommandRef, String, bool)], state
defs
}
/// `defs` without the commands a linked framework set defines (Undo, Redo, Cut, Copy, Paste and Tab's panels toggles):
/// the set's definition is the command's. With them, the keys each has beyond the set's, as the set's keys and those
/// (Cut, Copy and Paste's F2, F3 and F4 outside macOS).
fn without_linked(defs: Vec<CommandDef>) -> (Vec<CommandDef>, Vec<(String, Vec<Binding>)>) {
let mut own = Vec::with_capacity(defs.len());
let mut keys = Vec::new();
for def in defs {
let Some(mut set_keys) = linked_defaults(&def.command) else {
own.push(def);
continue;
};
let extra: Vec<Binding> = def.defaults.into_iter().filter(|key| !set_keys.contains(key)).collect();
if !extra.is_empty() {
set_keys.extend(extra);
keys.push((def.command.id, set_keys));
}
}
(own, keys)
}
/// The default keys of `command` when a linked framework set defines it.
fn linked_defaults(command: &CommandRef) -> Option<Vec<Binding>> {
let defs = if EditCommands::from_ref(command).is_some() {
EditCommands::defs()
} else if ChromeCommand::from_ref(command).is_some() {
ChromeCommand::defs()
} else {
return None;
};
defs.ok()?.into_iter().find(|def| def.command.id == command.id).map(|def| def.defaults)
}
/// The state of the row `command`, named `label` in the catalog: on or dimmed with its reason, checked, and its title
/// where the app shows another.
fn row_state(app: &VectorcraftApp, command: &CommandRef, label: &str) -> CommandState {
+2 -3
View File
@@ -1131,7 +1131,7 @@ impl Specs {
let grids = layout_of(&app.ui)
.panels()
.into_iter()
.filter_map(|panel| rail_owner(&app.ui, panel).map(|owner| (panel.clone(), crate::toolbar::dock_grid(app, &owner, app.ui_ctx.as_ref()))))
.filter_map(|panel| rail_owner(&app.ui, panel).map(|owner| (panel.clone(), crate::toolbar::dock_grid(app, &owner))))
.collect();
Specs {
lang: crate::i18n::current().code(),
@@ -1234,8 +1234,7 @@ impl DockPanels<String> for Panels<'_> {
fn group_header(&mut self, panels: &[String], active: usize, ui: &mut egui::Ui, _cx: &mut BodyCx<'_>) {
let Some(panel) = panels.get(active).filter(|p| sizes::has_sizes(p)) else { return };
// PLAN: the cycle control's icon (two stacked triangles) is not an app asset yet; `cycle-sizes` names it for whoever draws it.
IconButton::command(IconId::new("cycle-sizes"), CommandRef::with_params("window.panel.cycleOptions", json!({"panel": panel}))).show(ui);
IconButton::command(IconId::new("dc-cycle-sizes"), CommandRef::with_params("window.panel.cycleOptions", json!({"panel": panel}))).show(ui);
}
fn panel_rows(&mut self, panel: &String) -> Vec<PanelRow> {
+12 -4
View File
@@ -75,6 +75,7 @@ use craft::ui::popover::Popover;
use craft::ui::primitives::IconSpec;
use craft::ui::runtime::commands::CommandStates;
use craft::ui::runtime::env::Label;
use craft::ui::sections::{HeaderStrength, Section};
use craft::ui::text::{NumberField, link_toggle};
use egui::Ui;
use serde_json::{Value, json};
@@ -244,9 +245,10 @@ 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, and each tool's, which the tool rail and its flyouts show. `None` for every other command.
/// The icon the command catalog gives command `id`: the Align panel's distribute and Align To
/// buttons' (its align buttons' as the Control bar draws them, [`align::bar_glyph`]) and the
/// Pathfinder panel's, so a bar or menu row of the command shows the panel's 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:") {
@@ -264,7 +266,7 @@ pub(crate) fn command_icon(id: &str) -> Option<&'static str> {
}
let in_table = |table: &[(&'static str, &str, &str, &str)], axis: &str, v: &str| table.iter().find(|r| r.2 == axis && r.3 == v).map(|r| r.0);
match align::button(id)? {
Button::Align(axis, v) => in_table(&align::ALIGN, axis, v),
b @ Button::Align(..) => align::bar_glyph(b),
Button::AlignCenters => Some("dc-al-center"),
Button::Distribute(axis, v) => in_table(&align::DISTRIBUTE, axis, v),
Button::Spacing("vertical") => Some("dc-dist-vspace"),
@@ -893,6 +895,12 @@ pub(crate) fn whole_steps(range: std::ops::RangeInclusive<f64>) -> ChannelRule {
rule
}
/// A section of a panel or dialog under its heading in label text: the reference app's section headings are regular
/// weight, not bold.
pub(crate) fn section<'a>(title: impl Into<Label>) -> Section<'a> {
Section::fixed(title).strength(HeaderStrength::Normal)
}
/// The empty state of a panel with nothing to show: `icon` over the title and the message,
/// centred in the panel.
pub(crate) fn empty_state(ui: &mut Ui, icon: &'static str, title: &str, body: &str) {
+23 -6
View File
@@ -10,7 +10,6 @@ use craft::ui::buttons::{IconButton, PopupMark, ToggleButton};
use craft::ui::contract::{Bind, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
use craft::ui::menu::{Menu, MenuItem, PanelRow};
use craft::ui::runtime::commands::{CommandState, CommandStates};
use craft::ui::sections::{HeaderStrength, Section};
use craft::ui::text::NumberField;
use egui::Ui;
use serde::Serialize;
@@ -100,6 +99,24 @@ pub const ALIGN: [(&str, &str, &str, &str); 6] = [
("dc-al-bottom", "Vertical Align Bottom", "vertical", "bottom"),
];
/// The glyphs of [`ALIGN`]'s buttons, in its order, in the Control bar and the Properties panel: the reference app drew
/// them there with Lucide's align glyphs, and only the Align panel with its own.
const BAR_ALIGN: [&str; 6] = [
"align-start-vertical",
"align-center-vertical",
"align-end-vertical",
"align-start-horizontal",
"align-center-horizontal",
"align-end-horizontal",
];
/// The glyph of align button `b` in the Control bar and the Properties panel ([`BAR_ALIGN`]); `None` for the other
/// buttons, which draw the panel's glyph there too.
pub(crate) fn bar_glyph(b: Button) -> Option<&'static str> {
let Button::Align(axis, v) = b else { return None };
ALIGN.iter().position(|r| r.2 == axis && r.3 == v).map(|i| BAR_ALIGN[i])
}
pub const DISTRIBUTE: [(&str, &str, &str, &str); 6] = [
("dc-dist-top", "Vertical Distribute Top", "vertical", "top"),
("dc-dist-vcenter", "Vertical Distribute Center", "vertical", "center"),
@@ -289,7 +306,7 @@ fn bar_items(buttons: impl Iterator<Item = Button>) -> BarItems {
pub(crate) fn align_buttons(_app: &mut VectorcraftApp, ui: &mut Ui) {
ui.horizontal(|ui| {
for (icon, b) in align_icons() {
command_button(ui, icon, b);
command_button(ui, bar_glyph(b).unwrap_or(icon), b);
}
});
}
@@ -479,14 +496,14 @@ pub(crate) fn run_align_to(app: &mut VectorcraftApp, v: AlignTo) -> Result<Value
/// Spacing with its value and Align To. The buttons are commands, so their state and clicks come
/// from the command layer ([`button_enabled`], [`run_button`]).
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
Section::fixed(tl!("Align Objects:")).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Align Objects:")).show(ui, |ui, _| {
ui.horizontal(|ui| {
for (icon, b) in align_icons() {
command_button(ui, icon, b);
}
});
});
Section::fixed(tl!("Distribute Objects:")).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Distribute Objects:")).show(ui, |ui, _| {
ui.horizontal(|ui| {
for (icon, b) in distribute_icons() {
command_button(ui, icon, b);
@@ -504,7 +521,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let lengths = crate::canvas::general_lengths(app);
let min_spacing = spacing_min(app);
let mut edited = None;
Section::fixed(tl!("Distribute Spacing:")).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Distribute Spacing:")).show(ui, |ui, _| {
ui.horizontal(|ui| {
command_button(ui, "dc-dist-vspace", Button::Spacing("vertical"));
command_button(ui, "dc-dist-hspace", Button::Spacing("horizontal"));
@@ -519,7 +536,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
if let Some(v) = edited {
app.ui.align_spacing = v;
}
Section::fixed(tl!("Align To:")).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Align To:")).show(ui, |ui, _| {
// With one object selected the buttons align it to the artboard, and Align To shows Artboard.
let anchor = key_is_anchor(app);
ui.horizontal(|ui| {
+2 -2
View File
@@ -47,7 +47,7 @@ use craft::ui::notices::{Notice, NoticeIcon, NoticeLayout};
use craft::ui::pickers::Select;
use craft::ui::primitives::IconSpec;
use craft::ui::runtime::commands::{CommandState, CommandStates};
use craft::ui::sections::{DropAction, FooterAction, FooterBar, Section};
use craft::ui::sections::{DropAction, FooterAction, FooterBar};
use craft::ui::tile_grid::{BadgeKind, BadgeSlot, Tile, TileBadge, TileGrid};
use egui::{Color32, Rect, Ui};
use serde_json::{Map, Value, json};
@@ -524,7 +524,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let (mut export_clicked, mut footer, mut screens) = (false, None, false);
// The grid takes the room the settings, Export and the footer bar leave.
let footed = Stack::new().fill().footer(|ui, _| {
Section::fixed(tl!("Export Settings")).show(ui, |ui, _| {
crate::panels::section(tl!("Export Settings")).show(ui, |ui, _| {
let (change, files_each) = settings(ui, st);
(seen.change, seen.files_each) = (change, files_each);
seen.format_3d = format_3d(ui, st, &sel_or_all(&shown_sel, &all));
+5 -5
View File
@@ -31,7 +31,7 @@ use craft::ui::form::Field;
use craft::ui::list::{List, ListRow, ThumbSize};
use craft::ui::menu::{Menu, MenuItem, PanelRow};
use craft::ui::runtime::commands::{CommandState, CommandStates};
use craft::ui::sections::{FooterAction, FooterBar, Panel, Section};
use craft::ui::sections::{FooterAction, FooterBar, Panel};
use egui::Ui;
use serde_json::{Value, json};
use vectorcraft_doc::NodeId;
@@ -586,8 +586,8 @@ fn mask_name(app: &VectorcraftApp, doc: &vectorcraft_doc::Document, cache: &Cach
/// The icon of a row's status mark.
fn status_icon(status: &str) -> &'static str {
match status {
"missing" => "circle-help",
"modified" => "triangle-alert",
"missing" => "dc-help",
"modified" => "warning",
"embedded" => "image",
_ => "link",
}
@@ -782,7 +782,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
row = row.trailing(page.to_string());
}
if r["dcsTransparency"] == true {
row = row.trailing_icon(IconId::new("triangle-alert"), tip.clone());
row = row.trailing_icon(IconId::new("warning"), tip.clone());
}
row.trailing_icon(IconId::new(status_icon(r["status"].as_str().unwrap_or_default())), tip)
});
@@ -920,7 +920,7 @@ fn info_row(ui: &mut Ui, label: &'static str, value: String) {
/// The Link Info section: the details of `info` (`links.info`), or a hint.
fn link_info(ui: &mut Ui, info: Option<&Value>, units: vectorcraft_doc::Unit) {
Section::fixed(tl!("Link Info")).show(ui, |ui, _| {
crate::panels::section(tl!("Link Info")).show(ui, |ui, _| {
let Some(i) = info else {
Text::new(tl!("Select an image to see its Link Info.")).shade(Shade::Muted).show(ui);
return;
+2 -3
View File
@@ -12,7 +12,6 @@ use craft::ui::menu::PanelRow;
use craft::ui::primitives::{Glyph, IconSpec, paint_icon};
use craft::ui::runtime::commands::{CommandState, CommandStates};
use craft::ui::runtime::env::Direction;
use craft::ui::sections::{HeaderStrength, Section};
use craft::ui::style::UiTokens;
use egui::{Align2, Color32, FontId, Painter, Rect, Stroke, Ui, vec2};
use serde_json::{Value, json};
@@ -133,7 +132,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let mixed = !modes.is_empty() && shared.is_none();
// Selected members can always take a mode.
let count = if modes.is_empty() { n } else { n.max(2) };
Section::fixed(tl!("Shape Modes:")).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Shape Modes:")).show(ui, |ui, _| {
Row::new().gap(Gap::Item).show(ui, |ui, _| {
for ((icon, label, op), mode) in SHAPE_MODES.into_iter().zip(ShapeMode::ALL) {
let glyph = ShapeModeGlyph { icon: IconId::new(icon), mixed };
@@ -154,7 +153,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
.show(ui);
});
});
Section::fixed(tl!("Pathfinders:")).strength(HeaderStrength::Caption).show(ui, |ui, _| {
crate::panels::section(tl!("Pathfinders:")).show(ui, |ui, _| {
Row::new().gap(Gap::Item).show(ui, |ui, _| {
for (icon, label, op) in PATHFINDERS {
IconButton::command(IconSpec::svg(IconId::new(icon)), CommandRef::new(format!("object.pathfinder.{op}")))
+1 -7
View File
@@ -7,12 +7,11 @@ use craft::ui::layout_components::{Grid, Row, Stack};
use craft::ui::patterns::panels::Inspector;
use craft::ui::runtime::commands::CommandRef;
use craft::ui::sections::{HeaderStrength, Section};
use egui::Ui;
use serde_json::json;
use vectorcraft_doc::{LiveShape, Node, NodeKind};
use super::first_selected;
use super::{first_selected, section};
use crate::VectorcraftApp;
/// Run-only state of the Properties panel.
@@ -68,11 +67,6 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
});
}
/// 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> {
@@ -34,7 +34,7 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
Grid::new(&HALVES).show(ui, |ui, _| {
Button::command(CommandRef::new("file.documentSetup")).sizing(Sizing::FillWidth).show(ui);
Button::command(CommandRef::new("file.documentSetup")).label(tl!("Document Setup")).sizing(Sizing::FillWidth).show(ui);
Button::command(CommandRef::with_params("tool.select", json!({ "tool": "artboard" })))
.label(tl!("Edit Artboards"))
.sizing(Sizing::FillWidth)
@@ -90,8 +90,9 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut 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);
// The reference panel's buttons name the dialog without the menu's ellipsis.
for (command, label) in [("file.documentSetup", tl!("Document Setup")), ("edit.preferences", tl!("Preferences"))] {
Button::command(CommandRef::new(command)).label(label).sizing(Sizing::FillWidth).show(ui);
}
});
});
+3 -4
View File
@@ -25,7 +25,6 @@ use craft::ui::notices::Notice;
use craft::ui::pickers::Select;
use craft::ui::runtime::commands::{CommandState, CommandStates};
use craft::ui::runtime::env::Label;
use craft::ui::sections::Section;
use egui::{Color32, Ui};
use serde_json::{Value, json};
use vectorcraft_color::cms::{self, Intent, Policy, ProfileKind};
@@ -423,10 +422,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
// pass (not a sizing one) spends it.
let reveal = app.ui.color_settings_scroll;
Stack::new().label(tl!("Separations Preview")).show(ui, |ui, _| {
Section::fixed(tl!("Separations Preview")).show(ui, |ui, _| plates_section(app, ui));
Section::fixed(tl!("Proof Setup")).show(ui, |ui, _| proof_section(app, ui));
crate::panels::section(tl!("Separations Preview")).show(ui, |ui, _| plates_section(app, ui));
crate::panels::section(tl!("Proof Setup")).show(ui, |ui, _| proof_section(app, ui));
Lazy::new("color-settings", COLOR_SETTINGS_ESTIMATE).reveal(reveal).show(ui, |ui| {
Section::fixed(tl!("Color Settings")).show(ui, |ui, _| settings_rows(app, ui));
crate::panels::section(tl!("Color Settings")).show(ui, |ui, _| settings_rows(app, ui));
});
});
if reveal && !ui.is_sizing_pass() {
+1 -1
View File
@@ -268,7 +268,7 @@ pub const ICON_PANELS: &[(&str, &str, &str)] = &[
(crate::addons::cleanup::ID, "Artwork Cleanup", "sparkles"),
(crate::addons::color::ID, "Color Effects", "sun"),
(crate::addons::packaging::ID, "Fold Lines", "scissors"),
(crate::addons::packaging::preview::ID, "Fold Preview", "box"),
(crate::addons::packaging::preview::ID, "Fold Preview", "dc-cube"),
(crate::addons::pathtools::ID, "Anchor Inspector", "dc-anchor-smooth"),
(crate::addons::pathtools::shape::ID, "Parametric Shape", "hexagon"),
(crate::addons::pen::ID, "Smart Pen", "spline-pointer"),
+8 -24
View File
@@ -14,18 +14,17 @@ use craft::behavior::overlay::Side;
use craft::behavior::{EditEvent, IconId, Mixed};
use craft::color_ui::ui::PaintChip;
use craft::draw::ui::transform::{SizeUnit, TransformField, TransformFields, TransformGroups, TransformRow, TransformSource};
use craft::theme::{ControlSize, Size};
use craft::theme::ControlSize;
use craft::ui::buttons::{Button, IconButton};
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, BodyCx, Entry, Gap, Props as _, Show as _, ShowContainer as _, ThemeScope, Tracked};
use craft::ui::contract::{Bind, BodyCx, Entry, Gap, Props as _, Show as _, ShowContainer as _, Tracked};
use craft::ui::display::Divider;
use craft::ui::docking::{DockGrid, DockSizes, GroupAt};
use craft::ui::docking::{DockGrid, GroupAt};
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::pickers::{Anchor9, ReferencePointLook, Select};
use craft::ui::rails::{LastUsed, RailFooter, RailTool, SlotId, ToolRail, ToolSlot};
use craft::ui::runtime::commands::{self, CommandRef};
use craft::ui::style::StyleCx;
use craft::ui::text::NumberField;
use egui::{Pos2, Ui, Vec2};
use serde_json::{Value, json};
@@ -254,28 +253,14 @@ fn strip_tools(app: &VectorcraftApp, parent: &Owner, first: &str) -> Vec<&'stati
groups_of(app, parent).into_iter().find(|g| g.first().is_some_and(|f| *f == first)).unwrap_or_default()
}
/// The density the rail of `owner` draws at. The app's chrome is at the compact density: the Tools panel steps up to
/// the comfortable one unless its own compact setting is on, as production's larger Tools cells did; named toolbars
/// and strips keep the chrome's.
fn rail_scope(app: &VectorcraftApp, owner: &Owner) -> ThemeScope {
match owner {
Owner::Tools => ThemeScope::new().density(if app.ui.toolbar_compact { Size::Compact } else { Size::Comfortable }),
_ => ThemeScope::new(),
}
}
/// The dock grid of the rail panel `owner`: a cell for each of its slots and its Edit Toolbar button, in the density
/// its rail draws at, so the dock column's steps fit its buttons. Without `ctx` the dock resolves it in its own.
pub(crate) fn dock_grid(app: &VectorcraftApp, owner: &Owner, ctx: Option<&egui::Context>) -> DockGrid {
/// The dock grid of the rail panel `owner`: a cell for each of its slots and its Edit Toolbar button. Its rail draws at
/// the chrome's density, so the dock resolves the grid's steps in its own.
pub(crate) fn dock_grid(app: &VectorcraftApp, owner: &Owner) -> DockGrid {
let cells = match owner {
Owner::Strip(parent, first) => strip_tools(app, parent, first).len(),
_ => groups_of(app, owner).len() + 1,
};
let grid = DockGrid::rail(cells);
match ctx {
Some(ctx) => grid.resolved(&StyleCx::with_root_scoped(ctx, &rail_scope(app, owner), DockSizes::style)),
None => grid,
}
DockGrid::rail(cells)
}
/// The groups of several tools of the Tools panel's toolbar (`toolbar` none) or of the toolbar made
@@ -396,14 +381,13 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m
let tools_panel = owner == Owner::Tools;
let own_bar = !matches!(owner, Owner::Strip(..));
let opens = opens(app, &owner);
let scope = rail_scope(app, &owner);
// A Learn link's tool on this rail wears the mark; the pass that shows the rail scrolls its slot into view and opens
// its flyout, once.
let home = Home::Rail(&owner);
let located = locate::wanted(&app.ui, &home);
let holds = |tool: &str| model.slots.iter().any(|slot| slot.tools.iter().any(|t| t.id == tool));
let reveal = matches!(at, GroupAt::Show(_)).then(|| locate::take_reveal(&mut app.ui, &home, holds)).flatten();
let mut rail = ToolRail::new(tl!("Tools"), &model.slots, &current, &model.last_used).opens(opens).theme(scope).tips(&cards);
let mut rail = ToolRail::new(tl!("Tools"), &model.slots, &current, &model.last_used).opens(opens).tips(&cards);
if let Some(tool) = &located {
rail = rail.mark(tool);
}