summaryrefslogtreecommitdiffstats
path: root/examples/custom_widget
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/custom_widget
parent0524e9b4571d264018656418f02a1f9e27e268d7 (diff)
downloadiced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip
Introduce `Program` API
Diffstat (limited to 'examples/custom_widget')
-rw-r--r--examples/custom_widget/src/main.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index 305ef7dd..aa49ebd0 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -83,10 +83,10 @@ mod circle {
use circle::circle;
use iced::widget::{column, container, slider, text};
-use iced::{Alignment, Element, Length, Sandbox, Settings};
+use iced::{Alignment, Element, Length};
pub fn main() -> iced::Result {
- Example::run(Settings::default())
+ iced::run("Custom Widget - Iced", Example::update, Example::view)
}
struct Example {
@@ -98,17 +98,11 @@ enum Message {
RadiusChanged(f32),
}
-impl Sandbox for Example {
- type Message = Message;
-
+impl Example {
fn new() -> Self {
Example { radius: 50.0 }
}
- fn title(&self) -> String {
- String::from("Custom widget - Iced")
- }
-
fn update(&mut self, message: Message) {
match message {
Message::RadiusChanged(radius) => {
@@ -136,3 +130,9 @@ impl Sandbox for Example {
.into()
}
}
+
+impl Default for Example {
+ fn default() -> Self {
+ Self::new()
+ }
+}