Skip to main content

PositionedRenderObject

Struct PositionedRenderObject 

Source
pub struct PositionedRenderObject {
    pub offset: Point,
    pub signal: Option<Signal<Point>>,
    /* private fields */
}
Expand description

在父容器内按指定 offset 摆放子节点(不影响父容器布局)

阶段 5-G 扩展:可选 signal: Signal<Point> 用于外部驱动位置。

  • None → 静态位置(self.offset)
  • Some(signal) → paint/hit_test 走 enter_subscriber(ro_id) + signal.get() 实时读值,并自动让 RO 作为 signal 的 subscriber(signal.set 触发 RO 所在 element dirty → paint 重跑)。

Fields§

§offset: Point§signal: Option<Signal<Point>>

Implementations§

Source§

impl PositionedRenderObject

Source

pub fn new(offset: Point, child: impl RenderObject + 'static) -> Self

Source

pub fn new_dynamic( offset: Point, signal: Signal<Point>, child: impl RenderObject + 'static, ) -> Self

阶段 5-G:动态位置(外部 Signal 驱动)

Source

pub fn set_ro_subscriber_id(&mut self, id: SubscriberId)

ElementTree 在 mount 时调用,把 element 的 SubscriberId 注入 RO, 让 paint/hit_test 走 enter_subscriber + signal.get() 时 RO 成为 signal 的 subscriber(从而 Signal::set 触发 element dirty)。

Trait Implementations§

Source§

impl RenderObject for PositionedRenderObject

Source§

fn child_slots(&self) -> Vec<(Point, SharedRO)>

阶段 2-E:element_origin 遍历用 — child 在当前 offset 处

Source§

fn push_child(&mut self, offset: Point, child: SharedRO)

阶段 4-D:Positioned 包装一层, push_child 在原 offset 上再加一层 但 push_child 调用时 caller 应该传 final position,我们这里覆盖 offset 简化:push 时如果 self.offset 是 0,用 caller 的 offset;否则保留 self.offset 实际 mount 时 caller 知道完整 offset,所以这里支持 caller offset

Source§

fn set_subscriber_id(&mut self, id: SubscriberId)

阶段 5-G:必须放在 impl RenderObject for PositionedRenderObject 块内 (在 impl PositionedRenderObject 块里只是 inherent method,不会覆盖 trait 默认 noop, 导致 Box<dyn RenderObject>::set_subscriber_id 调到这里走 noop,Signal 订阅链路断裂)

Source§

fn layout( &mut self, constraints: BoxConstraints, ctx: &mut LayoutContext, ) -> Size

在给定约束下计算并缓存自身尺寸,返回最终 content size。 Read more
Source§

fn content_size(&self) -> Size

阶段 4-D(候选 2):返回 RO 的内容 size(已 layout 后)。 Read more
Source§

fn paint(&self, offset: Point, painter: &mut PaintList)

把自身内容追加到 painter;offset 是本 RO 原点在目标坐标系中的位置。
Source§

fn hit_test(&self, position: Point, offset: Point) -> Option<ElementId>

命中测试:position 为目标坐标系,offset 为本 RO 原点;返回命中的 element id。
Source§

fn propagate_element_ids( &mut self, child_ids: &[ElementId], stateful_ros: &mut [SharedRO], )

把子 element_id 注入到 RO 内部的子 RO。 Read more
Source§

fn for_each_child(&self, f: &mut dyn FnMut(Point, &SharedRO))

P1-7:无分配遍历直接子槽(offset 相对本 RO 原点)。 Read more
Source§

fn children_count(&self) -> usize

阶段 4-D:容器 RO 的 children 数量(让 Element 层知道 RO 是否还有空 slot) 默认 0(叶子 RO 没有 children)
Source§

fn scrollbar_lane_hit(&self, _local: Point) -> bool

本 RO 的滚动条车道是否覆盖这个本地坐标点(local = 相对本 RO 原点)。 Read more
Source§

fn set_element_id(&mut self, _id: ElementId)

Element 树 mount 时调用,让 RO 记录自己归属哪个 Element。 阶段 2 仅 RRectRenderObject 有 element_id 字段,其他 RO 默认 noop。
Source§

fn content_size_opt(&self) -> Option<Size>

P1-7:显式的有效内容尺寸(finite 且 > 0)。 Read more
Source§

fn layer_size_hint(&self) -> Option<Size>

P1-7:layer texture 的尺寸提示:优先真实内容尺寸,其次边界盒子尺寸。 Read more
Source§

fn layer_layout_size(&self) -> Option<Size>

边界 RO 在父布局中实际占用的尺寸(供嵌套 layer 局部重排)。 Read more
Source§

fn layer_relayout_constraints(&self, layout_size: Size) -> BoxConstraints

嵌套 layer 局部重排时对该边界根使用的约束(默认 loose:允许内容收缩)。 Read more
Source§

fn paint_as_layer_root(&self, offset: Point, painter: &mut PaintList)

bugfix(showcase effect 色块不显示):作为 layer root 收集本层内容时调用 (paint_layer_recursive 专用)。 Read more
Source§

fn layer_effect(&self) -> LayerEffect

阶段 5:返回此 RO 携带的 layer 视觉效果(Transform / Opacity / ClipRRect…) Read more
Source§

fn element_id(&self) -> Option<ElementId>

阶段 2-E:RO 持有的 element_id(未设置 = None) Read more
Source§

fn apply_state(&mut self, _state: &mut dyn Any) -> StateApply

P0-1:由具体 RO 从 state 读取可变量并就地写回自身。 Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.