refactor: renaming windowing system to generic app, and add run convenience method on builder

This commit is contained in:
drendog 2025-11-19 19:54:37 +01:00
parent f31b039a02
commit adc9344b85
Signed by: dwenya
GPG key ID: 8DD77074645332D0
5 changed files with 35 additions and 19 deletions

View file

@ -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()
}
}

View file

@ -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};
}

View file

@ -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>>,

View file

@ -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};

View file

@ -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