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,10 +1,10 @@
use iced::widget::{
column, combo_box, container, scrollable, text, vertical_space,
};
use iced::{Alignment, Element, Length, Sandbox, Settings};
use iced::{Alignment, Element, Length};
pub fn main() -> iced::Result {
Example::run(Settings::default())
iced::run("Combo Box - Iced", Example::update, Example::view)
}
struct Example {
@ -20,9 +20,7 @@ enum Message {
Closed,
}
impl Sandbox for Example {
type Message = Message;
impl Example {
fn new() -> Self {
Self {
languages: combo_box::State::new(Language::ALL.to_vec()),
@ -31,10 +29,6 @@ impl Sandbox for Example {
}
}
fn title(&self) -> String {
String::from("Combo box - Iced")
}
fn update(&mut self, message: Message) {
match message {
Message::Selected(language) => {
@ -83,6 +77,12 @@ impl Sandbox for Example {
}
}
impl Default for Example {
fn default() -> Self {
Example::new()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Language {
Danish,