mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-02 08:20:09 +00:00
Still paint group hover handler for invisible divs
Fixes bug where tab close icon show on hover is inconsistent
This commit is contained in:
parent
bc09ce6ffc
commit
cdc227b32f
1 changed files with 21 additions and 16 deletions
|
@ -978,12 +978,31 @@ impl Interactivity {
|
||||||
f: impl FnOnce(&Style, Point<Pixels>, &mut WindowContext),
|
f: impl FnOnce(&Style, Point<Pixels>, &mut WindowContext),
|
||||||
) {
|
) {
|
||||||
let style = self.compute_style(Some(bounds), element_state, cx);
|
let style = self.compute_style(Some(bounds), element_state, cx);
|
||||||
|
let z_index = style.z_index.unwrap_or(0);
|
||||||
|
|
||||||
|
let paint_hover_group_handler = |cx: &mut WindowContext| {
|
||||||
|
let hover_group_bounds = self
|
||||||
|
.group_hover_style
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|group_hover| GroupBounds::get(&group_hover.group, cx));
|
||||||
|
|
||||||
|
if let Some(group_bounds) = hover_group_bounds {
|
||||||
|
let hovered = group_bounds.contains(&cx.mouse_position());
|
||||||
|
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
||||||
|
if phase == DispatchPhase::Capture
|
||||||
|
&& group_bounds.contains(&event.position) != hovered
|
||||||
|
{
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if style.visibility == Visibility::Hidden {
|
if style.visibility == Visibility::Hidden {
|
||||||
|
cx.with_z_index(z_index, |cx| paint_hover_group_handler(cx));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let z_index = style.z_index.unwrap_or(0);
|
|
||||||
cx.with_z_index(z_index, |cx| {
|
cx.with_z_index(z_index, |cx| {
|
||||||
style.paint(bounds, cx, |cx| {
|
style.paint(bounds, cx, |cx| {
|
||||||
cx.with_text_style(style.text_style().cloned(), |cx| {
|
cx.with_text_style(style.text_style().cloned(), |cx| {
|
||||||
|
@ -1166,21 +1185,7 @@ impl Interactivity {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let hover_group_bounds = self
|
paint_hover_group_handler(cx);
|
||||||
.group_hover_style
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|group_hover| GroupBounds::get(&group_hover.group, cx));
|
|
||||||
|
|
||||||
if let Some(group_bounds) = hover_group_bounds {
|
|
||||||
let hovered = group_bounds.contains(&cx.mouse_position());
|
|
||||||
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
|
||||||
if phase == DispatchPhase::Capture
|
|
||||||
&& group_bounds.contains(&event.position) != hovered
|
|
||||||
{
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.hover_style.is_some()
|
if self.hover_style.is_some()
|
||||||
|| self.base_style.mouse_cursor.is_some()
|
|| self.base_style.mouse_cursor.is_some()
|
||||||
|
|
Loading…
Reference in a new issue