Struct PopupSemantics

Source
#[non_exhaustive]
pub struct PopupSemantics { /* private fields */ }
Expand description

Provider-neutral interaction and accessibility contract for a popup.

Defaults describe an interactive generic popup: outside press/Escape close it, pointer input is consumed, and focus is restored on close, but opening does not move focus. Builder booleans mean exactly whether each behavior is requested; the portal does not infer a role-specific override.

§Examples

use ailloli_ui_runtime::popup::PopupSemantics;
let semantics = PopupSemantics::new();
assert!(semantics.dismisses_on_escape() && semantics.consumes_pointer_input());

Implementations§

Source§

impl PopupSemantics

Constructors, accessors, and immutable-style semantic builders.

Source

pub const fn new() -> Self

Creates the interactive generic defaults.

§Examples
use ailloli_ui_runtime::popup::{PopupFocusPolicy, PopupRole, PopupSemantics};
let value = PopupSemantics::new();
assert_eq!((value.role(), value.focus_policy()), (PopupRole::Generic, PopupFocusPolicy::None));
assert!(value.dismisses_on_outside_press() && value.dismisses_on_escape() && value.consumes_pointer_input() && value.restores_focus_on_close());
Source

pub const fn role(&self) -> PopupRole

Returns the semantic category.

§Examples
use ailloli_ui_runtime::popup::{PopupRole, PopupSemantics};
assert_eq!(PopupSemantics::new().with_role(PopupRole::Menu).role(), PopupRole::Menu);
Source

pub const fn focus_policy(&self) -> PopupFocusPolicy

Returns requested focus behavior on open.

§Examples
use ailloli_ui_runtime::popup::{PopupFocusPolicy, PopupSemantics};
assert_eq!(PopupSemantics::new().with_focus_policy(PopupFocusPolicy::MoveIntoPopup).focus_policy(), PopupFocusPolicy::MoveIntoPopup);
Source

pub const fn dismisses_on_outside_press(&self) -> bool

Reports whether an outside press requests dismissal.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().dismiss_on_outside_press(false).dismisses_on_outside_press());
Source

pub const fn dismisses_on_escape(&self) -> bool

Reports whether Escape requests dismissal.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().dismiss_on_escape(false).dismisses_on_escape());
Source

pub const fn consumes_pointer_input(&self) -> bool

Reports whether routed pointer input is considered handled.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().consume_pointer_input(false).consumes_pointer_input());
Source

pub const fn restores_focus_on_close(&self) -> bool

Reports whether close emits owner focus restoration.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().restore_focus_on_close(false).restores_focus_on_close());
Source

pub const fn with_role(self, role: PopupRole) -> Self

Replaces the semantic category without changing other behavior.

§Examples
use ailloli_ui_runtime::popup::{PopupRole, PopupSemantics};
assert_eq!(PopupSemantics::new().with_role(PopupRole::Listbox).role(), PopupRole::Listbox);
Source

pub const fn with_focus_policy(self, focus_policy: PopupFocusPolicy) -> Self

Replaces focus-on-open behavior.

§Examples
use ailloli_ui_runtime::popup::{PopupFocusPolicy, PopupSemantics};
assert_eq!(PopupSemantics::new().with_focus_policy(PopupFocusPolicy::TrapWithinPopup).focus_policy(), PopupFocusPolicy::TrapWithinPopup);
Source

pub const fn dismiss_on_outside_press(self, dismiss: bool) -> Self

Sets outside-press dismissal exactly to dismiss.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().dismiss_on_outside_press(false).dismisses_on_outside_press());
Source

pub const fn dismiss_on_escape(self, dismiss: bool) -> Self

Sets Escape dismissal exactly to dismiss.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().dismiss_on_escape(false).dismisses_on_escape());
Source

pub const fn consume_pointer_input(self, consume: bool) -> Self

Sets pointer-input consumption exactly to consume.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().consume_pointer_input(false).consumes_pointer_input());
Source

pub const fn restore_focus_on_close(self, restore: bool) -> Self

Sets owner focus restoration exactly to restore.

§Examples
use ailloli_ui_runtime::popup::PopupSemantics;
assert!(!PopupSemantics::new().restore_focus_on_close(false).restores_focus_on_close());
Source

pub const fn tooltip() -> Self

Non-interactive semantics suitable for a tooltip.

Role is tooltip; Escape dismissal stays enabled, while outside press, pointer consumption, and focus restoration are disabled.

§Examples
use ailloli_ui_runtime::popup::{PopupRole, PopupSemantics};
let value = PopupSemantics::tooltip();
assert_eq!(value.role(), PopupRole::Tooltip);
assert!(value.dismisses_on_escape());
assert!(!value.dismisses_on_outside_press() && !value.consumes_pointer_input());
assert!(!value.restores_focus_on_close());

Trait Implementations§

Source§

impl Clone for PopupSemantics

Source§

fn clone(&self) -> PopupSemantics

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 PopupSemantics

Source§

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

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

impl Default for PopupSemantics

Uses the interactive defaults from PopupSemantics::new.

Source§

fn default() -> Self

Source§

impl PartialEq for PopupSemantics

Source§

fn eq(&self, other: &PopupSemantics) -> 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 Eq for PopupSemantics

Source§

impl StructuralPartialEq for PopupSemantics

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Brush for T
where T: Clone + PartialEq + Default + Debug,

§

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

Source§

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