browser_window_core/
application.rs

1pub mod c;
2
3
4pub use c::ApplicationImpl;
5
6use crate::error::CbwResult;
7
8use std::{
9	path::PathBuf,
10	os::raw::{c_char, c_int},
11	time::Duration
12};
13
14
15
16pub trait ApplicationExt: Copy {
17	/// Asserts if not on the GUI thread
18	fn assert_correct_thread( &self );
19	/// Dispatches work to be executed on the GUI thread.
20	fn dispatch( &self, work: unsafe fn(ApplicationImpl, *mut ()), data: *mut () ) -> bool;
21	/// Dispatches work to be executed on the GUI thread, but delayed by the specified number of milliseconds.
22	fn dispatch_delayed(&self, work: unsafe fn(ApplicationImpl, *mut ()), data: *mut (), delay: Duration ) -> bool;
23	/// Causes the main loop to exit and lets it return the given code.
24	fn exit( &self, exit_code: i32 );
25	/// Same as `exit`, but is thread-safe.
26	fn exit_threadsafe( self: &Self, exit_code: i32 );
27	/// Shuts down all application processes and performs necessary clean-up code.
28	fn finish( &self ) {}
29	fn initialize( argc: c_int, argv: *mut *mut c_char, settings: &ApplicationSettings ) -> CbwResult<ApplicationImpl>;
30	/// When this is called, the runtime will exit as soon as there are no more windows left.
31	fn mark_as_done(&self);
32	/// Runs the main loop.
33	/// This blocks until the application is exitting.
34	fn run( &self, on_ready: unsafe fn(ApplicationImpl, *mut ()), data: *mut () ) -> i32;
35}
36
37pub struct ApplicationSettings {
38	pub engine_seperate_executable_path: Option<PathBuf>,
39	pub resource_dir: Option<String>
40}
41
42
43
44impl Default for ApplicationSettings {
45	fn default() -> Self {
46		Self {
47			engine_seperate_executable_path: None,
48			resource_dir: None
49		}
50	}
51}