Crates.io | flemish |
lib.rs | flemish |
version | 0.5.1 |
source | src |
created_at | 2021-08-10 23:12:49.470357 |
updated_at | 2024-05-12 19:56:52.488144 |
description | An Elmish architecture for fltk-rs |
homepage | |
repository | https://github.com/fltk-rs/flemish |
max_upload_size | |
id | 434498 |
size | 381,690 |
An elmish architecture for fltk-rs, inspired by Iced.
Add flemish to your dependencies:
[dependencies]
flemish = "0.5"
A usage example:
use flemish::{
button::Button, color_themes, frame::Frame, group::Flex, prelude::*, OnEvent, Sandbox, Settings,
};
pub fn main() {
Counter::new().run(Settings {
size: (300, 100),
resizable: true,
color_map: Some(color_themes::BLACK_THEME),
..Default::default()
})
}
#[derive(Default)]
struct Counter {
value: i32,
}
#[derive(Debug, Clone, Copy)]
enum Message {
IncrementPressed,
DecrementPressed,
}
impl Sandbox for Counter {
type Message = Message;
fn new() -> Self {
Self::default()
}
fn title(&self) -> String {
String::from("Counter - fltk-rs")
}
fn update(&mut self, message: Message) {
match message {
Message::IncrementPressed => {
self.value += 1;
}
Message::DecrementPressed => {
self.value -= 1;
}
}
}
fn view(&mut self) {
let col = Flex::default_fill().column();
Button::default()
.with_label("Increment")
.on_event(|_| Message::IncrementPressed);
Frame::default().with_label(&self.value.to_string());
Button::default()
.with_label("Decrement")
.on_event(|_| Message::DecrementPressed);
col.end();
}
}
To run the examples:
cargo run --example flcalculator
cargo run --example fldialect
cargo run --example flnetport
cargo run --example flpicture
...