Implement Widget::mouse_interaction for PaneGrid

... and fix rendering of drag interaction in `PaneGrid` by
introducing an explicit `with_translation` method to `Renderer`
and simplifying the `with_layer` and `Clip` primitive.
This commit is contained in:
Héctor Ramón Jiménez 2021-10-25 16:16:35 +07:00
parent 41394b4e90
commit 4a11cbd994
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
11 changed files with 167 additions and 66 deletions

View file

@ -1,6 +1,7 @@
use crate::container;
use crate::event::{self, Event};
use crate::layout;
use crate::mouse;
use crate::overlay;
use crate::renderer;
use crate::{
@ -249,6 +250,35 @@ where
control_status.merge(title_status)
}
pub(crate) fn mouse_interaction(
&self,
layout: Layout<'_>,
viewport: &Rectangle,
cursor_position: Point,
) -> mouse::Interaction {
let mut children = layout.children();
let padded = children.next().unwrap();
let mut children = padded.children();
let title_layout = children.next().unwrap();
let title_interaction = self.content.mouse_interaction(
title_layout,
viewport,
cursor_position,
);
if let Some(controls) = &self.controls {
let controls_layout = children.next().unwrap();
controls
.mouse_interaction(controls_layout, viewport, cursor_position)
.max(title_interaction)
} else {
title_interaction
}
}
pub(crate) fn overlay(
&mut self,
layout: Layout<'_>,