From 2303111e09d806ef2a652bddc2b73be6dccf6ae2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 10 Nov 2019 01:55:32 +0100 Subject: Draft new layout API --- wgpu/src/renderer/widget/checkbox.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'wgpu/src/renderer/widget/checkbox.rs') diff --git a/wgpu/src/renderer/widget/checkbox.rs b/wgpu/src/renderer/widget/checkbox.rs index 1594c769..de921e6b 100644 --- a/wgpu/src/renderer/widget/checkbox.rs +++ b/wgpu/src/renderer/widget/checkbox.rs @@ -1,31 +1,30 @@ use crate::{Primitive, Renderer}; use iced_native::{ - checkbox, text, text::HorizontalAlignment, text::VerticalAlignment, Align, - Background, Checkbox, Column, Layout, Length, MouseCursor, Node, - Point, Rectangle, Row, Text, Widget, + checkbox, layout, text, text::HorizontalAlignment, text::VerticalAlignment, + Background, Checkbox, Layout, MouseCursor, Point, Rectangle, Text, }; const SIZE: f32 = 28.0; impl checkbox::Renderer for Renderer { - fn node(&self, checkbox: &Checkbox) -> Node { - Row::<(), Self>::new() - .width(Length::Fill) - .spacing(15) - .align_items(Align::Center) - .push( - Column::new() - .width(Length::Units(SIZE as u16)) - .height(Length::Units(SIZE as u16)), - ) - .push(Text::new(&checkbox.label)) - .node(self) + fn layout( + &self, + checkbox: &Checkbox, + limits: &layout::Limits, + ) -> Layout { + // TODO + Layout::new(Rectangle { + x: 0.0, + y: 0.0, + width: 0.0, + height: 0.0, + }) } fn draw( &mut self, checkbox: &Checkbox, - layout: Layout<'_>, + layout: &Layout, cursor_position: Point, ) -> Self::Output { let bounds = layout.bounds(); -- cgit From 0240c3981b716c82ecb3364945815335b420a63e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 10 Nov 2019 06:05:20 +0100 Subject: Draft custom layout engine based on `druid` --- wgpu/src/renderer/widget/checkbox.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'wgpu/src/renderer/widget/checkbox.rs') diff --git a/wgpu/src/renderer/widget/checkbox.rs b/wgpu/src/renderer/widget/checkbox.rs index de921e6b..c2d7911c 100644 --- a/wgpu/src/renderer/widget/checkbox.rs +++ b/wgpu/src/renderer/widget/checkbox.rs @@ -1,7 +1,8 @@ use crate::{Primitive, Renderer}; use iced_native::{ checkbox, layout, text, text::HorizontalAlignment, text::VerticalAlignment, - Background, Checkbox, Layout, MouseCursor, Point, Rectangle, Text, + Align, Background, Checkbox, Column, Layout, Length, MouseCursor, Point, + Rectangle, Row, Text, Widget, }; const SIZE: f32 = 28.0; @@ -11,20 +12,23 @@ impl checkbox::Renderer for Renderer { &self, checkbox: &Checkbox, limits: &layout::Limits, - ) -> Layout { - // TODO - Layout::new(Rectangle { - x: 0.0, - y: 0.0, - width: 0.0, - height: 0.0, - }) + ) -> layout::Node { + Row::<(), Self>::new() + .spacing(15) + .align_items(Align::Center) + .push( + Column::new() + .width(Length::Units(SIZE as u16)) + .height(Length::Units(SIZE as u16)), + ) + .push(Text::new(&checkbox.label)) + .layout(self, limits) } fn draw( &mut self, checkbox: &Checkbox, - layout: &Layout, + layout: Layout<'_>, cursor_position: Point, ) -> Self::Output { let bounds = layout.bounds(); -- cgit