summaryrefslogtreecommitdiffstats
path: root/examples/geometry
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-16 05:33:47 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-16 05:33:47 +0100
commitc22269bff3085012d326a0df77bf27ad5bcb41b7 (patch)
tree1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/geometry
parent0524e9b4571d264018656418f02a1f9e27e268d7 (diff)
downloadiced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip
Introduce `Program` API
Diffstat (limited to 'examples/geometry')
-rw-r--r--examples/geometry/src/main.rs58
1 files changed, 21 insertions, 37 deletions
diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs
index 1ccc4dd6..52c10c33 100644
--- a/examples/geometry/src/main.rs
+++ b/examples/geometry/src/main.rs
@@ -147,51 +147,35 @@ mod rainbow {
}
use iced::widget::{column, container, scrollable};
-use iced::{Element, Length, Sandbox, Settings};
+use iced::{Element, Length};
use rainbow::rainbow;
pub fn main() -> iced::Result {
- Example::run(Settings::default())
+ iced::run("Custom 2D Geometry - Iced", |_, _| {}, view)
}
-struct Example;
-
-impl Sandbox for Example {
- type Message = ();
-
- fn new() -> Self {
- Self
- }
-
- fn title(&self) -> String {
- String::from("Custom 2D geometry - Iced")
- }
-
- fn update(&mut self, _: ()) {}
-
- fn view(&self) -> Element<()> {
- let content = column![
- rainbow(),
- "In this example we draw a custom widget Rainbow, using \
+fn view(_state: &()) -> Element<'_, ()> {
+ let content = column![
+ rainbow(),
+ "In this example we draw a custom widget Rainbow, using \
the Mesh2D primitive. This primitive supplies a list of \
triangles, expressed as vertices and indices.",
- "Move your cursor over it, and see the center vertex \
+ "Move your cursor over it, and see the center vertex \
follow you!",
- "Every Vertex2D defines its own color. You could use the \
+ "Every Vertex2D defines its own color. You could use the \
Mesh2D primitive to render virtually any two-dimensional \
geometry for your widget.",
- ]
- .padding(20)
- .spacing(20)
- .max_width(500);
-
- let scrollable =
- scrollable(container(content).width(Length::Fill).center_x());
-
- container(scrollable)
- .width(Length::Fill)
- .height(Length::Fill)
- .center_y()
- .into()
- }
+ ]
+ .padding(20)
+ .spacing(20)
+ .max_width(500);
+
+ let scrollable =
+ scrollable(container(content).width(Length::Fill).center_x());
+
+ container(scrollable)
+ .width(Length::Fill)
+ .height(Length::Fill)
+ .center_y()
+ .into()
}