mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-24 23:47:05 +00:00
Hide the toolbar if it has no visible items (#3654)
This PR makes the toolbar hide itself if it has no visible items. This removes the double border beneath the tab bar when there are no visible tools in the toolbar. Release Notes: - N/A
This commit is contained in:
parent
fd133df896
commit
c6e44683e6
1 changed files with 10 additions and 0 deletions
|
@ -55,6 +55,12 @@ pub struct Toolbar {
|
|||
}
|
||||
|
||||
impl Toolbar {
|
||||
fn has_any_visible_items(&self) -> bool {
|
||||
self.items
|
||||
.iter()
|
||||
.any(|(_item, location)| *location != ToolbarItemLocation::Hidden)
|
||||
}
|
||||
|
||||
fn left_items(&self) -> impl Iterator<Item = &dyn ToolbarItemViewHandle> {
|
||||
self.items.iter().filter_map(|(item, location)| {
|
||||
if *location == ToolbarItemLocation::PrimaryLeft {
|
||||
|
@ -90,6 +96,10 @@ impl Render for Toolbar {
|
|||
type Element = Div;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
if !self.has_any_visible_items() {
|
||||
return div();
|
||||
}
|
||||
|
||||
let secondary_item = self.secondary_items().next().map(|item| item.to_any());
|
||||
|
||||
v_stack()
|
||||
|
|
Loading…
Reference in a new issue