Trait rui::View

source ·
pub trait View: Sealed + 'static {
    // Required methods
    fn draw(&self, id: ViewId, args: &mut DrawArgs<'_>);
    fn layout(&self, id: ViewId, args: &mut LayoutArgs<'_>) -> LocalSize;

    // Provided methods
    fn access(
        &self,
        _id: ViewId,
        _cx: &mut Context,
        _nodes: &mut Vec<(NodeId, Node)>
    ) -> Option<NodeId> { ... }
    fn commands(
        &self,
        _id: ViewId,
        _cx: &mut Context,
        _cmds: &mut Vec<CommandInfo>
    ) { ... }
    fn dirty(&self, _id: ViewId, _xform: LocalToWorld, _cx: &mut Context) { ... }
    fn gc(&self, _id: ViewId, _cx: &mut Context, _map: &mut Vec<ViewId>) { ... }
    fn hittest(
        &self,
        _id: ViewId,
        _pt: LocalPoint,
        _cx: &mut Context
    ) -> Option<ViewId> { ... }
    fn is_flexible(&self) -> bool { ... }
    fn process(
        &self,
        _event: &Event,
        _id: ViewId,
        _cx: &mut Context,
        _actions: &mut Vec<Box<dyn Any>>
    ) { ... }
    fn tid(&self) -> TypeId { ... }
}
Expand description

Trait for the unit of UI composition.

Required Methods§

source

fn draw(&self, id: ViewId, args: &mut DrawArgs<'_>)

Draws the view using vger.

source

fn layout(&self, id: ViewId, args: &mut LayoutArgs<'_>) -> LocalSize

Lays out subviews and return the size of the view.

sz is the available size for the view vger can be used to get text sizing

Note that we should probably have a separate text sizing interface so we don’t need a GPU and graphics context set up to test layout.

Provided Methods§

source

fn access( &self, _id: ViewId, _cx: &mut Context, _nodes: &mut Vec<(NodeId, Node)> ) -> Option<NodeId>

Builds an AccessKit tree. The node ID for the subtree is returned. All generated nodes are accumulated.

source

fn commands(&self, _id: ViewId, _cx: &mut Context, _cmds: &mut Vec<CommandInfo>)

Accumulates information about menu bar commands.

source

fn dirty(&self, _id: ViewId, _xform: LocalToWorld, _cx: &mut Context)

Determines dirty regions which need repainting.

source

fn gc(&self, _id: ViewId, _cx: &mut Context, _map: &mut Vec<ViewId>)

Gets IDs for views currently in use.

Push onto map if the view stores layout or state info.

source

fn hittest( &self, _id: ViewId, _pt: LocalPoint, _cx: &mut Context ) -> Option<ViewId>

Returns the topmost view which the point intersects.

source

fn is_flexible(&self) -> bool

For detecting flexible sized things in stacks.

source

fn process( &self, _event: &Event, _id: ViewId, _cx: &mut Context, _actions: &mut Vec<Box<dyn Any>> )

Processes an event.

source

fn tid(&self) -> TypeId

Returns the type ID of the underlying view.

Implementors§

source§

impl View for AnyView

source§

impl View for Circle

source§

impl View for EmptyView

source§

impl View for Rectangle

source§

impl View for Spacer

source§

impl View for Text

source§

impl<F> View for Canvas<F>where F: Fn(&mut Context, LocalRect, &mut Vger) + 'static,

source§

impl<ID, V, F> View for List<ID, F>where ID: Hash + 'static, V: View, F: Fn(&ID) -> V + 'static,

source§

impl<S1, V, SF, F> View for MapView<S1, SF, F>where V: View, S1: Clone + 'static, SF: Fn(S1, &mut Context) + 'static, F: Fn(StateHandle<S1>, &mut Context) -> V + 'static,

source§

impl<S, V, F> View for ModView<S, F>where V: View, S: Clone + Default + 'static, F: Fn(S, &mut Context) -> V + 'static,

source§

impl<V0, V1> View for Cond<V0, V1>where V0: View, V1: View,

source§

impl<V> View for Clip<V>where V: View,

source§

impl<V> View for Flex<V>where V: View,

source§

impl<V> View for FullscreenView<V>where V: View,

source§

impl<V> View for Offset<V>where V: View,

source§

impl<V> View for Padding<V>where V: View,

source§

impl<V> View for RoleView<V>where V: View,

source§

impl<V> View for Size<V>where V: View,

source§

impl<V> View for TitleView<V>where V: View,

source§

impl<V> View for Vwhere V: Display + Debug + 'static,

source§

impl<V, A> View for TapA<V, A>where V: View, A: Clone + 'static,

source§

impl<V, BG> View for Background<V, BG>where V: View, BG: View,

source§

impl<V, C> View for CommandGroup<V, C>where V: View, C: CommandTuple + 'static,

source§

impl<V, E> View for SetenvView<V, E>where V: View, E: Clone + 'static,

source§

impl<V, F> View for AnimView<V, F>where V: View, F: Fn(&mut Context, f32) + 'static + Clone,

source§

impl<V, F> View for Command<V, F>where V: View, F: Fn(&mut Context) + 'static,

source§

impl<V, F> View for Focus<F>where V: View, F: Fn(bool) -> V + 'static,

source§

impl<V, F> View for Geom<V, F>where V: View, F: Fn(&mut Context, LocalSize, LocalToWorld) + 'static,

source§

impl<V, F, A> View for Drag<V, F>where V: View, F: Fn(&mut Context, LocalOffset, GestureState, Option<MouseButton>) -> A + 'static, A: 'static,

source§

impl<V, F, A> View for Handle<V, F, A>where V: View, F: Fn(&mut Context, &A) + 'static, A: 'static,

source§

impl<V, F, A> View for Hover<V, F>where V: View, F: Fn(&mut Context, bool) -> A + 'static, A: 'static,

source§

impl<V, F, A> View for KeyView<V, F>where V: View, F: Fn(&mut Context, Key) -> A + 'static, A: 'static,

source§

impl<V, F, A> View for Tap<V, F>where V: View, F: Fn(&mut Context) -> A + 'static, A: 'static,

source§

impl<V, F, A, B, T> View for DragS<V, F, B, T>where V: View, F: Fn(&mut T, LocalOffset, GestureState, Option<MouseButton>) -> A + 'static, B: Binding<T>, A: 'static, T: 'static,