1// Copyright 2023 System76 <info@system76.com>
2// SPDX-License-Identifier: MPL-2.0
34//! A selection of multiple choices appearing as a conjoined button.
5//!
6//! See the [`segmented_button`] module for more details.
78use super::segmented_button::{
9self, HorizontalSegmentedButton, Model, Selectable, VerticalSegmentedButton,
10};
1112/// A selection of multiple choices appearing as a conjoined button.
13///
14/// The data for the widget comes from a model that is maintained the application.
15///
16/// For details on the model, see the [`segmented_button`] module for more details.
17pub fn horizontal<SelectionMode: Default, Message>(
18 model: &Model<SelectionMode>,
19) -> HorizontalSegmentedButton<SelectionMode, Message>
20where
21Model<SelectionMode>: Selectable,
22{
23let space_s = crate::theme::spacing().space_s;
24let space_xxs = crate::theme::spacing().space_xxs;
2526 segmented_button::horizontal(model)
27 .button_alignment(iced::Alignment::Center)
28 .dividers(true)
29 .button_height(32)
30 .button_padding([space_s, 0, space_s, 0])
31 .button_spacing(space_xxs)
32 .style(crate::theme::SegmentedButton::Control)
33 .font_active(Some(crate::font::semibold()))
34}
3536/// A selection of multiple choices appearing as a conjoined button.
37///
38/// The data for the widget comes from a model that is maintained the application.
39///
40/// For details on the model, see the [`segmented_button`] module for more details.
41pub fn vertical<SelectionMode, Message>(
42 model: &Model<SelectionMode>,
43) -> VerticalSegmentedButton<SelectionMode, Message>
44where
45Model<SelectionMode>: Selectable,
46 SelectionMode: Default,
47{
48let space_s = crate::theme::spacing().space_s;
49let space_xxs = crate::theme::spacing().space_xxs;
5051 segmented_button::vertical(model)
52 .button_alignment(iced::Alignment::Center)
53 .dividers(true)
54 .button_height(32)
55 .button_padding([space_s, 0, space_s, 0])
56 .button_spacing(space_xxs)
57 .style(crate::theme::SegmentedButton::Control)
58 .font_active(Some(crate::font::semibold()))
59}