Trait druid::widget::TabsPolicy
source · pub trait TabsPolicy: Data {
type Key: Hash + Eq + Clone;
type Input: Data;
type BodyWidget: Widget<Self::Input>;
type LabelWidget: Widget<Self::Input>;
type Build;
// Required methods
fn tabs_changed(&self, old_data: &Self::Input, data: &Self::Input) -> bool;
fn tabs(&self, data: &Self::Input) -> Vec<Self::Key> ⓘ;
fn tab_info(&self, key: Self::Key, data: &Self::Input) -> TabInfo<Self::Input>;
fn tab_body(&self, key: Self::Key, data: &Self::Input) -> Self::BodyWidget;
fn tab_label(
&self,
key: Self::Key,
info: TabInfo<Self::Input>,
data: &Self::Input
) -> Self::LabelWidget;
// Provided methods
fn close_tab(&self, key: Self::Key, data: &mut Self::Input) { ... }
fn build(build: Self::Build) -> Self { ... }
fn default_make_label(info: TabInfo<Self::Input>) -> Label<Self::Input> { ... }
}
Expand description
A policy that determines how a Tabs instance derives its tabs from its app data.
Required Associated Types§
sourcetype Input: Data
type Input: Data
The input data that will: a) be used to determine the tabs present b) be the input data for all of the child widgets.
sourcetype BodyWidget: Widget<Self::Input>
type BodyWidget: Widget<Self::Input>
The common type for all body widgets in this set of tabs. A flexible default is Box<dyn WidgetSelf::Input>
sourcetype LabelWidget: Widget<Self::Input>
type LabelWidget: Widget<Self::Input>
The common type for all label widgets in this set of tabs Usually this would be LabelSelf::Input
sourcetype Build
type Build
The information required to build up this policy. This is to support policies where at least some tabs are provided up front during widget construction. If the Build type implements the AddTab trait, the add_tab and with_tab methods will be available on the Tabs instance to allow the It can be filled in with () by implementations that do not require it.
Required Methods§
sourcefn tabs_changed(&self, old_data: &Self::Input, data: &Self::Input) -> bool
fn tabs_changed(&self, old_data: &Self::Input, data: &Self::Input) -> bool
Examining the input data, has the set of tabs present changed? Expected to be cheap, eg pointer or numeric comparison.
sourcefn tabs(&self, data: &Self::Input) -> Vec<Self::Key> ⓘ
fn tabs(&self, data: &Self::Input) -> Vec<Self::Key> ⓘ
From the input data, return the new set of tabs
sourcefn tab_info(&self, key: Self::Key, data: &Self::Input) -> TabInfo<Self::Input>
fn tab_info(&self, key: Self::Key, data: &Self::Input) -> TabInfo<Self::Input>
For this tab key, return the relevant tab information that will drive label construction
sourcefn tab_body(&self, key: Self::Key, data: &Self::Input) -> Self::BodyWidget
fn tab_body(&self, key: Self::Key, data: &Self::Input) -> Self::BodyWidget
For this tab key, return the body widget
Provided Methods§
sourcefn close_tab(&self, key: Self::Key, data: &mut Self::Input)
fn close_tab(&self, key: Self::Key, data: &mut Self::Input)
Change the data to reflect the user requesting to close a tab.
sourcefn build(build: Self::Build) -> Self
fn build(build: Self::Build) -> Self
Construct an instance of this TabsFromData from its Build type. The main use case for this is StaticTabs, where the tabs are provided by the app developer up front.