pub struct Application {
pub view_models: ViewModelCollection,
pub animations_delta_time: Scalar,
/* private fields */
}
Expand description
Contains and orchestrates application layout, animations, interactions, etc.
See the application
module for more information and examples.
Fields§
§view_models: ViewModelCollection
§animations_delta_time: Scalar
The amount of time between the last update, used when calculating animation progress
Implementations§
Source§impl Application
impl Application
Sourcepub fn setup<F>(&mut self, f: F)where
F: FnMut(&mut Self),
pub fn setup<F>(&mut self, f: F)where
F: FnMut(&mut Self),
Setup the application with a given a setup function
We need to run the setup
function for the application to register components and
properties if we want to support serialization of the UI. We pass it a function that will do
the actual registration.
Note: RAUI will work fine without running any
setup
if UI serialization is not required.
pub fn notifier(&self) -> ChangeNotifier
Sourcepub fn register_component(&mut self, type_name: &str, processor: FnWidget)
pub fn register_component(&mut self, type_name: &str, processor: FnWidget)
Register’s a component under a string name used when serializing the UI
This function is often used in setup
functions for registering batches of
components.
Sourcepub fn unregister_component(&mut self, type_name: &str)
pub fn unregister_component(&mut self, type_name: &str)
Unregisters a component
Sourcepub fn register_props<T>(&mut self, name: &str)
pub fn register_props<T>(&mut self, name: &str)
Register’s a property type under a string name used when serializing the UI
This function is often used in setup
functions for registering batches of
properties.
Sourcepub fn unregister_props(&mut self, name: &str)
pub fn unregister_props(&mut self, name: &str)
Unregisters a property type
See register_props
Sourcepub fn serialize_props(&self, props: &Props) -> Result<PrefabValue, PrefabError>
pub fn serialize_props(&self, props: &Props) -> Result<PrefabValue, PrefabError>
Serialize the given Props
to a PrefabValue
Sourcepub fn deserialize_props(&self, data: PrefabValue) -> Result<Props, PrefabError>
pub fn deserialize_props(&self, data: PrefabValue) -> Result<Props, PrefabError>
Deserialize Props
from a PrefabValue
Sourcepub fn serialize_node(
&self,
data: &WidgetNode,
) -> Result<PrefabValue, ApplicationError>
pub fn serialize_node( &self, data: &WidgetNode, ) -> Result<PrefabValue, ApplicationError>
Serialize a WidgetNode
to a PrefabValue
Sourcepub fn deserialize_node(
&self,
data: PrefabValue,
) -> Result<WidgetNode, ApplicationError>
pub fn deserialize_node( &self, data: PrefabValue, ) -> Result<WidgetNode, ApplicationError>
Deserialize a WidgetNode
from a PrefabValue
Sourcepub fn last_invalidation_cause(&self) -> &InvalidationCause
pub fn last_invalidation_cause(&self) -> &InvalidationCause
Get the reason that the application state was last invalidated and caused to re-process
Sourcepub fn dirty(&self) -> &WidgetIdCommon
pub fn dirty(&self) -> &WidgetIdCommon
Return’s common root widget ID of widgets that has to be to be re-processed
Sourcepub fn mark_dirty(&mut self)
pub fn mark_dirty(&mut self)
Force mark the application as needing to re-process its root
pub fn does_render_changed(&self) -> bool
Sourcepub fn tree(&self) -> &WidgetNode
pub fn tree(&self) -> &WidgetNode
Get the WidgetNode
for the application tree
Sourcepub fn rendered_tree(&self) -> &WidgetUnit
pub fn rendered_tree(&self) -> &WidgetUnit
Get the application widget tree rendered to raw WidgetUnit
’s
Sourcepub fn layout_data(&self) -> &Layout
pub fn layout_data(&self) -> &Layout
Get the application Layout
data
pub fn has_layout_widget(&self, id: &WidgetId) -> bool
Sourcepub fn apply(&mut self, tree: impl Into<WidgetNode>)
pub fn apply(&mut self, tree: impl Into<WidgetNode>)
Update the application widget tree
Sourcepub fn render<R, T, E>(
&self,
mapping: &CoordsMapping,
renderer: &mut R,
) -> Result<T, E>where
R: Renderer<T, E>,
pub fn render<R, T, E>(
&self,
mapping: &CoordsMapping,
renderer: &mut R,
) -> Result<T, E>where
R: Renderer<T, E>,
Render the application
Sourcepub fn render_change<R, T, E>(
&mut self,
mapping: &CoordsMapping,
renderer: &mut R,
) -> Result<Option<T>, E>where
R: Renderer<T, E>,
pub fn render_change<R, T, E>(
&mut self,
mapping: &CoordsMapping,
renderer: &mut R,
) -> Result<Option<T>, E>where
R: Renderer<T, E>,
Render the application, but only if something effecting the rendering has changed and it needs to be re-rendered
Sourcepub fn layout<L, E>(
&mut self,
mapping: &CoordsMapping,
layout_engine: &mut L,
) -> Result<(), E>where
L: LayoutEngine<E>,
pub fn layout<L, E>(
&mut self,
mapping: &CoordsMapping,
layout_engine: &mut L,
) -> Result<(), E>where
L: LayoutEngine<E>,
Calculate application layout
Sourcepub fn layout_change<L, E>(
&mut self,
mapping: &CoordsMapping,
layout_engine: &mut L,
) -> Result<bool, E>where
L: LayoutEngine<E>,
pub fn layout_change<L, E>(
&mut self,
mapping: &CoordsMapping,
layout_engine: &mut L,
) -> Result<bool, E>where
L: LayoutEngine<E>,
Calculate application layout, but only if something effecting application layout has changed and the layout needs to be re-done
Sourcepub fn interact<I, R, E>(&mut self, interactions_engine: &mut I) -> Result<R, E>where
I: InteractionsEngine<R, E>,
pub fn interact<I, R, E>(&mut self, interactions_engine: &mut I) -> Result<R, E>where
I: InteractionsEngine<R, E>,
Perform interactions on the application using the given interaction engine
Sourcepub fn send_message<T>(&mut self, id: &WidgetId, data: T)where
T: 'static + MessageData,
pub fn send_message<T>(&mut self, id: &WidgetId, data: T)where
T: 'static + MessageData,
Send a message to the given widget
Sourcepub fn send_message_raw(&mut self, id: &WidgetId, data: Message)
pub fn send_message_raw(&mut self, id: &WidgetId, data: Message)
Send raw message data to the given widget
Sourcepub fn consume_signals(&mut self) -> Vec<Signal> ⓘ
pub fn consume_signals(&mut self) -> Vec<Signal> ⓘ
Get the list of signals that have been sent by widgets, consuming the current list so that further calls will not include previously sent signals
Sourcepub fn forced_process(&mut self) -> bool
pub fn forced_process(&mut self) -> bool
process()
application, even if no changes have been detected