Trait avalanche::renderer::Renderer [−][src]
pub trait Renderer {
fn create_component(
&mut self,
native_type: &NativeType,
component: &View
) -> NativeHandle;
fn append_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
child_type: &NativeType,
child_handle: &NativeHandle
);
fn insert_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle
);
fn replace_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle
);
fn swap_children(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
a: usize,
b: usize
);
fn move_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
old: usize,
new: usize
);
fn remove_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize
);
fn update_component(
&mut self,
native_type: &NativeType,
native_handle: &mut NativeHandle,
component: &View
);
fn log(&self, _string: &str) { ... }
}
Expand description
The interface through which avalanche
updates the native UI as described by changes to components.
This allows avalanche
to be platform-agnostic.
Required methods
fn create_component(
&mut self,
native_type: &NativeType,
component: &View
) -> NativeHandle
fn create_component(
&mut self,
native_type: &NativeType,
component: &View
) -> NativeHandle
Given a component and its native type, generate its native representation and return
an opaque NativeHandle
to it.
fn append_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
child_type: &NativeType,
child_handle: &NativeHandle
)
fn append_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
child_type: &NativeType,
child_handle: &NativeHandle
)
Appends the component with handle child_handle
into the component with
handle parent_handle
’s children.
fn insert_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle
)
fn insert_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle
)
Inserts the component with handle child_handle
into the component with
handle parent_handle
’s children at the given index
, shifting all
children after it to the right.
Panics
Panics if index > len
, where len
is the number of children the parent has.
fn replace_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle
)
fn replace_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle
)
Replaces the component at position index
with the native component
with handle child_handle
.
The implementation should implement replacing a component with itself as a noop.
Panics
Panics if index > len - 1
, where len
is the number of children the parent has.
fn swap_children(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
a: usize,
b: usize
)
fn swap_children(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
a: usize,
b: usize
)
Swaps the children at indices a
and b
.
Panics
Panics if a
or b
are less than len
, where len
is the number of children the parent has.
fn move_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
old: usize,
new: usize
)
fn move_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
old: usize,
new: usize
)
Moves the child at position old
to the position new
.
Panics
Panics if old < len
or new < len
where len
is the number of children
fn remove_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize
)
fn remove_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize
)
Removes the component with the given index
from the component
with handle parent_handle
.
fn update_component(
&mut self,
native_type: &NativeType,
native_handle: &mut NativeHandle,
component: &View
)
fn update_component(
&mut self,
native_type: &NativeType,
native_handle: &mut NativeHandle,
component: &View
)
Updates the component
’s corresponding native handle so that the representation
and result match.