summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-11-22 04:06:52 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-11-22 04:06:52 +0100
commit5be1d545d0baa09b82fe380d9246f66474cce302 (patch)
tree3493b8fecf17740ad67cc9d5fe6f9f9073206098 /examples
parent6ccc828607b22a0583c12bad638ee2bc7e7310b8 (diff)
downloadiced-5be1d545d0baa09b82fe380d9246f66474cce302.tar.gz
iced-5be1d545d0baa09b82fe380d9246f66474cce302.tar.bz2
iced-5be1d545d0baa09b82fe380d9246f66474cce302.zip
Implement `pin` widget
Diffstat (limited to 'examples')
-rw-r--r--examples/layout/src/main.rs24
1 files changed, 23 insertions, 1 deletions
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<Length> + Copy) -> Element<'a, Message> {
struct Square;