settings_ui: Fix stepper buttons to Inactive Opacity to 0.1 increment adjustments (#40477)
Closes #40279 Release Notes: - Fix stepper buttons (+/-) to the Inactive Opacity setting for 0.1 increment adjustments on settings UI --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
@@ -8,7 +8,7 @@ use std::{
|
||||
use editor::{Editor, EditorStyle};
|
||||
use gpui::{ClickEvent, Entity, FocusHandle, Focusable, FontWeight, Modifiers};
|
||||
|
||||
use settings::{CodeFade, MinimumContrast};
|
||||
use settings::{CodeFade, InactiveOpacity, MinimumContrast};
|
||||
use ui::prelude::*;
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
@@ -79,6 +79,30 @@ impl NumberFieldType for settings::CodeFade {
|
||||
}
|
||||
}
|
||||
|
||||
impl NumberFieldType for settings::InactiveOpacity {
|
||||
fn default_step() -> Self {
|
||||
InactiveOpacity(0.10)
|
||||
}
|
||||
fn large_step() -> Self {
|
||||
InactiveOpacity(0.20)
|
||||
}
|
||||
fn small_step() -> Self {
|
||||
InactiveOpacity(0.05)
|
||||
}
|
||||
fn min_value() -> Self {
|
||||
InactiveOpacity(0.0)
|
||||
}
|
||||
fn max_value() -> Self {
|
||||
InactiveOpacity(1.0)
|
||||
}
|
||||
fn saturating_add(self, rhs: Self) -> Self {
|
||||
InactiveOpacity((self.0 + rhs.0).min(Self::max_value().0))
|
||||
}
|
||||
fn saturating_sub(self, rhs: Self) -> Self {
|
||||
InactiveOpacity((self.0 - rhs.0).max(Self::min_value().0))
|
||||
}
|
||||
}
|
||||
|
||||
impl NumberFieldType for settings::MinimumContrast {
|
||||
fn default_step() -> Self {
|
||||
MinimumContrast(1.0)
|
||||
|
||||
Reference in New Issue
Block a user