From 58fc0344595262a3557362ce880489cef7e97841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= Date: Wed, 25 Dec 2024 01:09:05 +0100 Subject: [PATCH] fix(dropdown): styling --- src/app/mod.rs | 30 +++++++++--------------------- src/theme/style/iced.rs | 25 +++++++++++-------------- src/widget/dropdown/menu/mod.rs | 30 +++++++++++++++--------------- src/widget/dropdown/multi/menu.rs | 28 ++++++++++++++-------------- src/widget/header_bar.rs | 6 +----- 5 files changed, 50 insertions(+), 69 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index d6864a501df..45b53fc6ea2 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -703,14 +703,11 @@ impl ApplicationExt for App { .focused_window() .is_some_and(|i| Some(i) == self.core().main_window_id()); - // Offset for the window border - let window_padding = if sharp_corners { 8 } else { 7 }; - let main_content_padding = if content_container { if nav_bar_active { - [0, window_padding, window_padding, 0] + [0, 8, 8, 0] } else { - [0, window_padding, window_padding, window_padding] + [0, 8, 8, 8] } } else { [0, 0, 0, 0] @@ -724,11 +721,7 @@ impl ApplicationExt for App { .nav_bar() .map(|nav| id_container(nav, iced_core::id::Id::new("COSMIC_nav_bar"))) { - widgets.push( - container(nav) - .padding([0, window_padding, window_padding, window_padding]) - .into(), - ); + widgets.push(container(nav).padding([0, 8, 8, 8]).into()); true } else { false @@ -760,7 +753,7 @@ impl ApplicationExt for App { }) .apply(container) .padding(if content_container { - [0, window_padding, window_padding, 0] + [0, 8, 8, 0] } else { [0, 0, 0, 0] }) @@ -808,7 +801,7 @@ impl ApplicationExt for App { }) .apply(container) .padding(if content_container { - [0, window_padding, window_padding, 0] + [0, 8, 8, 0] } else { [0, 0, 0, 0] }) @@ -825,14 +818,10 @@ impl ApplicationExt for App { }); let content_col = crate::widget::column::with_capacity(2) .push(content_row) - .push_maybe(self.footer().map(|footer| { - container(footer.map(Message::App)).padding([ - 0, - window_padding, - window_padding, - window_padding, - ]) - })); + .push_maybe( + self.footer() + .map(|footer| container(footer.map(Message::App)).padding([0, 8, 8, 8])), + ); let content: Element<_> = if core.window.content_container { content_col .apply(container) @@ -851,7 +840,6 @@ impl ApplicationExt for App { let mut header = crate::widget::header_bar() .focused(focused) .title(&core.window.header_title) - .horizontal_padding(window_padding) .on_drag(Message::Cosmic(cosmic::Message::Drag)) .on_right_click(Message::Cosmic(cosmic::Message::ShowWindowMenu)) .on_double_click(Message::Cosmic(cosmic::Message::Maximize)); diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index b6e866b799c..b12d77f4ff1 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -536,20 +536,17 @@ impl iced_container::Catalog for Theme { Container::Secondary => Container::secondary(cosmic), - Container::Dropdown => { - let theme = self.cosmic(); - - iced_container::Style { - icon_color: None, - text_color: None, - background: Some(iced::Background::Color(theme.primary.base.into())), - border: Border { - radius: cosmic.corner_radii.radius_xs.into(), - ..Default::default() - }, - shadow: Shadow::default(), - } - } + Container::Dropdown => iced_container::Style { + icon_color: None, + text_color: None, + background: Some(iced::Background::Color(cosmic.bg_component_color().into())), + border: Border { + color: cosmic.bg_component_divider().into(), + width: 1.0, + radius: cosmic.corner_radii.radius_s.into(), + }, + shadow: Shadow::default(), + }, Container::Tooltip => iced_container::Style { icon_color: None, diff --git a/src/widget/dropdown/menu/mod.rs b/src/widget/dropdown/menu/mod.rs index 6657442000f..045a5ef0ad3 100644 --- a/src/widget/dropdown/menu/mod.rs +++ b/src/widget/dropdown/menu/mod.rs @@ -156,21 +156,21 @@ impl<'a, Message: 'a> Overlay<'a, Message> { style, } = menu; - let mut container = Container::new(Scrollable::new(List { - options, - icons, - hovered_option, - selected_option, - on_selected, - on_option_hovered, - text_size, - text_line_height, - padding, - })); - - container = container - .padding(padding) - .class(crate::style::Container::Dropdown); + let mut container = Container::new(Scrollable::new( + Container::new(List { + options, + icons, + hovered_option, + selected_option, + on_selected, + on_option_hovered, + text_size, + text_line_height, + padding, + }) + .padding(padding), + )) + .class(crate::style::Container::Dropdown); state.tree.diff(&mut container as &mut dyn Widget<_, _, _>); diff --git a/src/widget/dropdown/multi/menu.rs b/src/widget/dropdown/multi/menu.rs index 5e3aa6a6d4d..f5ee5f5b6d4 100644 --- a/src/widget/dropdown/multi/menu.rs +++ b/src/widget/dropdown/multi/menu.rs @@ -152,20 +152,20 @@ impl<'a, Message: 'a> Overlay<'a, Message> { style, } = menu; - let mut container = Container::new(Scrollable::new(InnerList { - options, - hovered_option, - selected_option, - on_selected, - on_option_hovered, - padding, - text_size, - text_line_height, - })); - - container = container - .padding(padding) - .class(crate::style::Container::Dropdown); + let mut container = Container::new(Scrollable::new( + Container::new(InnerList { + options, + hovered_option, + selected_option, + on_selected, + on_option_hovered, + padding, + text_size, + text_line_height, + }) + .padding(padding), + )) + .class(crate::style::Container::Dropdown); state.tree.diff(&mut container as &mut dyn Widget<_, _, _>); diff --git a/src/widget/header_bar.rs b/src/widget/header_bar.rs index 07b2593bdc5..1f70220fca3 100644 --- a/src/widget/header_bar.rs +++ b/src/widget/header_bar.rs @@ -22,7 +22,6 @@ pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> { center: Vec::new(), end: Vec::new(), density: None, - horizontal_padding: 8, focused: false, on_double_click: None, } @@ -75,9 +74,6 @@ pub struct HeaderBar<'a, Message> { #[setters(strip_option)] density: Option, - /// Horizontal padding of the headerbar - horizontal_padding: u16, - /// Focused state of the window focused: bool, } @@ -346,7 +342,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> { ) .align_y(iced::Alignment::Center) .height(Length::Fixed(height)) - .padding([0, self.horizontal_padding]) + .padding([0, 8]) .spacing(8) .apply(widget::container) .class(crate::theme::Container::HeaderBar {