Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(applet): add padded control #188

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
Loading