Skip to content

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

fix(ui): make painting symmetry available across all themes (#2704)

Nigel Ihza Firdausy4908fde283c6
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index 1ec9cbabb..003f2b2e7 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -859,7 +859,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if icons::button(ui, "circle-dot", 24.0, b.pressure_size, tl!("Always use pressure for size")).clicked() {
b.pressure_size = !b.pressure_size;
}
- crate::symmetry_ui::menu(app, ui);
}
// Pencil: Photoshop's options (no hardness or flow: the pencil is always hard).
Tool::Pencil => {
@@ -1283,6 +1282,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Retouching and smart-selection tools draw their bar in `retouch_ui::options_bar`.
_ => {}
}
+ // Painting symmetry is independent of visual theme. Keep the options-bar
+ // action available for Brush, Pencil and Eraser in every palette (#2659).
+ if matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser) {
+ crate::symmetry_ui::menu(app, ui);
+ }
crate::brush_panel::commit_gesture(app, ui.ctx(), &brush_before, &brush);
});
});
@@ -3367,6 +3371,27 @@ fn selection_mode_buttons(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.spacing_mut().item_spacing.x = 8.0;
}
+#[cfg(test)]
+mod symmetry_theme_tests {
+ use super::*;
+ use egui_kittest::{Harness, kittest::Queryable};
+
+ #[test]
+ fn brush_pencil_and_eraser_expose_symmetry_menu_in_every_theme() {
+ for kind in crate::theme::ThemeKind::ALL {
+ for tool in [Tool::Brush, Tool::Pencil, Tool::Eraser] {
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"width": 80, "height": 80})).unwrap();
+ app.ui.tool = tool;
+ let mut h = Harness::builder().with_size(vec2(1600.0, 300.0)).build_ui_state(|ui, app| options_bar(app, ui), app);
+ PhotocraftApp::setup_context(&h.ctx, kind);
+ h.run_steps(4);
+ assert!(h.query_by_label("Set painting symmetry options").is_some(), "missing symmetry menu in {:?} for {:?}", kind, tool);
+ }
+ }
+ }
+}
+
#[cfg(test)]
mod color_tests {
use super::*;