summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-16 13:22:00 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-07-08 10:41:16 +0200
commitf064f0482b653a1fbee4afbddcecf91e3a399004 (patch)
tree2a468e4dc80be13cbf0ae7dd703607010e16697c /graphics
parentc901f40fd6c5aa39f4dc056b2b59bc7133b287e6 (diff)
downloadiced-f064f0482b653a1fbee4afbddcecf91e3a399004.tar.gz
iced-f064f0482b653a1fbee4afbddcecf91e3a399004.tar.bz2
iced-f064f0482b653a1fbee4afbddcecf91e3a399004.zip
Introduce `Layer` trait
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/renderer.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index 44bacd4e..771f436c 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -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>