Skip to content

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

Options bar: Brush and Eraser size go to 5000 px in every theme (#5708) (#5709)

David Mann772dfb9e7ee9
diff --git a/crates/ui-egui/src/brush_panel_tests.rs b/crates/ui-egui/src/brush_panel_tests.rs
index cffbb5b53..670f442be 100644
--- a/crates/ui-egui/src/brush_panel_tests.rs
+++ b/crates/ui-egui/src/brush_panel_tests.rs
@@ -399,6 +399,21 @@ fn brush_mode_dropdown_shows_outside_the_pro_themes() {
assert_eq!(j[n].0, "tools.setBrush");
}
+#[test]
+fn brush_and_eraser_size_fields_keep_sizes_above_2500_px() {
+ // #5708: outside the Pro themes the Size field capped at 2500 px and clamped a bigger brush
+ // (set from the picker or `]`) on the next frame; Photoshop and the engine allow 5000 px.
+ for tool in [crate::state::Tool::Brush, crate::state::Tool::Eraser] {
+ let mut h = options_bar_harness(tool);
+ let n = h.state().session.journal.len();
+ h.state_mut().session.tools.brush.size = 4000.0;
+ h.run_steps(4);
+ assert_eq!(h.state().session.tools.brush.size, 4000.0, "{tool:?}");
+ let j = &h.state().session.journal;
+ assert_eq!(j.len(), n, "showing the bar issues nothing: {:?}", &j[n..]);
+ }
+}
+
#[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 82c2b667a..156a0a3f2 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -1044,7 +1044,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let block = crate::eraser_ui::block_mode(app, app.ui.tool);
ui.add_enabled_ui(!block, |ui| {
opt_label(ui, tl!("Size"));
- widgets::value_field(ui, &mut b.size, 1.0..=2500.0, "px", 76.0);
+ widgets::value_field(ui, &mut b.size, 1.0..=photocraft_engine::paint::MAX_BRUSH_SIZE, "px", 76.0);
});
widgets::vline(ui, 22.0);
if app.ui.tool == Tool::Eraser {