pub struct DocumentTabs { /* private fields */ }Expand description
Tabs for open documents, as a browser or an editor has: they close, change places by dragging or with Alt and the arrows, are renamed with a double click, F2 or the menu, carry a color and a dot for what was not saved, and scroll with arrows when they do not fit. The arrows alone move between them, and Delete closes. The tabs belong to the app, which applies what the handlers tell it.
use ravenrs_reactive::State;
use ravenrs_widgets::{DocumentTab, DocumentTabs, Ui};
let active = State::new(1_u64);
let tabs = DocumentTabs::new(
vec![DocumentTab::new(1, "Wedding"), DocumentTab::new(2, "Portraits").unsaved(true)],
active.binding(),
)
.on_close(|id| println!("close {id}"))
.on_reorder(|from, to| println!("{from} to {to}"));
let mut ui = Ui::new(tabs, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl DocumentTabs
impl DocumentTabs
Sourcepub fn new(tabs: Vec<DocumentTab>, active: Binding<u64>) -> DocumentTabs
pub fn new(tabs: Vec<DocumentTab>, active: Binding<u64>) -> DocumentTabs
These tabs, in this order, with the id of the open one in active.
Sourcepub fn on_close(self, handler: impl Fn(u64) + 'static) -> DocumentTabs
pub fn on_close(self, handler: impl Fn(u64) + 'static) -> DocumentTabs
Called with a tab to close, and turns on what closes them.
Sourcepub fn on_reorder(
self,
handler: impl Fn(usize, usize) + 'static,
) -> DocumentTabs
pub fn on_reorder( self, handler: impl Fn(usize, usize) + 'static, ) -> DocumentTabs
Called with where a tab was and where it should go, and lets them be moved.
Sourcepub fn on_rename(self, handler: impl Fn(u64, String) + 'static) -> DocumentTabs
pub fn on_rename(self, handler: impl Fn(u64, String) + 'static) -> DocumentTabs
Called with a tab and its new name, and lets them be renamed.
Sourcepub fn on_new(self, handler: impl Fn() + 'static) -> DocumentTabs
pub fn on_new(self, handler: impl Fn() + 'static) -> DocumentTabs
Shows a button at the end that calls this.
More items for a tab’s menu, above the ones it already has.
Sourcepub fn label(self, label: impl Into<String>) -> DocumentTabs
pub fn label(self, label: impl Into<String>) -> DocumentTabs
What screen readers call the strip, instead of the name in Labels.
Sourcepub fn fade(self, fade: Semantic) -> DocumentTabs
pub fn fade(self, fade: Semantic) -> DocumentTabs
The color behind the strip, which its arrows fade from.
Trait Implementations§
Source§impl Debug for DocumentTabs
impl Debug for DocumentTabs
Auto Trait Implementations§
impl !RefUnwindSafe for DocumentTabs
impl !Send for DocumentTabs
impl !Sync for DocumentTabs
impl !UnwindSafe for DocumentTabs
impl Freeze for DocumentTabs
impl Unpin for DocumentTabs
impl UnsafeUnpin for DocumentTabs
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.