Begin new GUI with Iced
This commit is contained in:
parent
5e8888e56b
commit
6c1dbeb009
1940
Cargo.lock
generated
1940
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,9 @@ edition = "2018"
|
||||
[[bin]]
|
||||
name = "dust"
|
||||
|
||||
[[bin]]
|
||||
name = "gui"
|
||||
|
||||
[lib]
|
||||
name = "dust_lib"
|
||||
path = "src/lib.rs"
|
||||
@ -19,7 +22,6 @@ path = "src/lib.rs"
|
||||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
chrono = "0.4.26"
|
||||
eframe = "0.22.0"
|
||||
trash = "3.0.3"
|
||||
rayon = "1.7.0"
|
||||
serde = { version = "1.0.171", features = ["derive"] }
|
||||
@ -36,3 +38,4 @@ serde_json = "1.0.104"
|
||||
egui_extras = "0.22.0"
|
||||
rustyline = { version = "12.0.0", features = ["with-file-history", "derive"] }
|
||||
ansi_term = "0.12.1"
|
||||
iced = "0.10.0"
|
||||
|
50
src/bin/gui.rs
Normal file
50
src/bin/gui.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use iced::widget::{button, column, text};
|
||||
use iced::{Alignment, Element, Sandbox, Settings};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
Counter::run(Settings::default())
|
||||
}
|
||||
|
||||
struct Counter {
|
||||
value: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum Message {
|
||||
IncrementPressed,
|
||||
DecrementPressed,
|
||||
}
|
||||
|
||||
impl Sandbox for Counter {
|
||||
type Message = Message;
|
||||
|
||||
fn new() -> Self {
|
||||
Self { value: 0 }
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
String::from("Counter - Iced")
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::IncrementPressed => {
|
||||
self.value += 1;
|
||||
}
|
||||
Message::DecrementPressed => {
|
||||
self.value -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
column![
|
||||
button("Increment").on_press(Message::IncrementPressed),
|
||||
text(self.value).size(50),
|
||||
button("Decrement").on_press(Message::DecrementPressed)
|
||||
]
|
||||
.padding(20)
|
||||
.align_items(Alignment::Center)
|
||||
.into()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user