Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

The Studio themes show the Move tool's Auto-Select toggle (#1275) (#1333)

BFlatb3d10f9a4847
diff --git a/crates/ui-egui/src/move_auto_select_tests.rs b/crates/ui-egui/src/move_auto_select_tests.rs
index 074e60dcf..a71876230 100644
--- a/crates/ui-egui/src/move_auto_select_tests.rs
+++ b/crates/ui-egui/src/move_auto_select_tests.rs
@@ -125,3 +125,29 @@ fn shift_click_adds_the_layer_under_the_pointer() {
assert!(st.is_layer_selected(a) && st.is_layer_selected(b));
assert_eq!(bounds(&app, a), Rect::new(8, 8, 24, 24));
}
+
+#[test]
+fn every_theme_shows_the_auto_select_toggle() {
+ // #1275: the Studio themes' options bar had only a hint for the Move tool, so Auto-Select
+ // could not be turned off there.
+ use egui_kittest::Harness;
+ use egui_kittest::kittest::Queryable;
+ for theme in [crate::theme::ThemeKind::ProMedium, crate::theme::ThemeKind::Studio] {
+ let (app, _, _) = app();
+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 60.0)).build_ui_state(
+ |ui, app: &mut PhotocraftApp| {
+ if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {
+ return;
+ }
+ crate::panels::options_bar(app, ui);
+ },
+ app,
+ );
+ PhotocraftApp::setup_context(&h.ctx, theme);
+ h.run_steps(4);
+ assert!(h.state().ui.tool_options.move_auto_select);
+ h.get_by_label("Auto-Select:").click();
+ h.run_steps(2);
+ assert!(!h.state().ui.tool_options.move_auto_select, "{theme:?}: the toggle turns Auto-Select off");
+ }
+}
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index d11b103cd..dab9af8c6 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -841,7 +841,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
crate::shortcuts::pretty("Shift+Alt")
),
),
- Tool::Move => hint(ui, tl!("Drag to move the active layer")),
+ Tool::Move => {
+ // The Studio themes keep Photoshop's Auto-Select toggle too (#1275).
+ widgets::checkbox(ui, &mut app.ui.tool_options.move_auto_select, tl!("Auto-Select:"));
+ hint(ui, tl!("Drag to move the active layer"));
+ }
Tool::Eyedropper => hint(
ui,
&crate::i18n::fmt(