From 1ace4f12e9ad628d792fbbae3f28830015bb4224 Mon Sep 17 00:00:00 2001 From: Rebornim <250083243+Rebornim@users.noreply.github.com> Date: Fri, 27 Nov 2026 01:19:29 +0000 Subject: [PATCH] Set the lazy mouse in the top bar only, and give its Spacing the Properties range The Brush section's folded Lazy mouse band repeated the top bar's button and distance; it goes, as the reference keeps the lazy mouse in the top bar. The top bar's Spacing slider stopped at 200 % while Properties' goes to 1000 %; both now reach 1000 %. Saved values are unchanged. --- crates/ui-egui/src/brush_sheet.rs | 11 +----- crates/ui-egui/src/toolbar.rs | 2 +- .../ui-egui/tests/it/brush_section_reset.rs | 12 ++++-- crates/ui-egui/tests/it/toolbar.rs | 37 ++++++++++++++++++- crates/ui-egui/tests/ui_snapshots.rs | 6 +-- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/crates/ui-egui/src/brush_sheet.rs b/crates/ui-egui/src/brush_sheet.rs index 1f08fd32..cf4a7022 100644 --- a/crates/ui-egui/src/brush_sheet.rs +++ b/crates/ui-egui/src/brush_sheet.rs @@ -41,12 +41,11 @@ const POSITION_JITTER_PERCENT_RANGE: RangeInclusive = 0.0..=400.0; const PERCENT_RANGE: RangeInclusive = 0.0..=100.0; -/// The ranges of Stamp depth, Gravity, particles per stamp, a particle's lifetime in steps and the lazy mouse distance in pixels +/// The ranges of Stamp depth, Gravity, particles per stamp, and a particle's lifetime in steps const STAMP_DEPTH_RANGE: RangeInclusive = 0.05..=4.0; const GRAVITY_RANGE: RangeInclusive = 0.0..=2.0; const PARTICLE_COUNT_RANGE: RangeInclusive = 1.0..=16.0; const PARTICLE_LIFETIME_RANGE: RangeInclusive = 1.0..=128.0; -const LAZY_DISTANCE_RANGE: RangeInclusive = 0.0..=200.0; /// Width of the brush presets list const PRESETS_WIDTH: f32 = 230.0; @@ -156,14 +155,6 @@ pub(crate) fn brush_section(app: &mut TextureCraftApp, sheet: &mut PropertySheet sheet.slider(tr("Gravity"), &mut particles.gravity, GRAVITY_RANGE, 2); } - let band = sheet.band(tr("Lazy mouse"), false, Some(brush.lazy != defaults.lazy), None); - if band.reset { - brush.lazy = defaults.lazy; - } - if band.open { - sheet.slider(tr("Lazy mouse distance"), &mut brush.lazy, LAZY_DISTANCE_RANGE, 0); - } - *brush = brush.sanitized(); } diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 21cf3c93..842f4dc7 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -283,7 +283,7 @@ fn tool_controls(app: &mut TextureCraftApp, ui: &mut egui::Ui, tokens: &Tokens) const SIZE_PERCENT_RANGE: std::ops::RangeInclusive = 0.05..=100.0; /// Spacing's track, in percent of the brush's diameter - const SPACING_PERCENT_RANGE: std::ops::RangeInclusive = 1.0..=200.0; + const SPACING_PERCENT_RANGE: std::ops::RangeInclusive = 1.0..=1000.0; /// Lazy mouse Distance's track, in pixels const LAZY_DISTANCE_RANGE_PX: std::ops::RangeInclusive = 1.0..=200.0; diff --git a/crates/ui-egui/tests/it/brush_section_reset.rs b/crates/ui-egui/tests/it/brush_section_reset.rs index 88d15966..3bf18f0a 100644 --- a/crates/ui-egui/tests/it/brush_section_reset.rs +++ b/crates/ui-egui/tests/it/brush_section_reset.rs @@ -18,7 +18,7 @@ const SETTLE_FRAMES: usize = 3; type SectionReset = fn(&mut BrushSettings, &BrushSettings); /// Each band's title, a label shown only while it is open, whether it starts open, and its reset -const SECTIONS: [(&str, &str, bool, SectionReset); 7] = [ +const SECTIONS: [(&str, &str, bool, SectionReset); 6] = [ ("Size", "Minimum Size (%)", true, |brush, defaults| { (brush.size, brush.size_pressure, brush.min_size, brush.spacing) = (defaults.size, defaults.size_pressure, defaults.min_size, defaults.spacing) }), @@ -33,7 +33,6 @@ const SECTIONS: [(&str, &str, bool, SectionReset); 7] = [ (defaults.alignment, defaults.backface_culling, defaults.angle_fade, defaults.screen_space, defaults.depth) }), ("Particles", "Gravity", false, |brush, defaults| brush.particles = defaults.particles), - ("Lazy mouse", "Lazy mouse distance", false, |brush, defaults| brush.lazy = defaults.lazy), ]; /// A valid brush with every section field changed and a custom alpha that resets must preserve @@ -81,7 +80,7 @@ fn app_with_brush(brush: BrushSettings) -> Harness<'static, TextureCraftApp> { harness } -/// The band titled `title` in Properties: the rightmost, as the top bar has a Size and a Lazy mouse too +/// The band titled `title` in Properties: the rightmost, as the top bar has a Size too fn band<'tree>(harness: &'tree Harness<'_, TextureCraftApp>, title: &str) -> egui_kittest::Node<'tree> { harness .query_all_by_role(egui::Role::Button) @@ -108,6 +107,13 @@ fn click_reset(harness: &mut Harness<'_, TextureCraftApp>, title: &str) { harness.run_steps(SETTLE_FRAMES); } +#[test] +fn the_lazy_mouse_is_set_only_in_the_top_bar() { + let harness = app_with_brush(BrushSettings::default()); + + assert_eq!(harness.query_all_by_label("Lazy mouse").count(), 1, "the top bar's button, no band in Properties"); +} + #[test] fn each_reset_puts_back_only_its_own_section() { let defaults = BrushSettings::default(); diff --git a/crates/ui-egui/tests/it/toolbar.rs b/crates/ui-egui/tests/it/toolbar.rs index c9271888..9c1b1adf 100644 --- a/crates/ui-egui/tests/it/toolbar.rs +++ b/crates/ui-egui/tests/it/toolbar.rs @@ -6,6 +6,8 @@ use texturecraft_engine::{Session, Tool}; use texturecraft_ui_egui::state::{Mode, ViewLayout}; use texturecraft_ui_egui::{TextureCraftApp, theme, toolbar}; +use crate::DRAG_STEP_FRAMES; + fn toolbar_harness(width: f32, tool: Tool) -> Harness<'static, TextureCraftApp> { let session = Session::new_project("Toolbar", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); let context = eframe::CreationContext::_new_kittest(egui::Context::default()); @@ -24,12 +26,17 @@ fn toolbar_harness(width: f32, tool: Tool) -> Harness<'static, TextureCraftApp> } fn size_label(harness: &Harness<'_, TextureCraftApp>) -> (egui::Pos2, egui::Rect) { + bar_label(harness, "Size") +} + +/// Where the top bar paints the slider label `label`, and that text's clip +fn bar_label(harness: &Harness<'_, TextureCraftApp>, label: &str) -> (egui::Pos2, egui::Rect) { harness .output() .shapes .iter() .find_map(|shape| match &shape.shape { - egui::Shape::Text(text) if text.galley.text() == "Size" => Some((text.pos, shape.clip_rect)), + egui::Shape::Text(text) if text.galley.text() == label => Some((text.pos, shape.clip_rect)), _ => None, }) .unwrap() @@ -88,6 +95,34 @@ fn arrows_and_wheel_scroll_without_changing_the_brush() { assert_eq!(harness.state().session.tool.brush, brush); } +#[test] +fn the_spacing_slider_reaches_as_far_as_the_properties_one() { + // Wide enough that the bar shows Spacing without scrolling + const BAR_WIDTH: f32 = 1600.0; + // From the label's top left onto its text, which drags the value + const LABEL_GRAB_OFFSET: egui::Vec2 = egui::vec2(4.0, 8.0); + // Far enough right to pass the slider's end + const DRAG_PAST_END: f32 = 400.0; + // The top bar's old Spacing limit: 200 % of the diameter + const OLD_SPACING_LIMIT: f32 = 2.0; + + let mut harness = toolbar_harness(BAR_WIDTH, Tool::Paint); + let (label, _) = bar_label(&harness, "Spacing"); + let from = label + LABEL_GRAB_OFFSET; + let past_the_end = from + egui::vec2(DRAG_PAST_END, 0.0); + + harness.hover_at(from); + harness.event(egui::Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE }); + harness.run_steps(DRAG_STEP_FRAMES); + harness.hover_at(past_the_end); + harness.run_steps(DRAG_STEP_FRAMES); + harness.event(egui::Event::PointerButton { pos: past_the_end, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE }); + harness.run_steps(DRAG_STEP_FRAMES); + + // Properties' Spacing goes to 1000 % of the diameter + assert!(harness.state().session.tool.brush.spacing > OLD_SPACING_LIMIT, "past the 200 % the top bar used to stop at"); +} + #[test] fn shorter_tools_and_wider_windows_remove_the_arrows() { let mut harness = toolbar_harness(700.0, Tool::Path); diff --git a/crates/ui-egui/tests/ui_snapshots.rs b/crates/ui-egui/tests/ui_snapshots.rs index fe164ce6..4e275b7c 100644 --- a/crates/ui-egui/tests/ui_snapshots.rs +++ b/crates/ui-egui/tests/ui_snapshots.rs @@ -3273,11 +3273,11 @@ fn paint_tool_properties_snapshots() { tool.brush = default_brush; tool.values = default_values; - // The top bar has a Lazy mouse button too: Properties is the rightmost + // The top bar has labels of the same names: Properties is the rightmost let in_properties = |harness: &Harness<'_, TextureCraftApp>, label: &str| { harness.get_all_by_label(label).map(|node| node.rect().center()).max_by(|a, b| a.x.total_cmp(&b.x)).unwrap() }; - for header in ["Particles", "Lazy mouse"] { + for header in ["Particles"] { harness.get_all_by_label(header).max_by(|a, b| a.rect().left().total_cmp(&b.rect().left())).unwrap().scroll_to_me(); harness.run_steps(3); let at = in_properties(&harness, header); @@ -3290,7 +3290,7 @@ fn paint_tool_properties_snapshots() { harness.get_by_label_contains("Brush presets").scroll_to_me(); harness.run_steps(3); save(&mut harness, &output_dir, "paint-brush-open"); - harness.get_all_by_label("Lazy mouse").max_by(|a, b| a.rect().left().total_cmp(&b.rect().left())).unwrap().scroll_to_me(); + harness.get_all_by_label("Particles").max_by(|a, b| a.rect().left().total_cmp(&b.rect().left())).unwrap().scroll_to_me(); harness.run_steps(6); save(&mut harness, &output_dir, "paint-brush-scrolled");