Skip to content

Commit

Permalink
dock: Fix toggle dock button display when have nested panels. (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee authored Oct 4, 2024
1 parent 185eca6 commit cf88a48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/app/src/story_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl StoryWorkspace {
vec![Arc::new(StoryContainer::panel::<ListStory>(cx))];

let bottom_panels: Vec<Arc<dyn PanelView>> = vec![
Arc::new(StoryContainer::panel::<TextStory>(cx)),
Arc::new(StoryContainer::panel::<TooltipStory>(cx)),
Arc::new(StoryContainer::panel::<IconStory>(cx)),
];

Expand Down
4 changes: 0 additions & 4 deletions crates/story/src/icon_story.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ impl super::Story for IconStory {
"Icon"
}

fn description() -> &'static str {
"Icon use examples"
}

fn new_view(cx: &mut WindowContext) -> View<impl gpui::FocusableView> {
Self::view(cx)
}
Expand Down
8 changes: 8 additions & 0 deletions crates/ui/src/dock/stack_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ impl StackPanel {
pub(super) fn is_top_left_panel(&self, panel: View<TabPanel>, cx: &AppContext) -> bool {
let first_panel = self.panels.first();

if let Some(parent) = &self.parent {
return parent.read(cx).is_top_left_panel(panel, cx);
}

if let Some(view) = first_panel {
if let Ok(view) = view.view().downcast::<TabPanel>() {
return view.entity_id() == panel.entity_id();
Expand All @@ -300,6 +304,10 @@ impl StackPanel {
self.panels.last()
};

if let Some(parent) = &self.parent {
return parent.read(cx).is_top_right_panel(panel, cx);
}

if let Some(view) = first_panel {
if let Ok(view) = view.view().downcast::<TabPanel>() {
return view.entity_id() == panel.entity_id();
Expand Down

0 comments on commit cf88a48

Please sign in to comment.