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:
parent
41394b4e90
commit
4a11cbd994
11 changed files with 167 additions and 66 deletions
|
|
@ -175,11 +175,7 @@ impl<'a> Layer<'a> {
|
|||
});
|
||||
}
|
||||
}
|
||||
Primitive::Clip {
|
||||
bounds,
|
||||
offset,
|
||||
content,
|
||||
} => {
|
||||
Primitive::Clip { bounds, content } => {
|
||||
let layer = &mut layers[current_layer];
|
||||
let translated_bounds = *bounds + translation;
|
||||
|
||||
|
|
@ -192,8 +188,7 @@ impl<'a> Layer<'a> {
|
|||
|
||||
Self::process_primitive(
|
||||
layers,
|
||||
translation
|
||||
- Vector::new(offset.x as f32, offset.y as f32),
|
||||
translation,
|
||||
content,
|
||||
layers.len() - 1,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@ pub enum Primitive {
|
|||
Clip {
|
||||
/// The bounds of the clip
|
||||
bounds: Rectangle,
|
||||
/// The offset transformation of the clip
|
||||
offset: Vector<u32>,
|
||||
/// The content of the clip
|
||||
content: Box<Primitive>,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -51,12 +51,7 @@ where
|
|||
layout
|
||||
}
|
||||
|
||||
fn with_layer(
|
||||
&mut self,
|
||||
bounds: Rectangle,
|
||||
offset: Vector<u32>,
|
||||
f: impl FnOnce(&mut Self),
|
||||
) {
|
||||
fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)) {
|
||||
let current_primitives =
|
||||
std::mem::replace(&mut self.primitives, Vec::new());
|
||||
|
||||
|
|
@ -67,7 +62,27 @@ where
|
|||
|
||||
self.primitives.push(Primitive::Clip {
|
||||
bounds,
|
||||
offset,
|
||||
content: Box::new(Primitive::Group {
|
||||
primitives: layer_primitives,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
fn with_translation(
|
||||
&mut self,
|
||||
translation: Vector,
|
||||
f: impl FnOnce(&mut Self),
|
||||
) {
|
||||
let current_primitives =
|
||||
std::mem::replace(&mut self.primitives, Vec::new());
|
||||
|
||||
f(self);
|
||||
|
||||
let layer_primitives =
|
||||
std::mem::replace(&mut self.primitives, current_primitives);
|
||||
|
||||
self.primitives.push(Primitive::Translate {
|
||||
translation,
|
||||
content: Box::new(Primitive::Group {
|
||||
primitives: layer_primitives,
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue