mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-23 09:15:55 +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::system::WindowingSystem;
|
||||
use crate::system::App;
|
||||
use layer_shika_adapters::platform::slint_interpreter::{CompilationResult, Compiler};
|
||||
use layer_shika_domain::errors::DomainError;
|
||||
use layer_shika_domain::prelude::{
|
||||
|
|
@ -194,7 +194,7 @@ impl LayerShika<HasComponent> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> Result<WindowingSystem> {
|
||||
pub fn build(self) -> Result<App> {
|
||||
let component_definition = self
|
||||
.state
|
||||
.compilation_result
|
||||
|
|
@ -206,10 +206,15 @@ impl LayerShika<HasComponent> {
|
|||
),
|
||||
})?;
|
||||
|
||||
WindowingSystem::new(
|
||||
App::new(
|
||||
component_definition,
|
||||
Some(self.state.compilation_result),
|
||||
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,
|
||||
};
|
||||
pub use slint_callbacks::{SlintCallbackContract, SlintCallbackNames};
|
||||
pub use system::{EventLoopHandle, ShellContext, WindowingSystem};
|
||||
pub use system::{App, EventLoopHandle, ShellContext};
|
||||
|
||||
pub mod calloop {
|
||||
pub use layer_shika_adapters::platform::calloop::{
|
||||
|
|
@ -41,6 +41,19 @@ pub enum Error {
|
|||
#[error("Domain error: {0}")]
|
||||
Domain(#[from] DomainError),
|
||||
|
||||
#[error("WindowingSystem has been dropped")]
|
||||
#[error("App has been dropped")]
|
||||
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>>,
|
||||
popup_command_sender: channel::Sender<PopupCommand>,
|
||||
callback_contract: SlintCallbackContract,
|
||||
}
|
||||
|
||||
impl WindowingSystem {
|
||||
impl App {
|
||||
pub(crate) fn new(
|
||||
component_definition: ComponentDefinition,
|
||||
compilation_result: Option<Rc<CompilationResult>>,
|
||||
|
|
|
|||
15
src/lib.rs
15
src/lib.rs
|
|
@ -22,14 +22,11 @@
|
|||
//! ```rust,no_run
|
||||
//! 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_anchor(AnchorEdges::top_bar())
|
||||
//! .with_exclusive_zone(42)
|
||||
//! .build()?;
|
||||
//!
|
||||
//! let mut system = system;
|
||||
//! system.run()?;
|
||||
//! .run()?;
|
||||
//! # Ok::<(), layer_shika::Error>(())
|
||||
//! ```
|
||||
//!
|
||||
|
|
@ -45,10 +42,10 @@
|
|||
pub mod prelude;
|
||||
|
||||
pub use layer_shika_composition::{
|
||||
AnchorEdges, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika, OutputGeometry,
|
||||
OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode,
|
||||
PopupRequest, PopupSize, PopupWindow, Result, ShellContext, SlintCallbackContract,
|
||||
SlintCallbackNames, WindowingSystem,
|
||||
AnchorEdges, App, Error, EventLoopHandle, KeyboardInteractivity, Layer, LayerShika,
|
||||
OutputGeometry, OutputHandle, OutputInfo, OutputPolicy, OutputRegistry, PopupAt, PopupHandle,
|
||||
PopupPositioningMode, PopupRequest, PopupSize, PopupWindow, Result, ShellContext,
|
||||
SlintCallbackContract, SlintCallbackNames,
|
||||
};
|
||||
|
||||
pub use layer_shika_composition::{slint, slint_interpreter};
|
||||
|
|
|
|||
|
|
@ -10,14 +10,15 @@
|
|||
|
||||
// Core API types
|
||||
pub use crate::{
|
||||
Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext, SlintCallbackContract,
|
||||
SlintCallbackNames, WindowingSystem,
|
||||
App, Error, EventLoopHandle, LayerShika, PopupWindow, Result, ShellContext,
|
||||
SlintCallbackContract, SlintCallbackNames,
|
||||
};
|
||||
|
||||
// Domain value objects
|
||||
pub use crate::{
|
||||
AnchorEdges, KeyboardInteractivity, Layer, OutputGeometry, OutputHandle, OutputInfo,
|
||||
OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, PopupRequest, PopupSize,
|
||||
OutputPolicy, OutputRegistry, PopupAt, PopupHandle, PopupPositioningMode, PopupRequest,
|
||||
PopupSize,
|
||||
};
|
||||
|
||||
// Event loop types
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue