#gui #bindings #graphics

fltk

Rust bindings for the FLTK GUI library

19 releases

✓ Uses Rust 2018 edition

new 0.1.18 Mar 28, 2020
0.1.17 Mar 28, 2020

#38 in GUI

Download history 94/week @ 2020-03-16

116 downloads per month

MIT license

8MB
177K SLoC

C++ 107K SLoC // 0.2% comments C 54K SLoC // 0.2% comments Rust 10K SLoC // 0.0% comments Objective-C++ 5K SLoC // 0.1% comments Shell 270 SLoC // 0.2% comments

fltk-rs

Rust bindings for the FLTK Graphical User Interface library. Still in alpha.

The FLTK crate is a crossplatform lightweight gui library which can be statically linked to produce small, self-contained and fast gui applications.

Documentation

Usage

Just add the following to your project's Cargo.toml file:

[dependencies]
fltk = "^0.1.18"

An example hello world application:

use fltk::{app::*, window::*};

fn main() {
    let app = App::default();
    let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
    wind.show();
    app.run().unwrap();
}

Please check the examples directory for more examples. You will notice that all widgets are instantiated with a new() method, taking the x and y coordinates, as well as the width and height of the widget. Most widgets, except the TextDisplay and TextEditor, also take a label which can be left blank if needed. Another way to initialize a widget is using the builder pattern: (The following buttons are equivalent)

let but1 = Button::new(10, 10, 80, 40, "Button 1");

let but2 = Button::default()
    .with_pos(10, 10)
    .with_size(80, 40)
    .with_label("Button 2");

Dependencies

CMake and a C++ compiler need to be installed and in your PATH for a crossplatform build.

  • Windows: None.
  • MacOs: None.
  • Linux: X11 development headers need to be installed for development. For Debian-based distribution, that means running:
$ sudo apt-get install libx11-dev libxext-dev libxft-dev libxinerama-dev libxcursor-dev libxrender-dev libxfixes-dev

Building

To build, just run:

$ git clone https://github.com/MoAlyousef/fltk-rs
$ cd fltk-rs
$ cargo build

Examples

To run the examples:

$ cargo run --example editor
$ cargo run --example calculator
$ cargo run --example gallery
$ cargo run --example button
$ cargo run --example terminal
$ cargo run --example hello

alt_test

alt_test

Setting the scheme to Gtk.

alt_test

alt_test

Setting the scheme to Gtk

alt_test

Currently implemented widgets

Most common widgets are implemented:

  • Images (BMP, JPEG, GIF, PNG, SVG)
  • Button
  • RadioButton
  • ToggleButton
  • RoundButton
  • CheckButton
  • LightButton
  • RepeatButton
  • Native FileDialog
  • Frame (Fl_Box)
  • Window
  • DoubleWindow
  • MenuWindow
  • Group
  • Pack
  • Tabs
  • Scroll
  • Tile
  • TextDisplay
  • TextEditor
  • Input
  • IntInput
  • FloatInput
  • MultilineInput
  • SecretInput
  • FileInput
  • Output
  • MultilineOutput
  • MenuBar
  • MenuItem
  • Choice (dropdown list)
  • Slider
  • ValueSlider
  • Dial
  • Counter
  • Scrollbar
  • Roller
  • Adjuster
  • ValueInput
  • Browser
  • SelectBrowser
  • HoldBrowser
  • MultiBrowser

Todo

  • Complete widget set
  • Better documentation
  • Better testing

Contributions

Contributions are very welcome!

Dependencies