pub trait ViewObject:
Priority
+ Positionable
+ Disposable
+ Updateable {
// Required methods
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§
Sourcefn 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).
Sourcefn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Get the visibility of this view.
Sourcefn 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.
Sourcefn 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.
Sourcefn global_x(&self) -> f32
fn global_x(&self) -> f32
The horizontal position considering all parent’s positions / scene graph.
Sourcefn global_y(&self) -> f32
fn global_y(&self) -> f32
The vertical position considering all parent’s positions / scene graph.
Sourcefn 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.
Sourcefn 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.