Trait primitives::prelude::ViewObject
source · [−]pub trait ViewObject: Priority + Positionable + Disposable + Updateable {
fn parent(&self) -> Box<dyn ViewObject>;
fn is_visible(&self) -> bool;
fn set_visible(&self, val: bool);
fn is_in_view_stack(&self) -> bool;
fn global_x(&self) -> f32;
fn global_y(&self) -> f32;
fn add_child(
&self,
child: Box<dyn ViewObject>,
priority: Option<i32>
) -> Box<dyn ViewObject>;
fn remove_child(&self, child: Box<dyn ViewObject>);
fn clear(&self);
fn remove(&self);
}
Expand description
The View should be implemented by all objects in the view broad phase traversal stack.
Required Methods
fn parent(&self) -> Box<dyn ViewObject>
fn parent(&self) -> Box<dyn ViewObject>
The parent view of this view. The reference is null if this view has no parent (for exemple a view not in the view traversal stack).
fn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Get the visibility of this view.
fn set_visible(&self, val: bool)
fn set_visible(&self, val: bool)
Specify the visibility of this view. If true the view will be displayed, if false the view is hidden.
fn is_in_view_stack(&self) -> bool
fn is_in_view_stack(&self) -> bool
Determined by whether this view is visible and included in a visible branch of the view stack (i.e. actually has the potential to be drawn within the overlay). If true the view is potentially visible, if false the view is impossible to be seen.
The horizontal position considering all parent’s positions / scene graph.
The vertical position considering all parent’s positions / scene graph.
fn add_child(
&self,
child: Box<dyn ViewObject>,
priority: Option<i32>
) -> Box<dyn ViewObject>
fn add_child(
&self,
child: Box<dyn ViewObject>,
priority: Option<i32>
) -> Box<dyn ViewObject>
Adds a new view child to this view. A view can have multiple children, and when you add a child to a view, it is automatically connected to the parent node through its parent property.
Arguments
child
- The child view to add.priority
- The sorting priority of the child view to add. Higher numbers will appear towards the top of the view stack. Default value is 0.
Return: Added view (to allow decoration). Or null if addition was unsuccessful.
fn remove_child(&self, child: Box<dyn ViewObject>)
fn remove_child(&self, child: Box<dyn ViewObject>)
Remove the specified view. The removed view will no longer be included in the view traversal stack so will no longer be visible. The view itself is still in memory, if you want to free them completely call child.dispose().
Arguments
child
- The view to remove.
Removes all child views. The children are still in memory, if you want to free them completely call view.dispose() from their owner object.