diff --git a/Cargo.toml b/Cargo.toml index 5bf9c83..df9b4ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" description = "A simple demonstration of the Iced GUI library." license = "MIT" -#license-file = "LICENSE.txt" repository = "no" # This application was created and tested with Rust version 1.81.0-nightly diff --git a/src/main.rs b/src/main.rs index eac61be..375c709 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use race::Race; use iced::widget::{button, column, combo_box, row, text, Column, ComboBox, Text}; use iced::{Alignment, Padding}; +use iced::{Element, Sandbox}; /// Represents the state of our application and handles /// message matching and updating the state accordingly. @@ -36,7 +37,9 @@ enum Command { Closed, } -impl State { +impl Sandbox for State { + type Message = Command; + // Constructor for the state, nothing special here. fn new() -> Self { Self { @@ -47,6 +50,10 @@ impl State { } } + fn title(&self) -> String { + String::from("Test Example") + } + // On each update, we recieve a command and update the state accordingly. fn update(&mut self, command: Command) { match command { @@ -60,7 +67,7 @@ impl State { // Called every frame to render the user interface. // Changes to the state are reflected here. - fn view(&self) -> Column { + fn view(&self) -> Element { // Our combo box let combo_box: ComboBox = combo_box::ComboBox::new( &self.races, @@ -93,14 +100,16 @@ impl State { .align_items(Alignment::Start) .spacing(10) .width(iced::Length::Fill) + .into() } } fn main() { // Iced::run is an entry point for the application. // It may fail so we match on the result. - match iced::run("Test Example", State::update, State::view) { - Ok(_) => {} - Err(error) => eprintln!("Error: {}", error), - } + // match iced::run("Test Example", State::update, State::view) { + // Ok(_) => {} + // Err(error) => eprintln!("Error: {}", error), + // } + State::run(iced::Settings::default()); }