ui: Add NumericStepper
component (#13954)
This PR adds a `NumericStepper` component that can be used to display a numeric value along with controls to increment, decrement, and reset the value. The `ApplicationMenu` has been updated to use the `NumericStepper` for adjusting the buffer and UI font size. Here it is in action: https://github.com/zed-industries/zed/assets/1486634/03cffe67-1256-4283-aa3d-560fffa06dad Note: Due to the way we do font adjustments, once modified the reset button will be displayed until it is clicked (or the font size adjustment is otherwise reset). Simply returning to the original value will currently not hide the reset button. Release Notes: - N/A
This commit is contained in:
parent
97f315356d
commit
9e36a66fec
8 changed files with 159 additions and 122 deletions
|
@ -75,6 +75,19 @@ impl IconSize {
|
|||
IconSize::Medium => rems_from_px(16.),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the length of a side of the square that contains this [`IconSize`], with padding.
|
||||
pub(crate) fn square(&self, cx: &mut WindowContext) -> Pixels {
|
||||
let icon_size = self.rems() * cx.rem_size();
|
||||
let padding = match self {
|
||||
IconSize::Indicator => Spacing::None.px(cx),
|
||||
IconSize::XSmall => Spacing::XSmall.px(cx),
|
||||
IconSize::Small => Spacing::XSmall.px(cx),
|
||||
IconSize::Medium => Spacing::XSmall.px(cx),
|
||||
};
|
||||
|
||||
icon_size + padding * 2.
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Copy, Clone, EnumIter, Serialize, Deserialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue