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>) -> Self
pub fn new(tabs: Vec<DocumentTab>, active: Binding<u64>) -> Self
These tabs, in this order, with the id of the open one in active.
Sourcepub fn on_close(self, handler: impl Fn(u64) + 'static) -> Self
pub fn on_close(self, handler: impl Fn(u64) + 'static) -> Self
Called with a tab to close, and turns on what closes them.
Sourcepub fn on_reorder(self, handler: impl Fn(usize, usize) + 'static) -> Self
pub fn on_reorder(self, handler: impl Fn(usize, usize) + 'static) -> Self
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) -> Self
pub fn on_rename(self, handler: impl Fn(u64, String) + 'static) -> Self
Called with a tab and its new name, and lets them be renamed.
Sourcepub fn on_new(self, handler: impl Fn() + 'static) -> Self
pub fn on_new(self, handler: impl Fn() + 'static) -> Self
Shows a button at the end that calls this.
More items for a tab’s menu, above the ones it already has.
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§
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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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>
Adds padding inside the box, in logical pixels.
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Paints a background behind the content.
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
Fixes the width and/or height in logical pixels;
None keeps the content size.