Add _with_flags() variants to settings helpers (#85)
This commit is contained in:
parent
8232e1d249
commit
2dde95ee42
3 changed files with 24 additions and 12 deletions
|
|
@ -81,20 +81,26 @@ impl CosmicAppletHelper {
|
|||
|
||||
#[must_use]
|
||||
pub fn window_settings<F: Default>(&self) -> Settings<F> {
|
||||
let mut settings = crate::settings();
|
||||
self.window_settings_with_flags(F::default())
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn window_settings_with_flags<F>(&self, flags: F) -> Settings<F> {
|
||||
let (width, height) = self.suggested_size();
|
||||
let width = u32::from(width);
|
||||
let height = u32::from(height);
|
||||
settings.initial_surface = InitialSurface::XdgWindow(SctkWindowSettings {
|
||||
iced_settings: iced_native::window::Settings {
|
||||
size: (width + APPLET_PADDING * 2, height + APPLET_PADDING * 2),
|
||||
min_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)),
|
||||
max_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)),
|
||||
Settings {
|
||||
initial_surface: InitialSurface::XdgWindow(SctkWindowSettings {
|
||||
iced_settings: iced_native::window::Settings {
|
||||
size: (width + APPLET_PADDING * 2, height + APPLET_PADDING * 2),
|
||||
min_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)),
|
||||
max_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
settings
|
||||
}),
|
||||
..crate::settings_with_flags(flags)
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub mod widget;
|
|||
pub use executor::single::Executor as SingleThreadExecutor;
|
||||
|
||||
pub mod settings;
|
||||
pub use settings::settings;
|
||||
pub use settings::{settings, settings_with_flags};
|
||||
|
||||
mod ext;
|
||||
pub use ext::ElementExt;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,18 @@ pub fn set_default_icon_theme(name: impl Into<String>) {
|
|||
/// Default iced settings for COSMIC applications.
|
||||
#[must_use]
|
||||
pub fn settings<Flags: Default>() -> iced::Settings<Flags> {
|
||||
settings_with_flags(Flags::default())
|
||||
}
|
||||
|
||||
/// Default iced settings for COSMIC applications.
|
||||
#[must_use]
|
||||
pub fn settings_with_flags<Flags>(flags: Flags) -> iced::Settings<Flags> {
|
||||
iced::Settings {
|
||||
default_font: match font::FONT {
|
||||
iced::Font::Default => None,
|
||||
iced::Font::External { bytes, .. } => Some(bytes),
|
||||
},
|
||||
default_text_size: 18,
|
||||
..iced::Settings::default()
|
||||
..iced::Settings::with_flags(flags)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue