Introduce Program API
This commit is contained in:
parent
0524e9b457
commit
c22269bff3
43 changed files with 1141 additions and 831 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue