From a7d11944039a1b5ea5b72256e8d15367d99e6010 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 5 Oct 2019 03:56:18 +0200 Subject: Add `Renderer` and `Primitive` concepts --- wgpu/src/lib.rs | 70 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'wgpu/src/lib.rs') diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 1e11749b..28964858 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -1,7 +1,7 @@ use iced_native::{ - button, checkbox, image, radio, renderer::Debugger, slider, text, Button, - Checkbox, Color, Image, Layout, MouseCursor, Node, Point, Radio, Slider, - Style, Text, + button, checkbox, column, image, radio, renderer::Debugger, row, slider, + text, Button, Checkbox, Color, Column, Image, Layout, Node, Point, Radio, + Row, Slider, Style, Text, Widget, }; use raw_window_handle::HasRawWindowHandle; @@ -87,12 +87,36 @@ impl Renderer { } } +impl column::Renderer for Renderer { + fn draw( + &mut self, + _column: &Column<'_, Message, Self>, + _layout: Layout<'_>, + _cursor_position: Point, + ) -> Self::Primitive { + () + } +} + +impl row::Renderer for Renderer { + fn draw( + &mut self, + _column: &Row<'_, Message, Self>, + _layout: Layout<'_>, + _cursor_position: Point, + ) -> Self::Primitive { + () + } +} + impl text::Renderer for Renderer { fn node(&self, _text: &Text) -> Node { Node::new(Style::default()) } - fn draw(&mut self, _text: &Text, _layout: Layout<'_>) {} + fn draw(&mut self, _text: &Text, _layout: Layout<'_>) -> Self::Primitive { + () + } } impl checkbox::Renderer for Renderer { @@ -105,8 +129,8 @@ impl checkbox::Renderer for Renderer { _checkbox: &Checkbox, _layout: Layout<'_>, _cursor_position: Point, - ) -> MouseCursor { - MouseCursor::OutOfBounds + ) -> Self::Primitive { + () } } @@ -120,8 +144,8 @@ impl radio::Renderer for Renderer { _radio: &Radio, _layout: Layout<'_>, _cursor_position: Point, - ) -> MouseCursor { - MouseCursor::OutOfBounds + ) -> Self::Primitive { + () } } @@ -135,8 +159,8 @@ impl slider::Renderer for Renderer { _slider: &Slider, _layout: Layout<'_>, _cursor_position: Point, - ) -> MouseCursor { - MouseCursor::OutOfBounds + ) -> Self::Primitive { + () } } @@ -145,7 +169,13 @@ impl image::Renderer<&str> for Renderer { Node::new(Style::default()) } - fn draw(&mut self, _checkbox: &Image<&str>, _layout: Layout<'_>) {} + fn draw( + &mut self, + _checkbox: &Image<&str>, + _layout: Layout<'_>, + ) -> Self::Primitive { + () + } } impl button::Renderer for Renderer { @@ -158,11 +188,23 @@ impl button::Renderer for Renderer { _button: &Button, _layout: Layout<'_>, _cursor_position: Point, - ) -> MouseCursor { - MouseCursor::OutOfBounds + ) -> Self::Primitive { + () } } +impl iced_native::Renderer for Renderer { + type Primitive = (); +} + impl Debugger for Renderer { - fn explain(&mut self, _layout: &Layout<'_>, _color: Color) {} + fn explain( + &mut self, + widget: &dyn Widget, + layout: Layout<'_>, + cursor_position: Point, + _color: Color, + ) -> Self::Primitive { + widget.draw(self, layout, cursor_position) + } } -- cgit