Struct acrylic::app::Application
source · [−]pub struct Application {
pub view: RcNode,
pub fonts: HashMap<Option<String>, Arc<Mutex<Font>>>,
pub default_font_size: usize,
pub data_requests: Vec<DataRequest>,
pub model: Box<dyn Any>,
pub output: Bitmap,
pub should_recompute: bool,
}Expand description
The Application structure represents your application.
It has a [Tree] containing nodes, a model field
where you can store your application-specific model,
and a vector of DataRequest where you can add
you own data requests (which the platform will handle).
Fields
view: RcNodefonts: HashMap<Option<String>, Arc<Mutex<Font>>>Fonts that can be used by widgets to draw glyphs
default_font_size: usizeDefault font size used by textual widgets
data_requests: Vec<DataRequest>Data requests allow widgets to load external assets, partially or completely. You can append new ones to this vector.
model: Box<dyn Any>This field’s content is completely up to you. You should use it to store the global state of your application.
output: BitmapThis Bitmap is used to store the final frame of
the application, to be rendered by the platform.
should_recompute: boolImplementations
sourceimpl Application
impl Application
sourcepub fn new<M: Any + 'static>(model: M) -> Self
pub fn new<M: Any + 'static>(model: M) -> Self
The Application constructor. If you omit the tree
argument, it will be initialized to an empty tree.
sourcepub fn model<M: Any + 'static>(&mut self) -> Option<&mut M>
pub fn model<M: Any + 'static>(&mut self) -> Option<&mut M>
This getter allows you to get your model as its initial
type. If M is the original type of your model, this
will return Some, and None if it is not.
Under the hood, this is a simple downcast.
sourcepub fn add_font(&mut self, name: String, data: Vec<u8>, default: bool)
pub fn add_font(&mut self, name: String, data: Vec<u8>, default: bool)
Adds a font to the font store. If default is true,
this font will be used by default when textual nodes
are created.
pub fn get_node(&mut self, path: &NodePath) -> Option<RcNode>
pub fn add_node(
&mut self,
path: &NodePath,
child: RcNode
) -> Result<usize, String>
pub fn replace_node(
&mut self,
path: &NodePath,
new_node: RcNode
) -> Result<(), String>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Application
impl !Send for Application
impl !Sync for Application
impl Unpin for Application
impl !UnwindSafe for Application
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more