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
|
@ -381,6 +381,10 @@ pub fn adjust_buffer_font_size(cx: &mut AppContext, f: fn(&mut Pixels)) {
|
|||
cx.refresh();
|
||||
}
|
||||
|
||||
pub fn has_adjusted_buffer_font_size(cx: &mut AppContext) -> bool {
|
||||
cx.has_global::<AdjustedBufferFontSize>()
|
||||
}
|
||||
|
||||
pub fn reset_buffer_font_size(cx: &mut AppContext) {
|
||||
if cx.has_global::<AdjustedBufferFontSize>() {
|
||||
cx.remove_global::<AdjustedBufferFontSize>();
|
||||
|
@ -417,6 +421,10 @@ pub fn adjust_ui_font_size(cx: &mut WindowContext, f: fn(&mut Pixels)) {
|
|||
cx.refresh();
|
||||
}
|
||||
|
||||
pub fn has_adjusted_ui_font_size(cx: &mut AppContext) -> bool {
|
||||
cx.has_global::<AdjustedUiFontSize>()
|
||||
}
|
||||
|
||||
pub fn reset_ui_font_size(cx: &mut WindowContext) {
|
||||
if cx.has_global::<AdjustedUiFontSize>() {
|
||||
cx.remove_global::<AdjustedUiFontSize>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue