From 5be1d545d0baa09b82fe380d9246f66474cce302 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 22 Nov 2024 04:06:52 +0100 Subject: Implement `pin` widget --- examples/layout/src/main.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'examples/layout') diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs index 4280a003..d71cbcbc 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)").width(Fill).height(Fill).x(50).y(50)) + .width(500) + .height(500) + .style(container::bordered_box), + pin("• (300, 300)").width(Fill).height(Fill).x(300).y(300), + ] + ] + .align_x(Center) + .spacing(10) + .into() +} + fn square<'a>(size: impl Into + Copy) -> Element<'a, Message> { struct Square; -- cgit