Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fltk-rs/flemish
An elmish architecture for fltk-rs
https://github.com/fltk-rs/flemish
Last synced: about 2 months ago
JSON representation
An elmish architecture for fltk-rs
- Host: GitHub
- URL: https://github.com/fltk-rs/flemish
- Owner: fltk-rs
- License: mit
- Created: 2021-08-10T23:09:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-26T20:35:42.000Z (5 months ago)
- Last Synced: 2024-10-13T16:51:57.004Z (3 months ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flemish
An elmish architecture for fltk-rs, inspired by Iced.
## Usage
Add flemish to your dependencies:
```toml
[dependencies]
flemish = "0.5"
```A usage example:
```rust
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();
}
}
```