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 --- native/src/widget.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/widget.rs') diff --git a/native/src/widget.rs b/native/src/widget.rs index 01f5c92e..0dfd5fd7 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -52,7 +52,7 @@ pub use text::Text; #[doc(no_inline)] pub use text_input::TextInput; -use crate::{Event, Hasher, Layout, Node, Point}; +use crate::{layout, Event, Hasher, Layout, Point}; /// A component that displays information and allows interaction. /// @@ -73,7 +73,7 @@ where /// [`Node`]: ../struct.Node.html /// [`Widget`]: trait.Widget.html /// [`Layout`]: ../struct.Layout.html - fn node(&self, renderer: &Renderer) -> Node; + fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> Layout; /// Draws the [`Widget`] using the associated `Renderer`. /// @@ -81,7 +81,7 @@ where fn draw( &self, renderer: &mut Renderer, - layout: Layout<'_>, + layout: &Layout, cursor_position: Point, ) -> Renderer::Output; @@ -117,7 +117,7 @@ where fn on_event( &mut self, _event: Event, - _layout: Layout<'_>, + _layout: &Layout, _cursor_position: Point, _messages: &mut Vec, _renderer: &Renderer, -- 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` --- native/src/widget.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'native/src/widget.rs') diff --git a/native/src/widget.rs b/native/src/widget.rs index 0dfd5fd7..2d6d347f 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -52,7 +52,7 @@ pub use text::Text; #[doc(no_inline)] pub use text_input::TextInput; -use crate::{layout, Event, Hasher, Layout, Point}; +use crate::{layout, Event, Hasher, Layout, Length, Point}; /// A component that displays information and allows interaction. /// @@ -73,7 +73,19 @@ where /// [`Node`]: ../struct.Node.html /// [`Widget`]: trait.Widget.html /// [`Layout`]: ../struct.Layout.html - fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> Layout; + fn layout( + &self, + renderer: &Renderer, + limits: &layout::Limits, + ) -> layout::Node; + + fn width(&self) -> Length { + Length::Shrink + } + + fn height(&self) -> Length { + Length::Shrink + } /// Draws the [`Widget`] using the associated `Renderer`. /// @@ -81,7 +93,7 @@ where fn draw( &self, renderer: &mut Renderer, - layout: &Layout, + layout: Layout<'_>, cursor_position: Point, ) -> Renderer::Output; @@ -117,7 +129,7 @@ where fn on_event( &mut self, _event: Event, - _layout: &Layout, + _layout: Layout<'_>, _cursor_position: Point, _messages: &mut Vec, _renderer: &Renderer, -- cgit From ceb02f4a36769c488c2525db2fb73f092a6c2706 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 11 Nov 2019 05:26:08 +0100 Subject: Implement `Container` widget Remove `align_self` and `justify_content` methods --- native/src/widget.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'native/src/widget.rs') diff --git a/native/src/widget.rs b/native/src/widget.rs index 2d6d347f..9010b06f 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -31,6 +31,8 @@ pub mod slider; pub mod text; pub mod text_input; +mod container; + #[doc(no_inline)] pub use button::Button; #[doc(no_inline)] @@ -38,6 +40,8 @@ pub use checkbox::Checkbox; #[doc(no_inline)] pub use column::Column; #[doc(no_inline)] +pub use container::Container; +#[doc(no_inline)] pub use image::Image; #[doc(no_inline)] pub use radio::Radio; -- cgit