Look like production: title bar, command search, switcher, status bar, rail card, option links (#9220)

More of the window's chrome looks like production's VectorCraft, through craft-libs options already on the app's pin.

- **Title bar:** drawn on the background surface, as production's app bar was. Its trailing items leave by rank as the window narrows (Discord, then Learn, then Arrange, then the search) before the menus fold, as production's did.
- **Search:** the command search is a field (`CommandSearch`).
- **Workspace switcher:** quiet, and as wide as the workspace it shows.
- **Menus:** menu titles sit closer together (`MenuTitlePad::Control`).
- **Document tab:** the unsaved mark follows the document's name: "Untitled-1* @ 92 % (RGB/Preview)".
- **Status bar:** the position and timings sit at the bar's end and leave first when it narrows.
- **Tools rail:** shown as a card on the dock's background (`rail_cards`). Window › Toolbars › Compact packs it densely.
- **Option links** ("Opacity:", "Style:", "Character:" and the Appearance list's links) are drawn in the normal ink with an underline, as production drew them. Links that leave the panel's subject keep the accent. The Stroke field's label link still takes the accent; it needs a framework option and follows separately.

Tests: the app-bar fit test now expects the search field to keep its width until it drops; production narrowed it to its icon first. A framework option for a ranked unit with a short form is an open follow-up.

Checks: `vectorcraft-ui-egui` lib tests 3780 passed, 0 failed. Clippy (`vectorcraft-ui-egui`, `vectorcraft`, all targets, `-D warnings`) and `cargo fmt --check` are clean.
This commit is contained in:
BFlat
2026-11-24 17:36:14 +07:00
committed by GitHub
parent e9ddb9dad7
commit 4fbca02f5b
14 changed files with 94 additions and 91 deletions
+3
View File
@@ -5,6 +5,7 @@ use craft::platform::clock::monotonic_ms;
use craft::theme::variant::Tone;
use craft::ui::buttons::{ActiveLook, PushButtonLook};
use craft::ui::contract::{Bind, GlyphColon};
use craft::ui::menu::MenuTitlePad;
use craft::ui::runtime::env::{RootEnv, Scale, ScrubDrags, WindowKey};
use craft::ui::runtime::frame::{FrameInput, FrameOutput};
use craft::ui::runtime::toast::{self, Toast};
@@ -676,6 +677,8 @@ pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32) -> Ro
// A glyph that stands for a word caption ("X", "W") takes a form's colon as production drew it ("X:"); "#" and
// the colour channel letters stay bare.
root.values.set(GlyphColon::Form);
// The menu bar's titles stand as close as production's, which share the line with the bar's other controls.
root.values.set(MenuTitlePad::Control);
// A bare Tab on the canvas, or with nothing focused, toggles the panels (`window.dock`) instead of moving focus.
root.tab_toggles_chrome = true;
// Escape in a text field gives up its focus, reverting any typing, so the next keys are the window's.
+28 -47
View File
@@ -4,17 +4,16 @@ use std::borrow::Cow;
use std::cell::RefCell;
use craft::behavior::IconId;
use craft::behavior::fit::{FitItem, FitKeep, fit_items};
use craft::menu::MenuBarUi;
use craft::ui::buttons::{Button, ButtonChord, IconButton, PopupMark, ToggleButton};
use craft::ui::buttons::{Button, CommandSearch, 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;
use craft::ui::layout_components::Row;
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::primitives::{HAlign, IconSpec};
use craft::ui::primitives::IconSpec;
use craft::ui::runtime::windows::WindowHost;
use craft::ui::shell::{Frame, Title, TitleBar};
use craft::ui::style::Variant;
use craft::ui::style::{SurfaceKind, Variant};
use egui::Ui;
use serde_json::json;
@@ -69,18 +68,21 @@ enum Trailing {
impl Trailing {
/// The controls in the order they are drawn.
const SHOWN: [Trailing; 6] = [Trailing::Discord, Trailing::Learn, Trailing::Search, Trailing::Arrange, Trailing::Safe, Trailing::Switcher];
/// The controls in the order the fit gives them up, last first: each is also in a menu, so a hidden one goes nowhere.
const DROPPED_LAST_FIRST: [Trailing; 6] =
[Trailing::Safe, Trailing::Switcher, Trailing::Search, Trailing::Arrange, Trailing::Learn, Trailing::Discord];
/// Whether the fit may drop it.
fn keep(self) -> FitKeep {
if matches!(self, Trailing::Safe | Trailing::Switcher) { FitKeep::Pinned } else { FitKeep::Free }
/// The rank the bar gives it up in, lowest first: Discord, tutorials, Arrange Documents, then the search. Each is
/// also in a menu, so a hidden one goes nowhere. Safe Mode and the switcher always show.
fn rank(self) -> Option<u8> {
match self {
Trailing::Discord => Some(1),
Trailing::Learn => Some(2),
Trailing::Arrange => Some(3),
Trailing::Search => Some(4),
Trailing::Safe | Trailing::Switcher => None,
}
}
/// Shows the control, in its shorter form when `short` (the search as its icon); the fit measures it through the
/// same call.
fn show(self, app: &mut VectorcraftApp, ui: &mut Ui, short: bool) {
/// Shows the control.
fn show(self, app: &mut VectorcraftApp, ui: &mut Ui) {
match self {
Trailing::Safe => {
let shown = Button::new(tl!("Safe Mode")).variant(Variant::GHOST).tooltip(tl!("Safe Mode…")).show(ui);
@@ -97,19 +99,9 @@ impl Trailing {
.show(ui);
}
Trailing::Arrange => arrange_documents(app, ui),
Trailing::Search if short => {
IconButton::command(IconId::new("search"), PALETTE).label(tl!("Search commands")).show(ui);
}
// Named as production's field, not after the command's menu row.
Trailing::Search => {
// PLAN: assumed `Button::command` is bound by a `&str` command id; the command opens the palette.
// Named as production's field, not after the command's menu row.
Button::command(PALETTE)
.label(tl!("Search commands"))
.icon(IconSpec::svg(IconId::new("search")))
.variant(Variant::SECONDARY)
.align(HAlign::Start)
.chord(ButtonChord::Trailing)
.show(ui);
CommandSearch::new(PALETTE, tl!("Search commands")).show(ui);
}
// PLAN: assumed `crate::workspaces::switcher(app: &mut VectorcraftApp, ui: &mut Ui)` (chrome-w14's `WorkspaceSwitcher`).
Trailing::Switcher => crate::workspaces::switcher(app, ui),
@@ -171,29 +163,18 @@ fn leading(ui: &mut Ui, app: &mut VectorcraftApp) {
}
}
/// The end of the bar: the controls that fit in the room, the first-listed going last.
/// The end of the bar: each ranked control in a row of its own, which the fitted title bar gives up whole, lowest rank
/// first, before the menus narrow.
fn trailing(ui: &mut Ui, app: &mut VectorcraftApp) {
let safe = vectorcraft_plugins::safe_mode::active();
let order: Vec<Trailing> = Trailing::DROPPED_LAST_FIRST.into_iter().filter(|t| safe || *t != Trailing::Safe).collect();
let gap = ui.spacing().item_spacing.x;
let room = ui.available_width();
let mut measure = |t: Trailing, short: bool| measure_slot(ui, room, |ui| t.show(app, ui, short)).x;
let items: Vec<FitItem> = order
.iter()
.map(|&t| {
let item = FitItem::new(measure(t, false), 0, t.keep());
// The search narrows to its icon before it goes.
if t == Trailing::Search { item.short(measure(t, true)) } else { item }
})
.collect();
let fit = fit_items(&items, room, gap, gap, 0.0);
ui.horizontal_centered(|ui| {
for t in Trailing::SHOWN {
if let Some(at) = order.iter().position(|o| *o == t).filter(|at| fit.shown.contains(at)) {
t.show(app, ui, fit.short.contains(&at));
for t in Trailing::SHOWN.into_iter().filter(|t| safe || *t != Trailing::Safe) {
match t.rank() {
Some(rank) => {
Row::new().fit_rank(rank).show(ui, |ui, _| t.show(app, ui));
}
None => t.show(app, ui),
}
});
}
}
/// The application bar, the body of the shell's title bar: brand mark, Home and menus, then Discord,
@@ -207,9 +188,9 @@ pub fn app_bar(ui: &mut Ui, _cx: &mut BodyCx<'_>, app: &mut VectorcraftApp) {
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)
TitleBar::new().surface(SurfaceKind::Background).show_titled(ui, Title::new(tl!("VectorCraft")), start, end)
} else {
TitleBar::new().trailing(end).show(ui, start).output
TitleBar::new().surface(SurfaceKind::Background).show_fitted(ui, start, end)
};
}
+3 -3
View File
@@ -1,6 +1,6 @@
use craft::behavior::IconId;
use craft::ui::bars::{Bar, BarKind};
use craft::ui::buttons::{Button, IconButton, Link};
use craft::ui::buttons::{Button, IconButton};
use craft::ui::contract::{Bind, PopupKind, Props as _, Show as _, ShowContainer as _, SideLabel, Trigger};
use craft::ui::display::{Divider, Elide, Shade, Text};
use craft::ui::form::Field;
@@ -323,7 +323,7 @@ fn opacity_field(app: &mut VectorcraftApp, ui: &mut Ui, opacity: f32, selected:
fn style_group(app: &mut VectorcraftApp, ui: &mut Ui) {
let mut open = false;
ranked(ui, rank::GROUP, |ui| {
open |= Link::new(tl!("Style:")).show(ui).clicked();
open |= crate::panels::option_link(tl!("Style:")).show(ui).clicked();
crate::panels::graphic_styles::style_picker(app, ui);
});
if open {
@@ -533,7 +533,7 @@ fn object_name(app: &VectorcraftApp, anchors: AnchorControls) -> Option<(&'stati
fn object_label(app: &mut VectorcraftApp, ui: &mut Ui, label: &'static str, image: bool) {
if !image {
Text::new(label).elide(Elide::End).show(ui);
} else if Link::new(label).show(ui).clicked() {
} else if crate::panels::option_link(label).show(ui).clicked() {
crate::panels::links::show_selected_image(app, ui.ctx());
}
}
+22 -19
View File
@@ -3,7 +3,7 @@ use craft::behavior::IconId;
use craft::behavior::kurbo::Size;
use craft::ui::bars::{Bar, BarKind, StatusMessage, StatusProgress};
use craft::ui::buttons::{Button, IconButton};
use craft::ui::contract::{Bind, Entry, Gap, LabelKind, Outcome as _, Props as _, Show as _, ShowContainer as _, SideLabel, Trigger};
use craft::ui::contract::{Bind, BodyCx, Entry, Gap, LabelKind, Outcome as _, Props as _, Show as _, ShowContainer as _, SideLabel, Trigger};
use craft::ui::display::{Divider, Elide, Shade, Text};
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
@@ -42,8 +42,28 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
let busy = busy_labels(app);
let (mut zoom_to, mut rotate_to, mut go, mut show_pick, mut stop) = (None, None, None, None, false);
// The readouts end the bar, the pointer's position and then the timings; a narrow bar leaves out the timings
// first, then the position, before the message.
let readouts = |ui: &mut Ui, _: &mut BodyCx<'_>| {
// With no hover point the axes stay empty and keep their width.
let origin = app.ruler_origin();
Row::new().gap(Gap::Item).fit_rank(2).show(ui, |ui, _| {
for (axis, value) in [("X", app.hover_doc.map(|p| p.x - origin.x)), ("Y", app.hover_doc.map(|p| p.y - origin.y))] {
let text = value.map(|v| format!("{axis}: {}", unit.readout(v))).unwrap_or_default();
Text::new(text).role(TypeRole::Mono).shade(Shade::Muted).sample(format!("{axis}: -8888.88 {}", unit.suffix())).show(ui);
}
});
let readout = |text: String, sample: String| Text::new(text).shade(Shade::Faint).sample(sample);
Row::new().gap(Gap::Item).fit_rank(1).show(ui, |ui, _| {
readout(format!("{render} {:.1} ms", app.perf.render_ms), format!("{render} 8888.8 ms")).show(ui);
readout(format!("{ui_name} {:.1} ms", app.perf.frame_ms), format!("{ui_name} 8888.8 ms")).show(ui);
// No rate until the window has drawn continuously for a moment (`frame_rate`).
let fps = if app.perf.fps > 0.0 { format!("{:.0} fps", app.perf.fps) } else { "\u{2013} fps".into() };
readout(fps, "8888 fps".into()).show(ui);
});
};
// PLAN: assumed VectorcraftApp::canvas_view() -> Option<CanvasView> (cv.S4) and the label msgid "Status Bar".
Bar::new(tl!("Status Bar"), BarKind::Status).show(ui, |ui, _| {
Bar::new(tl!("Status Bar"), BarKind::Status).trailing(readouts).show(ui, |ui, _| {
let zoom = Field::new(tl!("Zoom"))
.side(SideLabel::new().kind(LabelKind::Hidden))
.show(ui, |ui, _| ZoomField::new(tl!("Zoom"), app.canvas_view(), document).scrub(true).show(ui));
@@ -81,23 +101,6 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
Text::new(shown.to_owned()).shade(Shade::Muted).elide(Elide::End).show(ui);
let more = IconButton::new(IconId::new("chevron_down")).label(tl!("Show")).show(ui);
show_pick = Menu::new(tl!("Show")).values().opened_by(more.response(), Trigger::Press).pick(ui, &shows).picked;
// A narrow bar leaves out the timings first, then the pointer's position, before the message.
let readout = |text: String, sample: String| Text::new(text).shade(Shade::Faint).sample(sample);
Row::new().gap(Gap::Item).fit_rank(1).show(ui, |ui, _| {
readout(format!("{render} {:.1} ms", app.perf.render_ms), format!("{render} 8888.8 ms")).show(ui);
readout(format!("{ui_name} {:.1} ms", app.perf.frame_ms), format!("{ui_name} 8888.8 ms")).show(ui);
// No rate until the window has drawn continuously for a moment (`frame_rate`).
let fps = if app.perf.fps > 0.0 { format!("{:.0} fps", app.perf.fps) } else { "\u{2013} fps".into() };
readout(fps, "8888 fps".into()).show(ui);
});
// With no hover point the axes stay empty and keep their width.
let origin = app.ruler_origin();
Row::new().gap(Gap::Item).fit_rank(2).show(ui, |ui, _| {
for (axis, value) in [("X", app.hover_doc.map(|p| p.x - origin.x)), ("Y", app.hover_doc.map(|p| p.y - origin.y))] {
let text = value.map(|v| format!("{axis}: {}", unit.readout(v))).unwrap_or_default();
Text::new(text).role(TypeRole::Mono).shade(Shade::Muted).sample(format!("{axis}: -8888.88 {}", unit.suffix())).show(ui);
}
});
if app.session.script_running() {
stop = Button::new(tl!("Stop")).show(ui).response().clicked();
}
+2 -1
View File
@@ -83,7 +83,8 @@ pub fn doc_tabs(app: &mut VectorcraftApp, ui: &mut Ui) {
// 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)
// The modified mark follows the document's name, before the view's zoom and mode.
DocumentTab::new(w, whole).name_len(view_tab_name(d, doc_windows::label(app, w), false).len())
} else {
DocumentTab::new(w, view_tab_name(d, doc_windows::label(app, w), false)).tooltip(whole)
};
+3 -4
View File
@@ -261,8 +261,8 @@ fn hints_name_keys_as_the_menus_do() {
}
/// As the window narrows, the app bar gives up its right-hand controls one at a time, each before the one after it:
/// Discord, Explore tutorials, Arrange Documents, the search and last the workspace switcher; the search narrows to its
/// icon before it goes. Whatever shows lies inside the window. Safe Mode's rows are in `tests/safe_mode.rs`, whose
/// Discord, Explore tutorials, Arrange Documents, the search and last the workspace switcher; each keeps its whole width
/// until it goes. Whatever shows lies inside the window. Safe Mode's rows are in `tests/safe_mode.rs`, whose
/// process owns the Safe Mode switch.
#[test]
fn the_app_bar_gives_up_its_right_hand_controls_in_order() {
@@ -291,13 +291,12 @@ fn the_app_bar_gives_up_its_right_hand_controls_in_order() {
assert!(on.iter().zip(before).all(|(now, was)| !now || *was), "{width}: a control came back as the window narrowed: {on:?}");
}
if let Some(search) = shown[3] {
assert!(search_widths.last().is_none_or(|w: &f32| search.rect.width() <= *w + 0.5), "{width}: the search widened as the window narrowed");
search_widths.push(search.rect.width());
}
before = Some(on);
}
let (widest, narrowest) = (search_widths.first().copied(), search_widths.last().copied());
assert!(widest.zip(narrowest).is_some_and(|(w, n)| n < w), "the search field becomes its icon before it goes: {search_widths:?}");
assert!(widest.zip(narrowest).is_some_and(|(w, n)| n >= w - 0.5), "the search field keeps its width until it goes: {search_widths:?}");
}
/// A text the status bar painted, with where it lies.
+1 -1
View File
@@ -1316,7 +1316,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, keeps_tools: boo
Bind::bound(&mut workspace),
&specs,
&mut panels,
DockConfig::default().panel_menu_always(true).panel_menu_icon(IconId::new("menu")),
DockConfig::default().panel_menu_always(true).panel_menu_icon(IconId::new("menu")).rail_cards(true),
)
.hide(hide)
.flyout(Bind::bound(&mut flyout));
+7 -1
View File
@@ -62,7 +62,7 @@ use craft::color_ui::ui::{PaintChip, PairWell, SwatchPair, SwatchPairOutput, Swa
use craft::keymap::CommandRef;
use craft::theme::Srgba;
use craft::theme::variant::Tone;
use craft::ui::buttons::{IconButton, PopupMark};
use craft::ui::buttons::{IconButton, Link, PopupMark};
use craft::ui::choice::SwatchSpacing;
use craft::ui::contract::{Bind, CommandSet as _, Entry, ListDrag, PopupKind, Props as _, Show as _, ShowContainer as _, Sizing, Trigger};
use craft::ui::display::{Divider, Shade, Text};
@@ -907,6 +907,12 @@ pub(crate) fn subheading<'a>(title: impl Into<Label>) -> Section<'a> {
Section::fixed(title).strength(HeaderStrength::Subheading)
}
/// A link to a control's options ("Stroke", "Opacity:", "Character:"): underlined in the normal ink, as the reference
/// app drew them; links that leave the panel's subject (a file, more results) keep the accent.
pub(crate) fn option_link(label: impl Into<Label>) -> Link {
Link::new(label).tone(Tone::Neutral)
}
/// 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) {
+5 -5
View File
@@ -23,7 +23,7 @@ use std::sync::{Arc, OnceLock};
use craft::behavior::overlay::{Align, Side};
use craft::behavior::{ColumnKey, ColumnWidth, CopyKeys, DisplayOrder, EditEvent, IconId, ItemSource, Selection};
use craft::theme::Srgba;
use craft::ui::buttons::{Button, ButtonOutput, Link};
use craft::ui::buttons::{Button, ButtonOutput};
use craft::ui::choice::{Swatch, SwatchOutput};
use craft::ui::contract::overlay::{Anchor, Place};
use craft::ui::contract::{
@@ -813,7 +813,7 @@ fn item_row<'r>(cx: &'r RowCx<'_>, key: RowKey, i: usize) -> ListRow<'r> {
let (name, link) = if fill { (tl!("Fill"), tl!("Fill:")) } else { (tl!("Stroke"), tl!("Stroke:")) };
let mut row = ListRow::new(name).toggle(ToggleCell::eye(EYE, it.visible())).cell_field(
NAME,
Link::new(link).tooltip(tl!("Click to edit")),
crate::panels::option_link(link).tooltip(tl!("Click to edit")),
link_output(cx.pass, key),
);
// The first trailing part added is the outermost: the profile closes the row, the swatch sits
@@ -876,7 +876,7 @@ fn opacity_row<'r>(cx: &'r RowCx<'_>, key: RowKey) -> ListRow<'r> {
};
ListRow::new(tl!("Opacity"))
.toggle(ToggleCell::eye(EYE, true))
.cell_field(NAME, Link::new(tl!("Opacity:")).tooltip(tl!("Click to edit")), link_output(cx.pass, key))
.cell_field(NAME, crate::panels::option_link(tl!("Opacity:")).tooltip(tl!("Click to edit")), link_output(cx.pass, key))
// A screen reader reads the shown opacity as the row's description.
.description(shown.clone())
.trailing(shown)
@@ -892,7 +892,7 @@ fn contents_row<'r>(cx: &'r RowCx<'_>) -> ListRow<'r> {
let characters = matches!(n.kind, vectorcraft_doc::NodeKind::Text(_));
let mut row = ListRow::new(label.clone()).toggle(ToggleCell::eye(EYE, true));
if characters {
row = row.cell_field(NAME, Link::new(label).tooltip(tl!("Click to edit")), link_output(cx.pass, RowKey::Contents));
row = row.cell_field(NAME, crate::panels::option_link(label).tooltip(tl!("Click to edit")), link_output(cx.pass, RowKey::Contents));
// The characters' stroke closes the row, their fill before it.
for stroke in [true, false] {
let paint = n.proxy_paint_only(stroke, None).cloned().unwrap_or(Paint::None);
@@ -918,7 +918,7 @@ fn effect_row<'r>(cx: &'r RowCx<'_>, key: RowKey, item: &mut ItemCx<'_, 'r, RowK
let tip = skipped_effect_tip(&e.id).unwrap_or_else(|| tl!("Click to edit").to_string());
let row = ListRow::new(label.clone())
.toggle(ToggleCell::eye(EYE, e.visible))
.cell_field(NAME, Link::new(label).tooltip(tip), link_output(cx.pass, key))
.cell_field(NAME, crate::panels::option_link(label).tooltip(tip), link_output(cx.pass, key))
.trailing_icon(fx_icon(), Label::Empty)
.tooltip(tl!("Double-click to edit"));
if cx.open.contains(&key) {
+1 -2
View File
@@ -19,7 +19,6 @@ use craft::text::ui::character::{
FontHeightReference as HeightReference, FontPickerSource, Kerning, Leading, SIZE_PRESETS, keys,
};
use craft::text::ui::type_options::TextAntiAlias;
use craft::ui::buttons::Link;
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Entry, Lazy, Props as _, Show as _, ShowContainer as _, Trigger};
use craft::ui::display::Divider;
@@ -1306,7 +1305,7 @@ pub(crate) fn control_bar(app: &mut VectorcraftApp, ui: &mut Ui) -> bool {
return true;
}
Divider::vertical().show(ui);
let link = Link::new(tl!("Character:")).show(ui).response;
let link = crate::panels::option_link(tl!("Character:")).show(ui).response;
Popover::new(tl!("Character options"), Bind::kept()).overlay(|overlay| overlay.opened_by(&link, Trigger::Click)).show(ui, |ui, _| show(app, ui));
Row::new().show(ui, |ui, _| {
font_menu::font_fields(app, ui);
+2 -2
View File
@@ -10,7 +10,7 @@
use craft::behavior::{IconId, Mixed};
use craft::keymap::CommandRef;
use craft::text::ui::character::{DirectionRow, ParagraphChange, ParagraphControls, ParagraphDirection, ParagraphValues, TextAlign};
use craft::ui::buttons::{IconButton, Link, PopupMark, ToggleButton};
use craft::ui::buttons::{IconButton, PopupMark, ToggleButton};
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Entry, MemoProps, Props as _, Show as _, ShowContainer as _, Trigger};
use craft::ui::form::Field;
@@ -440,7 +440,7 @@ pub(crate) fn control_bar(app: &mut VectorcraftApp, ui: &mut Ui) -> bool {
}
// PLAN: the members' `Row::fit_rank` (ch.K30: toggles out before the link) belongs to chrome-w16's row; `horizontal` stands in until it lands.
ui.horizontal(|ui| {
let link = Link::new(tl!("Paragraph:")).tooltip(tl!("Paragraph options")).show(ui);
let link = crate::panels::option_link(tl!("Paragraph:")).tooltip(tl!("Paragraph options")).show(ui);
Popover::new(tl!("Paragraph"), Bind::kept())
.overlay(|overlay| overlay.opened_by(&link.response, Trigger::Click))
.show(ui, |ui, _| show(app, ui));
+2 -2
View File
@@ -13,7 +13,7 @@ use craft::draw::ui::transform::{
FieldArrangement, SizeUnit, TransformField, TransformFields, TransformFieldsOutput, TransformGroups, TransformRow, TransformSource,
};
use craft::keymap::CommandRef;
use craft::ui::buttons::{IconButton, Link};
use craft::ui::buttons::IconButton;
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Entry, GlyphLabel, LabelKind, LabelPress, Props, Show, ShowContainer, SideLabel, Sizing};
use craft::ui::display::{Shade, Text};
@@ -655,7 +655,7 @@ fn pixel_aligned_ids(app: &VectorcraftApp) -> Vec<u64> {
/// The Control bar's underlined "Transform" link: a click toggles the Transform panel in a
/// popover under it, as the Stroke link does with the Stroke panel.
pub(crate) fn link(app: &mut VectorcraftApp, ui: &mut Ui) {
let out = Link::new(tl!("Transform")).tooltip(tl!("Transform options")).show(ui);
let out = crate::panels::option_link(tl!("Transform")).tooltip(tl!("Transform options")).show(ui);
popover(app, ui, &out.response);
}
+13 -3
View File
@@ -23,7 +23,7 @@ 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::rails::{LastUsed, RailDensity, RailFooter, RailTool, SlotId, ToolRail, ToolSlot};
use craft::ui::runtime::commands::{self, CommandRef};
use craft::ui::text::NumberField;
use egui::{Pos2, Ui, Vec2};
@@ -260,7 +260,13 @@ pub(crate) fn dock_grid(app: &VectorcraftApp, owner: &Owner) -> DockGrid {
Owner::Strip(parent, first) => strip_tools(app, parent, first).len(),
_ => groups_of(app, owner).len() + 1,
};
DockGrid::rail(cells)
DockGrid::rail(cells).density(rail_density(app, owner))
}
/// How tightly the rail of `owner` packs its buttons: the Tools panel's packs them tight under Window › Toolbars ›
/// Compact.
fn rail_density(app: &VectorcraftApp, owner: &Owner) -> RailDensity {
if matches!(owner, Owner::Tools) && app.ui.toolbar_compact { RailDensity::Dense } else { RailDensity::Regular }
}
/// The groups of several tools of the Tools panel's toolbar (`toolbar` none) or of the toolbar made
@@ -388,7 +394,11 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m
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();
// The current tool in production's pressed fill, with no accent edge.
let mut rail = ToolRail::new(tl!("Tools"), &model.slots, &current, &model.last_used).opens(opens).tips(&cards).active_look(ActiveLook::Pressed);
let mut rail = ToolRail::new(tl!("Tools"), &model.slots, &current, &model.last_used)
.opens(opens)
.tips(&cards)
.active_look(ActiveLook::Pressed)
.density(rail_density(app, &owner));
if let Some(tool) = &located {
rail = rail.mark(tool);
}
+2 -1
View File
@@ -18,6 +18,7 @@ use craft::keymap::CommandRef;
use craft::ui::dialog::{DialogResult, dialog_id};
use craft::ui::patterns::dock::{HostedNewWorkspace, NewWorkspace, WorkspaceSwitcher};
use craft::ui::patterns::form_dialogs::{ActionEnabled, HostedListManager, ListManagerAction, ListManagerChoice, ListManagerEntry};
use craft::ui::pickers::SelectLook;
use craft::ui::rails::LastUsed;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
@@ -525,7 +526,7 @@ pub fn menu_items(saved: &[String]) -> Vec<crate::menus::Node> {
/// Manage Workspaces…; picking a workspace runs `window.workspace`.
pub fn switcher(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
let rows = ["window.workspace.reset", "window.workspace.new", "window.workspace.manage"].map(CommandRef::new).to_vec();
let shown = WorkspaceSwitcher::new(&app.ui.workspaces.set).commands(rows).show(ui);
let shown = WorkspaceSwitcher::new(&app.ui.workspaces.set).commands(rows).look(SelectLook::Quiet).show(ui);
if let Some(id) = shown.switched {
crate::menus::invoke(app, "window.workspace", json!({"name": id}));
}