From 6f108045ba10d69097c6d656b5bf4cd483724234 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 20 Oct 2023 13:05:04 -0400 Subject: [PATCH] refactor(applet): add padded control --- src/applet/mod.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/applet/mod.rs b/src/applet/mod.rs index 83c6c0cb61e..0963fb9d550 100644 --- a/src/applet/mod.rs +++ b/src/applet/mod.rs @@ -1,4 +1,3 @@ -use crate::widget::button::StyleSheet; use crate::{ app::Core, iced::{ @@ -13,6 +12,7 @@ use crate::{ }; pub use cosmic_panel_config; use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize}; +use iced_core::Padding; use iced_style::container::Appearance; use iced_widget::runtime::command::platform_specific::wayland::popup::{ SctkPopupSettings, SctkPositioner, @@ -291,6 +291,24 @@ pub fn menu_button<'a, Message>( ) -> crate::widget::Button<'a, Message, crate::Renderer> { crate::widget::Button::new(content) .style(Button::AppletMenu) - .padding([8, 24]) + .padding(menu_control_padding()) .width(Length::Fill) } + +pub fn padded_control<'a, Message>( + content: impl Into>, +) -> crate::widget::container::Container<'a, Message, crate::Renderer> { + crate::widget::container(content) + .padding(menu_control_padding()) + .width(Length::Fill) +} + +pub fn menu_control_padding() -> Padding { + THEME + .with(|t| { + let t = t.borrow(); + let cosmic = t.cosmic(); + [cosmic.space_xxs(), cosmic.space_m()] + }) + .into() +}