mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 15:21:17 -05:00
The app bar's search narrows to its icon before it goes; key tests: a held OK closes its dialog on the window's next pass, a dialog opened after the window's pass is answered once shown, and the panel shortcut test checks production's params
This commit is contained in:
@@ -79,8 +79,9 @@ impl Trailing {
|
||||
if matches!(self, Trailing::Safe | Trailing::Switcher) { FitKeep::Pinned } else { FitKeep::Free }
|
||||
}
|
||||
|
||||
/// Shows the control; the fit measures it through the same call.
|
||||
fn show(self, app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
/// 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) {
|
||||
match self {
|
||||
Trailing::Safe => {
|
||||
let shown = Button::new(tl!("Safe Mode")).variant(Variant::GHOST).tooltip(tl!("Safe Mode…")).show(ui);
|
||||
@@ -97,6 +98,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);
|
||||
}
|
||||
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.
|
||||
@@ -173,12 +177,20 @@ fn trailing(ui: &mut Ui, app: &mut VectorcraftApp) {
|
||||
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 items: Vec<FitItem> = order.iter().map(|t| FitItem::new(measure_slot(ui, room, |ui| t.show(app, ui)).x, 0, t.keep())).collect();
|
||||
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 order.iter().position(|o| *o == t).is_some_and(|at| fit.shown.contains(&at)) {
|
||||
t.show(app, ui);
|
||||
if let Some(at) = order.iter().position(|o| *o == t).filter(|at| fit.shown.contains(at)) {
|
||||
t.show(app, ui, fit.short.contains(&at));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -218,15 +218,14 @@ fn named_panel_default_chords_toggle_their_panels() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A panel command with no `toggle` param reveals its panel and keeps it shown.
|
||||
/// A shortcut on a panel without a function key of its own runs `window.panel` with the params it has: no toggle is
|
||||
/// added, as production checked.
|
||||
#[test]
|
||||
fn other_panel_shortcuts_keep_plain_panel_params() {
|
||||
let mut app = new_app();
|
||||
for panel in ["character", "swatches"] {
|
||||
for _ in 0..2 {
|
||||
app.run("window.panel", json!({"panel": panel})).unwrap();
|
||||
assert!(crate::panel_docking::showing(&app.ui, panel), "{panel} stays shown");
|
||||
}
|
||||
let params = super::shortcut_params(&craft::keymap::CommandRef::with_params("window.panel", json!({"panel": panel})));
|
||||
assert!(params.get("toggle").is_none(), "{panel} gained toggle");
|
||||
assert!(params.get("toggleGroup").is_none(), "{panel} gained toggleGroup");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1426,8 +1425,9 @@ fn enter_opens_the_tools_dialog_and_leaves_it_open() {
|
||||
key_frame(&mut app, &ctx, vec![]);
|
||||
assert_eq!(dialog_kind(&app).as_deref(), Some(dialog), "{tool}: and it stays open");
|
||||
assert_eq!(steps(&app), before, "{tool}: the Enter that opened it didn't confirm it");
|
||||
// With its default values only Reflect changes the art.
|
||||
// With its default values only Reflect changes the art. A held OK closes its dialog on the window's next pass.
|
||||
key_frame(&mut app, &ctx, enter());
|
||||
key_frame(&mut app, &ctx, vec![]);
|
||||
let after = (before.0 + usize::from(dialog == "object.reflect"), before.1 + 1);
|
||||
assert_eq!((dialog_kind(&app), steps(&app)), (None, after), "{tool}: Enter confirms");
|
||||
}
|
||||
@@ -1465,9 +1465,12 @@ fn enter_after_a_drag_repeats_its_offset() {
|
||||
assert_eq!(dialog_field(&app, "dx").and_then(|v| v.as_f64()).map(f64::round), Some(step));
|
||||
set_top_field(&mut app, "copy", json!(true));
|
||||
key_frame(&mut app, &ctx, enter());
|
||||
// A held OK closes its dialog on the window's next pass.
|
||||
key_frame(&mut app, &ctx, vec![]);
|
||||
for _ in 0..2 {
|
||||
key_frame(&mut app, &ctx, enter());
|
||||
key_frame(&mut app, &ctx, enter());
|
||||
key_frame(&mut app, &ctx, vec![]);
|
||||
}
|
||||
assert!(dialog_kind(&app).is_none());
|
||||
assert_eq!(lefts(&app), (0..4).map(|i| moved + step * f64::from(i)).collect::<Vec<_>>());
|
||||
|
||||
Reference in New Issue
Block a user