Restrict multiple hovered regions to a single stacking context
We won't hover regions from stacking contexts that are below the one being hovered.
This commit is contained in:
parent
9099c40364
commit
5413a97c7e
3 changed files with 20 additions and 13 deletions
|
@ -28,7 +28,7 @@ pub struct Presenter {
|
|||
pub(crate) rendered_views: HashMap<usize, ElementBox>,
|
||||
parents: HashMap<usize, usize>,
|
||||
cursor_regions: Vec<CursorRegion>,
|
||||
mouse_regions: Vec<MouseRegion>,
|
||||
mouse_regions: Vec<(MouseRegion, usize)>,
|
||||
font_cache: Arc<FontCache>,
|
||||
text_layout_cache: TextLayoutCache,
|
||||
asset_cache: Arc<AssetCache>,
|
||||
|
@ -230,7 +230,7 @@ impl Presenter {
|
|||
|
||||
match event {
|
||||
Event::LeftMouseDown { position, .. } => {
|
||||
for region in self.mouse_regions.iter().rev() {
|
||||
for (region, _) in self.mouse_regions.iter().rev() {
|
||||
if region.bounds.contains_point(position) {
|
||||
invalidated_views.push(region.view_id);
|
||||
mouse_down_region = Some((region.clone(), position));
|
||||
|
@ -254,7 +254,7 @@ impl Presenter {
|
|||
}
|
||||
}
|
||||
Event::RightMouseDown { position, .. } => {
|
||||
for region in self.mouse_regions.iter().rev() {
|
||||
for (region, _) in self.mouse_regions.iter().rev() {
|
||||
if region.bounds.contains_point(position) {
|
||||
invalidated_views.push(region.view_id);
|
||||
right_mouse_down_region = Some((region.clone(), position));
|
||||
|
@ -291,9 +291,13 @@ impl Presenter {
|
|||
}
|
||||
cx.platform().set_cursor_style(style_to_assign);
|
||||
|
||||
for region in self.mouse_regions.iter().rev() {
|
||||
let mut hover_depth = None;
|
||||
for (region, depth) in self.mouse_regions.iter().rev() {
|
||||
let region_id = region.id();
|
||||
if region.bounds.contains_point(position) {
|
||||
if region.bounds.contains_point(position)
|
||||
&& hover_depth.map_or(true, |hover_depth| hover_depth == *depth)
|
||||
{
|
||||
hover_depth = Some(*depth);
|
||||
if !self.hovered_region_ids.contains(®ion_id) {
|
||||
invalidated_views.push(region.view_id);
|
||||
hovered_regions.push(region.clone());
|
||||
|
|
|
@ -210,11 +210,16 @@ impl Scene {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn mouse_regions(&self) -> Vec<MouseRegion> {
|
||||
self.layers()
|
||||
.flat_map(|layer| &layer.mouse_regions)
|
||||
.cloned()
|
||||
.collect()
|
||||
pub fn mouse_regions(&self) -> Vec<(MouseRegion, usize)> {
|
||||
let mut regions = Vec::new();
|
||||
for (stacking_depth, stacking_context) in self.stacking_contexts.iter().enumerate() {
|
||||
for layer in &stacking_context.layers {
|
||||
for mouse_region in &layer.mouse_regions {
|
||||
regions.push((mouse_region.clone(), stacking_depth));
|
||||
}
|
||||
}
|
||||
}
|
||||
regions
|
||||
}
|
||||
|
||||
pub fn push_stacking_context(&mut self, clip_bounds: Option<RectF>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue