Struct PopupPlacementInput

Source
pub struct PopupPlacementInput { /* private fields */ }
Expand description

Complete provider-neutral input to popup placement resolution.

All rectangles/sizes/gaps are logical pixels. Construction and builder calls store values verbatim; resolve_popup_placement validates finite, non-negative geometry and a non-empty viewport.

§Examples

use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementInput;
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 10.0, 5.0), Size::new(20.0, 10.0), Rect::new(0.0, 0.0, 100.0, 80.0));
assert!(input.allows_flip());

Implementations§

Source§

impl PopupPlacementInput

Builder and accessor operations for complete placement resolution input.

Source

pub fn new(anchor: Rect, desired_size: Size, viewport: Rect) -> Self

Creates bottom-centered overlay input with zero gap and flipping enabled.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::{PopupBackend, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::new(10.0, 5.0), Rect::new(0.0, 0.0, 100.0, 100.0));
assert_eq!(input.backend(), PopupBackend::Overlay);
assert_eq!(input.gap(), 0.0);
Source

pub const fn anchor(self) -> Rect

Returns the stored global logical-pixel anchor.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let anchor = Rect::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(PopupPlacementInput::new(anchor, Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).anchor(), anchor);
Source

pub const fn desired_size(self) -> Size

Returns the requested logical-pixel popup size.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let size = Size::new(3.0, 4.0);
assert_eq!(PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), size, Rect::new(0.0, 0.0, 1.0, 1.0)).desired_size(), size);
Source

pub const fn viewport(self) -> Rect

Returns the complete global logical-pixel viewport.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let viewport = Rect::new(5.0, 6.0, 100.0, 80.0);
assert_eq!(PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), viewport).viewport(), viewport);
Source

pub const fn placement(self) -> PopupPlacement

Returns the preferred vertical side.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::{PopupPlacement, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0));
assert_eq!(input.placement(), PopupPlacement::Bottom);
Source

pub const fn alignment(self) -> PopupAlignment

Returns the cross-axis anchor alignment.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::{PopupAlignment, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0));
assert_eq!(input.alignment(), PopupAlignment::Center);
Source

pub const fn gap(self) -> f32

Returns the requested logical-pixel gap.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_gap(3.0);
assert_eq!(input.gap(), 3.0);
Source

pub const fn allows_flip(self) -> bool

Returns whether vertical side flipping is enabled.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_flip(false);
assert!(!input.allows_flip());
Source

pub const fn backend(self) -> PopupBackend

Returns the requested presentation backend.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::{PopupBackend, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_backend(PopupBackend::Native);
assert_eq!(input.backend(), PopupBackend::Native);
Source

pub const fn with_placement(self, placement: PopupPlacement) -> Self

Replaces the preferred vertical side.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::{PopupPlacement, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_placement(PopupPlacement::Top);
assert_eq!(input.placement(), PopupPlacement::Top);
Source

pub const fn with_alignment(self, alignment: PopupAlignment) -> Self

Replaces the cross-axis alignment.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::{PopupAlignment, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_alignment(PopupAlignment::Start);
assert_eq!(input.alignment(), PopupAlignment::Start);
Source

pub const fn with_gap(self, gap: f32) -> Self

Replaces the logical-pixel gap without validating it.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_gap(2.0);
assert_eq!(input.gap(), 2.0);
Source

pub const fn with_flip(self, allow_flip: bool) -> Self

Enables or disables automatic vertical flipping.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::PopupPlacementInput;
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_flip(false);
assert!(!input.allows_flip());
Source

pub const fn with_backend(self, backend: PopupBackend) -> Self

Replaces the preferred backend; capability fallback occurs at resolve.

§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::{PopupBackend, PopupPlacementInput};
let input = PopupPlacementInput::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default(), Rect::new(0.0, 0.0, 1.0, 1.0)).with_backend(PopupBackend::Native);
assert_eq!(input.backend(), PopupBackend::Native);

Trait Implementations§

Source§

impl Clone for PopupPlacementInput

Source§

fn clone(&self) -> PopupPlacementInput

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PopupPlacementInput

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PopupPlacementInput

Source§

fn eq(&self, other: &PopupPlacementInput) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PopupPlacementInput

Source§

impl StructuralPartialEq for PopupPlacementInput

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<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,