Expand description
§Flemish
An elmish architecture for fltk-rs, inspired by Iced.
§Usage
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();
}
}
§Examples
To run the examples:
cargo run --example flcalculator
cargo run --example fldialect
cargo run --example flnetport
cargo run --example flpicture
...
§FlCalculator
§FlDialect
§FlNetPort
§FlPicture
Modules§
- Application related methods and functions
- Browser widgets
- Button widgets
- Dialog widgets
- Drawing primitives
- Fltk defined enums: Color, Font,
CallbackTrigger
etc - Documentation for the examples
- Basic fltk box/frame widget
- Group widgets
- Image types supported by fltk
- Input widgets
- mod macros;
- Menu widgets
- Miscellaneous widgets not fitting a certain group
- Output widgets
- All fltk widget traits and flt error types
- Printing related functions
- Widget surface to image functions
- Table widgets
- Text display widgets
- Tree widgets
- General utility functions
- Valuator widgets
- Basic empty widget
- Window widgets
Macros§
- Defines a set of convenience functions for constructing and anchoring custom widgets. Usage: fltk::widget_extends!(CustomWidget, BaseWidget, member); It basically implements Deref and DerefMut on the custom widget, and adds the aforementioned methods. This means you can call widget methods directly, for e.x.
custom_widget.set_color(enums::Color::Red)
. For your custom widget to be treated as a widget it would need dereferencing:group.add(&*custom_widget);
Structs§
- Color map struct. (index, r, g, b)
- A theme is just a Vec of colormaps
- A widget scheme sets the style of drawing a widget without interfering with coloring
- A widget theme is a scheme + a set of default colors
Enums§
- Lists supported schemes
- Lists supported themes