From cf88a48becd717a5df8950a6486b01e9b7bce440 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 4 Oct 2024 14:22:24 +0800 Subject: [PATCH] dock: Fix toggle dock button display when have nested panels. (#309) --- crates/app/src/story_workspace.rs | 2 +- crates/story/src/icon_story.rs | 4 ---- crates/ui/src/dock/stack_panel.rs | 8 ++++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/app/src/story_workspace.rs b/crates/app/src/story_workspace.rs index 9889812..8c9bdf3 100644 --- a/crates/app/src/story_workspace.rs +++ b/crates/app/src/story_workspace.rs @@ -65,7 +65,7 @@ impl StoryWorkspace { vec![Arc::new(StoryContainer::panel::(cx))]; let bottom_panels: Vec> = vec![ - Arc::new(StoryContainer::panel::(cx)), + Arc::new(StoryContainer::panel::(cx)), Arc::new(StoryContainer::panel::(cx)), ]; diff --git a/crates/story/src/icon_story.rs b/crates/story/src/icon_story.rs index 4c1c6c0..a5c69ba 100644 --- a/crates/story/src/icon_story.rs +++ b/crates/story/src/icon_story.rs @@ -29,10 +29,6 @@ impl super::Story for IconStory { "Icon" } - fn description() -> &'static str { - "Icon use examples" - } - fn new_view(cx: &mut WindowContext) -> View { Self::view(cx) } diff --git a/crates/ui/src/dock/stack_panel.rs b/crates/ui/src/dock/stack_panel.rs index ef9c0fb..2458f37 100644 --- a/crates/ui/src/dock/stack_panel.rs +++ b/crates/ui/src/dock/stack_panel.rs @@ -282,6 +282,10 @@ impl StackPanel { pub(super) fn is_top_left_panel(&self, panel: View, 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::() { 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::() { return view.entity_id() == panel.entity_id();