Trait floem::view::View

source ·
pub trait View {
Show 18 methods // Required methods fn view_data(&self) -> &ViewData; fn view_data_mut(&mut self) -> &mut ViewData; // Provided methods fn for_each_child<'a>( &'a self, _for_each: &mut dyn FnMut(&'a dyn View) -> bool ) { ... } fn for_each_child_mut<'a>( &'a mut self, _for_each: &mut dyn FnMut(&'a mut dyn View) -> bool ) { ... } fn for_each_child_rev_mut<'a>( &'a mut self, _for_each: &mut dyn FnMut(&'a mut dyn View) -> bool ) { ... } fn id(&self) -> Id { ... } fn view_style(&self) -> Option<Style> { ... } fn view_class(&self) -> Option<StyleClassRef> { ... } fn child(&self, id: Id) -> Option<&dyn View> { ... } fn child_mut(&mut self, id: Id) -> Option<&mut dyn View> { ... } fn debug_name(&self) -> Cow<'static, str> { ... } fn update(&mut self, _cx: &mut UpdateCx<'_>, _state: Box<dyn Any>) { ... } fn style(&mut self, cx: &mut StyleCx<'_>) { ... } fn layout(&mut self, cx: &mut LayoutCx<'_>) -> Node { ... } fn compute_layout(&mut self, cx: &mut ComputeLayoutCx<'_>) -> Option<Rect> { ... } fn event( &mut self, cx: &mut EventCx<'_>, id_path: Option<&[Id]>, event: Event ) -> EventPropagation { ... } fn paint(&mut self, cx: &mut PaintCx<'_>) { ... } fn scroll_to( &mut self, cx: &mut AppState, target: Id, rect: Option<Rect> ) -> bool { ... }
}

Required Methods§

source

fn view_data(&self) -> &ViewData

source

fn view_data_mut(&mut self) -> &mut ViewData

Provided Methods§

source

