298 releases (125 stable)

new 1.5.2 Jan 11, 2025
1.5.0 Dec 8, 2024
1.4.36 Nov 13, 2024
1.4.33 Jul 30, 2024
0.1.22 Mar 31, 2020

#1473 in GUI

Download history 3861/week @ 2024-09-26 3036/week @ 2024-10-03 3824/week @ 2024-10-10 3895/week @ 2024-10-17 6559/week @ 2024-10-24 8476/week @ 2024-10-31 6630/week @ 2024-11-07 8551/week @ 2024-11-14 10089/week @ 2024-11-21 10077/week @ 2024-11-28 9544/week @ 2024-12-05 10093/week @ 2024-12-12 6417/week @ 2024-12-19 5110/week @ 2024-12-26 6185/week @ 2025-01-02 6255/week @ 2025-01-09

25,471 downloads per month
Used in 58 crates (2 directly)

MIT license

11MB
258K SLoC

C++ 146K SLoC // 0.2% comments C 62K SLoC // 0.2% comments Rust 42K SLoC // 0.0% comments Objective-C++ 6K SLoC // 0.1% comments Shell 339 SLoC // 0.2% comments Objective-C 33 SLoC

Contains (obscure autoconf code, 64KB) cfltk/fltk/configure.ac

fltk-sys

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

Usage

[dependencies]
fltk-sys = "1.5"

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++17 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