Skip to main content

ItemsViewSource

Struct ItemsViewSource 

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

What an ItemsView shows and what of it is selected: WinUI’s ItemsSource and the SelectionModel and current-element model that ItemsView keeps over it, as one object the application holds.

The application makes one with ItemsViewSource::new, giving the number of items, hands it to the ItemsView, and disposes it after the view. set_items is assigning a new ItemsSource: SelectionModel::Source(value) clears the selection and the anchor and raises SelectionChanged (controls/dev/Repeater/SelectionModel.cpp, 44), and ItemsView does it when it is given an ItemsSource (ItemsView.cpp, OnItemsSourceChanged, or OnItemsRepeaterItemsSourceChanged once its repeater exists). A selection taken after that, before the view is built, is kept, as WinUI’s is before Loaded; an index past the items is ignored, as SelectionNode::Select ignores it, and SelectionChanged raised all the same, as SelectionModel::SelectImpl raises it. Items added or removed in place (SelectionNode::OnSourceListChanged) are not ported: the application gives the new items with set_items.

Implementations§

Source§

impl ItemsViewSource

Source

pub fn new(app: &mut App, item_count: usize) -> Ref<Self>

Creates a source of item_count items with nothing selected, for ItemsView’s default Single mode.

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Releases the listeners; the selection is not used after.

Source

pub fn is_selected(self: Handle<Self>, app: &App, index: usize) -> bool

IsSelected.

Source

pub fn selected_indices(self: Handle<Self>, app: &App) -> Vec<usize>

The selected indices in ascending order: SelectedItems as positions.

Source

pub fn selected_index(self: Handle<Self>, app: &App) -> Option<usize>

SelectedItem as a position: the first selected index.

Source

pub fn current_item_index(self: Handle<Self>, app: &App) -> Option<usize>

CurrentItemIndex.

Source

pub fn select(self: Handle<Self>, app: &mut App, index: usize)

Select.

Source

pub fn deselect(self: Handle<Self>, app: &mut App, index: usize)

Deselect.

Source

pub fn select_all(self: Handle<Self>, app: &mut App)

SelectAll (SelectAllFlat): every item, whatever the mode, as WinUI’s model does.

Source

pub fn deselect_all(self: Handle<Self>, app: &mut App)

DeselectAll.

Source

pub fn invert_selection(self: Handle<Self>, app: &mut App)

InvertSelection: the selected items become unselected and the others selected.

Source

pub fn item_count(self: Handle<Self>, app: &App) -> usize

The number of items: ItemsSource’s count.

Source

pub fn set_items(self: Handle<Self>, app: &mut App, count: usize)

Assigns new items: ItemsView.ItemsSource set, which sets the selection model’s Source. The selection and the anchor are cleared and SelectionChanged raised once (SelectionModel.cpp, 44).

Trait Implementations§

Source§

impl ChangeNotifier for ItemsViewSource

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>