mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-23 11:25:54 +00:00
refactor: renaming windowing system to generic app, and add run convenience method on builder
This commit is contained in:
parent
f31b039a02
commit
adc9344b85
5 changed files with 35 additions and 19 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
use crate::system::WindowingSystem;
|
use crate::system::App;
|
||||||
use layer_shika_adapters::platform::slint_interpreter::{CompilationResult, Compiler};
|
use layer_shika_adapters::platform::slint_interpreter::{CompilationResult, Compiler};
|
||||||
use layer_shika_domain::errors::DomainError;
|
use layer_shika_domain::errors::DomainError;
|
||||||
use layer_shika_domain::prelude::{
|
use layer_shika_domain::prelude::{
|
||||||
|
|
@ -194,7 +194,7 @@ impl LayerShika<HasComponent> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<WindowingSystem> {
|
pub fn build(self) -> Result<App> {
|
||||||
let component_definition = self
|
let component_definition = self
|
||||||
.state
|
.state
|
||||||
.compilation_result
|
.compilation_result
|
||||||
|
|
@ -206,10 +206,15 @@ impl LayerShika<HasComponent> {
|
||||||
),
|
),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
WindowingSystem::new(
|
App::new(
|
||||||
component_definition,
|
component_definition,
|
||||||
Some(self.state.compilation_result),
|
Some(self.state.compilation_result),
|
||||||
self.config,
|
self.config,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run(self) -> Result<()> {
|
||||||
|
let mut app = self.build()?;
|
||||||
|
app.run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub use layer_shika_domain::value_objects::popup_request::{
|
||||||
PopupAt, PopupHandle, PopupRequest, PopupSize,
|
PopupAt, PopupHandle, PopupRequest, PopupSize,
|
||||||
};
|
};
|
||||||
pub use slint_callbacks::{SlintCallbackContract, SlintCallbackNames};
|
pub use slint_callbacks::{SlintCallbackContract, SlintCallbackNames};
|
||||||
pub use system::{EventLoopHandle, ShellContext, WindowingSystem};
|
pub use system::{App, EventLoopHandle, ShellContext};
|
||||||
|
|
||||||
pub mod calloop {
|
pub mod calloop {
|
||||||
pub use layer_shika_adapters::platform::calloop::{
|
pub use layer_shika_adapters::platform::calloop::{
|
||||||
|
|
@ -41,6 +41,19 @@ pub enum Error {
|
||||||
#[error("Domain error: {0}")]
|
#[error("Domain error: {0}")]
|
||||||
Domain(#[from] DomainError),
|
Domain(#[from] DomainError),
|
||||||
|
|
||||||
#[error("WindowingSystem has been dropped")]
|
#[error("App has been dropped")]
|
||||||
SystemDropped,
|
SystemDropped,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
pub use crate::{
|
||||||
|
AnchorEdges, App, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika,
|
||||||
|
OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt,
|
||||||
|
PopupHandle, PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result,
|
||||||
|
ShellContext, SlintCallbackContract, SlintCallbackNames,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub use crate::calloop::{Generic, Interest, Mode, PostAction, RegistrationToken, Timer};
|
||||||
|
|
||||||
|
pub use crate::{slint, slint_interpreter};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -391,13 +391,13 @@ impl ShellContext<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowingSystem {
|
pub struct App {
|
||||||
inner: Rc<RefCell<WindowingSystemFacade>>,
|
inner: Rc<RefCell<WindowingSystemFacade>>,
|
||||||
popup_command_sender: channel::Sender<PopupCommand>,
|
popup_command_sender: channel::Sender<PopupCommand>,
|
||||||
callback_contract: SlintCallbackContract,
|
callback_contract: SlintCallbackContract,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowingSystem {
|
impl App {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
component_definition: ComponentDefinition,
|
component_definition: ComponentDefinition,
|
||||||
compilation_result: Option<Rc<CompilationResult>>,
|
compilation_result: Option<Rc<CompilationResult>>,
|
||||||
|
|
|
||||||
15
src/lib.rs
15
src/lib.rs
|
|
@ -22,14 +22,11 @@
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use layer_shika::prelude::*;
|
//! use layer_shika::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! let system = LayerShika::from_file("ui/main.slint", Some("AppWindow"))?
|
//! LayerShika::from_file("ui/main.slint", Some("AppWindow"))?
|
||||||
//! .with_height(42)
|
//! .with_height(42)
|
||||||
//! .with_anchor(AnchorEdges::top_bar())
|
//! .with_anchor(AnchorEdges::top_bar())
|
||||||
//! .with_exclusive_zone(42)
|
//! .with_exclusive_zone(42)
|
||||||
//! .build()?;
|
//! .run()?;
|
||||||
//!
|
|
||||||
//! let mut system = system;
|
|
||||||
//! system.run()?;
|
|
||||||
//! # Ok::<(), layer_shika::Error>(())
|
//! # Ok::<(), layer_shika::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
@ -45,10 +42,10 @@
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
||||||
pub use layer_shika_composition::{
|
pub use layer_shika_composition::{
|
||||||
AnchorEdges, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry,
|
AnchorEdges, App, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika,
|
||||||
OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode,
|
OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle,
|
||||||
PopupRequest, PopupSize, PopupWindow, Result, ShellContext, SlintCallbackContract,
|
PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, ShellContext,
|
||||||
SlintCallbackNames, WindowingSystem,
|
SlintCallbackContract, SlintCallbackNames,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use layer_shika_composition::{slint, slint_interpreter};
|
pub use layer_shika_composition::{slint, slint_interpreter};
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,15 @@
|
||||||
|
|
||||||
// Core API types
|
// Core API types
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext, SlintCallbackContract,
|
App, Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext,
|
||||||
SlintCallbackNames, WindowingSystem,
|
SlintCallbackContract, SlintCallbackNames,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Domain value objects
|
// Domain value objects
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
AnchorEdges, KeyboardInteractivity, Layer, OutputGeometry, OutputHandle, OutputInfo,
|
AnchorEdges, KeyboardInteractivity, Layer, OutputGeometry, OutputHandle, OutputInfo,
|
||||||
OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize,
|
OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, PopupRequest,
|
||||||
|
PopupSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Event loop types
|
// Event loop types
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue