2022-12-28 23:18:31 +01:00
|
|
|
// Copyright 2022 System76 <info@system76.com>
|
2022-12-28 12:42:28 +01:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
2022-12-28 23:18:31 +01:00
|
|
|
|
2024-01-30 22:14:00 -05:00
|
|
|
use iced_core::{border::Radius, Background, Color};
|
2022-12-28 12:42:28 +01:00
|
|
|
|
2023-01-17 18:49:40 +01:00
|
|
|
/// Appearance of the segmented button.
|
2023-01-04 05:37:20 +01:00
|
|
|
#[derive(Default, Clone, Copy)]
|
2022-12-28 12:42:28 +01:00
|
|
|
pub struct Appearance {
|
2022-12-28 19:27:05 +01:00
|
|
|
pub background: Option<Background>,
|
2024-01-30 22:14:00 -05:00
|
|
|
pub border_radius: Radius,
|
2023-01-04 05:37:20 +01:00
|
|
|
pub border_bottom: Option<(f32, Color)>,
|
|
|
|
|
pub border_end: Option<(f32, Color)>,
|
|
|
|
|
pub border_start: Option<(f32, Color)>,
|
|
|
|
|
pub border_top: Option<(f32, Color)>,
|
2023-01-17 18:49:40 +01:00
|
|
|
pub active: ItemStatusAppearance,
|
|
|
|
|
pub inactive: ItemStatusAppearance,
|
|
|
|
|
pub hover: ItemStatusAppearance,
|
|
|
|
|
pub focus: ItemStatusAppearance,
|
2022-12-28 12:42:28 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-17 18:49:40 +01:00
|
|
|
/// Appearance of an item in the segmented button.
|
2023-01-04 05:37:20 +01:00
|
|
|
#[derive(Default, Clone, Copy)]
|
2023-01-17 18:49:40 +01:00
|
|
|
pub struct ItemAppearance {
|
2024-01-30 22:14:00 -05:00
|
|
|
pub border_radius: Radius,
|
2022-12-28 12:42:28 +01:00
|
|
|
pub border_bottom: Option<(f32, Color)>,
|
2023-01-04 05:37:20 +01:00
|
|
|
pub border_end: Option<(f32, Color)>,
|
|
|
|
|
pub border_start: Option<(f32, Color)>,
|
|
|
|
|
pub border_top: Option<(f32, Color)>,
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 18:49:40 +01:00
|
|
|
/// Appearance of an item based on its status.
|
2023-01-04 05:37:20 +01:00
|
|
|
#[derive(Default, Clone, Copy)]
|
2023-01-17 18:49:40 +01:00
|
|
|
pub struct ItemStatusAppearance {
|
2023-01-04 05:37:20 +01:00
|
|
|
pub background: Option<Background>,
|
2023-01-17 18:49:40 +01:00
|
|
|
pub first: ItemAppearance,
|
|
|
|
|
pub middle: ItemAppearance,
|
|
|
|
|
pub last: ItemAppearance,
|
2022-12-28 12:42:28 +01:00
|
|
|
pub text_color: Color,
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-28 23:18:31 +01:00
|
|
|
/// Defines the [`Appearance`] of a segmented button.
|
2022-12-28 12:42:28 +01:00
|
|
|
pub trait StyleSheet {
|
|
|
|
|
/// The supported style of the [`StyleSheet`].
|
|
|
|
|
type Style: Default;
|
|
|
|
|
|
2023-01-03 19:35:34 +01:00
|
|
|
/// The horizontal [`Appearance`] of the segmented button.
|
|
|
|
|
fn horizontal(&self, style: &Self::Style) -> Appearance;
|
|
|
|
|
|
|
|
|
|
/// The vertical [`Appearance`] of the segmented button.
|
|
|
|
|
fn vertical(&self, style: &Self::Style) -> Appearance;
|
2022-12-28 12:42:28 +01:00
|
|
|
}
|