pub struct Engine {
pub id: usize,
/* private fields */
}Expand description
Public API for the Layers Engine
§Usage: Setup a basic scene with a root layer
use layers::prelude::*;
let engine = Engine::create(800.0, 600.0);
let layer = engine.new_layer();
let engine = Engine::create(1024.0, 768.0);
let root_layer = engine.new_layer();
root_layer.set_position(Point { x: 0.0, y: 0.0 }, None);
root_layer.set_background_color(
PaintColor::Solid {
color: Color::new_rgba255(180, 180, 180, 255),
},
None,
);
root_layer.set_border_corner_radius(10.0, None);
root_layer.set_layout_style(taffy::Style {
position: taffy::Position::Absolute,
display: taffy::Display::Flex,
flex_direction: taffy::FlexDirection::Column,
justify_content: Some(taffy::JustifyContent::Center),
align_items: Some(taffy::AlignItems::Center),
..Default::default()
});
engine.add_layer(&root_layer);§Usage: Update the engine
use layers::prelude::*;
let engine = Engine::create(800.0, 600.0);
// setup the scene...
engine.update(0.016);Fields§
§id: usizeImplementations§
source§impl Engine
impl Engine
pub fn create(width: f32, height: f32) -> Arc<Self>
sourcepub fn scene_set_root(&self, layer: impl Into<Layer>) -> NodeRef
pub fn scene_set_root(&self, layer: impl Into<Layer>) -> NodeRef
set the layer as the root of the scene and root of the layout tree
sourcepub fn scene_set_size(&self, width: f32, height: f32)
pub fn scene_set_size(&self, width: f32, height: f32)
Set the size of the scene
pub fn get_layer<'a>(&self, node: impl Into<&'a NodeRef>) -> Option<Layer>
pub fn with_layers(&self, f: impl Fn(&HashMap<NodeRef, Layer>))
sourcepub fn append_layer<'a>(
&self,
layer_id: impl Into<&'a NodeRef>,
parent: impl Into<Option<NodeRef>>,
)
pub fn append_layer<'a>( &self, layer_id: impl Into<&'a NodeRef>, parent: impl Into<Option<NodeRef>>, )
Append the layer’s node to the scene tree and layout tree the layer is appended to the parent node if it is provided otherwise it is appended to the root of the scene
sourcepub fn add_layer<'a>(&self, layer: impl Into<&'a NodeRef>)
pub fn add_layer<'a>(&self, layer: impl Into<&'a NodeRef>)
Append the layer to the root of the scene alias for append_layer, without a parent
sourcepub fn prepend_layer(
&self,
layer: impl Into<Layer>,
parent: impl Into<Option<NodeRef>>,
)
pub fn prepend_layer( &self, layer: impl Into<Layer>, parent: impl Into<Option<NodeRef>>, )
Prepend the layer to the root of the scene or to a parent node if the parent is provided
pub fn add_layer_to_positioned( &self, layer: impl Into<Layer>, parent: Option<NodeRef>, )
pub fn mark_for_delete(&self, layer: NodeRef)
pub fn scene(&self) -> Arc<Scene>
pub fn scene_root(&self) -> Option<NodeRef>
pub fn node_children(&self, node_ref: &NodeRef) -> Vec<NodeRef>
pub fn node_descendants(&self, node_ref: &NodeRef) -> Vec<NodeRef>
pub fn render_layer<'a>( &self, node_ref: impl Into<&'a NodeRef>, ) -> Option<RenderLayer>
pub fn renderable<'a>( &self, node_ref: impl Into<&'a NodeRef>, ) -> Option<SceneNodeRenderable>
pub fn node_render_size<'a>( &self, node_ref: impl Into<&'a NodeRef>, ) -> (f32, f32)
sourcepub fn scene_get_node(
&self,
node_ref: impl Into<NodeRef>,
) -> Option<Node<SceneNode>>
pub fn scene_get_node( &self, node_ref: impl Into<NodeRef>, ) -> Option<Node<SceneNode>>
Get a copy of the node
pub fn scene_get_node_parent(&self, node_ref: NodeRef) -> Option<NodeRef>
pub fn now(&self) -> f32
pub fn add_animation_from_transition( &self, transition: &Transition, autostart: bool, ) -> AnimationRef
pub fn add_animation( &self, animation: Animation, autostart: bool, ) -> AnimationRef
pub fn start_animation(&self, animation: AnimationRef, delay: f32)
pub fn get_transaction( &self, tref: TransactionRef, ) -> Option<AnimatedNodeChange>
pub fn get_transaction_for_value( &self, value_id: usize, ) -> Option<AnimatedNodeChange>
pub fn get_animation(&self, animation: AnimationRef) -> Option<AnimationState>
pub fn schedule_change( &self, target_id: NodeRef, change: Arc<dyn SyncCommand>, animation_id: Option<AnimationRef>, ) -> TransactionRef
pub fn schedule_changes( &self, animated_changes: &[AnimatedNodeChange], animation: impl Into<Option<AnimationRef>>, ) -> Vec<TransactionRef>
pub fn attach_animation( &self, transaction: TransactionRef, animation: AnimationRef, )
pub fn cancel_animation(&self, animation: AnimationRef)
pub fn cancel_transaction(&self, transaction: TransactionRef)
pub fn step_time(&self, dt: f32)
pub fn update(&self, dt: f32) -> bool
pub fn update_nodes(&self) -> Rect
pub fn get_node_layout_style(&self, node: NodeId) -> Style
pub fn set_node_layout_style(&self, node: NodeId, style: Style)
pub fn set_node_layout_size(&self, node: NodeId, size: Size) -> bool
pub fn scene_layer_at(&self, point: Point) -> Option<NodeRef>
sourcepub fn debug_print_transaction_handlers(&self)
pub fn debug_print_transaction_handlers(&self)
Prints the current transaction handlers, grouped by transaction id, to help debug leaks.
sourcepub fn debug_print_value_handlers(&self)
pub fn debug_print_value_handlers(&self)
Prints the current value handlers, grouped by value id, to help debug leaks.
sourcepub fn debug_print_pointer_handlers(&self)
pub fn debug_print_pointer_handlers(&self)
Prints the current pointer handlers, grouped by node id, to help debug leaks.
pub fn clear_value_handlers(&self, value_id: usize)
pub fn on_start<F: Into<TransactionCallback>>( &self, transaction: TransactionRef, handler: F, once: bool, )
pub fn on_finish<F: Into<TransactionCallback>>( &self, transaction: TransactionRef, handler: F, once: bool, )
pub fn on_update<F: Into<TransactionCallback>>( &self, transaction: TransactionRef, handler: F, once: bool, )
pub fn on_update_value<F: Into<TransactionCallback>>( &self, value_id: usize, handler: F, once: bool, )
pub fn on_start_value<F: Into<TransactionCallback>>( &self, value_id: usize, handler: F, once: bool, )
pub fn on_finish_value<F: Into<TransactionCallback>>( &self, value_id: usize, handler: F, once: bool, )
pub fn on_animation_start<F: Into<AnimationCallback>>( &self, animation: AnimationRef, handler: F, once: bool, )
pub fn on_animation_update<F: Into<AnimationCallback>>( &self, animation: AnimationRef, handler: F, once: bool, )
pub fn on_animation_finish<F: Into<AnimationCallback>>( &self, animation: AnimationRef, handler: F, once: bool, )
pub fn remove_pointer_handler(&self, layer_node: NodeRef, handler_id: usize)
pub fn remove_all_pointer_handlers(&self, layer_node: NodeRef)
sourcepub fn pointer_move(
&self,
p: &Point,
root_id: impl Into<Option<NodeId>>,
) -> bool
pub fn pointer_move( &self, p: &Point, root_id: impl Into<Option<NodeId>>, ) -> bool
Sends pointer move event to the engine
pub fn current_hover(&self) -> Option<NodeRef>
pub fn get_pointer_position(&self) -> Point
pub fn layer_as_content(&self, layer: &Layer) -> ContentDrawFunction
pub fn damage(&self) -> Rect
pub fn clear_damage(&self)
pub fn add_damage(&self, rect: Rect)
sourcepub fn invalidate_hit_test_node_list(&self)
pub fn invalidate_hit_test_node_list(&self)
Mark the hit test node list as dirty, requiring rebuild on next update. Called when visibility or tree structure changes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnwindSafe for Engine
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more