refactor: renaming

This commit is contained in:
drendog 2025-12-03 12:38:30 +01:00
parent dc9374b76d
commit 408355e980
Signed by: dwenya
GPG key ID: 8DD77074645332D0
5 changed files with 19 additions and 22 deletions

View file

@ -137,7 +137,7 @@ impl LayerShika<NeedsComponent> {
impl LayerShika<HasComponent> {
#[must_use]
pub fn dimensions(mut self, width: u32, height: u32) -> Self {
pub fn size(mut self, width: u32, height: u32) -> Self {
self.config.dimensions = WindowDimension::new(width, height);
self
}

View file

@ -75,7 +75,9 @@ pub mod prelude {
pub use crate::{slint, slint_interpreter};
pub use layer_shika_domain::prelude::{Margins, ScaleFactor, WindowConfig, WindowDimension};
pub use layer_shika_domain::prelude::{
LogicalSize, Margins, PhysicalSize, ScaleFactor, WindowConfig, WindowDimension,
};
pub use layer_shika_adapters::platform::wayland::Anchor;
}

View file

@ -1,10 +1,14 @@
use crate::value_objects::output_info::OutputInfo;
use std::fmt;
use std::rc::Rc;
type OutputFilter = Rc<dyn Fn(&OutputInfo) -> bool>;
#[derive(Clone)]
pub enum OutputPolicy {
AllOutputs,
PrimaryOnly,
Custom(Box<dyn Fn(&OutputInfo) -> bool>),
Custom(OutputFilter),
}
impl OutputPolicy {
@ -28,7 +32,7 @@ impl OutputPolicy {
where
F: Fn(&OutputInfo) -> bool + 'static,
{
Self::Custom(Box::new(filter))
Self::Custom(Rc::new(filter))
}
}
@ -38,21 +42,12 @@ impl Default for OutputPolicy {
}
}
impl Clone for OutputPolicy {
fn clone(&self) -> Self {
match self {
OutputPolicy::AllOutputs | OutputPolicy::Custom(_) => OutputPolicy::AllOutputs,
OutputPolicy::PrimaryOnly => OutputPolicy::PrimaryOnly,
}
}
}
impl fmt::Debug for OutputPolicy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
OutputPolicy::AllOutputs => write!(f, "OutputPolicy::AllOutputs"),
OutputPolicy::PrimaryOnly => write!(f, "OutputPolicy::PrimaryOnly"),
OutputPolicy::Custom(_) => write!(f, "OutputPolicy::Custom(<function>)"),
OutputPolicy::Custom(_) => write!(f, "OutputPolicy::Custom(<filter>)"),
}
}
}

View file

@ -22,7 +22,7 @@
//! ```rust,no_run
//! use layer_shika::prelude::*;
//!
//! LayerShika::from_file("ui/main.slint", Some("AppWindow"))?
//! LayerShika::from_file("ui/main.slint")?
//! .height(42)
//! .anchor(AnchorEdges::top_bar())
//! .exclusive_zone(42)
@ -63,10 +63,10 @@
pub mod prelude;
pub use layer_shika_composition::{
AnchorEdges, AnchorStrategy, Error, EventContext, EventLoopHandle, KeyboardInteractivity,
Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry,
PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow,
Result, ShellControl, ShellRuntime, SingleWindowShell, DEFAULT_WINDOW_NAME,
AnchorEdges, AnchorStrategy, DEFAULT_WINDOW_NAME, Error, EventContext, EventLoopHandle,
KeyboardInteractivity, Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo,
OutputPolicy, OutputRegistry, PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest,
PopupSize, PopupWindow, Result, ShellControl, ShellRuntime, SingleWindowShell,
};
pub use layer_shika_composition::{

View file

@ -9,8 +9,8 @@
#![allow(clippy::pub_use)]
pub use crate::{
Error, EventContext, EventLoopHandle, LayerShika, PopupWindow, Result, ShellControl,
ShellRuntime, SingleWindowShell, DEFAULT_WINDOW_NAME,
DEFAULT_WINDOW_NAME, Error, EventContext, EventLoopHandle, LayerShika, PopupWindow, Result,
ShellControl, ShellRuntime, SingleWindowShell,
};
pub use crate::{
@ -25,7 +25,7 @@ pub use crate::{
};
pub use layer_shika_composition::prelude::{
Anchor, Margins, ScaleFactor, WindowConfig, WindowDimension,
Anchor, LogicalSize, Margins, PhysicalSize, ScaleFactor, WindowConfig, WindowDimension,
};
pub use crate::calloop;