diff --git a/src/shell/element/stack/tab.rs b/src/shell/element/stack/tab.rs index b46e88f8..2ea045f0 100644 --- a/src/shell/element/stack/tab.rs +++ b/src/shell/element/stack/tab.rs @@ -1,26 +1,18 @@ use cosmic::{ font::Font, - iced::{ - widget::{self, container::draw_background, rule::FillMode}, - Element, - }, + iced::widget::{self, container::draw_background, rule::FillMode}, iced_core::{ alignment, event, layout::{Layout, Limits, Node}, mouse, overlay, renderer, widget::{ operation::{Operation, OperationOutputWrapper}, - text::StyleSheet as TextStyleSheet, tree::Tree, Id, Widget, }, Clipboard, Color, Length, Rectangle, Shell, Size, }, - iced_style::{ - button::StyleSheet as ButtonStyleSheet, container::StyleSheet as ContainerStyleSheet, - rule::StyleSheet as RuleStyleSheet, - }, - iced_widget::{scrollable::AbsoluteOffset, text}, + iced_widget::scrollable::AbsoluteOffset, theme, widget::{icon::from_name, Icon}, Apply, @@ -52,28 +44,29 @@ pub(super) fn selected_state_color(theme: &cosmic::cosmic_theme::Theme) -> Color } } +#[derive(Clone, Copy)] pub(super) enum TabRuleTheme { ActiveActivated, ActiveDeactivated, Default, } -impl Into for TabRuleTheme { - fn into(self) -> theme::Rule { - match self { - Self::ActiveActivated => theme::Rule::custom(|theme| widget::rule::Appearance { +impl From for theme::Rule { + fn from(theme: TabRuleTheme) -> Self { + match theme { + TabRuleTheme::ActiveActivated => Self::custom(|theme| widget::rule::Appearance { color: theme.cosmic().accent_color().into(), width: 4, radius: 0.0.into(), fill_mode: FillMode::Full, }), - Self::ActiveDeactivated => theme::Rule::custom(|theme| widget::rule::Appearance { + TabRuleTheme::ActiveDeactivated => Self::custom(|theme| widget::rule::Appearance { color: theme.cosmic().palette.neutral_5.into(), width: 4, radius: 0.0.into(), fill_mode: FillMode::Full, }), - Self::Default => theme::Rule::custom(|theme| widget::rule::Appearance { + TabRuleTheme::Default => Self::custom(|theme| widget::rule::Appearance { color: theme.cosmic().palette.neutral_5.into(), width: 4, radius: 8.0.into(), @@ -103,30 +96,30 @@ impl TabBackgroundTheme { } } -impl Into for TabBackgroundTheme { - fn into(self) -> theme::Container { - match self { - Self::ActiveActivated => { - theme::Container::custom(move |theme| widget::container::Appearance { +impl From for theme::Container { + fn from(background_theme: TabBackgroundTheme) -> Self { + match background_theme { + TabBackgroundTheme::ActiveActivated => { + Self::custom(move |theme| widget::container::Appearance { icon_color: Some(Color::from(theme.cosmic().accent_text_color())), text_color: Some(Color::from(theme.cosmic().accent_text_color())), - background: Some(self.background_color(theme).into()), + background: Some(background_theme.background_color(theme).into()), border_radius: 0.0.into(), border_width: 0.0, border_color: Color::TRANSPARENT, }) } - Self::ActiveDeactivated => { - theme::Container::custom(move |theme| widget::container::Appearance { + TabBackgroundTheme::ActiveDeactivated => { + Self::custom(move |theme| widget::container::Appearance { icon_color: None, text_color: None, - background: Some(self.background_color(theme).into()), + background: Some(background_theme.background_color(theme).into()), border_radius: 0.0.into(), border_width: 0.0, border_color: Color::TRANSPARENT, }) } - Self::Default => theme::Container::Transparent, + TabBackgroundTheme::Default => Self::Transparent, } } } @@ -154,7 +147,7 @@ pub struct Tab { active: bool, } -impl Tab { +impl Tab { pub fn new(title: impl Into, app_id: impl Into, id: Id) -> Self { Tab { id, @@ -210,20 +203,7 @@ impl Tab { self } - pub(super) fn internal<'a, Renderer>(self, idx: usize) -> TabInternal<'a, Message, Renderer> - where - Renderer: cosmic::iced_core::Renderer + 'a, - Renderer: cosmic::iced_core::text::Renderer, - Renderer::Theme: ButtonStyleSheet