summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-07 07:24:34 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-07 07:24:34 +0100
commitaa4b5bb6b962b48715023e3ce567d1a18473bffa (patch)
tree5dcb839dac56c81a9b9b618db86f67f3e72af9d3 /core
parentd3900e067361c82fd857fc92b81284146140bc3b (diff)
parentdf68cca0c9dda051ae979ccc2f5ca8d37c3e3cb5 (diff)
downloadiced-aa4b5bb6b962b48715023e3ce567d1a18473bffa.tar.gz
iced-aa4b5bb6b962b48715023e3ce567d1a18473bffa.tar.bz2
iced-aa4b5bb6b962b48715023e3ce567d1a18473bffa.zip
Merge branch 'master' into feature/software-renderer
Diffstat (limited to 'core')
-rw-r--r--core/Cargo.toml2
-rw-r--r--core/src/alignment.rs3
-rw-r--r--core/src/layout/flex.rs67
-rw-r--r--core/src/layout/node.rs6
-rw-r--r--core/src/padding.rs10
5 files changed, 15 insertions, 73 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 9edc20f6..dac31828 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "iced_core"
-version = "0.8.0"
+version = "0.8.1"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
description = "The essential concepts of Iced"
diff --git a/core/src/alignment.rs b/core/src/alignment.rs
index 73f41d3f..51b7fca9 100644
--- a/core/src/alignment.rs
+++ b/core/src/alignment.rs
@@ -11,9 +11,6 @@ pub enum Alignment {
/// Align at the end of the axis.
End,
-
- /// Fill the entire axis.
- Fill,
}
impl From<Horizontal> for Alignment {
diff --git a/core/src/layout/flex.rs b/core/src/layout/flex.rs
index 5d70c2fc..8b967849 100644
--- a/core/src/layout/flex.rs
+++ b/core/src/layout/flex.rs
@@ -81,32 +81,6 @@ where
let mut nodes: Vec<Node> = Vec::with_capacity(items.len());
nodes.resize(items.len(), Node::default());
- if align_items == Alignment::Fill {
- let mut fill_cross = axis.cross(limits.min());
-
- items.iter().for_each(|child| {
- let cross_fill_factor = match axis {
- Axis::Horizontal => child.as_widget().height(),
- Axis::Vertical => child.as_widget().width(),
- }
- .fill_factor();
-
- if cross_fill_factor == 0 {
- let (max_width, max_height) = axis.pack(available, max_cross);
-
- let child_limits =
- Limits::new(Size::ZERO, Size::new(max_width, max_height));
-
- let layout = child.as_widget().layout(renderer, &child_limits);
- let size = layout.size();
-
- fill_cross = fill_cross.max(axis.cross(size));
- }
- });
-
- cross = fill_cross;
- }
-
for (i, child) in items.iter().enumerate() {
let fill_factor = match axis {
Axis::Horizontal => child.as_widget().width(),
@@ -115,31 +89,16 @@ where
.fill_factor();
if fill_factor == 0 {
- let (min_width, min_height) = if align_items == Alignment::Fill {
- axis.pack(0.0, cross)
- } else {
- axis.pack(0.0, 0.0)
- };
+ let (max_width, max_height) = axis.pack(available, max_cross);
- let (max_width, max_height) = if align_items == Alignment::Fill {
- axis.pack(available, cross)
- } else {
- axis.pack(available, max_cross)
- };
-
- let child_limits = Limits::new(
- Size::new(min_width, min_height),
- Size::new(max_width, max_height),
- );
+ let child_limits =
+ Limits::new(Size::ZERO, Size::new(max_width, max_height));
let layout = child.as_widget().layout(renderer, &child_limits);
let size = layout.size();
available -= axis.main(size);
-
- if align_items != Alignment::Fill {
- cross = cross.max(axis.cross(size));
- }
+ cross = cross.max(axis.cross(size));
nodes[i] = layout;
} else {
@@ -164,17 +123,10 @@ where
max_main
};
- let (min_width, min_height) = if align_items == Alignment::Fill {
- axis.pack(min_main, cross)
- } else {
- axis.pack(min_main, axis.cross(limits.min()))
- };
+ let (min_width, min_height) =
+ axis.pack(min_main, axis.cross(limits.min()));
- let (max_width, max_height) = if align_items == Alignment::Fill {
- axis.pack(max_main, cross)
- } else {
- axis.pack(max_main, max_cross)
- };
+ let (max_width, max_height) = axis.pack(max_main, max_cross);
let child_limits = Limits::new(
Size::new(min_width, min_height),
@@ -182,10 +134,7 @@ where
);
let layout = child.as_widget().layout(renderer, &child_limits);
-
- if align_items != Alignment::Fill {
- cross = cross.max(axis.cross(layout.size()));
- }
+ cross = cross.max(axis.cross(layout.size()));
nodes[i] = layout;
}
diff --git a/core/src/layout/node.rs b/core/src/layout/node.rs
index e0c7dcb2..2b44a7d5 100644
--- a/core/src/layout/node.rs
+++ b/core/src/layout/node.rs
@@ -56,9 +56,6 @@ impl Node {
Alignment::End => {
self.bounds.x += space.width - self.bounds.width;
}
- Alignment::Fill => {
- self.bounds.width = space.width;
- }
}
match vertical_alignment {
@@ -69,9 +66,6 @@ impl Node {
Alignment::End => {
self.bounds.y += space.height - self.bounds.height;
}
- Alignment::Fill => {
- self.bounds.height = space.height;
- }
}
}
diff --git a/core/src/padding.rs b/core/src/padding.rs
index 752b2b86..0b1bba13 100644
--- a/core/src/padding.rs
+++ b/core/src/padding.rs
@@ -77,12 +77,14 @@ impl Padding {
/// Fits the [`Padding`] between the provided `inner` and `outer` [`Size`].
pub fn fit(self, inner: Size, outer: Size) -> Self {
let available = (outer - inner).max(Size::ZERO);
+ let new_top = self.top.min(available.height);
+ let new_left = self.left.min(available.width);
Padding {
- top: self.top.min(available.height / 2.0),
- right: self.right.min(available.width / 2.0),
- bottom: self.bottom.min(available.height / 2.0),
- left: self.left.min(available.width / 2.0),
+ top: new_top,
+ bottom: self.bottom.min(available.height - new_top),
+ left: new_left,
+ right: self.right.min(available.width - new_left),
}
}
}