pub struct AnimatedRRectWidget { /* private fields */ }Expand description
动画化圆角矩形:color / corner / bounds(size)都是 PaintCommand::Rect 的字段/尺寸。
与 opacity/scale(走 LayerEffect 实时读、不必重画)的本质差异:这三类变化后
必须让 RO 所在 layer 重新 paint 才会生成新的绘制命令。这里走
State.tick → apply_to_ro 就地写 RO 字段 → 框架把所在 layer 标 dirty 重画 ——
只重画这一个 layer 的 PaintList,不 mount/update/layout → rebuilt==false。
bounds 的额外语义:size 是 content_size() / hit_test / a11y bounds 的来源,
所以 size 推进时必须 bump 语义版本(与纯视觉的 color/corner 相反);但 apply_state
只写 RO 的 size 字段、不失效 layout 缓存 —— 一旦失效,layout_cached 会用布局
约束 constrain() 二次 clamp 掉呈现值,呈现(presented)优先于布局约束。
叶子 widget(无 child),不是 repaint boundary:画进所在祖先 layer。
Implementations§
Source§impl AnimatedRRectWidget
impl AnimatedRRectWidget
Sourcepub fn new(
size: Size,
color: SharedPropertyTrack<Color>,
corner: SharedPropertyTrack<f32>,
) -> Self
pub fn new( size: Size, color: SharedPropertyTrack<Color>, corner: SharedPropertyTrack<f32>, ) -> Self
size 静态(用一条静止轨道占位),color/corner 可各自带轨道。
Sourcepub fn with_size(
size: SharedPropertyTrack<Size>,
color: SharedPropertyTrack<Color>,
corner: SharedPropertyTrack<f32>,
) -> Self
pub fn with_size( size: SharedPropertyTrack<Size>, color: SharedPropertyTrack<Color>, corner: SharedPropertyTrack<f32>, ) -> Self
size 也由轨道驱动(bounds 动画);color/corner 各自带轨道。
Sourcepub fn with_color(
size: Size,
color: SharedPropertyTrack<Color>,
radius: f32,
) -> Self
pub fn with_color( size: Size, color: SharedPropertyTrack<Color>, radius: f32, ) -> Self
只动画 color:corner 与 size 固定。
Sourcepub fn with_corner(
size: Size,
color: Color,
corner: SharedPropertyTrack<f32>,
) -> Self
pub fn with_corner( size: Size, color: Color, corner: SharedPropertyTrack<f32>, ) -> Self
只动画 corner:color 与 size 固定。
Sourcepub fn with_bounds(
size: SharedPropertyTrack<Size>,
color: Color,
radius: f32,
) -> Self
pub fn with_bounds( size: SharedPropertyTrack<Size>, color: Color, radius: f32, ) -> Self
只动画 bounds(size):color 与 corner 固定。
pub fn size_track(&self) -> &SharedPropertyTrack<Size>
pub fn color_track(&self) -> &SharedPropertyTrack<Color>
pub fn corner_track(&self) -> &SharedPropertyTrack<f32>
Trait Implementations§
Source§impl Clone for AnimatedRRectWidget
impl Clone for AnimatedRRectWidget
Source§impl Debug for AnimatedRRectWidget
impl Debug for AnimatedRRectWidget
Source§impl Widget for AnimatedRRectWidget
impl Widget for AnimatedRRectWidget
Source§fn is_stateful(&self) -> bool
fn is_stateful(&self) -> bool
是否 stateful(true 则 Element 自动创建 State 并持久化)
Source§fn create_render_object(&self) -> Box<dyn RenderObject>
fn create_render_object(&self) -> Box<dyn RenderObject>
创建 RenderObject(桥接到渲染子系统)
Source§fn is_equivalent(&self, old: &dyn Widget) -> bool
fn is_equivalent(&self, old: &dyn Widget) -> bool
P0-1:新旧 widget 的全部输入是否等价(不含 State)。 Read more
Source§fn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
是否可聚焦(Tab 焦点链 + 键盘激活)
Source§fn captures_tab(&self) -> bool
fn captures_tab(&self) -> bool
是否捕获 Tab 键(编辑器等需要 Tab 缩进的输入组件)。
true 时框架焦点遍历跳过该组件,Tab/BackTab 直接投递给焦点 element。
Source§fn children(&self) -> Vec<WidgetNode>
fn children(&self) -> Vec<WidgetNode>
子 widget 列表(Element 树递归用)
Source§fn children_with_positions(&self) -> Vec<(Point, WidgetNode)>
fn children_with_positions(&self) -> Vec<(Point, WidgetNode)>
子 widget + 各自在父内的 offset(Stack/Positioned 等需要)
Source§fn handle_event(&self, event: &WidgetEvent, local_pos: Point)
fn handle_event(&self, event: &WidgetEvent, local_pos: Point)
处理事件(不可变 — Widget 是 Rc 共享的;stateful widget 通常把逻辑放在 State 里)
Source§fn handle_event_ctx(
&self,
event: &WidgetEvent,
local_pos: Point,
_ctx: &mut EventContext,
)
fn handle_event_ctx( &self, event: &WidgetEvent, local_pos: Point, _ctx: &mut EventContext, )
带消费语义的事件处理;默认转发
Self::handle_event 并继续冒泡。Source§fn accepts_scroll(&self) -> bool
fn accepts_scroll(&self) -> bool
是否接受滚动事件(ScrollView/ListView 返回 true)
Source§fn gesture_state(&self) -> Option<GestureState>
fn gesture_state(&self) -> Option<GestureState>
手势竞技场仲裁(返回 Some 表示参与指针竞争)
Source§fn semantics(&self) -> Option<WidgetSemantics>
fn semantics(&self) -> Option<WidgetSemantics>
返回无障碍语义(阶段 A11y)
Source§fn as_inherited(&self) -> Option<&dyn InheritedWidget>
fn as_inherited(&self) -> Option<&dyn InheritedWidget>
如果是 InheritedWidget,返回引用(主题/布局约束等传播)
Source§fn can_update(&self, old: &dyn Widget) -> bool
fn can_update(&self, old: &dyn Widget) -> bool
Element diff 时判断新旧 widget 是否“兼容“(类型相同 + key 相同)
默认:type_id 比较
Source§fn is_repaint_boundary(&self) -> bool
fn is_repaint_boundary(&self) -> bool
是否 RepaintBoundary(dirty 重绘边界)
Source§fn visible_children(&self) -> Option<Vec<bool>>
fn visible_children(&self) -> Option<Vec<bool>>
逐子节点可见性(按
children() 顺序)。None = 全部可见(默认,零行为变化)。
Some(vec) 与 children() 等长;false 表示该子节点的整棵子树
(含其内部 RepaintBoundary layer)不参与合成。 Read moreSource§fn parent_data(&self) -> Option<ParentData>
fn parent_data(&self) -> Option<ParentData>
父容器在布局阶段读取的子节点元数据(如 Flex 的 grow/basis)。
默认
None(无元数据)。Expanded/Flexible 等 override 返回 ParentData::Flex。Auto Trait Implementations§
impl !RefUnwindSafe for AnimatedRRectWidget
impl !Send for AnimatedRRectWidget
impl !Sync for AnimatedRRectWidget
impl !UnwindSafe for AnimatedRRectWidget
impl Forget for AnimatedRRectWidget
impl Freeze for AnimatedRRectWidgetwhere
*const RcInner<RefCell<dyn Track<Size>>> is !null: Freeze,
PhantomData<RcInner<RefCell<dyn Track<Size>>>>: Freeze,
*const RcInner<RefCell<dyn Track<Color>>> is !null: Freeze,
PhantomData<RcInner<RefCell<dyn Track<Color>>>>: Freeze,
*const RcInner<RefCell<dyn Track<f32>>> is !null: Freeze,
PhantomData<RcInner<RefCell<dyn Track<f32>>>>: Freeze,
impl Move for AnimatedRRectWidget
impl Unpin for AnimatedRRectWidget
impl UnsafeUnpin for AnimatedRRectWidgetwhere
*const RcInner<RefCell<dyn Track<Size>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<dyn Track<Size>>>>: UnsafeUnpin,
*const RcInner<RefCell<dyn Track<Color>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<dyn Track<Color>>>>: UnsafeUnpin,
*const RcInner<RefCell<dyn Track<f32>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<dyn Track<f32>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more