diff --git a/crates/ui/src/dock/panel.rs b/crates/ui/src/dock/panel.rs index f0088d7c..2b83e13c 100644 --- a/crates/ui/src/dock/panel.rs +++ b/crates/ui/src/dock/panel.rs @@ -119,6 +119,11 @@ pub trait Panel: EventEmitter + Render + Focusable { fn dump(&self, cx: &App) -> PanelState { PanelState::new(self) } + + /// Whether the panel has inner padding when the panel is in the tabs layout, default is `true`. + fn inner_padding(&self, cx: &App) -> bool { + true + } } /// The PanelView trait used to define the panel view. @@ -137,6 +142,7 @@ pub trait PanelView: 'static + Send + Sync { fn view(&self) -> AnyView; fn focus_handle(&self, cx: &App) -> FocusHandle; fn dump(&self, cx: &App) -> PanelState; + fn inner_padding(&self, cx: &App) -> bool; } impl PanelView for Entity { @@ -195,6 +201,10 @@ impl PanelView for Entity { fn dump(&self, cx: &App) -> PanelState { self.read(cx).dump(cx) } + + fn inner_padding(&self, cx: &App) -> bool { + self.read(cx).inner_padding(cx) + } } impl From<&dyn PanelView> for AnyView { diff --git a/crates/ui/src/dock/tab_panel.rs b/crates/ui/src/dock/tab_panel.rs index 561f6b9e..5a26d563 100644 --- a/crates/ui/src/dock/tab_panel.rs +++ b/crates/ui/src/dock/tab_panel.rs @@ -131,6 +131,11 @@ impl Panel for TabPanel { } state } + + fn inner_padding(&self, cx: &App) -> bool { + self.active_panel(cx) + .map_or(true, |panel| panel.inner_padding(cx)) + } } impl TabPanel { @@ -761,7 +766,7 @@ impl TabPanel { return Empty {}.into_any_element(); }; - let is_render_in_tabs = self.panels.len() > 1; + let is_render_in_tabs = self.panels.len() > 1 && self.inner_padding(cx); v_flex() .id("tab-content")