pub struct AnimatedRRectState { /* private fields */ }Expand description
持久化 state:三条轨道各自推进,apply_to_ro 就地写 RRect 的尺寸/颜色/圆角。
Implementations§
Source§impl AnimatedRRectState
impl AnimatedRRectState
Sourcepub fn presented_size(&self) -> Size
pub fn presented_size(&self) -> Size
供 RRectRenderObject::apply_state downcast 后读当前呈现值。
pub fn presented_color(&self) -> Color
pub fn presented_corner(&self) -> f32
Trait Implementations§
Source§impl State for AnimatedRRectState
impl State for AnimatedRRectState
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
必须显式实现(框架约定)
Source§fn widget(&self) -> &WidgetNode
fn widget(&self) -> &WidgetNode
当前关联的 widget 节点(由框架在 mount/update 时写入)。
Source§fn set_widget(&mut self, widget: WidgetNode)
fn set_widget(&mut self, widget: WidgetNode)
框架在 widget 更新时调用,State 据此 adopt 新配置(保留自身字段)。
Source§fn is_animating(&self) -> bool
fn is_animating(&self) -> bool
ScrollView/ListView 特有:滚动动画中
Source§fn tick_settles_with_repaint(&self) -> bool
fn tick_settles_with_repaint(&self) -> bool
收敛帧(
tick 前 animating=true、tick 后=false)是否需要补一次重画把终值写回 RO。 Read moreSource§fn tick_changes_semantics(&self) -> bool
fn tick_changes_semantics(&self) -> bool
Source§fn apply_to_ro(&mut self, ro: &mut dyn RenderObject) -> StateApply
fn apply_to_ro(&mut self, ro: &mut dyn RenderObject) -> StateApply
P0-1:尝试把当前 state 就地写回已有 RO。 Read more
Source§fn init_state(&mut self)
fn init_state(&mut self)
首次挂载、State 创建后调用一次。
Source§fn did_update_widget(&mut self)
fn did_update_widget(&mut self)
widget 被替换(同类型复用)后调用;默认空实现。
Source§fn build(&self, ctx: &mut BuildContext<'_>) -> Vec<WidgetNode>
fn build(&self, ctx: &mut BuildContext<'_>) -> Vec<WidgetNode>
build 阶段:从 ctx 取主题等,返回子节点列表(默认 widget().children())
Source§fn create_render_object(&self) -> Box<dyn RenderObject>
fn create_render_object(&self) -> Box<dyn RenderObject>
创建 RenderObject —— 默认转发到 widget().create_render_object()
(大多数 State 不需要自己实现,除非需要定制 RenderObject)
Source§fn semantics(&self) -> Option<WidgetSemantics>
fn semantics(&self) -> Option<WidgetSemantics>
State 侧语义覆盖:用于暴露静态 widget 无法提供的动态值
(例如 TextField 的当前文本)。None = 使用
widget.semantics()。Source§fn set_element_id(&mut self, _id: ElementId)
fn set_element_id(&mut self, _id: ElementId)
mount 时注入本 State 所在的 element id(默认忽略)。
需要自身 id 的能力(如 DragSource 会话 owner)override 保存。
Source§fn handle_event(&mut self, event: &WidgetEvent, local_pos: Point)
fn handle_event(&mut self, event: &WidgetEvent, local_pos: Point)
处理指针/键盘/IME 事件(
local_pos 已折算到本 element 坐标系)。Source§fn handle_event_ctx(
&mut self,
event: &WidgetEvent,
local_pos: Point,
_ctx: &mut EventContext,
)
fn handle_event_ctx( &mut self, event: &WidgetEvent, local_pos: Point, _ctx: &mut EventContext, )
带消费语义的事件处理;默认转发
Self::handle_event 并继续冒泡。Source§fn accepts_scroll(&self) -> bool
fn accepts_scroll(&self) -> bool
动态滚动能力:本 State 当前是否愿意接收滚轮事件。 Read more
Source§fn scroll_into_view(&mut self, _target: Rect) -> bool
fn scroll_into_view(&mut self, _target: Rect) -> bool
无障碍 ScrollIntoView:把相对本元素左上角的
target 矩形滚动到可视区。 Read moreSource§fn handle_overlay_key(&mut self, _key: KeyCode, _mods: KeyModifiers) -> bool
fn handle_overlay_key(&mut self, _key: KeyCode, _mods: KeyModifiers) -> bool
覆盖层打开时的键盘导航钩子(方向键 / Home / End / Enter / Space)。 Read more
Source§fn tick_changes_geometry(&self) -> bool
fn tick_changes_geometry(&self) -> bool
Source§fn next_animation_delay(&self, _now_ms: u64) -> Option<u64>
fn next_animation_delay(&self, _now_ms: u64) -> Option<u64>
下一次需要 tick 的延迟(毫秒);None = 无定时任务。 Read more
Source§fn take_needs_build(&mut self) -> bool
fn take_needs_build(&mut self) -> bool
State 请求框架重建本 element 的 children(build + diff,与 update 同路径)。 Read more
Source§fn gesture_state(&self) -> Option<GestureState>
fn gesture_state(&self) -> Option<GestureState>
竞技场仲裁:有持续型手势胜出 → 返回 Accepted 独占指针
Source§fn reject_gestures(&mut self)
fn reject_gestures(&mut self)
被竞争失败:放弃进行中的手势
Source§fn handles_build_error(&self) -> bool
fn handles_build_error(&self) -> bool
是否处理 build panic(ErrorBoundary 用)
Source§fn on_build_error(&mut self, msg: &str)
fn on_build_error(&mut self, msg: &str)
build panic 时回调
Source§fn ime_cursor_area(&self) -> Option<(f32, f32, f32)>
fn ime_cursor_area(&self) -> Option<(f32, f32, f32)>
TextField/TextBox 用:IME 光标区域(x, y, line_height) — 多行感知
Source§fn as_overlay_aware(&mut self) -> Option<&mut dyn OverlayAware>
fn as_overlay_aware(&mut self) -> Option<&mut dyn OverlayAware>
Overlay-aware capability 探测 —— 返回 self 若实现了 OverlayAware trait,否则 None Read more
Source§fn accepts_drag(&self, _payload: &DragPayload) -> bool
fn accepts_drag(&self, _payload: &DragPayload) -> bool
应用内 DnD(1.1 M2):本 State 是否接受该 payload。
默认拒绝;
DropTarget 的 State override。只读,不改应用状态。Source§fn drop_payload(&mut self, _payload: &DragPayload) -> bool
fn drop_payload(&mut self, _payload: &DragPayload) -> bool
应用内 DnD:payload 被放到本目标上。返回 true 表示消费成功。
默认拒绝;在
Self::accepts_drag 为 true 的目标上由 DndManager::finish 调用。Source§fn drag_enter(&mut self, _payload: &DragPayload)
fn drag_enter(&mut self, _payload: &DragPayload)
应用内 DnD:拖拽 hover 进入本目标(可选高亮反馈)。
Source§fn drag_leave(&mut self)
fn drag_leave(&mut self)
应用内 DnD:拖拽 hover 离开本目标 / 会话取消(回滚高亮)。
Auto Trait Implementations§
impl !RefUnwindSafe for AnimatedRRectState
impl !Send for AnimatedRRectState
impl !Sync for AnimatedRRectState
impl !UnwindSafe for AnimatedRRectState
impl Forget for AnimatedRRectState
impl Freeze for AnimatedRRectStatewhere
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*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 AnimatedRRectState
impl Unpin for AnimatedRRectState
impl UnsafeUnpin for AnimatedRRectStatewhere
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*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