pub struct BrowserApp { /* private fields */ }Expand description
Main browser application struct.
Responsibilities:
- Manage the window collection and per-window
BrowserUiinstances. - Forward winit window events to each window’s UI.
- Coordinate resource loading and route fetched results to the owning window.
Tab state, input handling, and rendering are delegated to BrowserUi /
[BrowserRenderer].
Typical lifecycle:
- Construct
BrowserApp::new(...), which wires platform components (network, system). - Create
Tabobjects, wrap them in aBrowserUi, and callset_default_ui. - Call
run()to start the event loop. Each loop iteration:- Forward winit events to the owning window’s
BrowserUi. - Tick the UI, forward fetch requests to the network, and route responses back.
- Forward winit events to the owning window’s
Example usage:
use orinium_browser::browser::{BrowserApp, BrowserUi, Tab};
let mut tab = Tab::default();
tab.navigate("resource:///test/test.html".parse().unwrap());
let mut app = BrowserApp::default();
app.set_default_ui(BrowserUi::with_tab(tab));
app.run().unwrap();Implementations§
Source§impl BrowserApp
impl BrowserApp
Sourcepub fn run(self) -> Result<()>
pub fn run(self) -> Result<()>
Starts the main browser event loop asynchronously.
Returns an error if no default UI was set via set_default_ui.
Sourcepub fn new(
default_window_size: (u32, u32),
default_window_title: String,
) -> Result<Self, Error>
pub fn new( default_window_size: (u32, u32), default_window_title: String, ) -> Result<Self, Error>
Creates a new browser instance with the given default window size and title.
Windows are registered later via open_window.
Sourcepub fn open_window(
&mut self,
window_id: WindowId,
window_size: (u32, u32),
window_title: String,
scale_factor: f64,
root_ui: BrowserUi,
)
pub fn open_window( &mut self, window_id: WindowId, window_size: (u32, u32), window_title: String, scale_factor: f64, root_ui: BrowserUi, )
Registers a new window with the given id, size, title, scale factor, and associated UI.
Sourcepub fn close_window(&mut self, window_id: WindowId)
pub fn close_window(&mut self, window_id: WindowId)
Removes a window’s state when the window is closed.
Sourcepub fn default_window_size(&self) -> (f32, f32)
pub fn default_window_size(&self) -> (f32, f32)
Returns the default window size for opening new windows.
Sourcepub fn default_window_title(&self) -> String
pub fn default_window_title(&self) -> String
Returns the default window title for opening new windows.
Sourcepub fn set_default_ui(&mut self, ui: BrowserUi)
pub fn set_default_ui(&mut self, ui: BrowserUi)
Sets the UI to use when the first window opens.
Must be called before run().
Sourcepub fn take_default_ui(&mut self) -> Option<BrowserUi>
pub fn take_default_ui(&mut self) -> Option<BrowserUi>
Takes the default UI, or returns None if not set.
Sourcepub fn handle_window_event(
&mut self,
window_id: WindowId,
event: WindowEvent,
gpu: &mut GpuRenderer,
) -> BrowserCommand
pub fn handle_window_event( &mut self, window_id: WindowId, event: WindowEvent, gpu: &mut GpuRenderer, ) -> BrowserCommand
Handles a winit window event for the given window and returns a BrowserCommand.
Sourcepub fn redraw(&mut self, window_id: WindowId, gpu: &mut GpuRenderer)
pub fn redraw(&mut self, window_id: WindowId, gpu: &mut GpuRenderer)
Rebuilds the render tree and sends draw commands to the GPU for the given window.
Sourcepub fn apply_draw_commands(&self, window_id: WindowId, gpu: &mut GpuRenderer)
pub fn apply_draw_commands(&self, window_id: WindowId, gpu: &mut GpuRenderer)
Applies the current draw commands for the given window to the GPU renderer.
Sourcepub fn window_size(&self, window_id: WindowId) -> (f32, f32)
pub fn window_size(&self, window_id: WindowId) -> (f32, f32)
Returns the current window size for the given window as (width, height) in floating-point pixels.
Sourcepub fn window_title(&self, window_id: WindowId) -> String
pub fn window_title(&self, window_id: WindowId) -> String
Returns the window title for the given window.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BrowserApp
impl !Send for BrowserApp
impl !Sync for BrowserApp
impl !UnwindSafe for BrowserApp
impl Freeze for BrowserApp
impl Unpin for BrowserApp
impl UnsafeUnpin for BrowserApp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().