From 59b1e90661ee9e479f404bae71029db824cc7b46 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 28 Apr 2020 03:18:31 +0200 Subject: Introduce `Translate` primitive in `iced_wgpu` --- examples/geometry/src/main.rs | 108 +++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'examples/geometry/src/main.rs') diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs index 13a687ab..63e1bacd 100644 --- a/examples/geometry/src/main.rs +++ b/examples/geometry/src/main.rs @@ -12,7 +12,7 @@ mod rainbow { // implemented by `iced_wgpu` and other renderers. use iced_native::{ layout, Element, Hasher, Layout, Length, MouseCursor, Point, Size, - Widget, + Vector, Widget, }; use iced_wgpu::{ triangle::{Mesh2D, Vertex2D}, @@ -85,58 +85,60 @@ mod rainbow { let posn_l = [0.0, b.height / 2.0]; ( - Primitive::Mesh2D { - origin: Point::new(b.x, b.y), - buffers: Mesh2D { - vertices: vec![ - Vertex2D { - position: posn_center, - color: [1.0, 1.0, 1.0, 1.0], - }, - Vertex2D { - position: posn_tl, - color: color_r, - }, - Vertex2D { - position: posn_t, - color: color_o, - }, - Vertex2D { - position: posn_tr, - color: color_y, - }, - Vertex2D { - position: posn_r, - color: color_g, - }, - Vertex2D { - position: posn_br, - color: color_gb, - }, - Vertex2D { - position: posn_b, - color: color_b, - }, - Vertex2D { - position: posn_bl, - color: color_i, - }, - Vertex2D { - position: posn_l, - color: color_v, - }, - ], - indices: vec![ - 0, 1, 2, // TL - 0, 2, 3, // T - 0, 3, 4, // TR - 0, 4, 5, // R - 0, 5, 6, // BR - 0, 6, 7, // B - 0, 7, 8, // BL - 0, 8, 1, // L - ], - }, + Primitive::Translate { + translation: Vector::new(b.x, b.y), + content: Box::new(Primitive::Mesh2D { + buffers: Mesh2D { + vertices: vec![ + Vertex2D { + position: posn_center, + color: [1.0, 1.0, 1.0, 1.0], + }, + Vertex2D { + position: posn_tl, + color: color_r, + }, + Vertex2D { + position: posn_t, + color: color_o, + }, + Vertex2D { + position: posn_tr, + color: color_y, + }, + Vertex2D { + position: posn_r, + color: color_g, + }, + Vertex2D { + position: posn_br, + color: color_gb, + }, + Vertex2D { + position: posn_b, + color: color_b, + }, + Vertex2D { + position: posn_bl, + color: color_i, + }, + Vertex2D { + position: posn_l, + color: color_v, + }, + ], + indices: vec![ + 0, 1, 2, // TL + 0, 2, 3, // T + 0, 3, 4, // TR + 0, 4, 5, // R + 0, 5, 6, // BR + 0, 6, 7, // B + 0, 7, 8, // BL + 0, 8, 1, // L + ], + }, + }), }, MouseCursor::OutOfBounds, ) -- cgit From e65585ae17bf2fae1bbad1cde839d6f767a29b82 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 28 Apr 2020 04:41:09 +0200 Subject: Clip and cull `Mesh2D` primitives in `iced_wgpu` --- examples/geometry/src/main.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/geometry/src/main.rs') diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs index 63e1bacd..795cac27 100644 --- a/examples/geometry/src/main.rs +++ b/examples/geometry/src/main.rs @@ -88,6 +88,7 @@ mod rainbow { Primitive::Translate { translation: Vector::new(b.x, b.y), content: Box::new(Primitive::Mesh2D { + size: b.size(), buffers: Mesh2D { vertices: vec![ Vertex2D { -- cgit From 59403b6ca80081fa419fbef76c92397db68f1ab1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 29 Apr 2020 03:11:15 +0200 Subject: Remove `OutOfBounds` variant from `MouseCursor` --- examples/geometry/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/geometry/src/main.rs') diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs index 795cac27..2a3efd4a 100644 --- a/examples/geometry/src/main.rs +++ b/examples/geometry/src/main.rs @@ -141,7 +141,7 @@ mod rainbow { }, }), }, - MouseCursor::OutOfBounds, + MouseCursor::default(), ) } } -- cgit From 98bc8cf2a7c4944d762a0148ca9f615d6ccc0d6e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 30 Apr 2020 08:16:38 +0200 Subject: Rename `MouseCursor` to `mouse::Interaction` --- examples/geometry/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/geometry/src/main.rs') diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs index 2a3efd4a..aabe6b21 100644 --- a/examples/geometry/src/main.rs +++ b/examples/geometry/src/main.rs @@ -11,8 +11,8 @@ mod rainbow { // if you wish to, by creating your own `Renderer` trait, which could be // implemented by `iced_wgpu` and other renderers. use iced_native::{ - layout, Element, Hasher, Layout, Length, MouseCursor, Point, Size, - Vector, Widget, + layout, mouse, Element, Hasher, Layout, Length, Point, Size, Vector, + Widget, }; use iced_wgpu::{ triangle::{Mesh2D, Vertex2D}, @@ -54,7 +54,7 @@ mod rainbow { _defaults: &Defaults, layout: Layout<'_>, cursor_position: Point, - ) -> (Primitive, MouseCursor) { + ) -> (Primitive, mouse::Interaction) { let b = layout.bounds(); // R O Y G B I V @@ -141,7 +141,7 @@ mod rainbow { }, }), }, - MouseCursor::default(), + mouse::Interaction::default(), ) } } -- cgit