pane: Add settings to hide the tab bar buttons (#23752)
This PR adds the `show_tab_bar_buttons` under `tab_bar` that allows hiding the "New", "Split Pane", and "Zoom" buttons to the left of the pane tab bar. Release Notes: - Added a new `show_tab_bar_buttons` setting, under `tab_bar`, that enables hiding the pane tab bar buttons.
This commit is contained in:
parent
7a6223e71b
commit
5331418f3a
4 changed files with 36 additions and 9 deletions
|
@ -592,7 +592,9 @@
|
|||
// Whether or not to show the tab bar in the editor
|
||||
"show": true,
|
||||
// Whether or not to show the navigation history buttons.
|
||||
"show_nav_history_buttons": true
|
||||
"show_nav_history_buttons": true,
|
||||
/// Whether or not to show the tab bar buttons.
|
||||
"show_tab_bar_buttons": true
|
||||
},
|
||||
// Settings related to the editor's tabs
|
||||
"tabs": {
|
||||
|
|
|
@ -304,6 +304,7 @@ pub struct Pane {
|
|||
&mut Context<Pane>,
|
||||
) -> (Option<AnyElement>, Option<AnyElement>),
|
||||
>,
|
||||
show_tab_bar_buttons: bool,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
tab_bar_scroll_handle: ScrollHandle,
|
||||
/// Is None if navigation buttons are permanently turned off (and should not react to setting changes).
|
||||
|
@ -509,6 +510,7 @@ impl Pane {
|
|||
.into();
|
||||
(None, right_children)
|
||||
}),
|
||||
show_tab_bar_buttons: TabBarSettings::get_global(cx).show_tab_bar_buttons,
|
||||
display_nav_history_buttons: Some(
|
||||
TabBarSettings::get_global(cx).show_nav_history_buttons,
|
||||
),
|
||||
|
@ -659,9 +661,13 @@ impl Pane {
|
|||
}
|
||||
|
||||
fn settings_changed(&mut self, cx: &mut Context<Self>) {
|
||||
let tab_bar_settings = TabBarSettings::get_global(cx);
|
||||
|
||||
if let Some(display_nav_history_buttons) = self.display_nav_history_buttons.as_mut() {
|
||||
*display_nav_history_buttons = TabBarSettings::get_global(cx).show_nav_history_buttons;
|
||||
*display_nav_history_buttons = tab_bar_settings.show_nav_history_buttons;
|
||||
}
|
||||
self.show_tab_bar_buttons = tab_bar_settings.show_tab_bar_buttons;
|
||||
|
||||
if !PreviewTabsSettings::get_global(cx).enabled {
|
||||
self.preview_item_id = None;
|
||||
}
|
||||
|
@ -2581,12 +2587,15 @@ impl Pane {
|
|||
},
|
||||
)
|
||||
.map(|tab_bar| {
|
||||
let render_tab_buttons = self.render_tab_bar_buttons.clone();
|
||||
let (left_children, right_children) = render_tab_buttons(self, window, cx);
|
||||
|
||||
tab_bar
|
||||
.start_children(left_children)
|
||||
.end_children(right_children)
|
||||
if self.show_tab_bar_buttons {
|
||||
let render_tab_buttons = self.render_tab_bar_buttons.clone();
|
||||
let (left_children, right_children) = render_tab_buttons(self, window, cx);
|
||||
tab_bar
|
||||
.start_children(left_children)
|
||||
.end_children(right_children)
|
||||
} else {
|
||||
tab_bar
|
||||
}
|
||||
})
|
||||
.children(pinned_tabs.len().ne(&0).then(|| {
|
||||
h_flex()
|
||||
|
|
|
@ -147,6 +147,7 @@ pub struct WorkspaceSettingsContent {
|
|||
pub struct TabBarSettings {
|
||||
pub show: bool,
|
||||
pub show_nav_history_buttons: bool,
|
||||
pub show_tab_bar_buttons: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||
|
@ -159,6 +160,10 @@ pub struct TabBarSettingsContent {
|
|||
///
|
||||
/// Default: true
|
||||
pub show_nav_history_buttons: Option<bool>,
|
||||
/// Whether or not to show the tab bar buttons.
|
||||
///
|
||||
/// Default: true
|
||||
pub show_tab_bar_buttons: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||
|
|
|
@ -714,7 +714,8 @@ List of `string` values
|
|||
```json
|
||||
"tab_bar": {
|
||||
"show": true,
|
||||
"show_nav_history_buttons": true
|
||||
"show_nav_history_buttons": true,
|
||||
"show_tab_bar_buttons": true
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -738,6 +739,16 @@ List of `string` values
|
|||
|
||||
`boolean` values
|
||||
|
||||
### Tab Bar Buttons
|
||||
|
||||
- Description: Whether or not to show the tab bar buttons.
|
||||
- Setting: `show_tab_bar_buttons`
|
||||
- Default: `true`
|
||||
|
||||
**Options**
|
||||
|
||||
`boolean` values
|
||||
|
||||
## Editor Tabs
|
||||
|
||||
- Description: Configuration for the editor tabs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue