Modern iced working
This commit is contained in:
parent
a5bf20005e
commit
bbe05f64b8
25
src/iced.rs
25
src/iced.rs
@ -1,9 +1,26 @@
|
|||||||
//use iced::{Application, Command, executor, Clipboard, Element, Text, Settings};
|
use iced::{
|
||||||
|
widget::{button, text},
|
||||||
|
Element,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn iced_main() -> iced::Result {
|
pub fn iced_main() -> iced::Result {
|
||||||
println!("Iced");
|
println!("Iced");
|
||||||
Ok(())
|
iced::run("A counter", update, view)
|
||||||
//Gamarjoba::run(Settings::default())
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum Message {
|
||||||
|
Increment,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(counter: &mut u64, message: Message) {
|
||||||
|
match message {
|
||||||
|
Message::Increment => *counter += 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(counter: &u64) -> Element<Message> {
|
||||||
|
button(text(counter)).on_press(Message::Increment).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
40
src/main.rs
40
src/main.rs
@ -1,37 +1,31 @@
|
|||||||
mod iced;
|
mod iced;
|
||||||
|
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{anyhow, Result};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let framework = match args.get(1) {
|
||||||
|
Some(s) => s,
|
||||||
|
None => return Err(anyhow!("Specify a framework to use")),
|
||||||
|
};
|
||||||
|
|
||||||
let framework = match args.get(1) {
|
match framework.as_str() {
|
||||||
Some(s) => s,
|
"iced" => iced::iced_main().map_err(|err| anyhow!(err)),
|
||||||
None => return Err(anyhow!("Specify a framework to use"))
|
"druid" => druid_main(),
|
||||||
};
|
"egui" => egui_main(),
|
||||||
|
other => Err(anyhow!(
|
||||||
match framework.as_str() {
|
r#"You specified {other}, allowed values: "iced", "egui""#
|
||||||
"iced" => {
|
)),
|
||||||
iced::iced_main().map_err(|err| anyhow!(err))
|
|
||||||
},
|
|
||||||
"druid" => druid_main(),
|
|
||||||
"egui" => egui_main(),
|
|
||||||
other => {
|
|
||||||
Err(anyhow!(r#"You specified {other}, allowed values: "iced", "egui""#))
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn druid_main() -> Result<()> {
|
fn druid_main() -> Result<()> {
|
||||||
println!("druid");
|
println!("druid");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn egui_main() -> Result<()> {
|
fn egui_main() -> Result<()> {
|
||||||
println!("egui - not implemented yet");
|
println!("egui - not implemented yet");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user