pub struct TabBarLayout {
pub bar_width: f32,
pub bar_height: f32,
pub visible_tabs: Vec<VisibleTab>,
pub visible_segments: Vec<VisibleSegment>,
pub scroll_left: Option<Rect>,
pub scroll_right: Option<Rect>,
pub hit_regions: Vec<(Rect, TabBarHit)>,
pub resolved_scroll_offset: usize,
}Expand description
Fully-resolved tab-bar layout. Backends iterate visible_tabs /
visible_segments for painting; call Self::hit_test for clicks.
§Writing resolved_scroll_offset back
When a frame paints with a stale TabBar.scroll_offset (e.g. after a
window resize or a jump to a tab that wasn’t previously visible), the
layout corrects it. The backend should write resolved_scroll_offset
back to the app’s stored scroll state so the next frame starts
coherent. See TabBar::layout docs for the two-pass-paint pattern.
Fields§
§bar_width: f32Total bar width in the measurer’s unit (copied from input).
bar_height: f32Total bar height in the measurer’s unit (copied from input).
visible_tabs: Vec<VisibleTab>Tabs that made it onto the bar, left-to-right as drawn.
visible_segments: Vec<VisibleSegment>Right-aligned segments that fit, drawn left-to-right starting from their resolved left edge.
scroll_left: Option<Rect>Left scroll-arrow rectangle, present iff resolved_scroll_offset > 0
and scroll_arrow_width > 0.0.
scroll_right: Option<Rect>Right scroll-arrow rectangle, present iff tabs extend beyond the
visible area and scroll_arrow_width > 0.0.
hit_regions: Vec<(Rect, TabBarHit)>Ordered hit-region list. hit_test walks this from the start and
returns the first containing region. More-specific regions (close
buttons) come before containing regions (tab bodies).
resolved_scroll_offset: usizeScroll offset actually used. May differ from TabBar.scroll_offset
if the input was stale.
Implementations§
Source§impl TabBarLayout
impl TabBarLayout
Sourcepub fn hit_test(&self, x: f32, y: f32) -> TabBarHit
pub fn hit_test(&self, x: f32, y: f32) -> TabBarHit
Test which clickable region (if any) contains point (x, y).
Returns TabBarHit::Empty when no region matches.
Sourcepub fn tab_center(&self, tab_idx: usize) -> Option<(f32, f32)>
pub fn tab_center(&self, tab_idx: usize) -> Option<(f32, f32)>
Center point of tab tab_idx’s full bounds (label + close button),
in this layout’s own bar-relative coordinate space — the same
space visible_tabs[].bounds uses (origin at the bar’s top-left,
not the target surface). None if tab_idx isn’t in
visible_tabs, i.e. it’s scrolled out of view behind the bar’s
scroll_offset.
Backends that cache a TabBarLayout per WidgetId at paint time
add the cached bar rect’s own (x, y) origin to this to get an
absolute screen point — see TuiDriver::tab_center /
GtkDriver::tab_center, which every tab bar needs
since every tab paints the same label-independent chrome and
find() can’t disambiguate tab 3’s target from tab 0’s the way it
can for uniquely-labeled text.
Sourcepub fn tab_close_center(&self, tab_idx: usize) -> Option<(f32, f32)>
pub fn tab_close_center(&self, tab_idx: usize) -> Option<(f32, f32)>
Center point of tab tab_idx’s close-button hit region, in the
same bar-relative space as Self::tab_center. None when the
tab is scrolled out of view (see Self::tab_center) or when
it drew no close button this frame — is_closable: false on the
tab, or show_tab_close: false on the bar.
Trait Implementations§
Source§impl Clone for TabBarLayout
impl Clone for TabBarLayout
Source§impl Debug for TabBarLayout
impl Debug for TabBarLayout
Source§impl PartialEq for TabBarLayout
impl PartialEq for TabBarLayout
impl StructuralPartialEq for TabBarLayout
Auto Trait Implementations§
impl Freeze for TabBarLayout
impl RefUnwindSafe for TabBarLayout
impl Send for TabBarLayout
impl Sync for TabBarLayout
impl Unpin for TabBarLayout
impl UnsafeUnpin for TabBarLayout
impl UnwindSafe for TabBarLayout
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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