diff --git a/crates/imaging/src/ui/fill/bar.rs b/crates/imaging/src/ui/fill/bar.rs index f7fbf825d..e32cee89e 100644 --- a/crates/imaging/src/ui/fill/bar.rs +++ b/crates/imaging/src/ui/fill/bar.rs @@ -3,7 +3,6 @@ use egui::{Response, Ui}; use craft_behavior::IconId; -use craft_behavior::geometry::selection_op::SelectionOperation; use craft_ui::bars::{Bar, BarKind}; use craft_ui::buttons::{Button, IconButton}; use craft_ui::choice::Segmented; @@ -14,6 +13,8 @@ use craft_ui::primitives::IconSpec; use craft_ui::runtime::env::{Env, UnitKind}; use craft_ui::text::NumberField; +use crate::ui::select::operations::{SelectionOpWords, selection_operations}; + use super::lasso::FillAreaEdit; use super::tool::{FillTool, FillToolOptions}; use super::words::FillWords; @@ -80,13 +81,7 @@ impl<'a> FillBar<'a> { } } FillTool::Lasso => { - let icon = |name: &'static str| IconSpec::svg(IconId::new(name)); - let operations = [ - Entry::new(SelectionOperation::New, words.new_selection.clone()).icon(icon("square")), - Entry::new(SelectionOperation::Add, words.add_to_selection.clone()).icon(icon("plus")), - Entry::new(SelectionOperation::Subtract, words.subtract_from_selection.clone()).icon(icon("minus")), - Entry::new(SelectionOperation::Intersect, words.intersect_with_selection.clone()).icon(icon("squares_subtract")), - ]; + let operations = selection_operations(&env.words::()); let picked = Segmented::new(words.options.clone(), Bind::given(options.lasso), &operations).show(ui).value().copied(); if let Some(operation) = picked { options.lasso = operation; @@ -101,7 +96,7 @@ impl<'a> FillBar<'a> { if let Some(by) = number(ui, &words.grow_by, options.grow_by, min..=max) { options.grow_by = by; } - if clicked(&IconButton::new(icon("undo")).label(reset.clone()).id_salt("reset").show(ui)) { + if clicked(&IconButton::new(IconSpec::svg(IconId::new("undo"))).label(reset.clone()).id_salt("reset").show(ui)) { reset_fill_area = true; } } diff --git a/crates/imaging/src/ui/fill/words.rs b/crates/imaging/src/ui/fill/words.rs index 07eee2f67..d6ff91c1c 100644 --- a/crates/imaging/src/ui/fill/words.rs +++ b/crates/imaging/src/ui/fill/words.rs @@ -11,10 +11,6 @@ craft_ui::words! { add: "fill.add" = "Add"; subtract: "fill.subtract" = "Subtract"; size: "fill.size" = "Size"; - new_selection: "fill.newSelection" = "New selection"; - add_to_selection: "fill.addToSelection" = "Add to selection"; - subtract_from_selection: "fill.subtractFromSelection" = "Subtract from selection"; - intersect_with_selection: "fill.intersectWithSelection" = "Intersect with selection"; /// The caption of the Expand and Contract amount in the options bar. grow_by: "fill.growBy" = "By"; expand: "fill.expand" = "Expand"; diff --git a/crates/imaging/src/ui/select/operations.rs b/crates/imaging/src/ui/select/operations.rs index 5f8697f3c..c6bfd6268 100644 --- a/crates/imaging/src/ui/select/operations.rs +++ b/crates/imaging/src/ui/select/operations.rs @@ -1,7 +1,9 @@ //! The four selection operations as entries for a `Segmented`: New, Add, Subtract and Intersect. +use craft_behavior::IconId; use craft_behavior::geometry::selection_op::SelectionOperation; use craft_ui::contract::Entry; +use craft_ui::primitives::IconSpec; craft_ui::words! { /// The selection operations' words, English by default (Photoshop's names). @@ -15,6 +17,11 @@ craft_ui::words! { /// The four entries (icons `square`, `plus`, `minus`, `squares_subtract`) for a `Segmented`. pub fn selection_operations(words: &SelectionOpWords) -> [Entry; 4] { - let _ = words; - todo!("pn.C19") + let icon = |name: &'static str| IconSpec::svg(IconId::new(name)); + [ + Entry::new(SelectionOperation::New, words.new_selection.clone()).icon(icon("square")), + Entry::new(SelectionOperation::Add, words.add_to_selection.clone()).icon(icon("plus")), + Entry::new(SelectionOperation::Subtract, words.subtract_from_selection.clone()).icon(icon("minus")), + Entry::new(SelectionOperation::Intersect, words.intersect_with_selection.clone()).icon(icon("squares_subtract")), + ] } diff --git a/crates/ui-contract/src/contract/cx/edit.rs b/crates/ui-contract/src/contract/cx/edit.rs index ddd19c722..c253a0c62 100644 --- a/crates/ui-contract/src/contract/cx/edit.rs +++ b/crates/ui-contract/src/contract/cx/edit.rs @@ -338,17 +338,28 @@ impl Cx<'_, C> { } impl Cx<'_, C> { - /// Advances the component's wheel run, one edit gesture through the gesture slot: a `WheelPhase::End` share commits - /// a running run, any other notch with `Some(next)` proposes it. - #[allow(dead_code)] // P3(panels-w4): pn.C23 + /// Advances the component's wheel run, one edit gesture through the gesture slot: a notch with `Some(next)` + /// proposes it (the first notch begins the run), and a `WheelPhase::End` share, which the runtime hands a value + /// control when the wheel gesture ends, commits a running run. A run a host change or a removal cancelled stays + /// cancelled; the end then changes nothing. pub fn wheel_run(&mut self, phase: WheelPhase, next: Option>) { - let _ = (phase, next); - todo!("pn.C23") + if let Some(next) = next { + let running = self.gesture_slot().is_running(); + self.propose(next); + let slot = self.gesture_slot(); + // Only a run the wheel began is a wheel run: a notch inside a press-carried gesture joins that gesture. + if !running && slot.is_running() { + slot.wheel = true; + } + } + if phase == WheelPhase::End && self.in_wheel_run() { + self.commit(); + } } /// Whether the running gesture is a wheel run. - #[allow(dead_code)] // P3(panels-w4): pn.C23 pub fn in_wheel_run(&self) -> bool { - todo!("pn.C23") + let slot = self.core.memory.recall::>>(gesture_key(self.core.id)); + slot.is_running() && slot.wheel } } diff --git a/crates/ui-widgets/src/text/number.rs b/crates/ui-widgets/src/text/number.rs index 2d2e0a173..af759a050 100644 --- a/crates/ui-widgets/src/text/number.rs +++ b/crates/ui-widgets/src/text/number.rs @@ -211,9 +211,11 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { } /// Zoom typing: a Tab rewrites the draft and a press on the field's other parts keeps it unapplied. - #[allow(dead_code)] // P3(panels-w4): cw.C59 - pub(super) fn zoom_typing(self) -> Self { - todo!("cw.C59") + #[must_use] + pub(super) fn zoom_typing(mut self) -> Self { + self.options.tab_rewrites = true; + self.options.holds_drafts = true; + self } /// A drag on the field's side label scrubs the value too, with or without the focus in the field. @@ -229,17 +231,16 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { Rule::new(range.as_ref(), self.step) } - /// Reads what the field keeps from the env: a length field's scale from stored to shown, and the symbol of its unit - /// kind after the number unless the field sets a unit. + /// Reads a length field's scale from stored to shown from the env. fn settle_lengths(&mut self, units: &Units) { if let Some(lengths) = self.lengths { self.scale = units.length_scale(lengths).unwrap_or(1.0); } - if self.unit.is_none() - && let Some(kind) = self.unit_kind - { - self.unit = Some(units.symbol(kind).into()); - } + } + + /// The unit shown after the number: the field's own, else the symbol of its unit kind. + fn shown_unit(&self, units: &Units) -> Option