summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/row.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-05-28 21:52:34 +0200
committerLibravatar GitHub <noreply@github.com>2020-05-28 21:52:34 +0200
commitd3db055583f4cbef1441fd66d07da70424bd1200 (patch)
tree9f695bd26f688a5aaf3b8fa687a0e3ff096ffe11 /graphics/src/widget/row.rs
parentead4186870d1b46015986f702dd63382498060fc (diff)
parent709ed1f3f7ad8cf67a176763e394aaae4e808e93 (diff)
downloadiced-d3db055583f4cbef1441fd66d07da70424bd1200.tar.gz
iced-d3db055583f4cbef1441fd66d07da70424bd1200.tar.bz2
iced-d3db055583f4cbef1441fd66d07da70424bd1200.zip
Merge pull request #354 from hecrj/feature/glow-renderer
OpenGL renderer and backend-agnostic graphics subcrate
Diffstat (limited to 'graphics/src/widget/row.rs')
-rw-r--r--graphics/src/widget/row.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/graphics/src/widget/row.rs b/graphics/src/widget/row.rs
new file mode 100644
index 00000000..4c1dbadc
--- /dev/null
+++ b/graphics/src/widget/row.rs
@@ -0,0 +1,43 @@
+use crate::{Backend, Primitive, Renderer};
+use iced_native::mouse;
+use iced_native::row;
+use iced_native::{Element, Layout, Point};
+
+/// A container that distributes its contents horizontally.
+pub type Row<'a, Message, Backend> =
+ iced_native::Row<'a, Message, Renderer<Backend>>;
+
+impl<B> row::Renderer for Renderer<B>
+where
+ B: Backend,
+{
+ fn draw<Message>(
+ &mut self,
+ defaults: &Self::Defaults,
+ content: &[Element<'_, Message, Self>],
+ layout: Layout<'_>,
+ cursor_position: Point,
+ ) -> Self::Output {
+ let mut mouse_interaction = mouse::Interaction::default();
+
+ (
+ Primitive::Group {
+ primitives: content
+ .iter()
+ .zip(layout.children())
+ .map(|(child, layout)| {
+ let (primitive, new_mouse_interaction) =
+ child.draw(self, defaults, layout, cursor_position);
+
+ if new_mouse_interaction > mouse_interaction {
+ mouse_interaction = new_mouse_interaction;
+ }
+
+ primitive
+ })
+ .collect(),
+ },
+ mouse_interaction,
+ )
+ }
+}