Skip to main content

OverlayAnchor

Enum OverlayAnchor 

Source
pub enum OverlayAnchor {
    Point {
        position: Point,
        offset: Point,
    },
    Element {
        placement: AnchorPlacement,
        gap: f32,
        offset: Point,
    },
}
Expand description

锚点策略:state 拿不到全局几何,由 tree 在执行期解析

两种模式:

  • Point:窗口绝对定位(光标位置 / Dialog 中心 / 任意全局坐标), 可选 offset 做微调(正=下/右,负=上/左)
  • Element:相对某个 element 定位,用 placement(九宫格)决定方位、 gap 控制间距、offset 做位置微调(如触发组件不在正中心弹出)

Variants§

§

Point

窗口绝对定位

Fields

§position: Point

全局坐标(Dialog 用 Point::ZERO 表示“由 layer_tree 自己居中“)

§offset: Point

位置微调:正=下/右,负=上/左(默认 ZERO)

§

Element

相对触发组件定位

Fields

§placement: AnchorPlacement

九宫格方位:Bottom = 正下方居中、Right = 正右方垂直居中、…

§gap: f32

弹出框与触发组件的间距(像素)

§offset: Point

位置微调:在 placement 结果上叠加偏移(默认 ZERO) 例:Bottom + offset=(0, 4) = 正下方再往下偏 4px

Implementations§

Source§

impl OverlayAnchor

Source

pub fn point(position: Point) -> Self

便捷构造:窗口绝对定位,无偏移

Source

pub fn point_with_offset(position: Point, offset: Point) -> Self

便捷构造:窗口绝对定位 + 偏移

Source

pub fn element(placement: AnchorPlacement, gap: f32) -> Self

便捷构造:相对 element 定位,无偏移

Source

pub fn element_with_offset( placement: AnchorPlacement, gap: f32, offset: Point, ) -> Self

便捷构造:相对 element 定位 + 偏移

Trait Implementations§

Source§

impl Clone for OverlayAnchor

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for OverlayAnchor

Source§

impl Debug for OverlayAnchor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.