Skip to content

Commit

Permalink
refactor(applet): add padded control
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 authored and mmstick committed Oct 24, 2023
1 parent 390de9a commit 3341299
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/applet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::widget::button::StyleSheet;
use crate::{
app::Core,
iced::{
Expand All @@ -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,
Expand Down Expand Up @@ -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<Element<'a, Message>>,
) -> 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()
}

0 comments on commit 3341299

Please sign in to comment.