Fix DockItem::tabs, the items should use trait object to support difference type.
This commit is contained in:
parent
9baada4fb4
commit
b6374313b2
2 changed files with 16 additions and 17 deletions
|
|
@ -70,18 +70,18 @@ impl StoryWorkspace {
|
||||||
vec![
|
vec![
|
||||||
DockItem::tabs(
|
DockItem::tabs(
|
||||||
vec![
|
vec![
|
||||||
StoryContainer::panel::<ButtonStory>(cx),
|
Arc::new(StoryContainer::panel::<ButtonStory>(cx)),
|
||||||
StoryContainer::panel::<InputStory>(cx),
|
Arc::new(StoryContainer::panel::<InputStory>(cx)),
|
||||||
StoryContainer::panel::<DropdownStory>(cx),
|
Arc::new(StoryContainer::panel::<DropdownStory>(cx)),
|
||||||
StoryContainer::panel::<ModalStory>(cx),
|
Arc::new(StoryContainer::panel::<ModalStory>(cx)),
|
||||||
StoryContainer::panel::<PopupStory>(cx),
|
Arc::new(StoryContainer::panel::<PopupStory>(cx)),
|
||||||
StoryContainer::panel::<ListStory>(cx),
|
Arc::new(StoryContainer::panel::<ListStory>(cx)),
|
||||||
StoryContainer::panel::<SwitchStory>(cx),
|
Arc::new(StoryContainer::panel::<SwitchStory>(cx)),
|
||||||
StoryContainer::panel::<ProgressStory>(cx),
|
Arc::new(StoryContainer::panel::<ProgressStory>(cx)),
|
||||||
StoryContainer::panel::<TableStory>(cx),
|
Arc::new(StoryContainer::panel::<TableStory>(cx)),
|
||||||
StoryContainer::panel::<ImageStory>(cx),
|
Arc::new(StoryContainer::panel::<ImageStory>(cx)),
|
||||||
StoryContainer::panel::<ResizableStory>(cx),
|
Arc::new(StoryContainer::panel::<ResizableStory>(cx)),
|
||||||
StoryContainer::panel::<ScrollableStory>(cx),
|
Arc::new(StoryContainer::panel::<ScrollableStory>(cx)),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
&dock_area,
|
&dock_area,
|
||||||
|
|
@ -89,8 +89,8 @@ impl StoryWorkspace {
|
||||||
),
|
),
|
||||||
DockItem::tabs(
|
DockItem::tabs(
|
||||||
vec![
|
vec![
|
||||||
StoryContainer::panel::<ProgressStory>(cx),
|
Arc::new(StoryContainer::panel::<ProgressStory>(cx)),
|
||||||
StoryContainer::panel::<TextStory>(cx),
|
Arc::new(StoryContainer::panel::<TextStory>(cx)),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
&dock_area,
|
&dock_area,
|
||||||
|
|
|
||||||
|
|
@ -89,15 +89,14 @@ impl DockItem {
|
||||||
/// Create DockItem with tabs layout, items are displayed as tabs.
|
/// Create DockItem with tabs layout, items are displayed as tabs.
|
||||||
///
|
///
|
||||||
/// The `active_ix` is the index of the active tab, if `None` the first tab is active.
|
/// The `active_ix` is the index of the active tab, if `None` the first tab is active.
|
||||||
pub fn tabs<P: Panel>(
|
pub fn tabs(
|
||||||
items: Vec<View<P>>,
|
items: Vec<Arc<dyn PanelView>>,
|
||||||
active_ix: Option<usize>,
|
active_ix: Option<usize>,
|
||||||
dock_area: &View<DockArea>,
|
dock_area: &View<DockArea>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut new_items: Vec<Arc<dyn PanelView>> = vec![];
|
let mut new_items: Vec<Arc<dyn PanelView>> = vec![];
|
||||||
for item in items.into_iter() {
|
for item in items.into_iter() {
|
||||||
let item: Arc<dyn PanelView> = Arc::new(item);
|
|
||||||
new_items.push(item)
|
new_items.push(item)
|
||||||
}
|
}
|
||||||
Self::new_tabs(new_items, active_ix, dock_area, cx)
|
Self::new_tabs(new_items, active_ix, dock_area, cx)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue