Introduce Program API
This commit is contained in:
parent
0524e9b457
commit
c22269bff3
43 changed files with 1141 additions and 831 deletions
|
|
@ -1,6 +1,5 @@
|
|||
use iced::executor;
|
||||
use iced::widget::{column, container, row, slider, text};
|
||||
use iced::{Application, Command, Element, Length, Settings, Theme};
|
||||
use iced::{Element, Length};
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
@ -12,51 +11,28 @@ use circular::Circular;
|
|||
use linear::Linear;
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
LoadingSpinners::run(Settings {
|
||||
antialiasing: true,
|
||||
..Default::default()
|
||||
})
|
||||
iced::sandbox(LoadingSpinners::update, LoadingSpinners::view)
|
||||
.title("Loading Spinners - Iced")
|
||||
.antialiased()
|
||||
.run()
|
||||
}
|
||||
|
||||
struct LoadingSpinners {
|
||||
cycle_duration: f32,
|
||||
}
|
||||
|
||||
impl Default for LoadingSpinners {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
cycle_duration: 2.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum Message {
|
||||
CycleDurationChanged(f32),
|
||||
}
|
||||
|
||||
impl Application for LoadingSpinners {
|
||||
type Message = Message;
|
||||
type Flags = ();
|
||||
type Executor = executor::Default;
|
||||
type Theme = Theme;
|
||||
|
||||
fn new(_flags: Self::Flags) -> (Self, Command<Message>) {
|
||||
(Self::default(), Command::none())
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
String::from("Loading Spinners - Iced")
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Message) -> Command<Message> {
|
||||
impl LoadingSpinners {
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::CycleDurationChanged(duration) => {
|
||||
self.cycle_duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
Command::none()
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
|
|
@ -115,3 +91,11 @@ impl Application for LoadingSpinners {
|
|||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LoadingSpinners {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
cycle_duration: 2.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue