Skip to main content

FocusGrid

Struct FocusGrid 

Source
pub struct FocusGrid<T = WidgetId> {
    pub columns: usize,
    pub rows: usize,
    pub cells: Vec<Option<FocusCandidate<T>>>,
    pub wrap_mode: GridWrapMode,
    pub accelerator: Option<GridAccelerator>,
}
Expand description

A structured 2D multi-column container for deterministic grid navigation, boundary wrapping, and accelerated directional stepping.

Fields§

§columns: usize

Number of columns in the grid.

§rows: usize

Number of rows in the grid.

§cells: Vec<Option<FocusCandidate<T>>>

Cells arranged in row-major order (index = row * columns + col).

§wrap_mode: GridWrapMode

Boundary wrapping policy when reaching edges.

§accelerator: Option<GridAccelerator>

Optional navigation accelerator.

Implementations§

Source§

impl<T: Clone + PartialEq> FocusGrid<T>

Source

pub fn new(columns: usize, rows: usize) -> Self

Creates a new empty focus grid with the specified dimensions.

Source

pub fn from_candidates( columns: usize, candidates: Vec<FocusCandidate<T>>, ) -> Self

Populates a grid from a list of candidates in row-major order.

Source

pub fn with_wrap_mode(self, wrap_mode: GridWrapMode) -> Self

Configures the grid boundary wrap mode.

Source

pub fn with_accelerator(self, accelerator: GridAccelerator) -> Self

Enables navigation acceleration with the provided accelerator.

Source

pub fn reset_accelerator(&mut self)

Resets the internal accelerator if present.

Source

pub fn set_cell( &mut self, col: usize, row: usize, candidate: Option<FocusCandidate<T>>, )

Sets the candidate at cell coordinate (col, row).

Source

pub fn get_cell(&self, col: usize, row: usize) -> Option<&FocusCandidate<T>>

Retrieves the candidate at cell coordinate (col, row).

Source

pub fn is_cell_focusable(&self, col: usize, row: usize) -> bool

Returns true if the cell at (col, row) exists and is focusable.

Source

pub fn find_position(&self, id: &T) -> Option<(usize, usize)>

Finds the (col, row) coordinates of a candidate by its ID.

Source

pub fn navigate_step( &self, current_id: &T, direction: FocusDirection, step: usize, ) -> Option<&FocusCandidate<T>>

Navigates from current_id in direction using a specified step distance and grid wrap mode.

Skips empty or non-focusable cells along the path to find the next valid focusable candidate.

Source

pub fn navigate_accelerated( &mut self, current_id: &T, direction: FocusDirection, ) -> Option<&FocusCandidate<T>>

Navigates from current_id in direction applying the internal accelerator if configured.

Source

pub fn navigate_from_coords( &self, start_col: usize, start_row: usize, direction: FocusDirection, step: usize, ) -> Option<&FocusCandidate<T>>

Navigates from (start_col, start_row) in direction by step units.

Trait Implementations§

Source§

impl<T: Clone> Clone for FocusGrid<T>

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<T: Debug> Debug for FocusGrid<T>

Source§

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

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

impl<T: PartialEq> PartialEq for FocusGrid<T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for FocusGrid<T>

Auto Trait Implementations§

§

impl<T> Forget for FocusGrid<T>

§

impl<T> Freeze for FocusGrid<T>

§

impl<T> Move for FocusGrid<T>

§

impl<T> RefUnwindSafe for FocusGrid<T>
where T: RefUnwindSafe,

§

impl<T> Send for FocusGrid<T>
where T: Send, RawVecInner: Send,

§

impl<T> Sync for FocusGrid<T>
where T: Sync, RawVecInner: Sync,

§

impl<T> Unpin for FocusGrid<T>
where T: Unpin, *const u8 is !null: Unpin,

§

impl<T> UnsafeUnpin for FocusGrid<T>

§

impl<T> UnwindSafe for FocusGrid<T>
where RawVecInner: UnwindSafe, T: UnwindSafe,

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.