CursorState

Enum CursorState 

Source
pub enum CursorState {
    None,
    Hover(usize, usize),
    Selected(usize, usize),
}
Expand description

State of cursor

The 2 numbers represent the x and y in Framework.selectables rather than State.0

Variants§

§

None

Nothing is selected

§

Hover(usize, usize)

Cursor is hovering on an item

§

Selected(usize, usize)

An item is selected

Implementations§

Source§

impl CursorState

Source

pub fn is_selected(&self) -> bool

Source

pub fn is_hover(&self) -> bool

Source

pub fn is_none(&self) -> bool

Source§

impl CursorState

Source

pub fn select(&mut self) -> Result<(), FrameworkError>

Try select an item, will not work if an item is already selected or the cursor is not hovering on anything

Source

pub fn deselect(&mut self) -> Result<(), FrameworkError>

Try deselect an item, will not work if no items are selected

Source§

impl CursorState

Source

pub fn to_hover(location: (usize, usize)) -> Self

Source

pub fn to_selected(location: (usize, usize)) -> Self

Source

pub fn hover( &self, selectables: &[Vec<(usize, usize)>], ) -> Option<(usize, usize)>

Source

pub fn selected( &self, selectables: &[Vec<(usize, usize)>], ) -> Option<(usize, usize)>

Source§

impl CursorState

Source

pub fn move( &mut self, direction: FrameworkDirection, selectables: &[Vec<(usize, usize)>], ) -> Result<(), FrameworkError>

Move in the corresponding direction

Trait Implementations§

Source§

impl Clone for CursorState

Source§

fn clone(&self) -> CursorState

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 Default for CursorState

Source§

fn default() -> Self

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

impl PartialEq for CursorState

Source§

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

Source§

impl Eq for CursorState

Source§

impl StructuralPartialEq for CursorState

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> CloneAny for T
where T: Any + Clone,

Source§

fn clone_any(&self) -> Box<dyn CloneAny>

Source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

Source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

Source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

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

Source§

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T> UnsafeAny for T
where T: Any,