Introduce Layer trait

This commit is contained in:
Héctor Ramón Jiménez 2020-04-16 13:22:00 +02:00
parent c901f40fd6
commit f064f0482b
12 changed files with 252 additions and 54 deletions

View file

@ -1,7 +1,9 @@
use crate::{Backend, Defaults, Primitive};
use iced_native::layout::{self, Layout};
use iced_native::mouse;
use iced_native::{Background, Color, Element, Point, Widget};
use iced_native::{
Background, Color, Element, Point, Rectangle, Vector, Widget,
};
/// A backend-agnostic renderer that supports all the built-in widgets.
#[derive(Debug)]
@ -53,6 +55,31 @@ where
layout
}
fn overlay(
&mut self,
(base_primitive, base_cursor): (Primitive, mouse::Interaction),
(overlay_primitives, overlay_cursor): (Primitive, mouse::Interaction),
overlay_bounds: Rectangle,
) -> (Primitive, mouse::Interaction) {
(
Primitive::Group {
primitives: vec![
base_primitive,
Primitive::Clip {
bounds: overlay_bounds,
offset: Vector::new(0, 0),
content: Box::new(overlay_primitives),
},
],
},
if base_cursor > overlay_cursor {
base_cursor
} else {
overlay_cursor
},
)
}
}
impl<B> layout::Debugger for Renderer<B>