Iced hello world

This commit is contained in:
Greg Shuflin 2021-07-18 19:19:22 -07:00
parent 1c737a8cec
commit ba9c1e6dcc
2 changed files with 43 additions and 8 deletions

32
src/iced.rs Normal file
View File

@ -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()
}
}

View File

@ -1,12 +1,20 @@
mod iced;
fn main() -> Result<(), std::io::Error> {
let args: Vec<String> = 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");