summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-05 03:56:18 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-05 03:56:18 +0200
commita7d11944039a1b5ea5b72256e8d15367d99e6010 (patch)
tree0b90246e3bec0bb28a9a67b9c62af4bf7602cbc6 /wgpu
parent5204cc8c8bc8361a11815d7c711b7da10a6ca8e5 (diff)
downloadiced-a7d11944039a1b5ea5b72256e8d15367d99e6010.tar.gz
iced-a7d11944039a1b5ea5b72256e8d15367d99e6010.tar.bz2
iced-a7d11944039a1b5ea5b72256e8d15367d99e6010.zip
Add `Renderer` and `Primitive` concepts
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/lib.rs70
1 files changed, 56 insertions, 14 deletions
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<Message>(
+ &mut self,
+ _column: &Column<'_, Message, Self>,
+ _layout: Layout<'_>,
+ _cursor_position: Point,
+ ) -> Self::Primitive {
+ ()
+ }
+}
+
+impl row::Renderer for Renderer {
+ fn draw<Message>(
+ &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<Message>,
_layout: Layout<'_>,
_cursor_position: Point,
- ) -> MouseCursor {
- MouseCursor::OutOfBounds
+ ) -> Self::Primitive {
+ ()
}
}
@@ -120,8 +144,8 @@ impl radio::Renderer for Renderer {
_radio: &Radio<Message>,
_layout: Layout<'_>,
_cursor_position: Point,
- ) -> MouseCursor {
- MouseCursor::OutOfBounds
+ ) -> Self::Primitive {
+ ()
}
}
@@ -135,8 +159,8 @@ impl slider::Renderer for Renderer {
_slider: &Slider<Message>,
_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<Message>,
_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<Message>(
+ &mut self,
+ widget: &dyn Widget<Message, Self>,
+ layout: Layout<'_>,
+ cursor_position: Point,
+ _color: Color,
+ ) -> Self::Primitive {
+ widget.draw(self, layout, cursor_position)
+ }
}