Introduce Program API

This commit is contained in:
Héctor Ramón Jiménez 2024-03-16 05:33:47 +01:00
parent 0524e9b457
commit c22269bff3
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
43 changed files with 1141 additions and 831 deletions

View file

@ -1,21 +1,15 @@
use iced::alignment;
use iced::event::{self, Event};
use iced::executor;
use iced::widget::{button, checkbox, container, text, Column};
use iced::window;
use iced::{
Alignment, Application, Command, Element, Length, Settings, Subscription,
Theme,
};
use iced::{Alignment, Command, Element, Length, Subscription};
pub fn main() -> iced::Result {
Events::run(Settings {
window: window::Settings {
exit_on_close_request: false,
..window::Settings::default()
},
..Settings::default()
})
iced::application(Events::new, Events::update, Events::view)
.title("Events - Iced")
.subscription(Events::subscription)
.ignore_close_request()
.run()
}
#[derive(Debug, Default)]
@ -31,20 +25,11 @@ enum Message {
Exit,
}
impl Application for Events {
type Message = Message;
type Theme = Theme;
type Executor = executor::Default;
type Flags = ();
fn new(_flags: ()) -> (Events, Command<Message>) {
impl Events {
fn new() -> (Events, Command<Message>) {
(Events::default(), Command::none())
}
fn title(&self) -> String {
String::from("Events - Iced")
}
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::EventOccurred(event) if self.enabled => {