Modern iced working

This commit is contained in:
Greg Shuflin 2024-10-01 01:29:15 -07:00
parent a5bf20005e
commit bbe05f64b8
2 changed files with 38 additions and 27 deletions

View File

@ -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 {
println!("Iced");
Ok(())
//Gamarjoba::run(Settings::default())
println!("Iced");
iced::run("A counter", update, view)
}
#[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()
}
/*

View File

@ -1,37 +1,31 @@
mod iced;
use anyhow::{Result, anyhow};
use anyhow::{anyhow, 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) {
Some(s) => s,
None => return Err(anyhow!("Specify a framework to use"))
};
match framework.as_str() {
"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""#))
match framework.as_str() {
"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<()> {
println!("druid");
Ok(())
println!("druid");
Ok(())
}
fn egui_main() -> Result<()> {
println!("egui - not implemented yet");
Ok(())
println!("egui - not implemented yet");
Ok(())
}