cosmic/widget/segmented_button/
style.rs

1// Copyright 2022 System76 <info@system76.com>
2// SPDX-License-Identifier: MPL-2.0
3
4use iced::Border;
5use iced_core::{Background, Color};
6
7/// Appearance of the segmented button.
8#[derive(Default, Clone, Copy)]
9pub struct Appearance {
10    pub background: Option<Background>,
11    pub border: Border,
12    pub active_width: f32,
13    pub active: ItemStatusAppearance,
14    pub inactive: ItemStatusAppearance,
15    pub hover: ItemStatusAppearance,
16    pub pressed: ItemStatusAppearance,
17}
18
19/// Appearance of an item in the segmented button.
20#[derive(Default, Clone, Copy)]
21pub struct ItemAppearance {
22    pub border: Border,
23}
24
25/// Appearance of an item based on its status.
26#[derive(Default, Clone, Copy)]
27pub struct ItemStatusAppearance {
28    pub background: Option<Background>,
29    pub first: ItemAppearance,
30    pub middle: ItemAppearance,
31    pub last: ItemAppearance,
32    pub text_color: Color,
33}
34
35/// Defines the [`Appearance`] of a segmented button.
36pub trait StyleSheet {
37    /// The supported style of the [`StyleSheet`].
38    type Style: Default;
39
40    /// The horizontal [`Appearance`] of the segmented button.
41    fn horizontal(&self, style: &Self::Style) -> Appearance;
42
43    /// The vertical [`Appearance`] of the segmented button.
44    fn vertical(&self, style: &Self::Style) -> Appearance;
45}