fn for_each_child<'a>(&'a self, _for_each: &mut dyn FnMut(&'a dyn View) -> bool)

This method walks over children and must be implemented if the view has any children. It should return children back to front and should stop if _for_each returns true.

source

fn for_each_child_mut<'a>( &'a mut self, _for_each: &mut dyn FnMut(&'a mut dyn View) -> bool )

This method walks over children and must be implemented if the view has any children. It should return children back to front and should stop if _for_each returns true.

source

fn for_each_child_rev_mut<'a>( &'a mut self, _for_each: &mut dyn FnMut(&'a mut dyn View) -> bool )

This method walks over children and must be implemented if the view has any children. It should return children front to back and should stop if _for_each returns true.

source

fn id(&self) -> Id

source

fn view_style(&self) -> Option<Style>

source

fn view_class(&self) -> Option<StyleClassRef>

source

fn child(&self, id: Id) -> Option<&dyn View>

source

fn child_mut(&mut self, id: Id) -> Option<&mut dyn View>

source

fn debug_name(&self) -> Cow<'static, str>

source

fn update(&mut self, _cx: &mut UpdateCx<'_>, _state: Box<dyn Any>)

Use this method to react to changes in view-related state. You will usually send state to this hook manually using the View’s Id handle

self.id.update_state(SomeState)

You are in charge of downcasting the state to the expected type.

If the update needs other passes to run you’re expected to call _cx.app_state_mut().request_changes.

source

fn style(&mut self, cx: &mut StyleCx<'_>)

Use this method to style the view’s children.

If the style changes needs other passes to run you’re expected to call cx.app_state_mut().request_changes.

source

fn layout(&mut self, cx: &mut LayoutCx<'_>) -> Node

Use this method to layout the view’s children. Usually you’ll do this by calling LayoutCx::layout_node.

If the layout changes needs other passes to run you’re expected to call cx.app_state_mut().request_changes.

source

fn compute_layout(&mut self, cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>

Responsible for computing the layout of the view’s children.

If the layout changes needs other passes to run you’re expected to call cx.app_state_mut().request_changes.

source

fn event( &mut self, cx: &mut EventCx<'_>, id_path: Option<&[Id]>, event: Event ) -> EventPropagation

Implement this to handle events and to pass them down to children

Return true to stop the event from propagating to other views

If the event needs other passes to run you’re expected to call cx.app_state_mut().request_changes.

source

fn paint(&mut self, cx: &mut PaintCx<'_>)

View-specific implementation. Will be called in PaintCx::paint_view. Usually you’ll call paint_view for every child view. But you might also draw text, adjust the offset, clip or draw text.

source

fn scroll_to( &mut self, cx: &mut AppState, target: Id, rect: Option<Rect> ) -> bool

Scrolls the view and all direct and indirect children to bring the target view to be visible. Returns true if this view contains or is the target.

Trait Implementations§

source§

impl View for Box<dyn View>

source§

fn view_data(&self) -> &ViewData

source§

fn view_data_mut(&mut self) -> &mut ViewData

source§

fn for_each_child<'a>(&'a self, for_each: &mut dyn FnMut(&'a dyn View) -> bool)

This method walks over children and must be implemented if the view has any children. It should return children back to front and should stop if _for_each returns true.
source§

fn for_each_child_mut<'a>( &'a mut self, for_each: &mut dyn FnMut(&'a mut dyn View) -> bool )

This method walks over children and must be implemented if the view has any children. It should return children back to front and should stop if _for_each returns true.
source§

fn for_each_child_rev_mut<'a>( &'a mut self, for_each: &mut dyn FnMut(&'a mut dyn View) -> bool )

This method walks over children and must be implemented if the view has any children. It should return children front to back and should stop if _for_each returns true.
source§

fn id(&self) -> Id

source§

fn view_style(&self) -> Option<Style>

source§

fn view_class(&self) -> Option<StyleClassRef>

source§

fn child(&self, id: Id) -> Option<&dyn View>

source§

fn child_mut(&mut self, id: Id) -> Option<&mut dyn View>

source§

fn debug_name(&self) -> Cow<'static, str>

source§

fn update(&mut self, cx: &mut UpdateCx<'_>, state: Box<dyn Any>)

Use this method to react to changes in view-related state. You will usually send state to this hook manually using the View’s Id handle Read more
source§

fn style(&mut self, cx: &mut StyleCx<'_>)

Use this method to style the view’s children. Read more
source§

fn layout(&mut self, cx: &mut LayoutCx<'_>) -> Node

Use this method to layout the view’s children. Usually you’ll do this by calling LayoutCx::layout_node. Read more
source§

fn compute_layout(&mut self, cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>

Responsible for computing the layout of the view’s children. Read more
source§

fn event( &mut self, cx: &mut EventCx<'_>, id_path: Option<&[Id]>, event: Event ) -> EventPropagation

Implement this to handle events and to pass them down to children Read more
source§

fn paint(&mut self, cx: &mut PaintCx<'_>)

View-specific implementation. Will be called in PaintCx::paint_view. Usually you’ll call paint_view for every child view. But you might also draw text, adjust the offset, clip or draw text.
source§

fn scroll_to( &mut self, cx: &mut AppState, target: Id, rect: Option<Rect> ) -> bool

Scrolls the view and all direct and indirect children to bring the target view to be visible. Returns true if this view contains or is the target.

Implementations on Foreign Types§

source§

impl View for Box<dyn View>

source§

fn view_data(&self) -> &ViewData

source§

fn view_data_mut(&mut self) -> &mut ViewData

source§

fn for_each_child<'a>(&'a self, for_each: &mut dyn FnMut(&'a dyn View) -> bool)

source§

fn for_each_child_mut<'a>( &'a mut self, for_each: &mut dyn FnMut(&'a mut dyn View) -> bool )

source§

fn for_each_child_rev_mut<'a>( &'a mut self, for_each: &mut dyn FnMut(&'a mut dyn View) -> bool )

source§

fn id(&self) -> Id

source§

fn view_style(&self) -> Option<Style>

source§

fn view_class(&self) -> Option<StyleClassRef>

source§

fn child(&self, id: Id) -> Option<&dyn View>

source§

fn child_mut(&mut self, id: Id) -> Option<&mut dyn View>

source§

fn debug_name(&self) -> Cow<'static, str>

source§

fn update(&mut self, cx: &mut UpdateCx<'_>, state: Box<dyn Any>)

source§

fn style(&mut self, cx: &mut StyleCx<'_>)

source§

fn layout(&mut self, cx: &mut LayoutCx<'_>) -> Node

source§

fn compute_layout(&mut self, cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>

source§

fn event( &mut self, cx: &mut EventCx<'_>, id_path: Option<&[Id]>, event: Event ) -> EventPropagation

source§

fn paint(&mut self, cx: &mut PaintCx<'_>)

source§

fn scroll_to( &mut self, cx: &mut AppState, target: Id, rect: Option<Rect> ) -> bool

Implementors§

source§

impl View for Scroll

source§

impl View for Clip

source§

impl View for Container

source§

impl View for ContainerBox

source§

impl View for DragResizeWindowArea

source§

impl View for DragWindowArea

source§

impl View for Empty

source§

impl View for Img

source§

impl View for Label

source§

impl View for List

source§

impl View for RichText

source§

impl View for Stack

source§

impl View for Svg

source§

impl View for TextInput

source§

impl View for Tooltip

source§

impl View for Slider

source§

impl View for ToggleButton

source§

impl<T> View for VirtualList<T>

source§

impl<T: 'static> View for DynamicContainer<T>

source§

impl<V: View + 'static, T> View for DynStack<V, T>

source§

impl<V: View + 'static, T> View for Tab<V, T>

source§

impl<V: View + 'static, T> View for VirtualStack<V, T>