dock: Fix toggle dock button display when have nested panels. (#309)

This commit is contained in:
Jason Lee 2024-10-04 14:22:24 +08:00 committed by GitHub
parent 185eca6c67
commit cf88a48bec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -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)),
];

View file

@ -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)
}

View file

@ -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();
@ -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();