summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-21 13:53:02 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-21 13:53:02 +0100
commit428509c84a142a653be3ec4bbff0c23c466c44fa (patch)
tree3e58bd880f10a5afb5b9b0b7bea8c9b26855eab2 /native/src
parent65eb218d3d7ba52b2869a586a1480eeb3c8f84e4 (diff)
parent5adefdf6613bfe0738b573eab1d280fa041f5417 (diff)
downloadiced-428509c84a142a653be3ec4bbff0c23c466c44fa.tar.gz
iced-428509c84a142a653be3ec4bbff0c23c466c44fa.tar.bz2
iced-428509c84a142a653be3ec4bbff0c23c466c44fa.zip
Merge branch 'master' into improvement/docs
Diffstat (limited to 'native/src')
-rw-r--r--native/src/element.rs16
-rw-r--r--native/src/widget.rs12
-rw-r--r--native/src/widget/button.rs8
-rw-r--r--native/src/widget/checkbox.rs4
-rw-r--r--native/src/widget/column.rs4
-rw-r--r--native/src/widget/container.rs4
-rw-r--r--native/src/widget/image.rs8
-rw-r--r--native/src/widget/radio.rs4
-rw-r--r--native/src/widget/row.rs4
-rw-r--r--native/src/widget/scrollable.rs8
-rw-r--r--native/src/widget/slider.rs4
-rw-r--r--native/src/widget/text.rs4
-rw-r--r--native/src/widget/text_input.rs4
13 files changed, 76 insertions, 8 deletions
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<Message, Renderer>
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<Message, Renderer>
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<Message, Renderer> Widget<Message, Renderer> 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<Message, Renderer>
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,