From ba9c1e6dcc8983e3fb015875fd3337c44c381a5a Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 18 Jul 2021 19:19:22 -0700 Subject: [PATCH] Iced hello world --- src/iced.rs | 32 ++++++++++++++++++++++++++++++++ src/main.rs | 19 +++++++++++-------- 2 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 src/iced.rs diff --git a/src/iced.rs b/src/iced.rs new file mode 100644 index 0000000..a77ef54 --- /dev/null +++ b/src/iced.rs @@ -0,0 +1,32 @@ +use iced::{Application, Command, executor, Clipboard, Element, Text, Settings}; + +pub fn iced_main() -> iced::Result { + println!("Iced"); + Gamarjoba::run(Settings::default()) +} + +struct Gamarjoba; + + +impl Application for Gamarjoba { + type Executor = executor::Default; + type Message = (); + type Flags = (); + + fn new(_flags: (),) -> (Self, Command<()>) { + (Gamarjoba, Command::none()) + } + + fn title(&self) -> String { + "YOLO SWAGG 関ヶ原の乱 ჩემი სიტყვებში".to_owned() + } + + fn update(&mut self, _message: (), _clipboard: &mut Clipboard) -> Command<()> { + Command::none() + } + + fn view(&mut self) -> Element<()> { + Text::new("Gamarjoba, munde!").into() + } + +} diff --git a/src/main.rs b/src/main.rs index a053a25..8d38dff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,20 @@ +mod iced; + fn main() -> Result<(), std::io::Error> { let args: Vec = std::env::args().collect(); let framework = args.get(1).expect("Specify a GUI framework to run"); match framework.as_str() { - "iced" => iced_main(), - "druid" => druid_main(), - "egui" => egui_main(), + "iced" => { + iced::iced_main(); + }, + "druid" => { + druid_main(); + }, + "egui" => { + egui_main(); + }, x => { println!(r#"You specified {}, allowed values: "iced", "druid", "egui""#, x); } @@ -15,11 +23,6 @@ fn main() -> Result<(), std::io::Error> { } -fn iced_main() { - println!("Iced"); - -} - fn druid_main() { println!("druid");