From ab887aeeac3b3d24c80084407143afb8e7acc2c8 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 19 Mar 2025 19:24:09 +0100 Subject: [PATCH] feat: add `cosmic::theme::spacing()` --- examples/application/src/main.rs | 1 + src/theme/mod.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/application/src/main.rs b/examples/application/src/main.rs index bcffc316..50329298 100644 --- a/examples/application/src/main.rs +++ b/examples/application/src/main.rs @@ -205,6 +205,7 @@ impl cosmic::Application for App { .on_input(Message::Input2) .on_clear(Message::Ignore), ] + .spacing(cosmic::theme::spacing().space_s) .width(iced::Length::Fill) .height(iced::Length::Shrink) .align_x(iced::Alignment::Center), diff --git a/src/theme/mod.rs b/src/theme/mod.rs index b3cdaf81..f2e42036 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -6,11 +6,12 @@ #[cfg(feature = "xdg-portal")] pub mod portal; pub mod style; +use cosmic_theme::Spacing; use cosmic_theme::ThemeMode; pub use style::*; -use cosmic_config::config_subscription; use cosmic_config::CosmicConfigEntry; +use cosmic_config::config_subscription; use cosmic_theme::Component; use cosmic_theme::LayeredTheme; use iced_futures::Subscription; @@ -63,6 +64,12 @@ pub fn active_type() -> ThemeType { THEME.lock().unwrap().theme_type.clone() } +/// Preferred interface spacing parameters defined by the active theme. +#[inline(always)] +pub fn spacing() -> Spacing { + active().cosmic().spacing +} + /// Whether the active theme has a dark preference. #[must_use] pub fn is_dark() -> bool {