Skip to main content

SimplePopupState

Struct SimplePopupState 

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

Simple implementation of PopupState for prototyping

This struct provides a minimal state implementation for external projects that don’t need complex state management integration.

Tracks state for multiple popups using HashMap<String, T>.

§Usage

use popup::state::{PopupState, SimplePopupState};

let mut state = SimplePopupState::new();

// Open popup at position
state.set_open("context_menu", true);
state.set_position("context_menu", (100.0, 200.0));

assert!(state.is_open("context_menu"));
assert_eq!(state.position("context_menu"), (100.0, 200.0));

// Close popup
state.set_open("context_menu", false);
assert!(!state.is_open("context_menu"));

For production, implement PopupState for your app’s state manager instead.

Implementations§

Source§

impl SimplePopupState

Source

pub fn new() -> Self

Create new popup state

Source

pub fn clear(&mut self, popup_id: &str)

Clear all state for a popup

Source

pub fn clear_all(&mut self)

Clear all popup state

Trait Implementations§

Source§

impl Clone for SimplePopupState

Source§

fn clone(&self) -> SimplePopupState

Returns a duplicate 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 SimplePopupState

Source§

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

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

impl Default for SimplePopupState

Source§

fn default() -> SimplePopupState

Returns the “default value” for a type. Read more
Source§

impl PopupState for SimplePopupState

Source§

fn is_open(&self, popup_id: &str) -> bool

Check if popup is currently open Read more
Source§

fn position(&self, popup_id: &str) -> (f64, f64)

Get popup position Read more
Source§

fn selected_item(&self, popup_id: &str) -> Option<usize>

Get selected menu item index (ContextMenu) Read more
Source§

fn selected_color(&self, popup_id: &str) -> Option<String>

Get selected color (ColorPicker) Read more
Source§

fn is_custom_mode(&self, popup_id: &str) -> bool

Check if custom color mode is active (ColorPicker) Read more
Source§

fn set_open(&mut self, popup_id: &str, open: bool)

Set popup open/closed state Read more
Source§

fn set_position(&mut self, popup_id: &str, pos: (f64, f64))

Set popup position Read more
Source§

fn set_selected_item(&mut self, popup_id: &str, index: Option<usize>)

Set selected menu item (ContextMenu) Read more
Source§

fn set_selected_color(&mut self, popup_id: &str, color: Option<String>)

Set selected color (ColorPicker) Read more
Source§

fn set_custom_mode(&mut self, popup_id: &str, custom: bool)

Set custom color mode (ColorPicker) 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 = 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.