diff --git a/crates/ui-widgets/src/bars/status_readout.rs b/crates/ui-widgets/src/bars/status_readout.rs index cf64231a6..3d0439fad 100644 --- a/crates/ui-widgets/src/bars/status_readout.rs +++ b/crates/ui-widgets/src/bars/status_readout.rs @@ -219,7 +219,7 @@ impl<'a> StatusReadout<'a> { }; let field = Field::new(words.readout_zoom.clone()) .side(SideLabel::new().kind(LabelKind::Hidden)) - .show(ui, |ui, _| ZoomField::new(words.readout_zoom.clone(), current, document).scrub(true).show(ui)); + .show(ui, |ui, _| ZoomField::new(words.readout_zoom.clone(), current, document).scrub(true).status_bar().show(ui)); let field = field.inner.map(|zoom| { invalid_zoom = zoom.invalid_zoom; events = zoom.view; diff --git a/crates/ui-widgets/src/text/number.rs b/crates/ui-widgets/src/text/number.rs index 76f2dc992..4680f98e2 100644 --- a/crates/ui-widgets/src/text/number.rs +++ b/crates/ui-widgets/src/text/number.rs @@ -22,8 +22,9 @@ use craft_behavior::nav::{LARGE_STEPS, StepResult, ValueAxes, ValueSteps}; use craft_behavior::{ Codec, ColumnKey, HitLevel, HitPriority, Metrics, NavMove, NumberCodec, PartKey, PressPhase, Sense, ValueDrag, decimals_for_step, wheel_step, }; -use craft_theme::{Stateful, States}; -use egui::{Rect, Vec2}; +use craft_theme::{Rgba, Stateful, States}; +use egui::{CornerRadius, Rect, Vec2}; +use std::borrow::Cow; use std::marker::PhantomData; use std::ops::RangeInclusive; @@ -128,6 +129,8 @@ pub struct NumberField<'a, V: NumberValue + 'static = Option> { /// Whether the unit is drawn inside the field or left to the host to draw after it. #[prop] unit_placement: UnitPlacement, + #[style_key] + status_zoom: bool, /// The rows of the list a chevron after the field opens; Alt+Down opens it too. #[prop] presets: Option<&'a [Entry]>, @@ -203,6 +206,7 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { stepper: None, unit: None, unit_placement: UnitPlacement::Inside, + status_zoom: false, presets: None, popup_slider: None, snap_popup_slider: true, @@ -238,6 +242,13 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { self } + /// Keeps the entire zoom percentage together in an unframed well in the status bar. + #[must_use] + pub(super) fn status_zoom(mut self) -> Self { + self.status_zoom = true; + self.sizing(Sizing::Content) + } + /// A drag on the field's side label scrubs the value too, with or without the focus in the field. #[must_use] pub fn scrub_by_label(mut self) -> Self { @@ -261,7 +272,7 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { /// The unit drawn inside the field after the number: the field's own, else the symbol of its unit kind; none when /// the host draws it after the field. fn shown_unit(&self, units: &Units) -> Option