From c901f40fd6c5aa39f4dc056b2b59bc7133b287e6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 14 Apr 2020 12:11:10 +0200 Subject: Introduce `Widget::overlay` :tada: --- graphics/src/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index c9360f3a..44bacd4e 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -62,7 +62,7 @@ where fn explain( &mut self, defaults: &Defaults, - widget: &dyn Widget, + widget: &dyn Widget<'_, Message, Self>, layout: Layout<'_>, cursor_position: Point, color: Color, -- cgit From f064f0482b653a1fbee4afbddcecf91e3a399004 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 16 Apr 2020 13:22:00 +0200 Subject: Introduce `Layer` trait --- graphics/src/renderer.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'graphics/src/renderer.rs') 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 layout::Debugger for Renderer -- cgit From 33e6682882cd09dd210da123eb3b893e33bd977d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 8 Jul 2020 11:40:07 +0200 Subject: Avoid clipping antialiasing in `Renderer::overlay` --- graphics/src/renderer.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 771f436c..5ca6c057 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -67,7 +67,11 @@ where primitives: vec![ base_primitive, Primitive::Clip { - bounds: overlay_bounds, + 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), }, -- cgit From dc0e423142f053c59c326d92920e7829b6852cca Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 10 Jul 2020 02:01:30 +0200 Subject: Remove unnecessary lifetime in `Widget` trait --- graphics/src/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/renderer.rs') diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 5ca6c057..5d51e6d4 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -93,7 +93,7 @@ where fn explain( &mut self, defaults: &Defaults, - widget: &dyn Widget<'_, Message, Self>, + widget: &dyn Widget, layout: Layout<'_>, cursor_position: Point, color: Color, -- cgit