summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2024-09-24 21:59:41 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-24 21:59:41 +0200
commit142aba2f172c2df2572f6f5b19cdf8b2d565905a (patch)
tree70026cbed3c35693c38d09df02813afb4125df39 /examples
parent88a2fac1f9171f162ecfe2a033cba5ae62e23231 (diff)
parent1383c6a4f700ff246148c913000e9b9368ea9afc (diff)
downloadiced-142aba2f172c2df2572f6f5b19cdf8b2d565905a.tar.gz
iced-142aba2f172c2df2572f6f5b19cdf8b2d565905a.tar.bz2
iced-142aba2f172c2df2572f6f5b19cdf8b2d565905a.zip
Merge pull request #2598 from iced-rs/fix/shrink-cross-flex-layout
Fix flex layout of `Fill` elements in a `Shrink` cross axis
Diffstat (limited to 'examples')
-rw-r--r--examples/layout/src/main.rs40
1 files changed, 37 insertions, 3 deletions
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs
index cb33369b..4280a003 100644
--- a/examples/layout/src/main.rs
+++ b/examples/layout/src/main.rs
@@ -2,12 +2,12 @@ use iced::border;
use iced::keyboard;
use iced::mouse;
use iced::widget::{
- button, canvas, center, checkbox, column, container, horizontal_space,
- pick_list, row, scrollable, text,
+ button, canvas, center, checkbox, column, container, horizontal_rule,
+ horizontal_space, pick_list, row, scrollable, text, vertical_rule,
};
use iced::{
color, Center, Element, Fill, Font, Length, Point, Rectangle, Renderer,
- Subscription, Theme,
+ Shrink, Subscription, Theme,
};
pub fn main() -> iced::Result {
@@ -147,6 +147,10 @@ impl Example {
title: "Application",
view: application,
},
+ Self {
+ title: "Quotes",
+ view: quotes,
+ },
];
fn is_first(self) -> bool {
@@ -275,6 +279,36 @@ fn application<'a>() -> Element<'a, Message> {
column![header, row![sidebar, content]].into()
}
+fn quotes<'a>() -> Element<'a, Message> {
+ fn quote<'a>(
+ content: impl Into<Element<'a, Message>>,
+ ) -> Element<'a, Message> {
+ row![vertical_rule(2), content.into()]
+ .spacing(10)
+ .height(Shrink)
+ .into()
+ }
+
+ fn reply<'a>(
+ original: impl Into<Element<'a, Message>>,
+ reply: impl Into<Element<'a, Message>>,
+ ) -> Element<'a, Message> {
+ column![quote(original), reply.into()].spacing(10).into()
+ }
+
+ column![
+ reply(
+ reply("This is the original message", "This is a reply"),
+ "This is another reply",
+ ),
+ horizontal_rule(1),
+ "A separator ↑",
+ ]
+ .width(Shrink)
+ .spacing(10)
+ .into()
+}
+
fn square<'a>(size: impl Into<Length> + Copy) -> Element<'a, Message> {
struct Square;