pub struct Tabs<TP>where
TP: TabsPolicy,{ /* private fields */ }
Expand description
A tabs widget.
The tabs can be provided up front, using Tabs::new() and add_tab()/with_tab().
Or, the tabs can be derived from the input data by implementing TabsPolicy, and providing it to Tabs::from_policy()
use druid::widget::{Tabs, Label, WidgetExt};
use druid::{Data, Lens};
#[derive(Data, Clone, Lens)]
struct AppState{
name: String
}
let tabs = Tabs::new()
.with_tab("Connection", Label::new("Connection information"))
.with_tab("Proxy", Label::new("Proxy settings"))
.lens(AppState::name);
Implementations§
§impl<TP> Tabs<TP>where
TP: TabsPolicy,
impl<TP> Tabs<TP>where TP: TabsPolicy,
pub fn for_policy(tabs: TP) -> Tabs<TP>
pub fn for_policy(tabs: TP) -> Tabs<TP>
Create a Tabs widget using the provided policy. This is useful for tabs derived from data.
pub fn with_edge(self, edge: TabsEdge) -> Tabs<TP>
pub fn with_edge(self, edge: TabsEdge) -> Tabs<TP>
Put the tab bar on the specified edge of the cross axis.
pub fn with_transition(self, transition: TabsTransition) -> Tabs<TP>
pub fn with_transition(self, transition: TabsTransition) -> Tabs<TP>
Use the provided transition when tabs change
pub fn with_tab(
self,
name: impl Into<LabelText<<TP as TabsPolicy>::Input>>,
child: impl Widget<<TP as TabsPolicy>::Input> + 'static
) -> Tabs<TP>where
TP: AddTab,
pub fn with_tab( self, name: impl Into<LabelText<<TP as TabsPolicy>::Input>>, child: impl Widget<<TP as TabsPolicy>::Input> + 'static ) -> Tabs<TP>where TP: AddTab,
Available when the policy implements AddTab - e.g StaticTabs. Return this Tabs widget with the named tab added.
pub fn with_tab_index(self, idx: usize) -> Tabs<TP>
pub fn with_tab_index(self, idx: usize) -> Tabs<TP>
A builder-style method to specify the (zero-based) index of the selected tab.
pub fn add_tab(
&mut self,
name: impl Into<LabelText<<TP as TabsPolicy>::Input>>,
child: impl Widget<<TP as TabsPolicy>::Input> + 'static
)where
TP: AddTab,
pub fn add_tab( &mut self, name: impl Into<LabelText<<TP as TabsPolicy>::Input>>, child: impl Widget<<TP as TabsPolicy>::Input> + 'static )where TP: AddTab,
Available when the policy implements AddTab - e.g StaticTabs. Return this Tabs widget with the named tab added.
pub fn set_tab_index(&mut self, idx: usize)
pub fn set_tab_index(&mut self, idx: usize)
Set the selected (zero-based) tab index.
This tab will become visible if it exists. If animations are enabled (and the widget is laid out), the tab transition will be animated.
Trait Implementations§
§impl<TP> Widget<<TP as TabsPolicy>::Input> for Tabs<TP>where
TP: TabsPolicy,
impl<TP> Widget<<TP as TabsPolicy>::Input> for Tabs<TP>where TP: TabsPolicy,
§fn event(
&mut self,
ctx: &mut EventCtx<'_, '_>,
event: &Event,
data: &mut <TP as TabsPolicy>::Input,
env: &Env
)
fn event( &mut self, ctx: &mut EventCtx<'_, '_>, event: &Event, data: &mut <TP as TabsPolicy>::Input, env: &Env )
§fn lifecycle(
&mut self,
ctx: &mut LifeCycleCtx<'_, '_>,
event: &LifeCycle,
data: &<TP as TabsPolicy>::Input,
env: &Env
)
fn lifecycle( &mut self, ctx: &mut LifeCycleCtx<'_, '_>, event: &LifeCycle, data: &<TP as TabsPolicy>::Input, env: &Env )
§fn update(
&mut self,
ctx: &mut UpdateCtx<'_, '_>,
_old_data: &<TP as TabsPolicy>::Input,
data: &<TP as TabsPolicy>::Input,
env: &Env
)
fn update( &mut self, ctx: &mut UpdateCtx<'_, '_>, _old_data: &<TP as TabsPolicy>::Input, data: &<TP as TabsPolicy>::Input, env: &Env )
§fn layout(
&mut self,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &<TP as TabsPolicy>::Input,
env: &Env
) -> Size
fn layout( &mut self, ctx: &mut LayoutCtx<'_, '_>, bc: &BoxConstraints, data: &<TP as TabsPolicy>::Input, env: &Env ) -> Size
§fn paint(
&mut self,
ctx: &mut PaintCtx<'_, '_, '_>,
data: &<TP as TabsPolicy>::Input,
env: &Env
)
fn paint( &mut self, ctx: &mut PaintCtx<'_, '_, '_>, data: &<TP as TabsPolicy>::Input, env: &Env )
§fn compute_max_intrinsic(
&mut self,
axis: Axis,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> f64
fn compute_max_intrinsic( &mut self, axis: Axis, ctx: &mut LayoutCtx<'_, '_>, bc: &BoxConstraints, data: &T, env: &Env ) -> f64
Auto Trait Implementations§
impl<TP> !RefUnwindSafe for Tabs<TP>
impl<TP> !Send for Tabs<TP>
impl<TP> !Sync for Tabs<TP>
impl<TP> Unpin for Tabs<TP>where TP: Unpin, <TP as TabsPolicy>::Build: Unpin, <TP as TabsPolicy>::Input: Unpin,
impl<TP> !UnwindSafe for Tabs<TP>
Blanket Implementations§
§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> Pointable for T
impl<T> Pointable for T
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
§impl<T, W> TestWidgetExt<T> for Wwhere
T: Data,
W: Widget<T> + 'static,
impl<T, W> TestWidgetExt<T> for Wwhere T: Data, W: Widget<T> + 'static,
§impl<T, W> WidgetExt<T> for Wwhere
T: Data,
W: Widget<T> + 'static,
impl<T, W> WidgetExt<T> for Wwhere T: Data, W: Widget<T> + 'static,
§fn align_left(self) -> Align<T>
fn align_left(self) -> Align<T>
Align
widget, configured to align left.§fn align_right(self) -> Align<T>
fn align_right(self) -> Align<T>
Align
widget, configured to align right.§fn align_vertical(self, align: UnitPoint) -> Align<T>
fn align_vertical(self, align: UnitPoint) -> Align<T>
Align
widget, configured to align vertically.§fn align_horizontal(self, align: UnitPoint) -> Align<T>
fn align_horizontal(self, align: UnitPoint) -> Align<T>
Align
widget, configured to align horizontally.§fn fix_width(self, width: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
fn fix_width(self, width: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
SizedBox
with an explicit width.§fn fix_height(self, height: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
fn fix_height(self, height: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
SizedBox
with an explicit height.§fn fix_size(
self,
width: impl Into<KeyOrValue<f64>>,
height: impl Into<KeyOrValue<f64>>
) -> SizedBox<T>
fn fix_size( self, width: impl Into<KeyOrValue<f64>>, height: impl Into<KeyOrValue<f64>> ) -> SizedBox<T>
SizedBox
with an explicit width and height§fn expand_width(self) -> SizedBox<T>
fn expand_width(self) -> SizedBox<T>
§fn expand_height(self) -> SizedBox<T>
fn expand_height(self) -> SizedBox<T>
§fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
§fn foreground(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
fn foreground(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
§fn border(
self,
color: impl Into<KeyOrValue<Color>>,
width: impl Into<KeyOrValue<f64>>
) -> Container<T>
fn border( self, color: impl Into<KeyOrValue<Color>>, width: impl Into<KeyOrValue<f64>> ) -> Container<T>
§fn controller<C>(self, controller: C) -> ControllerHost<Self, C>where
C: Controller<T, Self>,
fn controller<C>(self, controller: C) -> ControllerHost<Self, C>where C: Controller<T, Self>,
Controller
.§fn on_added(
self,
f: impl Fn(&mut Self, &mut LifeCycleCtx<'_, '_>, &T, &Env) + 'static
) -> ControllerHost<Self, Added<T, Self>>
fn on_added( self, f: impl Fn(&mut Self, &mut LifeCycleCtx<'_, '_>, &T, &Env) + 'static ) -> ControllerHost<Self, Added<T, Self>>
§fn on_click(
self,
f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static
) -> ControllerHost<Self, Click<T>>
fn on_click( self, f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static ) -> ControllerHost<Self, Click<T>>
§fn debug_paint_layout(self) -> EnvScope<T, Self>
fn debug_paint_layout(self) -> EnvScope<T, Self>
layout
Rect
s of this widget and its children.§fn debug_widget_id(self) -> EnvScope<T, Self>
fn debug_widget_id(self) -> EnvScope<T, Self>
WidgetId
s for this widget and its children, when hot. Read more§fn debug_invalidation(self) -> DebugInvalidation<T, Self>
fn debug_invalidation(self) -> DebugInvalidation<T, Self>
§fn debug_widget(self) -> EnvScope<T, Self>
fn debug_widget(self) -> EnvScope<T, Self>
DEBUG_WIDGET
env variable for this widget (and its descendants). Read more§fn with_id(self, id: WidgetId) -> IdentityWrapper<Self>
fn with_id(self, id: WidgetId) -> IdentityWrapper<Self>
§fn disabled_if(
self,
disabled_if: impl Fn(&T, &Env) -> bool + 'static
) -> DisabledIf<T, Self>
fn disabled_if( self, disabled_if: impl Fn(&T, &Env) -> bool + 'static ) -> DisabledIf<T, Self>
DisabledIf
widget. Read more