Use an IconButton
for the tab close button
This commit is contained in:
parent
33245d119e
commit
1361b61708
2 changed files with 8 additions and 21 deletions
|
@ -159,7 +159,6 @@ impl Icon {
|
||||||
pub struct IconElement {
|
pub struct IconElement {
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
color: IconColor,
|
color: IconColor,
|
||||||
hover_color: Option<IconColor>,
|
|
||||||
size: IconSize,
|
size: IconSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +167,6 @@ impl IconElement {
|
||||||
Self {
|
Self {
|
||||||
icon,
|
icon,
|
||||||
color: IconColor::default(),
|
color: IconColor::default(),
|
||||||
hover_color: None,
|
|
||||||
size: IconSize::default(),
|
size: IconSize::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,11 +176,6 @@ impl IconElement {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hover_color(mut self, hover_color: impl Into<Option<IconColor>>) -> Self {
|
|
||||||
self.hover_color = hover_color.into();
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn size(mut self, size: IconSize) -> Self {
|
pub fn size(mut self, size: IconSize) -> Self {
|
||||||
self.size = size;
|
self.size = size;
|
||||||
self
|
self
|
||||||
|
@ -199,9 +192,6 @@ impl IconElement {
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.path(self.icon.path())
|
.path(self.icon.path())
|
||||||
.text_color(self.color.color(cx))
|
.text_color(self.color.color(cx))
|
||||||
.when_some(self.hover_color, |this, hover_color| {
|
|
||||||
this.hover(|style| style.text_color(hover_color.color(cx)))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ use crate::{
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::{HashMap, HashSet, VecDeque};
|
use collections::{HashMap, HashSet, VecDeque};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyView, AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle,
|
AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle, Model,
|
||||||
Model, PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
|
PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use project2::{Project, ProjectEntryId, ProjectPath};
|
use project2::{Project, ProjectEntryId, ProjectPath};
|
||||||
|
@ -1366,15 +1366,12 @@ impl Pane {
|
||||||
.id(item.id())
|
.id(item.id())
|
||||||
.invisible()
|
.invisible()
|
||||||
.group_hover("", |style| style.visible())
|
.group_hover("", |style| style.visible())
|
||||||
.child(
|
.child(IconButton::<Self>::new("close_tab", Icon::Close).on_click(
|
||||||
IconElement::new(Icon::Close)
|
move |pane: &mut Self, cx| {
|
||||||
.color(IconColor::Muted)
|
pane.close_item_by_id(id, SaveIntent::Close, cx)
|
||||||
.hover_color(IconColor::Accent),
|
.detach_and_log_err(cx);
|
||||||
)
|
},
|
||||||
.on_click(move |pane: &mut Self, _, cx| {
|
))
|
||||||
pane.close_item_by_id(id, SaveIntent::Close, cx)
|
|
||||||
.detach_and_log_err(cx);
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let (text_color, tab_bg, tab_hover_bg, tab_active_bg) = match ix == self.active_item_index {
|
let (text_color, tab_bg, tab_hover_bg, tab_active_bg) = match ix == self.active_item_index {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue