summaryrefslogtreecommitdiffstats
path: root/pure
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-12 18:02:29 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-12 18:02:29 +0700
commit09c96a6d8123a62411e2c461a018c3900dec71cb (patch)
treefaf12bfd5e0aea54ea180786134f55d2754f6dfd /pure
parent4c61601aa3fe7f6735e27c27d379090d777b56f7 (diff)
downloadiced-09c96a6d8123a62411e2c461a018c3900dec71cb.tar.gz
iced-09c96a6d8123a62411e2c461a018c3900dec71cb.tar.bz2
iced-09c96a6d8123a62411e2c461a018c3900dec71cb.zip
Add `max_width` to `Column` in `iced_pure`
Diffstat (limited to '')
-rw-r--r--pure/src/widget/column.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/pure/src/widget/column.rs b/pure/src/widget/column.rs
index 68d3c4b4..a9d7246e 100644
--- a/pure/src/widget/column.rs
+++ b/pure/src/widget/column.rs
@@ -10,12 +10,14 @@ use iced_native::{
};
use std::any::{self, Any};
+use std::u32;
pub struct Column<'a, Message, Renderer> {
spacing: u16,
padding: Padding,
width: Length,
height: Length,
+ max_width: u32,
align_items: Alignment,
children: Vec<Element<'a, Message, Renderer>>,
}
@@ -33,6 +35,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
padding: Padding::ZERO,
width: Length::Shrink,
height: Length::Shrink,
+ max_width: u32::MAX,
align_items: Alignment::Start,
children,
}
@@ -58,6 +61,12 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
self
}
+ /// Sets the maximum width of the [`Column`].
+ pub fn max_width(mut self, max_width: u32) -> Self {
+ self.max_width = max_width;
+ self
+ }
+
pub fn align_items(mut self, align: Alignment) -> Self {
self.align_items = align;
self
@@ -106,7 +115,10 @@ where
renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
- let limits = limits.width(self.width).height(self.height);
+ let limits = limits
+ .max_width(self.max_width)
+ .width(self.width)
+ .height(self.height);
flex::resolve(
flex::Axis::Vertical,
@@ -204,6 +216,7 @@ where
self.tag().hash(state);
self.width.hash(state);
self.height.hash(state);
+ self.max_width.hash(state);
self.align_items.hash(state);
self.spacing.hash(state);
self.padding.hash(state);