diff --git a/crates/adapters/src/rendering/egl/context.rs b/crates/adapters/src/rendering/egl/context.rs index 948fd80..b99d333 100644 --- a/crates/adapters/src/rendering/egl/context.rs +++ b/crates/adapters/src/rendering/egl/context.rs @@ -46,19 +46,19 @@ impl EGLContextBuilder { } #[must_use] - pub fn with_display_id(mut self, display_id: ObjectId) -> Self { + pub fn display_id(mut self, display_id: ObjectId) -> Self { self.display_id = Some(display_id); self } #[must_use] - pub fn with_surface_id(mut self, surface_id: ObjectId) -> Self { + pub fn surface_id(mut self, surface_id: ObjectId) -> Self { self.surface_id = Some(surface_id); self } #[must_use] - pub const fn with_size(mut self, size: PhysicalSize) -> Self { + pub const fn size(mut self, size: PhysicalSize) -> Self { self.size = Some(size); self } diff --git a/crates/composition/src/builder.rs b/crates/composition/src/builder.rs index 65e87f9..c05b322 100644 --- a/crates/composition/src/builder.rs +++ b/crates/composition/src/builder.rs @@ -137,55 +137,55 @@ impl LayerShika { impl LayerShika { #[must_use] - pub fn with_height(mut self, height: u32) -> Self { + pub fn height(mut self, height: u32) -> Self { self.config.height = WindowHeight::new(height); self } #[must_use] - pub const fn with_layer(mut self, layer: Layer) -> Self { + pub const fn layer(mut self, layer: Layer) -> Self { self.config.layer = layer; self } #[must_use] - pub fn with_margin(mut self, margin: impl Into) -> Self { + pub fn margin(mut self, margin: impl Into) -> Self { self.config.margin = margin.into(); self } #[must_use] - pub const fn with_anchor(mut self, anchor: AnchorEdges) -> Self { + pub const fn anchor(mut self, anchor: AnchorEdges) -> Self { self.config.anchor = anchor; self } #[must_use] - pub const fn with_exclusive_zone(mut self, zone: i32) -> Self { + pub const fn exclusive_zone(mut self, zone: i32) -> Self { self.config.exclusive_zone = zone; self } #[must_use] - pub fn with_namespace(mut self, namespace: impl Into) -> Self { + pub fn namespace(mut self, namespace: impl Into) -> Self { self.config.namespace = namespace.into(); self } #[must_use] - pub fn with_scale_factor(mut self, sf: impl TryInto) -> Self { + pub fn scale_factor(mut self, sf: impl TryInto) -> Self { self.config.scale_factor = sf.try_into().unwrap_or_default(); self } #[must_use] - pub const fn with_keyboard_interactivity(mut self, mode: KeyboardInteractivity) -> Self { + pub const fn keyboard_interactivity(mut self, mode: KeyboardInteractivity) -> Self { self.config.keyboard_interactivity = mode; self } #[must_use] - pub fn with_output_policy(mut self, policy: OutputPolicy) -> Self { + pub fn output_policy(mut self, policy: OutputPolicy) -> Self { self.config.output_policy = policy; self } diff --git a/crates/composition/src/lib.rs b/crates/composition/src/lib.rs index 06f1b2d..30b6c1b 100644 --- a/crates/composition/src/lib.rs +++ b/crates/composition/src/lib.rs @@ -25,7 +25,7 @@ pub use layer_shika_domain::value_objects::popup_request::{ PopupAt, PopupHandle, PopupRequest, PopupSize, }; pub use popup_builder::PopupBuilder; -pub use system::{App, EventLoopHandle, ShellContext, ShellControl}; +pub use system::{App, EventContext, EventLoopHandle, ShellControl}; pub mod calloop { pub use layer_shika_adapters::platform::calloop::{ @@ -49,10 +49,10 @@ pub enum Error { pub mod prelude { pub use crate::{ - AnchorEdges, AnchorStrategy, App, EventLoopHandle, KeyboardInteractivity, Layer, - LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, + AnchorEdges, AnchorStrategy, App, EventContext, EventLoopHandle, KeyboardInteractivity, + Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupBuilder, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, - PopupWindow, Result, ShellContext, ShellControl, + PopupWindow, Result, ShellControl, }; pub use crate::calloop::{Generic, Interest, Mode, PostAction, RegistrationToken, Timer}; diff --git a/crates/composition/src/system.rs b/crates/composition/src/system.rs index 2444f76..08616f5 100644 --- a/crates/composition/src/system.rs +++ b/crates/composition/src/system.rs @@ -118,14 +118,14 @@ impl EventLoopHandle { ) -> StdResult where S: EventSource + 'static, - F: FnMut(S::Event, &mut S::Metadata, ShellContext<'_>) -> R + 'static, + F: FnMut(S::Event, &mut S::Metadata, EventContext<'_>) -> R + 'static, { let system = self.system.upgrade().ok_or(Error::SystemDropped)?; let loop_handle = system.borrow().inner_ref().event_loop_handle(); loop_handle .insert_source(source, move |event, metadata, app_state| { - let shell_context = ShellContext { app_state }; + let shell_context = EventContext { app_state }; callback(event, metadata, shell_context) }) .map_err(|e| { @@ -140,7 +140,7 @@ impl EventLoopHandle { pub fn add_timer(&self, duration: Duration, mut callback: F) -> Result where - F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static, + F: FnMut(Instant, EventContext<'_>) -> TimeoutAction + 'static, { let timer = Timer::from_duration(duration); self.insert_source(timer, move |deadline, (), shell_context| { @@ -150,7 +150,7 @@ impl EventLoopHandle { pub fn add_timer_at(&self, deadline: Instant, mut callback: F) -> Result where - F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static, + F: FnMut(Instant, EventContext<'_>) -> TimeoutAction + 'static, { let timer = Timer::from_deadline(deadline); self.insert_source(timer, move |deadline, (), shell_context| { @@ -164,7 +164,7 @@ impl EventLoopHandle { ) -> Result<(RegistrationToken, channel::Sender)> where T: 'static, - F: FnMut(T, ShellContext<'_>) + 'static, + F: FnMut(T, EventContext<'_>) + 'static, { let (sender, receiver) = channel::channel(); let token = self.insert_source(receiver, move |event, (), shell_context| { @@ -184,7 +184,7 @@ impl EventLoopHandle { ) -> Result where T: AsFd + 'static, - F: FnMut(ShellContext<'_>) + 'static, + F: FnMut(EventContext<'_>) + 'static, { let generic = Generic::new(fd, interest, mode); self.insert_source(generic, move |_readiness, _fd, shell_context| { @@ -194,7 +194,7 @@ impl EventLoopHandle { } } -pub struct ShellContext<'a> { +pub struct EventContext<'a> { app_state: &'a mut AppState, } @@ -210,7 +210,7 @@ fn extract_dimensions_from_callback(args: &[Value]) -> PopupDimensions { ) } -impl ShellContext<'_> { +impl EventContext<'_> { #[must_use] pub fn component_instance(&self) -> Option<&ComponentInstance> { self.app_state @@ -660,7 +660,7 @@ impl App { loop_handle .insert_source(receiver, move |event, (), app_state| { if let channel::Event::Msg(command) = event { - let mut shell_context = ShellContext { app_state }; + let mut shell_context = EventContext { app_state }; match command { PopupCommand::Show(request) => { diff --git a/src/lib.rs b/src/lib.rs index deab662..96f8d95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,9 +23,9 @@ //! use layer_shika::prelude::*; //! //! LayerShika::from_file("ui/main.slint", Some("AppWindow"))? -//! .with_height(42) -//! .with_anchor(AnchorEdges::top_bar()) -//! .with_exclusive_zone(42) +//! .height(42) +//! .anchor(AnchorEdges::top_bar()) +//! .exclusive_zone(42) //! .run()?; //! # Ok::<(), layer_shika::Error>(()) //! ``` @@ -42,9 +42,9 @@ pub mod prelude; pub use layer_shika_composition::{ - AnchorEdges, AnchorStrategy, App, Error, EventLoopHandle, KeyboardInteractivity, Layer, - LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, - PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, ShellContext, + AnchorEdges, AnchorStrategy, App, Error, EventContext, EventLoopHandle, KeyboardInteractivity, + Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, + PopupAt, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, ShellControl, }; diff --git a/src/prelude.rs b/src/prelude.rs index 5dc4406..f209b5e 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -10,7 +10,7 @@ // Core API types pub use crate::{ - App, Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext, ShellControl, + App, Error, EventContext, EventLoopHandle, LayerShika, PopupWindow, Result, ShellControl, }; // Domain value objects