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