Skip to content

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

Brush: the Mode dropdown shows in every theme, not only Pro (#4537)

Marco Arnulfo04f0b0e86bff
diff --git a/crates/ui-egui/src/brush_panel_tests.rs b/crates/ui-egui/src/brush_panel_tests.rs
index 133d84993..9bd669fef 100644
--- a/crates/ui-egui/src/brush_panel_tests.rs
+++ b/crates/ui-egui/src/brush_panel_tests.rs
@@ -379,6 +379,26 @@ fn options_bar_edits_are_one_set_brush_per_gesture() {
assert_eq!(s.tools.brush, h.state().session.tools.brush);
}
+#[test]
+fn brush_mode_dropdown_shows_outside_the_pro_themes() {
+ // #4512: only the Pro themes drew the Brush's Mode; the Pencil has it in every theme.
+ use egui_kittest::kittest::{NodeT, Queryable};
+ let mut h = options_bar_harness(crate::state::Tool::Brush);
+ let n = h.state().session.journal.len();
+ assert!(h.query_by_label("Mode").is_some(), "the Brush's Mode label");
+ h.get_all_by_role(egui::accesskit::Role::ComboBox)
+ .find(|c| c.accesskit_node().value().as_deref() == Some("Normal"))
+ .expect("the Brush's Mode dropdown")
+ .click();
+ h.run();
+ h.key_press(egui::Key::ArrowDown);
+ h.run_steps(3);
+ assert_eq!(h.state().session.tools.brush.mode, photocraft_doc::BlendMode::Dissolve);
+ let j = &h.state().session.journal;
+ assert_eq!(j.len(), n + 1, "{:?}", &j[n..]);
+ assert_eq!(j[n].0, "tools.setBrush");
+}
+
#[test]
fn airbrush_smoothing_options_and_symmetry_buttons_work() {
// #1177: in the default (Photoshop) theme these options-bar buttons did nothing.
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index 702008363..2ab7fbf79 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -1062,6 +1062,10 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
widgets::vline(ui, 22.0);
if app.ui.tool == Tool::Eraser {
crate::eraser_ui::mode_dropdown(ui, &mut app.ui.tool_options.eraser_mode);
+ } else {
+ opt_label(ui, tl!("Mode"));
+ let held = app.held_erase;
+ paint_mode_dropdown(ui, "brush-mode", b, &mut app.ui.tool_options.brush_clear, held);
}
// A Pencil-mode Eraser is always hard and at full flow (Photoshop).
let fixed = block || crate::eraser_ui::pencil_mode(app, app.ui.tool);
@@ -5853,7 +5857,9 @@ mod compact_visual_regressions {
egui::RawInput {
time: Some(f64::from(frame) * 0.1),
events: vec![
- egui::Event::PointerMoved(pos2(width * 0.5, 20.0)),
+ // Studio: above the controls, clear of the Brush's Mode dropdown, which takes the wheel
+ // to step through blend modes (#4512).
+ egui::Event::PointerMoved(if Tokens::get(&ctx).pro { pos2(width * 0.5, 20.0) } else { pos2(width * 0.5, 2.0) }),
egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Point,
delta: vec2(-1500.0, 0.0),