mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-02 20:15:54 +00:00
refactor: minor renaming
This commit is contained in:
parent
dc676d606e
commit
b1c605dd7c
6 changed files with 32 additions and 32 deletions
|
|
@ -46,19 +46,19 @@ impl EGLContextBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.display_id = Some(display_id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.surface_id = Some(surface_id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.size = Some(size);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,55 +137,55 @@ impl LayerShika<NeedsComponent> {
|
||||||
|
|
||||||
impl LayerShika<HasComponent> {
|
impl LayerShika<HasComponent> {
|
||||||
#[must_use]
|
#[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.config.height = WindowHeight::new(height);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.config.layer = layer;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_margin(mut self, margin: impl Into<Margins>) -> Self {
|
pub fn margin(mut self, margin: impl Into<Margins>) -> Self {
|
||||||
self.config.margin = margin.into();
|
self.config.margin = margin.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.config.anchor = anchor;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.config.exclusive_zone = zone;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_namespace(mut self, namespace: impl Into<String>) -> Self {
|
pub fn namespace(mut self, namespace: impl Into<String>) -> Self {
|
||||||
self.config.namespace = namespace.into();
|
self.config.namespace = namespace.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_scale_factor(mut self, sf: impl TryInto<ScaleFactor, Error = DomainError>) -> Self {
|
pub fn scale_factor(mut self, sf: impl TryInto<ScaleFactor, Error = DomainError>) -> Self {
|
||||||
self.config.scale_factor = sf.try_into().unwrap_or_default();
|
self.config.scale_factor = sf.try_into().unwrap_or_default();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.config.keyboard_interactivity = mode;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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.config.output_policy = policy;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ pub use layer_shika_domain::value_objects::popup_request::{
|
||||||
PopupAt, PopupHandle, PopupRequest, PopupSize,
|
PopupAt, PopupHandle, PopupRequest, PopupSize,
|
||||||
};
|
};
|
||||||
pub use popup_builder::PopupBuilder;
|
pub use popup_builder::PopupBuilder;
|
||||||
pub use system::{App, EventLoopHandle, ShellContext, ShellControl};
|
pub use system::{App, EventContext, EventLoopHandle, ShellControl};
|
||||||
|
|
||||||
pub mod calloop {
|
pub mod calloop {
|
||||||
pub use layer_shika_adapters::platform::calloop::{
|
pub use layer_shika_adapters::platform::calloop::{
|
||||||
|
|
@ -49,10 +49,10 @@ pub enum Error {
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
AnchorEdges, AnchorStrategy, App, EventLoopHandle, KeyboardInteractivity, Layer,
|
AnchorEdges, AnchorStrategy, App, EventContext, EventLoopHandle, KeyboardInteractivity,
|
||||||
LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry,
|
Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry,
|
||||||
PopupAt, PopupBuilder, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize,
|
PopupAt, PopupBuilder, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize,
|
||||||
PopupWindow, Result, ShellContext, ShellControl,
|
PopupWindow, Result, ShellControl,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::calloop::{Generic, Interest, Mode, PostAction, RegistrationToken, Timer};
|
pub use crate::calloop::{Generic, Interest, Mode, PostAction, RegistrationToken, Timer};
|
||||||
|
|
|
||||||
|
|
@ -118,14 +118,14 @@ impl EventLoopHandle {
|
||||||
) -> StdResult<RegistrationToken, Error>
|
) -> StdResult<RegistrationToken, Error>
|
||||||
where
|
where
|
||||||
S: EventSource<Ret = R> + 'static,
|
S: EventSource<Ret = R> + '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 system = self.system.upgrade().ok_or(Error::SystemDropped)?;
|
||||||
let loop_handle = system.borrow().inner_ref().event_loop_handle();
|
let loop_handle = system.borrow().inner_ref().event_loop_handle();
|
||||||
|
|
||||||
loop_handle
|
loop_handle
|
||||||
.insert_source(source, move |event, metadata, app_state| {
|
.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)
|
callback(event, metadata, shell_context)
|
||||||
})
|
})
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
|
@ -140,7 +140,7 @@ impl EventLoopHandle {
|
||||||
|
|
||||||
pub fn add_timer<F>(&self, duration: Duration, mut callback: F) -> Result<RegistrationToken>
|
pub fn add_timer<F>(&self, duration: Duration, mut callback: F) -> Result<RegistrationToken>
|
||||||
where
|
where
|
||||||
F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static,
|
F: FnMut(Instant, EventContext<'_>) -> TimeoutAction + 'static,
|
||||||
{
|
{
|
||||||
let timer = Timer::from_duration(duration);
|
let timer = Timer::from_duration(duration);
|
||||||
self.insert_source(timer, move |deadline, (), shell_context| {
|
self.insert_source(timer, move |deadline, (), shell_context| {
|
||||||
|
|
@ -150,7 +150,7 @@ impl EventLoopHandle {
|
||||||
|
|
||||||
pub fn add_timer_at<F>(&self, deadline: Instant, mut callback: F) -> Result<RegistrationToken>
|
pub fn add_timer_at<F>(&self, deadline: Instant, mut callback: F) -> Result<RegistrationToken>
|
||||||
where
|
where
|
||||||
F: FnMut(Instant, ShellContext<'_>) -> TimeoutAction + 'static,
|
F: FnMut(Instant, EventContext<'_>) -> TimeoutAction + 'static,
|
||||||
{
|
{
|
||||||
let timer = Timer::from_deadline(deadline);
|
let timer = Timer::from_deadline(deadline);
|
||||||
self.insert_source(timer, move |deadline, (), shell_context| {
|
self.insert_source(timer, move |deadline, (), shell_context| {
|
||||||
|
|
@ -164,7 +164,7 @@ impl EventLoopHandle {
|
||||||
) -> Result<(RegistrationToken, channel::Sender<T>)>
|
) -> Result<(RegistrationToken, channel::Sender<T>)>
|
||||||
where
|
where
|
||||||
T: 'static,
|
T: 'static,
|
||||||
F: FnMut(T, ShellContext<'_>) + 'static,
|
F: FnMut(T, EventContext<'_>) + 'static,
|
||||||
{
|
{
|
||||||
let (sender, receiver) = channel::channel();
|
let (sender, receiver) = channel::channel();
|
||||||
let token = self.insert_source(receiver, move |event, (), shell_context| {
|
let token = self.insert_source(receiver, move |event, (), shell_context| {
|
||||||
|
|
@ -184,7 +184,7 @@ impl EventLoopHandle {
|
||||||
) -> Result<RegistrationToken>
|
) -> Result<RegistrationToken>
|
||||||
where
|
where
|
||||||
T: AsFd + 'static,
|
T: AsFd + 'static,
|
||||||
F: FnMut(ShellContext<'_>) + 'static,
|
F: FnMut(EventContext<'_>) + 'static,
|
||||||
{
|
{
|
||||||
let generic = Generic::new(fd, interest, mode);
|
let generic = Generic::new(fd, interest, mode);
|
||||||
self.insert_source(generic, move |_readiness, _fd, shell_context| {
|
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,
|
app_state: &'a mut AppState,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,7 +210,7 @@ fn extract_dimensions_from_callback(args: &[Value]) -> PopupDimensions {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellContext<'_> {
|
impl EventContext<'_> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn component_instance(&self) -> Option<&ComponentInstance> {
|
pub fn component_instance(&self) -> Option<&ComponentInstance> {
|
||||||
self.app_state
|
self.app_state
|
||||||
|
|
@ -660,7 +660,7 @@ impl App {
|
||||||
loop_handle
|
loop_handle
|
||||||
.insert_source(receiver, move |event, (), app_state| {
|
.insert_source(receiver, move |event, (), app_state| {
|
||||||
if let channel::Event::Msg(command) = event {
|
if let channel::Event::Msg(command) = event {
|
||||||
let mut shell_context = ShellContext { app_state };
|
let mut shell_context = EventContext { app_state };
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
PopupCommand::Show(request) => {
|
PopupCommand::Show(request) => {
|
||||||
|
|
|
||||||
12
src/lib.rs
12
src/lib.rs
|
|
@ -23,9 +23,9 @@
|
||||||
//! use layer_shika::prelude::*;
|
//! use layer_shika::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! LayerShika::from_file("ui/main.slint", Some("AppWindow"))?
|
//! LayerShika::from_file("ui/main.slint", Some("AppWindow"))?
|
||||||
//! .with_height(42)
|
//! .height(42)
|
||||||
//! .with_anchor(AnchorEdges::top_bar())
|
//! .anchor(AnchorEdges::top_bar())
|
||||||
//! .with_exclusive_zone(42)
|
//! .exclusive_zone(42)
|
||||||
//! .run()?;
|
//! .run()?;
|
||||||
//! # Ok::<(), layer_shika::Error>(())
|
//! # Ok::<(), layer_shika::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
@ -42,9 +42,9 @@
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
||||||
pub use layer_shika_composition::{
|
pub use layer_shika_composition::{
|
||||||
AnchorEdges, AnchorStrategy, App, Error, EventLoopHandle, KeyboardInteractivity, Layer,
|
AnchorEdges, AnchorStrategy, App, Error, EventContext, EventLoopHandle, KeyboardInteractivity,
|
||||||
LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt,
|
Layer, LayerShika, OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry,
|
||||||
PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, ShellContext,
|
PopupAt, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result,
|
||||||
ShellControl,
|
ShellControl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// Core API types
|
// Core API types
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
App, Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext, ShellControl,
|
App, Error, EventContext, EventLoopHandle, LayerShika, PopupWindow, Result, ShellControl,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Domain value objects
|
// Domain value objects
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue