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]
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,55 +137,55 @@ impl LayerShika<NeedsComponent> {
|
|||
|
||||
impl LayerShika<HasComponent> {
|
||||
#[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<Margins>) -> Self {
|
||||
pub fn margin(mut self, margin: impl Into<Margins>) -> 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<String>) -> Self {
|
||||
pub fn namespace(mut self, namespace: impl Into<String>) -> Self {
|
||||
self.config.namespace = namespace.into();
|
||||
self
|
||||
}
|
||||
|
||||
#[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
|
||||
}
|
||||
|
||||
#[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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -118,14 +118,14 @@ impl EventLoopHandle {
|
|||
) -> StdResult<RegistrationToken, Error>
|
||||
where
|
||||
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 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<F>(&self, duration: Duration, mut callback: F) -> Result<RegistrationToken>
|
||||
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<F>(&self, deadline: Instant, mut callback: F) -> Result<RegistrationToken>
|
||||
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<T>)>
|
||||
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<RegistrationToken>
|
||||
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) => {
|
||||
|
|
|
|||
12
src/lib.rs
12
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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue