mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Toolbar order applies to Shift-switch cycling only; plain letters keep their order (#11376)
With "Use Shift Key for Tool Switch" off, plain letters cycle the group, and that case was not measured. The toolbar-order sort now runs only when the preference is on; with it off the group keeps its Tool::ALL order. A test pins plain W from Magic Wand going Quick Selection, Object Selection, Magic Wand. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
8d33de79b0
commit
9afc9295a7
2 files changed
+26
-2
No files matched your search
@@ -906,8 +906,11 @@ fn select_tool_by_key(app: &mut PhotocraftApp, ctx: &egui::Context, pressed: &im
|
||||
if cycle_shift || pressed(k) {
|
||||
let before = app.ui.tool;
|
||||
let mut group: Vec<Tool> = Tool::ALL.iter().copied().filter(|x| x.key() == t.key() && crate::tool_shortcuts::uses_default(app, *x)).collect();
|
||||
// Shift+key steps in the toolbar flyout's order, not the order of `Tool::ALL`.
|
||||
group.sort_by_key(|x| crate::panels::toolbar::toolbar_position(*x));
|
||||
// With the Shift-switch preference, Shift+key steps in the toolbar flyout's order; with it off
|
||||
// plain keys keep the `Tool::ALL` order.
|
||||
if shift_switch {
|
||||
group.sort_by_key(|x| crate::panels::toolbar::toolbar_position(*x));
|
||||
}
|
||||
app.ui.tool = match group.iter().position(|x| *x == app.ui.tool) {
|
||||
Some(i) if shift_switch && !cycle_shift => group[i],
|
||||
Some(i) => group[(i + 1) % group.len()],
|
||||
|
||||
@@ -126,3 +126,24 @@ fn the_cycle_order_is_the_flattened_toolbar_order() {
|
||||
assert_eq!(toolbar_position(*t), i, "{t:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_the_shift_switch_preference_off_plain_w_keeps_the_old_order() {
|
||||
let mut app = app();
|
||||
app.session.edit_prefs(|p| p.tools.use_shift_key_for_tool_switch = false);
|
||||
app.ui.tool = Tool::MagicWand;
|
||||
let mut seen = Vec::new();
|
||||
for _ in 0..3 {
|
||||
let ctx = egui::Context::default();
|
||||
let modifiers = Modifiers::NONE;
|
||||
let raw = egui::RawInput {
|
||||
events: vec![egui::Event::Key { key: Key::W, physical_key: None, pressed: true, repeat: false, modifiers }],
|
||||
..Default::default()
|
||||
};
|
||||
ctx.begin_pass(raw);
|
||||
crate::shortcuts::handle(&mut app, &ctx);
|
||||
ctx.end_pass().textures_delta.clear();
|
||||
seen.push(app.ui.tool);
|
||||
}
|
||||
assert_eq!(seen, vec![Tool::QuickSelection, Tool::ObjectSelection, Tool::MagicWand]);
|
||||
}
|
||||
Reference in new issue
Block a user