diff options
author | 2024-11-24 14:00:18 +0100 | |
---|---|---|
committer | 2024-11-24 14:00:18 +0100 | |
commit | e8f8216ea1f9deef7f2d02fa2600a0b4e247f8fa (patch) | |
tree | 9a04331e34d54167cff40aab77d344f030b4d93e /examples/layout/src | |
parent | 6ccc828607b22a0583c12bad638ee2bc7e7310b8 (diff) | |
parent | a805177b250b2316c0a9b4de06a3be4556d6944a (diff) | |
download | iced-e8f8216ea1f9deef7f2d02fa2600a0b4e247f8fa.tar.gz iced-e8f8216ea1f9deef7f2d02fa2600a0b4e247f8fa.tar.bz2 iced-e8f8216ea1f9deef7f2d02fa2600a0b4e247f8fa.zip |
Merge pull request #2673 from iced-rs/feature/pin-widget
`pin` widget
Diffstat (limited to 'examples/layout/src')
-rw-r--r-- | examples/layout/src/main.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs index 4280a003..e83a1f7d 100644 --- a/examples/layout/src/main.rs +++ b/examples/layout/src/main.rs @@ -3,7 +3,8 @@ use iced::keyboard; use iced::mouse; use iced::widget::{ button, canvas, center, checkbox, column, container, horizontal_rule, - horizontal_space, pick_list, row, scrollable, text, vertical_rule, + horizontal_space, pick_list, pin, row, scrollable, stack, text, + vertical_rule, }; use iced::{ color, Center, Element, Fill, Font, Length, Point, Rectangle, Renderer, @@ -151,6 +152,10 @@ impl Example { title: "Quotes", view: quotes, }, + Self { + title: "Pinning", + view: pinning, + }, ]; fn is_first(self) -> bool { @@ -309,6 +314,23 @@ fn quotes<'a>() -> Element<'a, Message> { .into() } +fn pinning<'a>() -> Element<'a, Message> { + column![ + "The pin widget can be used to position a widget \ + at some fixed coordinates inside some other widget.", + stack![ + container(pin("• (50, 50)").x(50).y(50)) + .width(500) + .height(500) + .style(container::bordered_box), + pin("• (300, 300)").x(300).y(300), + ] + ] + .align_x(Center) + .spacing(10) + .into() +} + fn square<'a>(size: impl Into<Length> + Copy) -> Element<'a, Message> { struct Square; |