Skip to main content

TabBar

Struct TabBar 

Source
pub struct TabBar<'a, K, const N: usize> { /* private fields */ }
Expand description

Low-level tab bar renderer and interaction helper.

Implementations§

Source§

impl<'a, K: Copy, const N: usize> TabBar<'a, K, N>

Source

pub const fn new(tabs: [TabSpec<'a, K>; N], active_index: usize) -> Self

Creates a tab bar from specs and an active index.

Examples found in repository?
src/containers.rs (line 197)
195    pub const fn new(specs: [TabSpec<'a, TabId>; N], active_index: usize) -> Self {
196        Self {
197            tabs: TabBar::new(specs, active_index),
198        }
199    }
200
201    /// Replaces the tab set and active index.
202    pub fn set_tabs(&mut self, specs: [TabSpec<'a, TabId>; N], active_index: usize) {
203        self.tabs = TabBar::new(specs, active_index);
204    }
Source

pub fn select(&mut self, active_index: usize)

Selects a tab by index.

Examples found in repository?
src/containers.rs (line 213)
212    pub fn select_tab(&mut self, index: usize) {
213        self.tabs.select(index);
214    }
Source

pub fn active(&self) -> K

Returns the active tab identifier.

Examples found in repository?
src/containers.rs (line 208)
207    pub fn active_tab(&self) -> TabId {
208        self.tabs.active()
209    }
Source

pub fn content_frame(&self, bounds: Rectangle, theme: &FsTheme) -> Rectangle

Returns the content frame above the tab bar.

Examples found in repository?
src/containers.rs (line 218)
217    pub fn content_frame(&self, bounds: Rectangle, theme: &FsTheme) -> Rectangle {
218        self.tabs.content_frame(bounds, theme)
219    }
Source

pub fn handle_touch( &mut self, touch: TouchEvent, bounds: Rectangle, theme: &FsTheme, ) -> Option<K>

Routes one touch event to the tab bar.

Examples found in repository?
src/containers.rs (line 228)
222    pub fn handle_touch(
223        &mut self,
224        touch: TouchEvent,
225        bounds: Rectangle,
226        theme: &FsTheme,
227    ) -> Option<TabId> {
228        self.tabs.handle_touch(touch, bounds, theme)
229    }
Source

pub fn draw_bar<D>( &self, display: &mut D, bounds: Rectangle, theme: &FsTheme, i18n: &I18n<'a>, )
where D: DrawTarget<Color = Rgb565>,

Draws the tab bar.

Examples found in repository?
src/containers.rs (line 238)
232    pub fn draw_bar<D>(&self, display: &mut D, bounds: Rectangle, theme: &FsTheme, i18n: &I18n<'a>)
233    where
234        D: embedded_graphics::draw_target::DrawTarget<
235                Color = embedded_graphics::pixelcolor::Rgb565,
236            >,
237    {
238        self.tabs.draw_bar(display, bounds, theme, i18n);
239    }

Trait Implementations§

Source§

impl<'a, K: Clone, const N: usize> Clone for TabBar<'a, K, N>

Source§

fn clone(&self) -> TabBar<'a, K, N>

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<'a, K: Debug, const N: usize> Debug for TabBar<'a, K, N>

Source§

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

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

impl<'a, K: PartialEq, const N: usize> PartialEq for TabBar<'a, K, N>

Source§

fn eq(&self, other: &TabBar<'a, K, N>) -> 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<'a, K: Copy, const N: usize> Copy for TabBar<'a, K, N>

Source§

impl<'a, K: Eq, const N: usize> Eq for TabBar<'a, K, N>

Source§

impl<'a, K, const N: usize> StructuralPartialEq for TabBar<'a, K, N>

Auto Trait Implementations§

§

impl<'a, K, const N: usize> Freeze for TabBar<'a, K, N>
where K: Freeze,

§

impl<'a, K, const N: usize> RefUnwindSafe for TabBar<'a, K, N>
where K: RefUnwindSafe,

§

impl<'a, K, const N: usize> Send for TabBar<'a, K, N>
where K: Send,

§

impl<'a, K, const N: usize> Sync for TabBar<'a, K, N>
where K: Sync,

§

impl<'a, K, const N: usize> Unpin for TabBar<'a, K, N>
where K: Unpin,

§

impl<'a, K, const N: usize> UnsafeUnpin for TabBar<'a, K, N>
where K: UnsafeUnpin,

§

impl<'a, K, const N: usize> UnwindSafe for TabBar<'a, K, N>
where K: 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.