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§
sourcefn layout(&self, id: ViewId, args: &mut LayoutArgs<'_>) -> LocalSize
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§
sourcefn access(
&self,
_id: ViewId,
_cx: &mut Context,
_nodes: &mut Vec<(NodeId, Node)>
) -> Option<NodeId>
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.
sourcefn commands(&self, _id: ViewId, _cx: &mut Context, _cmds: &mut Vec<CommandInfo>)
fn commands(&self, _id: ViewId, _cx: &mut Context, _cmds: &mut Vec<CommandInfo>)
Accumulates information about menu bar commands.
sourcefn dirty(&self, _id: ViewId, _xform: LocalToWorld, _cx: &mut Context)
fn dirty(&self, _id: ViewId, _xform: LocalToWorld, _cx: &mut Context)
Determines dirty regions which need repainting.
sourcefn gc(&self, _id: ViewId, _cx: &mut Context, _map: &mut Vec<ViewId>)
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.
sourcefn hittest(
&self,
_id: ViewId,
_pt: LocalPoint,
_cx: &mut Context
) -> Option<ViewId>
fn hittest( &self, _id: ViewId, _pt: LocalPoint, _cx: &mut Context ) -> Option<ViewId>
Returns the topmost view which the point intersects.
sourcefn is_flexible(&self) -> bool
fn is_flexible(&self) -> bool
For detecting flexible sized things in stacks.