pub struct TransformRenderObject {
pub child: Option<SharedRO>,
pub element_id: Option<ElementId>,
pub size: Size,
pub transform: Transform2D,
}Expand description
阶段 5:Transform 容器 RO(平移 + 旋转 + 均匀缩放,绕 layer 中心)
Fields§
§child: Option<SharedRO>§element_id: Option<ElementId>LayerProxy 自己的 element_id(Transform 元素的 id)
size: Size透传 child layout 后的 size(供 layer.size)
transform: Transform2D2D 仿射变换参数
Implementations§
Source§impl TransformRenderObject
impl TransformRenderObject
pub fn new(child: Box<dyn RenderObject>, transform: Transform2D) -> Self
pub fn empty(transform: Transform2D) -> Self
Trait Implementations§
Source§impl RenderObject for TransformRenderObject
impl RenderObject for TransformRenderObject
Source§fn child_slots(&self) -> Vec<(Point, SharedRO)>
fn child_slots(&self) -> Vec<(Point, SharedRO)>
阶段 2-E:element_origin 遍历用(变换前的局部坐标;transform 之后的 视觉位置不考虑 — IME 定位场景下 TextField 不会包在 Transform 里)
Source§fn apply_state(&mut self, state: &mut dyn Any) -> StateApply
fn apply_state(&mut self, state: &mut dyn Any) -> StateApply
属性动画:从 AnimatedScaleState 就地读当前呈现 scale 写进 transform。
只改 scale_x/scale_y,保留 widget 原有的 rotation/translation;合成阶段
layer_effect() 每帧实时读新 transform,hit_test 走 inverse_apply_transform
也读同一字段 —— 像素与命中同源。幂等:值未变返回 Unchanged。
Source§fn layout(
&mut self,
constraints: BoxConstraints,
ctx: &mut LayoutContext,
) -> Size
fn layout( &mut self, constraints: BoxConstraints, ctx: &mut LayoutContext, ) -> Size
在给定约束下计算并缓存自身尺寸,返回最终 content size。 Read more
Source§fn paint(&self, _offset: Point, _painter: &mut PaintList)
fn paint(&self, _offset: Point, _painter: &mut PaintList)
把自身内容追加到
painter;offset 是本 RO 原点在目标坐标系中的位置。Source§fn paint_as_layer_root(&self, offset: Point, painter: &mut PaintList)
fn paint_as_layer_root(&self, offset: Point, painter: &mut PaintList)
bugfix(showcase effect 色块不显示):作为 layer root 收集本层内容时调用
(paint_layer_recursive 专用)。 Read more
Source§fn hit_test(&self, position: Point, offset: Point) -> Option<ElementId>
fn hit_test(&self, position: Point, offset: Point) -> Option<ElementId>
命中测试:
position 为目标坐标系,offset 为本 RO 原点;返回命中的 element id。Source§fn set_element_id(&mut self, _id: ElementId)
fn set_element_id(&mut self, _id: ElementId)
Element 树 mount 时调用,让 RO 记录自己归属哪个 Element。
阶段 2 仅
RRectRenderObject 有 element_id 字段,其他 RO 默认 noop。Source§fn for_each_child(&self, f: &mut dyn FnMut(Point, &SharedRO))
fn for_each_child(&self, f: &mut dyn FnMut(Point, &SharedRO))
P1-7:无分配遍历直接子槽(offset 相对本 RO 原点)。 Read more
Source§fn propagate_element_ids(
&mut self,
child_ids: &[ElementId],
stateful_ros: &mut [SharedRO],
)
fn propagate_element_ids( &mut self, child_ids: &[ElementId], stateful_ros: &mut [SharedRO], )
把子 element_id 注入到 RO 内部的子 RO。 Read more
Source§fn content_size(&self) -> Size
fn content_size(&self) -> Size
阶段 4-D(候选 2):返回 RO 的内容 size(已 layout 后)。 Read more
Source§fn push_child(&mut self, _offset: Point, _child: SharedRO)
fn push_child(&mut self, _offset: Point, _child: SharedRO)
阶段 4-D:容器 RO 暴露 push_child 让 Element 层在 mount 时填 children RO。
默认 noop(叶子 RO)。容器 RO(Stack/Column/ListView)override 实现 push 语义。 Read more
Source§fn children_count(&self) -> usize
fn children_count(&self) -> usize
阶段 4-D:容器 RO 的 children 数量(让 Element 层知道 RO 是否还有空 slot)
默认 0(叶子 RO 没有 children)
Source§fn layer_effect(&self) -> LayerEffect
fn layer_effect(&self) -> LayerEffect
阶段 5:返回此 RO 携带的 layer 视觉效果(Transform / Opacity / ClipRRect…) Read more
Source§fn scrollbar_lane_hit(&self, _local: Point) -> bool
fn scrollbar_lane_hit(&self, _local: Point) -> bool
本 RO 的滚动条车道是否覆盖这个本地坐标点(
local = 相对本 RO 原点)。 Read moreSource§fn layer_size_hint(&self) -> Option<Size>
fn layer_size_hint(&self) -> Option<Size>
P1-7:layer texture 的尺寸提示:优先真实内容尺寸,其次边界盒子尺寸。 Read more
Source§fn layer_relayout_constraints(&self, layout_size: Size) -> BoxConstraints
fn layer_relayout_constraints(&self, layout_size: Size) -> BoxConstraints
嵌套 layer 局部重排时对该边界根使用的约束(默认 loose:允许内容收缩)。 Read more
Source§fn set_subscriber_id(&mut self, _id: SubscriberId)
fn set_subscriber_id(&mut self, _id: SubscriberId)
阶段 5-G:由 ElementTree 在 mount/update 时调用,把 element 的
SubscriberId 注入 RO。只在 paint/hit_test 期间作为 signal 的
subscriber 用——PositionedRenderObject 之类持 Signal 的 RO override 此钩子;
其他 RO 默认 noop。Auto Trait Implementations§
impl !RefUnwindSafe for TransformRenderObject
impl !Send for TransformRenderObject
impl !Sync for TransformRenderObject
impl !UnwindSafe for TransformRenderObject
impl Forget for TransformRenderObject
impl Freeze for TransformRenderObject
impl Move for TransformRenderObject
impl Unpin for TransformRenderObject
impl UnsafeUnpin for TransformRenderObject
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