mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 08:54:04 +00:00
Allow transparent divs to be considered "top layers"
This changes the meaning of `was_top_layer` so that it is checking that nothing opaque is on top of the given layer. The layer in question need not be opaque.
This commit is contained in:
parent
b88370d5ad
commit
2979eb9da9
1 changed files with 20 additions and 13 deletions
|
@ -942,16 +942,20 @@ impl<'a> WindowContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the top-most opaque layer painted over this point was part of the
|
||||
/// same layer as the given stacking order.
|
||||
/// Returns true if there is no opaque layer containing the given point
|
||||
/// on top of the given level. Layers whose level is an extension of the
|
||||
/// level are not considered to be on top of the level.
|
||||
pub fn was_top_layer(&self, point: &Point<Pixels>, level: &StackingOrder) -> bool {
|
||||
for (stack, bounds) in self.window.rendered_frame.depth_map.iter() {
|
||||
if bounds.contains(point) {
|
||||
return level.starts_with(stack) || stack.starts_with(level);
|
||||
for (opaque_level, bounds) in self.window.rendered_frame.depth_map.iter() {
|
||||
if level >= opaque_level {
|
||||
break;
|
||||
}
|
||||
|
||||
if bounds.contains(point) && !opaque_level.starts_with(level) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
true
|
||||
}
|
||||
|
||||
pub fn was_top_layer_under_active_drag(
|
||||
|
@ -959,16 +963,19 @@ impl<'a> WindowContext<'a> {
|
|||
point: &Point<Pixels>,
|
||||
level: &StackingOrder,
|
||||
) -> bool {
|
||||
for (stack, bounds) in self.window.rendered_frame.depth_map.iter() {
|
||||
if stack.starts_with(&[ACTIVE_DRAG_Z_INDEX]) {
|
||||
for (opaque_level, bounds) in self.window.rendered_frame.depth_map.iter() {
|
||||
if level >= opaque_level {
|
||||
break;
|
||||
}
|
||||
if opaque_level.starts_with(&[ACTIVE_DRAG_Z_INDEX]) {
|
||||
continue;
|
||||
}
|
||||
if bounds.contains(point) {
|
||||
return level.starts_with(stack) || stack.starts_with(level);
|
||||
|
||||
if bounds.contains(point) && !opaque_level.starts_with(level) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
true
|
||||
}
|
||||
|
||||
/// Called during painting to get the current stacking order.
|
||||
|
|
Loading…
Reference in a new issue