Skip to main content

teksilo_scene/view/
widget_trait.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! `Widget` trait implementation for [`SceneView`].
5//!
6//! Each method is a thin delegation to its `*_impl` counterpart in the
7//! appropriate impl-split module (`build_impl`, `layout_impl`, `paint_impl`,
8//! `a11y_impl`). Notable flags: `clips_children` is `true` (the scene clips
9//! at the viewport boundary), `preserves_children_on_rebuild` is `true`
10//! (heavyweight widgets survive scene rebuild and are only destroyed when their
11//! item is removed), and `wants_descendant_redirects` is `true` (lightweight
12//! item AT nodes are synthetic — the a11y walker reparents them into the
13//! scene's virtual accessibility tree rather than as normal widget children).
14
15use super::*;
16
17impl Widget for SceneView {
18    fn build(&mut self, ctx: &mut BuildContext) -> Vec<WidgetId> {
19        self.build_impl(ctx)
20    }
21
22    fn layout_response(&self, proposal: SizeProposal, ctx: &LayoutContext) -> LayoutResponse {
23        self.layout_response_impl(proposal, ctx)
24    }
25
26    fn place_children(
27        &self,
28        bounds: Rect,
29        proposal: SizeProposal,
30        children: &mut [WidgetPlacement],
31        ctx: &LayoutContext,
32    ) {
33        self.place_children_impl(bounds, proposal, children, ctx)
34    }
35
36    fn paint(&self, bounds: Rect, canvas: &mut teksilo_canvas::Canvas, ctx: &PaintContext) {
37        self.paint_impl(bounds, canvas, ctx)
38    }
39
40    fn wants_post_paint(&self) -> bool {
41        self.wants_post_paint_impl()
42    }
43
44    fn post_paint(&self, bounds: Rect, canvas: &mut teksilo_canvas::Canvas, ctx: &PaintContext) {
45        self.post_paint_impl(bounds, canvas, ctx)
46    }
47
48    fn clips_children(&self) -> bool {
49        true
50    }
51
52    fn preserves_children_on_rebuild(&self) -> bool {
53        true
54    }
55
56    fn wants_descendant_redirects(&self) -> bool {
57        true
58    }
59
60    fn a11y_redirect_descendant(
61        &self,
62        self_id: WidgetId,
63        descendant: WidgetId,
64    ) -> Option<accesskit::NodeId> {
65        self.a11y_redirect_descendant_impl(self_id, descendant)
66    }
67
68    fn accessibility(&self, builder: &mut teksilo_core::accessibility::AccessNodeBuilder) {
69        self.accessibility_impl(builder)
70    }
71
72    fn as_any(&self) -> Option<&dyn std::any::Any> {
73        Some(self)
74    }
75
76    fn as_any_mut(&mut self) -> Option<&mut dyn std::any::Any> {
77        Some(self)
78    }
79}