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
|
/// Returns true if there is no opaque layer containing the given point
|
||||||
/// same layer as the given stacking order.
|
/// 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 {
|
pub fn was_top_layer(&self, point: &Point<Pixels>, level: &StackingOrder) -> bool {
|
||||||
for (stack, bounds) in self.window.rendered_frame.depth_map.iter() {
|
for (opaque_level, bounds) in self.window.rendered_frame.depth_map.iter() {
|
||||||
if bounds.contains(point) {
|
if level >= opaque_level {
|
||||||
return level.starts_with(stack) || stack.starts_with(level);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if bounds.contains(point) && !opaque_level.starts_with(level) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
true
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn was_top_layer_under_active_drag(
|
pub fn was_top_layer_under_active_drag(
|
||||||
|
@ -959,16 +963,19 @@ impl<'a> WindowContext<'a> {
|
||||||
point: &Point<Pixels>,
|
point: &Point<Pixels>,
|
||||||
level: &StackingOrder,
|
level: &StackingOrder,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
for (stack, bounds) in self.window.rendered_frame.depth_map.iter() {
|
for (opaque_level, bounds) in self.window.rendered_frame.depth_map.iter() {
|
||||||
if stack.starts_with(&[ACTIVE_DRAG_Z_INDEX]) {
|
if level >= opaque_level {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if opaque_level.starts_with(&[ACTIVE_DRAG_Z_INDEX]) {
|
||||||
continue;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
true
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called during painting to get the current stacking order.
|
/// Called during painting to get the current stacking order.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue