Skip to main content

MacCollectionView

Struct MacCollectionView 

Source
pub struct MacCollectionView<'a, T> { /* private fields */ }
Expand description

Authentic macOS Collection View (NSCollectionView equivalent).

§Example

use std::collections::BTreeSet;
use egui_macview::{MacAppearance, MacCollectionView, MacTheme};

let theme = MacTheme::new(MacAppearance::Aqua);
let items = ["Tile 1", "Tile 2", "Tile 3", "Tile 4"];
let mut selected = BTreeSet::from([0usize]);

MacCollectionView::new(&items, &mut selected)
    .theme(&theme)
    .show_with_response(ui, |tile_ui, label| {
        tile_ui.centered_and_justified(|ui| {
            ui.label(*label);
        });
    });

Implementations§

Source§

impl<'a, T> MacCollectionView<'a, T>

Source

pub fn new(items: &'a [T], selected_indices: &'a mut BTreeSet<usize>) -> Self

Creates a new collection view bound to an item slice and a mutable selection set.

Source

pub fn layout(self, layout: MacCollectionViewFlowLayout) -> Self

Overrides flow layout parameters.

Source

pub fn theme(self, theme: &'a MacTheme) -> Self

Injects dynamic theme.

Source

pub fn show_with_response<F>( self, ui: &mut Ui, render_item: F, ) -> (usize, Response)
where F: FnMut(&mut Ui, &T),

Shows the collection view and returns count of rendered items within the clip rect along with interaction response.

Source

pub fn show_with_item_tracker<F>(self, ui: &mut Ui, render_item: F) -> usize
where F: FnMut(&mut Ui, &T),

Shows the collection view and returns count of rendered items within the clip rect.

Source

pub fn show(self, ui: &mut Ui) -> Response

Shows the collection view with default item presentation.

Auto Trait Implementations§

§

impl<'a, T> !UnwindSafe for MacCollectionView<'a, T>

§

impl<'a, T> Forget for MacCollectionView<'a, T>

§

impl<'a, T> Freeze for MacCollectionView<'a, T>
where &'a [T]: Freeze,

§

impl<'a, T> RefUnwindSafe for MacCollectionView<'a, T>
where &'a [T]: RefUnwindSafe,

§

impl<'a, T> Send for MacCollectionView<'a, T>
where &'a [T]: Send,

§

impl<'a, T> Sync for MacCollectionView<'a, T>
where &'a [T]: Sync,

§

impl<'a, T> Unpin for MacCollectionView<'a, T>
where &'a [T]: Unpin,

§

impl<'a, T> UnsafeUnpin for MacCollectionView<'a, T>
where &'a [T]: UnsafeUnpin,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.