diff --git a/native/src/element.rs b/native/src/element.rs index cb8aaf54..3bf24317 100644 --- a/native/src/element.rs +++ b/native/src/element.rs @@ -255,6 +255,14 @@ where A: Clone, Renderer: crate::Renderer, { + fn width(&self) -> Length { + self.widget.width() + } + + fn height(&self) -> Length { + self.widget.height() + } + fn layout( &self, renderer: &Renderer, @@ -320,6 +328,14 @@ impl<'a, Message, Renderer> Widget where Renderer: crate::Renderer + renderer::Debugger, { + fn width(&self) -> Length { + self.element.widget.width() + } + + fn height(&self) -> Length { + self.element.widget.height() + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget.rs b/native/src/widget.rs index 9dd48697..61b66c5b 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -69,6 +69,10 @@ pub trait Widget where Renderer: crate::Renderer, { + fn width(&self) -> Length; + + fn height(&self) -> Length; + /// Returns the [`Node`] of the [`Widget`]. /// /// This [`Node`] is used by the runtime to compute the [`Layout`] of the @@ -83,14 +87,6 @@ where limits: &layout::Limits, ) -> layout::Node; - fn width(&self) -> Length { - Length::Shrink - } - - fn height(&self) -> Length { - Length::Shrink - } - /// Draws the [`Widget`] using the associated `Renderer`. /// /// [`Widget`]: trait.Widget.html diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index f2cce3d2..81cb9310 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -119,6 +119,14 @@ where Renderer: self::Renderer, Message: Clone, { + fn width(&self) -> Length { + self.width + } + + fn height(&self) -> Length { + Length::Shrink + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 47512089..f7bda146 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -72,6 +72,10 @@ where Length::Fill } + fn height(&self) -> Length { + Length::Shrink + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index 8d98795c..87c51f48 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -118,6 +118,10 @@ where self.width } + fn height(&self) -> Length { + self.height + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 54117eb1..2f15573d 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -99,6 +99,10 @@ where self.width } + fn height(&self) -> Length { + self.height + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/image.rs b/native/src/widget/image.rs index 8420ca76..696de683 100644 --- a/native/src/widget/image.rs +++ b/native/src/widget/image.rs @@ -58,6 +58,14 @@ impl Widget for Image where Renderer: self::Renderer, { + fn width(&self) -> Length { + self.width + } + + fn height(&self) -> Length { + self.height + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index a3a091b1..3dc764fe 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -82,6 +82,10 @@ where Length::Fill } + fn height(&self) -> Length { + Length::Shrink + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index e63d8d20..33222b8a 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -120,6 +120,10 @@ where self.width } + fn height(&self) -> Length { + self.height + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index d4568412..438f04cf 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -105,6 +105,14 @@ impl<'a, Message, Renderer> Widget where Renderer: self::Renderer + column::Renderer, { + fn width(&self) -> Length { + Length::Fill + } + + fn height(&self) -> Length { + self.height + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index f91d3ac5..113cc2a4 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -86,6 +86,10 @@ where self.width } + fn height(&self) -> Length { + Length::Shrink + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs index f949b607..c4ab88d3 100644 --- a/native/src/widget/text.rs +++ b/native/src/widget/text.rs @@ -117,6 +117,10 @@ where self.width } + fn height(&self) -> Length { + self.height + } + fn layout( &self, renderer: &Renderer, diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index bb5bb523..65306504 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -100,6 +100,10 @@ where self.width } + fn height(&self) -> Length { + Length::Shrink + } + fn layout( &self, renderer: &Renderer,