diff --git a/crates/adapters/src/wayland/surfaces/popup_manager.rs b/crates/adapters/src/wayland/surfaces/popup_manager.rs index 9aa1e4f..6d5b19f 100644 --- a/crates/adapters/src/wayland/surfaces/popup_manager.rs +++ b/crates/adapters/src/wayland/surfaces/popup_manager.rs @@ -244,8 +244,8 @@ impl PopupManager { let params = CreatePopupParams { last_pointer_serial, - reference_x: request.at.position().0, - reference_y: request.at.position().1, + reference_x: request.placement.position().0, + reference_y: request.placement.position().1, width, height, positioning_mode: request.mode, diff --git a/crates/composition/src/lib.rs b/crates/composition/src/lib.rs index 30b6c1b..85e71aa 100644 --- a/crates/composition/src/lib.rs +++ b/crates/composition/src/lib.rs @@ -22,7 +22,7 @@ pub use layer_shika_domain::value_objects::output_info::{OutputGeometry, OutputI pub use layer_shika_domain::value_objects::output_policy::OutputPolicy; pub use layer_shika_domain::value_objects::popup_positioning_mode::PopupPositioningMode; pub use layer_shika_domain::value_objects::popup_request::{ - PopupAt, PopupHandle, PopupRequest, PopupSize, + PopupHandle, PopupPlacement, PopupRequest, PopupSize, }; pub use popup_builder::PopupBuilder; pub use system::{App, EventContext, EventLoopHandle, ShellControl}; @@ -51,7 +51,7 @@ pub mod prelude { pub use crate::{ AnchorEdges, AnchorStrategy, App, EventContext, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, - PopupAt, PopupBuilder, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, + PopupBuilder, PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, ShellControl, }; diff --git a/crates/composition/src/popup_builder.rs b/crates/composition/src/popup_builder.rs index 22c693d..361f74f 100644 --- a/crates/composition/src/popup_builder.rs +++ b/crates/composition/src/popup_builder.rs @@ -3,12 +3,12 @@ use crate::system::App; use layer_shika_adapters::platform::slint_interpreter::Value; use layer_shika_domain::prelude::AnchorStrategy; use layer_shika_domain::value_objects::popup_positioning_mode::PopupPositioningMode; -use layer_shika_domain::value_objects::popup_request::{PopupAt, PopupRequest, PopupSize}; +use layer_shika_domain::value_objects::popup_request::{PopupPlacement, PopupRequest, PopupSize}; pub struct PopupBuilder<'a> { app: &'a App, component: String, - reference: PopupAt, + reference: PopupPlacement, anchor: PopupPositioningMode, size: PopupSize, grab: bool, @@ -21,7 +21,7 @@ impl<'a> PopupBuilder<'a> { Self { app, component, - reference: PopupAt::Cursor, + reference: PopupPlacement::AtCursor, anchor: PopupPositioningMode::TopLeft, size: PopupSize::Content, grab: false, @@ -32,19 +32,19 @@ impl<'a> PopupBuilder<'a> { #[must_use] pub fn relative_to_cursor(mut self) -> Self { - self.reference = PopupAt::Cursor; + self.reference = PopupPlacement::AtCursor; self } #[must_use] pub fn relative_to_point(mut self, x: f32, y: f32) -> Self { - self.reference = PopupAt::Absolute { x, y }; + self.reference = PopupPlacement::AtPosition { x, y }; self } #[must_use] pub fn relative_to_rect(mut self, x: f32, y: f32, w: f32, h: f32) -> Self { - self.reference = PopupAt::AnchorRect { x, y, w, h }; + self.reference = PopupPlacement::AtRect { x, y, w, h }; self } @@ -284,7 +284,7 @@ impl<'a> PopupBuilder<'a> { ); let mut builder = PopupRequest::builder(component_clone.clone()) - .at(PopupAt::absolute(reference_x, reference_y)) + .placement(PopupPlacement::at_position(reference_x, reference_y)) .size(PopupSize::Content) .grab(grab) .mode(mode); @@ -318,7 +318,7 @@ impl<'a> PopupBuilder<'a> { fn build_request(&self) -> PopupRequest { let mut builder = PopupRequest::builder(self.component.clone()) - .at(self.reference) + .placement(self.reference) .size(self.size) .mode(self.anchor) .grab(self.grab); diff --git a/crates/composition/src/system.rs b/crates/composition/src/system.rs index 08616f5..43e7cc7 100644 --- a/crates/composition/src/system.rs +++ b/crates/composition/src/system.rs @@ -21,7 +21,7 @@ use layer_shika_domain::value_objects::output_handle::OutputHandle; use layer_shika_domain::value_objects::output_info::OutputInfo; use layer_shika_domain::value_objects::popup_positioning_mode::PopupPositioningMode; use layer_shika_domain::value_objects::popup_request::{ - PopupAt, PopupHandle, PopupRequest, PopupSize, + PopupHandle, PopupPlacement, PopupRequest, PopupSize, }; use std::cell::Cell; use std::cell::RefCell; @@ -58,14 +58,14 @@ impl ShellControl { pub fn show_popup_at_cursor(&self, component: impl Into) -> Result<()> { let request = PopupRequest::builder(component.into()) - .at(PopupAt::Cursor) + .placement(PopupPlacement::AtCursor) .build(); self.show_popup(&request) } pub fn show_popup_centered(&self, component: impl Into) -> Result<()> { let request = PopupRequest::builder(component.into()) - .at(PopupAt::Cursor) + .placement(PopupPlacement::AtCursor) .mode(PopupPositioningMode::Center) .build(); self.show_popup(&request) @@ -78,7 +78,7 @@ impl ShellControl { y: f32, ) -> Result<()> { let request = PopupRequest::builder(component.into()) - .at(PopupAt::Absolute { x, y }) + .placement(PopupPlacement::AtPosition { x, y }) .build(); self.show_popup(&request) } @@ -342,8 +342,8 @@ impl EventContext<'_> { req.component, initial_dimensions.0, initial_dimensions.1, - req.at.position().0, - req.at.position().1, + req.placement.position().0, + req.placement.position().1, req.mode ); diff --git a/crates/domain/src/value_objects/popup_request.rs b/crates/domain/src/value_objects/popup_request.rs index 6ddbd65..a0839f3 100644 --- a/crates/domain/src/value_objects/popup_request.rs +++ b/crates/domain/src/value_objects/popup_request.rs @@ -18,7 +18,7 @@ impl PopupHandle { #[derive(Debug, Clone)] pub struct PopupRequest { pub component: String, - pub at: PopupAt, + pub placement: PopupPlacement, pub size: PopupSize, pub mode: PopupPositioningMode, pub grab: bool, @@ -30,13 +30,13 @@ impl PopupRequest { #[must_use] pub fn new( component: String, - at: PopupAt, + placement: PopupPlacement, size: PopupSize, mode: PopupPositioningMode, ) -> Self { Self { component, - at, + placement, size, mode, grab: false, @@ -52,33 +52,33 @@ impl PopupRequest { } #[derive(Debug, Clone, Copy)] -pub enum PopupAt { - Absolute { x: f32, y: f32 }, - Cursor, - AnchorRect { x: f32, y: f32, w: f32, h: f32 }, +pub enum PopupPlacement { + AtPosition { x: f32, y: f32 }, + AtCursor, + AtRect { x: f32, y: f32, w: f32, h: f32 }, } -impl PopupAt { +impl PopupPlacement { #[must_use] - pub const fn absolute(x: f32, y: f32) -> Self { - Self::Absolute { x, y } + pub const fn at_position(x: f32, y: f32) -> Self { + Self::AtPosition { x, y } } #[must_use] - pub const fn cursor() -> Self { - Self::Cursor + pub const fn at_cursor() -> Self { + Self::AtCursor } #[must_use] - pub const fn anchor_rect(x: f32, y: f32, w: f32, h: f32) -> Self { - Self::AnchorRect { x, y, w, h } + pub const fn at_rect(x: f32, y: f32, w: f32, h: f32) -> Self { + Self::AtRect { x, y, w, h } } #[must_use] pub const fn position(&self) -> (f32, f32) { match *self { - Self::Absolute { x, y } | Self::AnchorRect { x, y, .. } => (x, y), - Self::Cursor => (0.0, 0.0), + Self::AtPosition { x, y } | Self::AtRect { x, y, .. } => (x, y), + Self::AtCursor => (0.0, 0.0), } } } @@ -111,7 +111,7 @@ impl PopupSize { pub struct PopupRequestBuilder { component: String, - at: PopupAt, + placement: PopupPlacement, size: PopupSize, mode: PopupPositioningMode, grab: bool, @@ -124,7 +124,7 @@ impl PopupRequestBuilder { pub fn new(component: String) -> Self { Self { component, - at: PopupAt::Cursor, + placement: PopupPlacement::AtCursor, size: PopupSize::Content, mode: PopupPositioningMode::default(), grab: false, @@ -134,8 +134,8 @@ impl PopupRequestBuilder { } #[must_use] - pub const fn at(mut self, at: PopupAt) -> Self { - self.at = at; + pub const fn placement(mut self, placement: PopupPlacement) -> Self { + self.placement = placement; self } @@ -173,7 +173,7 @@ impl PopupRequestBuilder { pub fn build(self) -> PopupRequest { PopupRequest { component: self.component, - at: self.at, + placement: self.placement, size: self.size, mode: self.mode, grab: self.grab, diff --git a/src/lib.rs b/src/lib.rs index 96f8d95..d6cd843 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,8 +44,8 @@ pub mod prelude; pub use layer_shika_composition::{ AnchorEdges, AnchorStrategy, App, Error, EventContext, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, - PopupAt, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, - ShellControl, + PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, + Result, ShellControl, }; pub use layer_shika_composition::{slint, slint_interpreter}; diff --git a/src/prelude.rs b/src/prelude.rs index f209b5e..ae97841 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -16,7 +16,7 @@ pub use crate::{ // Domain value objects pub use crate::{ AnchorEdges, KeyboardInteractivity, Layer, OutputGeometry, OutputHandle, OutputInfo, - OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, PopupRequest, + OutputPolicy, OutputRegistry, PopupHandle, PopupPlacement, PopupPositioningMode, PopupRequest, PopupSize, };