#gui #bindings #graphics

sys fltk-sys

Rust bindings for the FLTK GUI library

261 releases (88 stable)

new 1.3.34 Mar 19, 2023
1.3.31 Feb 16, 2023
1.3.25 Dec 24, 2022
1.3.21 Nov 24, 2022
0.1.22 Mar 31, 2020

#146 in GUI

Download history 804/week @ 2022-11-28 973/week @ 2022-12-05 1186/week @ 2022-12-12 1189/week @ 2022-12-19 693/week @ 2022-12-26 565/week @ 2023-01-02 832/week @ 2023-01-09 608/week @ 2023-01-16 1211/week @ 2023-01-23 1289/week @ 2023-01-30 1437/week @ 2023-02-06 1308/week @ 2023-02-13 2195/week @ 2023-02-20 513/week @ 2023-02-27 1232/week @ 2023-03-06 544/week @ 2023-03-13

4,777 downloads per month
Used in 48 crates (2 directly)

MIT license

10MB
236K SLoC

C++ 128K SLoC // 0.2% comments C 62K SLoC // 0.2% comments Rust 40K SLoC // 0.0% comments Objective-C++ 5.5K SLoC // 0.1% comments Shell 334 SLoC // 0.2% comments Objective-C 33 SLoC

fltk-sys

Raw bindings for FLTK. These are generated using bindgen on the cfltk headers.

Usage

[dependencies]
fltk-sys = "1.3"

Example code:

use fltk_sys::*;
use std::os::raw::*;

unsafe extern "C" fn cb(_wid: *mut button::Fl_Widget, data: *mut c_void) {
    let frame = data as *mut frame::Fl_Box;
    frame::Fl_Box_set_label(frame, "Hello World\0".as_ptr() as *const _);
}

fn main() {
    unsafe {
        fl::Fl_init_all();
        image::Fl_register_images();
        fl::Fl_lock();
        let win = window::Fl_Window_new(100, 100, 400, 300, "Window\0".as_ptr() as *const _);
        let frame = frame::Fl_Box_new(0, 0, 400, 200, std::ptr::null());
        let but = button::Fl_Button_new(160, 220, 80, 40, "Click\0".as_ptr() as *const _);
        window::Fl_Window_end(win);
        window::Fl_Window_show(win);

        button::Fl_Button_set_callback(but, Some(cb), frame as *mut _);

        fl::Fl_run();
    }
}

Dependencies

CMake > 3.14, git and a C++11 compiler. The dev dependencies are basically the same as for fltk-rs.

Why you might want to use fltk-sys directly

  • If you need an abi stable cdylib that you can call into (as a plugin system for example).
  • To create your own wrapper around certain elements if you don't need the whole fltk crate.
  • fltk-sys, although memory and thread unsafe, is panic-safe.
  • You need a no-std gui library, in such case, you can replace the std:: prefix with the libc via bindgen (requires adding libc as a dependency).
  • Wrapping a 3rd-party widget like in fltk-flow.

Dependencies