layers::engine

Struct Engine

source
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: usize

Implementations§

source§

impl Engine

source

pub fn set_node_flags(&self, node: NodeRef, flags: RenderableFlags)

source§

impl Engine

source

pub fn create(width: f32, height: f32) -> Arc<Self>

source

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

source

pub fn scene_set_size(&self, width: f32, height: f32)

Set the size of the scene

source

pub fn new_layer(&self) -> Layer

Create a new layer associated with the engine

source

pub fn get_layer<'a>(&self, node: impl Into<&'a NodeRef>) -> Option<Layer>

source

pub fn with_layers(&self, f: impl Fn(&HashMap<NodeRef, Layer>))

source

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

source

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

source

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

source

pub fn add_layer_to_positioned( &self, layer: impl Into<Layer>, parent: Option<NodeRef>, )

source

pub fn mark_for_delete(&self, layer: NodeRef)

source

pub fn scene(&self) -> Arc<Scene>

source

pub fn scene_root(&self) -> Option<NodeRef>

source

pub fn node_children(&self, node_ref: &NodeRef) -> Vec<NodeRef>

source

pub fn node_descendants(&self, node_ref: &NodeRef) -> Vec<NodeRef>

source

pub fn render_layer<'a>( &self, node_ref: impl Into<&'a NodeRef>, ) -> Option<RenderLayer>

source

pub fn renderable<'a>( &self, node_ref: impl Into<&'a NodeRef>, ) -> Option<SceneNodeRenderable>

source

pub fn node_render_size<'a>( &self, node_ref: impl Into<&'a NodeRef>, ) -> (f32, f32)

source

pub fn scene_get_node( &self, node_ref: impl Into<NodeRef>, ) -> Option<Node<SceneNode>>

Get a copy of the node

source

pub fn scene_get_node_parent(&self, node_ref: NodeRef) -> Option<NodeRef>

source

pub fn now(&self) -> f32

source

pub fn add_animation_from_transition( &self, transition: &Transition, autostart: bool, ) -> AnimationRef

source

pub fn add_animation( &self, animation: Animation, autostart: bool, ) -> AnimationRef

source

pub fn start_animation(&self, animation: AnimationRef, delay: f32)

source

pub fn get_transaction( &self, tref: TransactionRef, ) -> Option<AnimatedNodeChange>

source

pub fn get_transaction_for_value( &self, value_id: usize, ) -> Option<AnimatedNodeChange>

source

pub fn get_animation(&self, animation: AnimationRef) -> Option<AnimationState>

source

pub fn schedule_change( &self, target_id: NodeRef, change: Arc<dyn SyncCommand>, animation_id: Option<AnimationRef>, ) -> TransactionRef

source

pub fn schedule_changes( &self, animated_changes: &[AnimatedNodeChange], animation: impl Into<Option<AnimationRef>>, ) -> Vec<TransactionRef>

source

pub fn attach_animation( &self, transaction: TransactionRef, animation: AnimationRef, )

source

pub fn cancel_animation(&self, animation: AnimationRef)

source

pub fn cancel_transaction(&self, transaction: TransactionRef)

source

pub fn step_time(&self, dt: f32)

source

pub fn update(&self, dt: f32) -> bool

source

pub fn update_nodes(&self) -> Rect

source

pub fn get_node_layout_style(&self, node: NodeId) -> Style

source

pub fn set_node_layout_style(&self, node: NodeId, style: Style)

source

pub fn set_node_layout_size(&self, node: NodeId, size: Size) -> bool

source

pub fn scene_layer_at(&self, point: Point) -> Option<NodeRef>

source

pub fn debug_print_transaction_handlers(&self)

Prints the current transaction handlers, grouped by transaction id, to help debug leaks.

source

pub fn debug_print_value_handlers(&self)

Prints the current value handlers, grouped by value id, to help debug leaks.

source

pub fn debug_print_pointer_handlers(&self)

Prints the current pointer handlers, grouped by node id, to help debug leaks.

source

pub fn clear_value_handlers(&self, value_id: usize)

source

pub fn on_start<F: Into<TransactionCallback>>( &self, transaction: TransactionRef, handler: F, once: bool, )

source

pub fn on_finish<F: Into<TransactionCallback>>( &self, transaction: TransactionRef, handler: F, once: bool, )

source

pub fn on_update<F: Into<TransactionCallback>>( &self, transaction: TransactionRef, handler: F, once: bool, )

source

pub fn on_update_value<F: Into<TransactionCallback>>( &self, value_id: usize, handler: F, once: bool, )

source

pub fn on_start_value<F: Into<TransactionCallback>>( &self, value_id: usize, handler: F, once: bool, )

source

pub fn on_finish_value<F: Into<TransactionCallback>>( &self, value_id: usize, handler: F, once: bool, )

source

pub fn on_animation_start<F: Into<AnimationCallback>>( &self, animation: AnimationRef, handler: F, once: bool, )

source

pub fn on_animation_update<F: Into<AnimationCallback>>( &self, animation: AnimationRef, handler: F, once: bool, )

source

pub fn on_animation_finish<F: Into<AnimationCallback>>( &self, animation: AnimationRef, handler: F, once: bool, )

source

pub fn remove_pointer_handler(&self, layer_node: NodeRef, handler_id: usize)

source

pub fn remove_all_pointer_handlers(&self, layer_node: NodeRef)

source

pub fn pointer_move( &self, p: &Point, root_id: impl Into<Option<NodeId>>, ) -> bool

Sends pointer move event to the engine

source

pub fn pointer_button_down(&self)

source

pub fn pointer_button_up(&self)

source

pub fn current_hover(&self) -> Option<NodeRef>

source

pub fn get_pointer_position(&self) -> Point

source

pub fn layer_as_content(&self, layer: &Layer) -> ContentDrawFunction

source

pub fn damage(&self) -> Rect

source

pub fn clear_damage(&self)

source

pub fn add_damage(&self, rect: Rect)

source

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§

source§

impl Debug for Engine

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more