[−][src]Struct pushrod::render::engine::Engine
This is a storage container for the Pushrod event engine.
Methods
impl Engine
[src]
This is the heart of the Pushrod event engine, and is what is used to drive the interaction between the user and your application. The suggested method of use for this code is as follows:
Create a new object
Use Engine::new(w, h, frame_rate)
to instantiate a new object.
Set up the base
Call engine.setup(width, height)
, by passing the width and height of the window that is
being created for the main application. This is required, as a base widget is added to the
render list. This BaseWidget
is considered the parent of the application screen.
Add Widgets to the Engine
Call add_widget(Box::new(widget), "name".to_string())
to add your Widget
to the managed
display list.
Call Run()
Calling run(sdl, window)
will manage the application screen after all widgets have been added
to the display list.
That's all there is to it. If you want to see more interactions on how the Engine
is used in
an application, check out the demo test code, and look at rust-pushrod-chassis
.
pub fn new(w: u32, h: u32, frame_rate: u8) -> Self
[src]
Creates a new Engine
object. Sets the engine up with the bounds of the screen, and the desired
FPS rate, which must be provided at instantiation time. This is in order to set up the
BaseWidget
in the top-level of the Engine
, so that it knows what area of the screen to
refresh when required as part of the draw cycle.
NOTE: Setting a lower frame_rate will increase the efficiency of your API, however, it could lower responsiveness if you have a very active UI.
pub fn add_widget(
&mut self,
widget: Box<dyn Widget>,
widget_name: String
) -> i32
[src]
&mut self,
widget: Box<dyn Widget>,
widget_name: String
) -> i32
Adds a Widget
to the display list. Widget
s are rendered in the order in which they were
created in the display list.
pub fn add_layout(&mut self, layout: Box<dyn Layout>) -> i32
[src]
Adds a Layout
to the Layout
list.
pub fn set_running(&mut self, state: bool)
[src]
Sets running flag: false
shuts down the engine.
pub fn on_exit<F>(&mut self, callback: F) where
F: FnMut(&mut Engine) -> bool + 'static,
[src]
F: FnMut(&mut Engine) -> bool + 'static,
Assigns the callback closure that will be used the application close/quit is triggered.
pub fn run(&mut self, sdl: Sdl, window: Window)
[src]
Main application run loop, controls interaction between the user and the application.
Auto Trait Implementations
impl !RefUnwindSafe for Engine
impl !Send for Engine
impl !Sync for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,