mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 03:59:55 +00:00
Render close icons on all tabs when tab bar is hovered
This commit is contained in:
parent
cab577406d
commit
b5c76ccc95
1 changed files with 34 additions and 33 deletions
|
@ -185,13 +185,13 @@ impl Pane {
|
|||
theme.workspace.tab.label.text.font_size,
|
||||
);
|
||||
|
||||
let mut row = Flex::row();
|
||||
for (ix, item) in self.items.iter().enumerate() {
|
||||
let is_active = ix == self.active_item;
|
||||
enum Tabs {}
|
||||
let tabs = MouseEventHandler::new::<Tabs, _, _, _>(0, cx, |mouse_state, cx| {
|
||||
let mut row = Flex::row();
|
||||
for (ix, item) in self.items.iter().enumerate() {
|
||||
let is_active = ix == self.active_item;
|
||||
|
||||
enum Tab {}
|
||||
row.add_child(
|
||||
MouseEventHandler::new::<Tab, _, _, _>(item.id(), cx, |mouse_state, cx| {
|
||||
row.add_child({
|
||||
let mut title = item.title(cx);
|
||||
if title.len() > MAX_TAB_TITLE_LEN {
|
||||
let mut truncated_len = MAX_TAB_TITLE_LEN;
|
||||
|
@ -276,7 +276,7 @@ impl Pane {
|
|||
)
|
||||
.with_child(
|
||||
Align::new(
|
||||
ConstrainedBox::new(if is_active || mouse_state.hovered {
|
||||
ConstrainedBox::new(if mouse_state.hovered {
|
||||
let item_id = item.id();
|
||||
enum TabCloseButton {}
|
||||
let icon = Svg::new("icons/x.svg");
|
||||
|
@ -316,36 +316,37 @@ impl Pane {
|
|||
})
|
||||
.boxed()
|
||||
})
|
||||
.boxed(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure there's always a minimum amount of space after the last tab,
|
||||
// so that the tab's border doesn't abut the window's border.
|
||||
let mut border = Border::bottom(1.0, Color::default());
|
||||
border.color = theme.workspace.tab.container.border.color;
|
||||
// Ensure there's always a minimum amount of space after the last tab,
|
||||
// so that the tab's border doesn't abut the window's border.
|
||||
let mut border = Border::bottom(1.0, Color::default());
|
||||
border.color = theme.workspace.tab.container.border.color;
|
||||
|
||||
row.add_child(
|
||||
ConstrainedBox::new(
|
||||
Container::new(Empty::new().boxed())
|
||||
.with_border(border)
|
||||
.boxed(),
|
||||
)
|
||||
.with_min_width(20.)
|
||||
.named("fixed-filler"),
|
||||
);
|
||||
row.add_child(
|
||||
ConstrainedBox::new(
|
||||
Container::new(Empty::new().boxed())
|
||||
.with_border(border)
|
||||
.boxed(),
|
||||
)
|
||||
.with_min_width(20.)
|
||||
.named("fixed-filler"),
|
||||
);
|
||||
|
||||
row.add_child(
|
||||
Expanded::new(
|
||||
0.0,
|
||||
Container::new(Empty::new().boxed())
|
||||
.with_border(border)
|
||||
.boxed(),
|
||||
)
|
||||
.named("filler"),
|
||||
);
|
||||
row.add_child(
|
||||
Expanded::new(
|
||||
0.0,
|
||||
Container::new(Empty::new().boxed())
|
||||
.with_border(border)
|
||||
.boxed(),
|
||||
)
|
||||
.named("filler"),
|
||||
);
|
||||
|
||||
ConstrainedBox::new(row.boxed())
|
||||
row.boxed()
|
||||
});
|
||||
|
||||
ConstrainedBox::new(tabs.boxed())
|
||||
.with_height(line_height + 16.)
|
||||
.named("tabs")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue