summaryrefslogtreecommitdiffstats
path: root/graphics/src/renderer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-07-16 05:00:37 +0200
committerLibravatar GitHub <noreply@github.com>2020-07-16 05:00:37 +0200
commitda5da3958e3b7fe85e371846a795c4ae05cb2df7 (patch)
treecd9f353e005ebc9c49d987125ba168a87982c629 /graphics/src/renderer.rs
parent62ec03a0afe8566a8f0b06675990a83fd65de1a9 (diff)
parent31c30fedd5e5ad74cc1f66162d7e5c0e5e3cf420 (diff)
downloadiced-da5da3958e3b7fe85e371846a795c4ae05cb2df7.tar.gz
iced-da5da3958e3b7fe85e371846a795c4ae05cb2df7.tar.bz2
iced-da5da3958e3b7fe85e371846a795c4ae05cb2df7.zip
Merge pull request #444 from hecrj/feature/overlay
Overlay support and `PickList` widget
Diffstat (limited to 'graphics/src/renderer.rs')
-rw-r--r--graphics/src/renderer.rs33
1 files changed, 32 insertions, 1 deletions
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index c9360f3a..5d51e6d4 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,35 @@ 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: Rectangle {
+ width: overlay_bounds.width + 0.5,
+ height: overlay_bounds.height + 0.5,
+ ..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>