refactor!(widget): rename segmented_selection to segmented_control to match Figma docs
This commit is contained in:
parent
366a450977
commit
bfc84c4759
6 changed files with 11 additions and 11 deletions
|
|
@ -13,7 +13,7 @@ pub enum SegmentedButton {
|
|||
#[default]
|
||||
ViewSwitcher,
|
||||
/// A widget for multiple choice selection.
|
||||
Selection,
|
||||
Control,
|
||||
/// Or implement any custom theme of your liking.
|
||||
Custom(Box<dyn Fn(&Theme) -> Appearance>),
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ impl StyleSheet for Theme {
|
|||
..Default::default()
|
||||
}
|
||||
}
|
||||
SegmentedButton::Selection => {
|
||||
SegmentedButton::Control => {
|
||||
let cosmic = self.cosmic();
|
||||
let active = horizontal::selection_active(cosmic);
|
||||
let mut neutral_5 = cosmic.palette.neutral_5;
|
||||
|
|
@ -110,7 +110,7 @@ impl StyleSheet for Theme {
|
|||
..Default::default()
|
||||
}
|
||||
}
|
||||
SegmentedButton::Selection => {
|
||||
SegmentedButton::Control => {
|
||||
let active = vertical::selection_active(cosmic);
|
||||
let mut neutral_5 = cosmic.palette.neutral_5;
|
||||
neutral_5.alpha = 0.2;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use super::button::StyleSheet;
|
|||
use super::divider::horizontal;
|
||||
use super::icon::{self, from_name};
|
||||
use super::segmented_button::{self, Model, SingleSelect};
|
||||
use super::{button, segmented_selection, text, text_input, tooltip, Icon};
|
||||
use super::{button, segmented_control, text, text_input, tooltip, Icon};
|
||||
|
||||
// TODO is this going to look correct enough?
|
||||
lazy_static! {
|
||||
|
|
@ -281,7 +281,7 @@ where
|
|||
let spacing = THEME.with(|t| t.borrow().cosmic().spacing);
|
||||
let mut inner = column![
|
||||
// segmented buttons
|
||||
segmented_selection::horizontal(self.model)
|
||||
segmented_control::horizontal(self.model)
|
||||
.on_activate(Box::new(move |e| on_update(
|
||||
ColorPickerUpdate::ActivateSegmented(e)
|
||||
)))
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ mod scrollable;
|
|||
pub use scrollable::*;
|
||||
|
||||
pub mod segmented_button;
|
||||
pub mod segmented_selection;
|
||||
pub mod segmented_control;
|
||||
|
||||
pub mod settings;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ where
|
|||
/ num as f32;
|
||||
}
|
||||
|
||||
let segmented_selection = matches!(self.style, crate::theme::SegmentedButton::Selection);
|
||||
let segmented_selection = matches!(self.style, crate::theme::SegmentedButton::Control);
|
||||
|
||||
Box::new(
|
||||
self.model
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ where
|
|||
width += f32::from(icon.size) + f32::from(self.button_spacing);
|
||||
} else if self.model.is_active(button) {
|
||||
// Add selection icon measurements when widget is a selection widget.
|
||||
if let crate::theme::SegmentedButton::Selection = self.style {
|
||||
if let crate::theme::SegmentedButton::Control = self.style {
|
||||
width += 16.0 + f32::from(self.button_spacing);
|
||||
}
|
||||
}
|
||||
|
|
@ -1061,7 +1061,7 @@ where
|
|||
} else {
|
||||
// Draw the selection indicator if widget is a segmented selection, and the item is selected.
|
||||
if key_is_active {
|
||||
if let crate::theme::SegmentedButton::Selection = self.style {
|
||||
if let crate::theme::SegmentedButton::Control = self.style {
|
||||
let mut image_bounds = bounds;
|
||||
image_bounds.y = center_y - 16.0 / 2.0;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ where
|
|||
.button_height(32)
|
||||
.button_padding([space_s, 0, space_s, 0])
|
||||
.button_spacing(space_xxs)
|
||||
.style(crate::theme::SegmentedButton::Selection)
|
||||
.style(crate::theme::SegmentedButton::Control)
|
||||
.font_active(Some(crate::font::FONT_SEMIBOLD))
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +56,6 @@ where
|
|||
.button_height(32)
|
||||
.button_padding([space_s, 0, space_s, 0])
|
||||
.button_spacing(space_xxs)
|
||||
.style(crate::theme::SegmentedButton::Selection)
|
||||
.style(crate::theme::SegmentedButton::Control)
|
||||
.font_active(Some(crate::font::FONT_SEMIBOLD))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue