feat(segmented-button): Selection style and implementation
This commit is contained in:
parent
3454483345
commit
bbac6b9bbf
6 changed files with 68 additions and 16 deletions
|
|
@ -871,6 +871,8 @@ pub enum SegmentedButton {
|
|||
/// A tabbed widget for switching between views in an interface.
|
||||
#[default]
|
||||
ViewSwitcher,
|
||||
/// A widget for multiple choice selection.
|
||||
Selection,
|
||||
/// Or implement any custom theme of your liking.
|
||||
Custom(fn(&Theme) -> segmented_button::Appearance)
|
||||
}
|
||||
|
|
@ -913,6 +915,39 @@ impl segmented_button::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
}
|
||||
SegmentedButton::Selection => {
|
||||
let cosmic = self.cosmic();
|
||||
segmented_button::Appearance {
|
||||
background: None,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border_radius: BorderRadius::from(0.0),
|
||||
border_width: 0.0,
|
||||
button_active: segmented_button::ButtonAppearance {
|
||||
background: Some(Background::Color(cosmic.secondary.component.divider.into())),
|
||||
border_bottom: None,
|
||||
border_radius_first: BorderRadius::from([24.0, 0.0, 0.0, 24.0]),
|
||||
border_radius_last: BorderRadius::from([0.0, 24.0, 24.0, 0.0]),
|
||||
border_radius_middle: BorderRadius::from(0.0),
|
||||
text_color: cosmic.accent.base.into(),
|
||||
},
|
||||
button_inactive: segmented_button::ButtonAppearance {
|
||||
background: Some(Background::Color(cosmic.secondary.component.base.into())),
|
||||
border_bottom: None,
|
||||
border_radius_first: BorderRadius::from([24.0, 0.0, 0.0, 24.0]),
|
||||
border_radius_last: BorderRadius::from([0.0, 24.0, 24.0, 0.0]),
|
||||
border_radius_middle: BorderRadius::from(0.0),
|
||||
text_color: cosmic.primary.on.into(),
|
||||
},
|
||||
button_hover: segmented_button::ButtonAppearance {
|
||||
background: Some(Background::Color(cosmic.primary.component.hover.into())),
|
||||
border_bottom: None,
|
||||
border_radius_first: BorderRadius::from([24.0, 0.0, 0.0, 24.0]),
|
||||
border_radius_last: BorderRadius::from([0.0, 24.0, 24.0, 0.0]),
|
||||
border_radius_middle: BorderRadius::from(0.0),
|
||||
text_color: cosmic.accent.base.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
SegmentedButton::Custom(func) => func(self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
mod state;
|
||||
mod style;
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ where
|
|||
pub fn new(state: &'a WidgetState) -> Self {
|
||||
Self {
|
||||
state,
|
||||
height: Length::Units(48),
|
||||
height: Length::Units(32),
|
||||
width: Length::Fill,
|
||||
spacing: 0,
|
||||
style: <Renderer::Theme as StyleSheet>::Style::default(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use slotmap::{SecondaryMap, SlotMap};
|
||||
|
||||
slotmap::new_key_type! {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use iced_core::{Background, BorderRadius, Color};
|
||||
|
||||
/// The appearance of a [`SegmentedButton`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue