pub struct GridViewHandle { /* private fields */ }Expand description
A handle on a GridView’s scroll position, for a
caller outside the widget: a toolbar, a “show current” command, a search
result, an observer of the application’s own state.
Taken with GridView::handle, cheap to clone,
and usable at once: a request made before the grid is mounted is kept and
applied at its first layout, and the handle keeps working through every
rebuild of the grid. Each method records a request and asks for a
relayout; the layout applies it after it has measured the detail band and
settled the scroll anchoring, so a request made in the same turn as a
change of layout lands where the new layout puts the tile:
// Open the band of tile 0 and put tile 30 at the top, in one turn.
expanded.set(Some(0));
handle.scroll_to_index(30, ScrollAnchor::Start);Only the latest request is applied: a later one replaces one still pending. A request for a tile the grid does not have when it is applied does nothing.
The handle also reads and moves the grid’s keyboard cursor, the tile
the arrow keys step from, the focus ring marks and assistive technology is
told is current: cursor,
set_cursor and cursor_signal.
In a multiple selection the cursor and the selection are separate: the
accelerator with an arrow moves the cursor alone, and a selection written
from outside leaves the cursor where it was.
Implementations§
Source§impl GridViewHandle
impl GridViewHandle
Sourcepub fn cursor(&self) -> Option<usize>
pub fn cursor(&self) -> Option<usize>
The tile the keyboard cursor is on, or None while the grid has no
cursor: it has not been navigated, clicked or given one by
set_cursor. With no cursor the keys start from
the first selected tile, and from the first or last tile when nothing
is selected.
In a single selection the cursor follows the selection: the keys move
them together, and a selection written from outside moves the cursor
onto it. In a multiple selection they are separate: the accelerator
with an arrow (Ctrl+Arrow) moves the cursor alone, and a selection
written from outside leaves the cursor where it was.
Sourcepub fn set_cursor(&self, index: Option<usize>)
pub fn set_cursor(&self, index: Option<usize>)
Move the keyboard cursor to tile index, or remove it with None.
An index past the last tile is clamped to the last tile; on an empty grid the cursor is removed. The focus ring moves at the next paint, while the grid holds keyboard focus, and the grid names the tile as its active descendant at the next accessibility update when the tile is realized. The next arrow key steps from it.
Keyboard focus and the selection are left alone, and the grid does not
scroll: pair it with ensure_index_visible
to bring the tile into view. Usable before the grid is mounted (the
first build finds the cursor there) and across its rebuilds. In a
single selection the next change of selection puts the cursor back on
the selected tile.
Sourcepub fn cursor_signal(&self) -> Signal<Option<usize>>
pub fn cursor_signal(&self) -> Signal<Option<usize>>
A read-only signal of the cursor, as cursor reports
it, for an application to observe or bind: a status line naming the
current tile, actions enabled for it. It changes with every write of
the cursor, by the keys, a click, the data shifting it or
set_cursor.
Sourcepub fn scroll_to_index(&self, index: usize, anchor: ScrollAnchor)
pub fn scroll_to_index(&self, index: usize, anchor: ScrollAnchor)
Scroll to tile index, forcing its position in the viewport per
anchor: ScrollAnchor::Start puts its top at the viewport’s top,
Center centres it,
End puts its bottom at the viewport’s bottom,
and Auto scrolls the least that shows it.
Clamped to the scroll range. Applied at the next layout.
Sourcepub fn ensure_index_visible(&self, index: usize, anchor: ScrollAnchor)
pub fn ensure_index_visible(&self, index: usize, anchor: ScrollAnchor)
Bring tile index into view: nothing when it is already fully
visible, otherwise a scroll per anchor, as
scroll_to_index. Applied at the next
layout, against the layout it will be shown in.
Sourcepub fn reveal_band(&self, index: usize)
pub fn reveal_band(&self, index: usize)
Scroll so tile index and its open detail band are both visible:
the least scroll that shows the span from the top of the tile’s row
to the bottom of its band, and the row first when the two do not fit
together, so the band reads as the tile’s. This is what the grid does
itself when a user opens a band.
When index’s band is not open at the layout that applies it (no
detail_row, another tile disclosed,
or a tile with nothing to disclose), the tile alone is brought into
view, as ensure_index_visible with
ScrollAnchor::Auto. Open the band and call this in the same turn:
the band is measured before the request is applied.
Trait Implementations§
Source§impl Clone for GridViewHandle
impl Clone for GridViewHandle
Source§fn clone(&self) -> GridViewHandle
fn clone(&self) -> GridViewHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GridViewHandle
impl !Send for GridViewHandle
impl !Sync for GridViewHandle
impl !UnwindSafe for GridViewHandle
impl Freeze for GridViewHandle
impl Unpin for GridViewHandle
impl UnsafeUnpin for GridViewHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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