Rust bindings for the FLTK GUI library.

Overview

fltk-rs

Documentation Crates.io License Build

Rust bindings for the FLTK Graphical User Interface library.

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

Resources:

Why choose FLTK?

  • Lightweight. Small binary, around 1mb after stripping. Small memory footprint.
  • Speed. Fast to install, fast to build, fast at startup and fast at runtime.
  • Single executable. No DLLs to deploy.
  • Supports old architectures.
  • FLTK's permissive license which allows static linking for closed-source applications.
  • Themeability (4 supported schemes: Base, GTK, Plastic and Gleam), and additional theming using fltk-theme.
  • Provides around 80 customizable widgets.
  • Has inbuilt image support.

Here is a list of software using FLTK. For software using fltk-rs, check here.

  • Link to the official FLTK repository.
  • Link to the official documentation.

Usage

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

[dependencies]
fltk = "^1.3"

To use the latest changes in the repo:

[dependencies]
fltk = { version = "^1.3", git = "https://github.com/fltk-rs/fltk-rs" }

To use the bundled libs (available for x64 windows (msvc & gnu (msys2-mingw)), x64 linux & macos):

[dependencies]
fltk = { version = "^1.3", features = ["fltk-bundled"] }

The library is automatically built and statically linked to your binary.

An example hello world application:

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

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

Another example showing the basic callback functionality:

use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};

fn main() {
    let app = app::App::default();
    let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
    let mut frame = Frame::new(0, 0, 400, 200, "");
    let mut but = Button::new(160, 210, 80, 40, "Click me!");
    wind.end();
    wind.show();
    but.set_callback(move |_| frame.set_label("Hello World!")); // the closure capture is mutable borrow to our button
    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, the width and height of the widget, as well as 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)

use fltk::{button::Button, prelude::*};
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");

An example of a counter showing use of the builder pattern:

use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};
fn main() {
    let app = app::App::default();
    let mut wind = Window::default()
        .with_size(160, 200)
        .center_screen()
        .with_label("Counter");
    let mut frame = Frame::default()
        .with_size(100, 40)
        .center_of(&wind)
        .with_label("0");
    let mut but_inc = Button::default()
        .size_of(&frame)
        .above_of(&frame, 0)
        .with_label("+");
    let mut but_dec = Button::default()
        .size_of(&frame)
        .below_of(&frame, 0)
        .with_label("-");
    wind.make_resizable(true);
    wind.end();
    wind.show();
    /* Event handling */
    app.run().unwrap();
}

Alternatively, you can use Pack, Flex (for flexbox layouts) or Grid:

use fltk::{app, button::Button, frame::Frame, group::Flex, prelude::*, window::Window};
fn main() {
    let app = app::App::default();
    let mut wind = Window::default().with_size(160, 200).with_label("Counter");
    let mut flex = Flex::default().with_size(120, 140).center_of_parent().column();
    let mut but_inc = Button::default().with_label("+");
    let mut frame = Frame::default().with_label("0");
    let mut but_dec = Button::default().with_label("-");
    flex.end();
    wind.end();
    wind.show();
    app.run().unwrap();
}

Events

Events can be handled using the set_callback method (as above) or the available fltk::app::set_callback() free function, which will handle the default trigger of each widget(like clicks for buttons):

    /* previous hello world code */
    but.set_callback(move |_| frame.set_label("Hello World!"));
    another_but.set_callback(|this_button| this_button.set_label("Works"));
    app.run().unwrap();

Another way is to use message passing:

    /* previous counter code */
    let (s, r) = app::channel::<Message>();

    but_inc.emit(s, Message::Increment);
    but_dec.emit(s, Message::Decrement);
    
    while app.wait() {
        let label: i32 = frame.label().parse().unwrap();
        if let Some(msg) = r.recv() {
            match msg {
                Message::Increment => frame.set_label(&(label + 1).to_string()),
                Message::Decrement => frame.set_label(&(label - 1).to_string()),
            }
        }
    }

For the remainder of the code, check the full example here.

For custom event handling, the handle() method can be used:

    some_widget.handle(move |widget, ev: Event| {
        match ev {
            Event::Push => {
                println!("Pushed!");
                true
            },
            /* other events to be handled */
            _ => false,
        }
    });

Handled or ignored events using the handle method should return true, unhandled events should return false. More examples are available in the fltk/examples directory.

For an alternative event handling mechanism using on_<event> methods, check the fltk-evented crate.

Theming

FLTK offers 4 application schemes:

  • Base
  • Gtk
  • Gleam
  • Plastic

(Additional theming can be found in the fltk-theme crate)

These can be set using the App::with_scheme() method.

let app = app::App::default().with_scheme(app::Scheme::Gleam);

Themes of individual widgets can be optionally modified using the provided methods in the WidgetExt trait, such as set_color(), set_label_font(), set_frame() etc:

    some_button.set_color(Color::Light1); // You can use one of the provided colors in the fltk enums
    some_button.set_color(Color::from_rgb(255, 0, 0)); // Or you can specify a color by rgb or hex/u32 value
    some_button.set_color(Color::from_u32(0xffebee));
    some_button.set_frame(FrameType::RoundUpBox);
    some_button.set_font(Font::TimesItalic);

For default application colors, fltk-rs provides app::background(), app::background2() and app::foreground(). You can also specify the default application selection/inactive colors, font, label size, frame type, scrollbar size, menu line-spacing. Additionally the fltk-theme crate offers some other predefined color maps (dark theme, tan etc) and widget themes which can be loaded into your application.

Dependencies

Rust (version > 1.45), CMake (version > 3.11), Git and a C++11 compiler need to be installed and in your PATH for a cross-platform build from source. Ninja is recommended, but not required. This crate also offers a bundled form of fltk on selected x86_64 platforms (Windows (msvc and gnu), MacOS, Linux), this can be enabled using the fltk-bundled feature flag as mentioned in the usage section (this requires curl and tar to download and unpack the bundled libraries).

  • Windows:
    • MSVC: Windows SDK
    • Gnu: No dependencies
  • MacOS: No dependencies.
  • Linux/BSD: X11 and OpenGL development headers need to be installed for development. The libraries themselves are normally available on linux/bsd distros with a graphical user interface.

For Debian-based GUI distributions, that means running:

$ sudo apt-get install libx11-dev libxext-dev libxft-dev libxinerama-dev libxcursor-dev libxrender-dev libxfixes-dev libpango1.0-dev libgl1-mesa-dev libglu1-mesa-dev

For RHEL-based GUI distributions, that means running:

$ sudo yum groupinstall "X Software Development" && yum install pango-devel libXinerama-devel

For Arch-based GUI distributions, that means running:

$ sudo pacman -S libx11 libxext libxft libxinerama libxcursor libxrender libxfixes pango cairo libgl mesa --needed

For Alpine linux:

$ apk add pango-dev fontconfig-dev libxinerama-dev libxfixes-dev libxcursor-dev mesa-gl

For NixOS (Linux distribution) this nix-shell environment can be used:

$ nix-shell --packages rustc cmake git gcc xorg.libXext xorg.libXft xorg.libXinerama xorg.libXcursor xorg.libXrender xorg.libXfixes libcerf pango cairo libGL mesa pkg-config

Features

The following are the features offered by the crate:

  • use-ninja: Uses the ninja build system if available for a faster build, especially on Windows.
  • no-pango: Build without pango support on Linux/BSD, if rtl/cjk font support is not needed.
  • fltk-bundled: Support for bundled versions of cfltk and fltk on selected platforms (requires curl and tar)
  • enable-glwindow: Support for drawing using OpenGL functions.
  • system-libpng: Uses the system libpng
  • system-libjpeg: Uses the system libjpeg
  • system-zlib: Uses the system zlib
  • use-wayland: Uses FLTK's wayland backend. Requires libwayland-dev, wayland-protocols, libdbus-1-dev, libxkbcommon-dev, libgtk-3-dev (optional, for the GTK-style titlebar), in place of the X11 development packages. Sample CI.

FAQ

please check the FAQ page for frequently asked questions, encountered issues, guides on deployment, and contribution.

Building

To build, just run:

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

Examples

To run the examples:

$ cargo run --example editor
$ cargo run --example calculator
$ cargo run --example calculator2
$ cargo run --example terminal
$ cargo run --example counter
$ cargo run --example hello
$ cargo run --example hello_button
$ cargo run --example fb
$ cargo run --example pong
$ cargo run --example custom_widgets
$ cargo run --example custom_dial
...

Using custom theming and also FLTK provided default schemes like Gtk:

Different frame types which can be used with many different widgets such as Frame, Button widgets, In/Output widgets...etc.

More interesting examples can be found in the fltk-rs-demos repo. Also a nice implementation of the 7guis tasks can be found here. Various advanced examples can also be found here.

Currently implemented types:

Image types:

  • SharedImage
  • BmpImage
  • JpegImage
  • GifImage
  • PngImage
  • SvgImage
  • Pixmap
  • RgbImage
  • XpmImage
  • XbmImage
  • PnmImage
  • TiledImage

Widgets:

  • Buttons
    • Button
    • RadioButton
    • ToggleButton
    • RoundButton
    • CheckButton
    • LightButton
    • RepeatButton
    • RadioLightButton
    • RadioRoundButton
  • Dialogs
    • Native FileDialog
    • FileChooser
    • HelpDialog
    • Message dialog
    • Alert dialog
    • Password dialog
    • Choice dialog
    • Input dialog
    • ColorChooser dialog
  • Frame (Fl_Box)
  • Windows
    • Window
    • SingleWindow (single buffered)
    • DoubleWindow (double buffered)
    • MenuWindow
    • OverlayWindow
    • GlWindow (requires the "enable-glwindow" flag)
    • Experimental GlWidgetWindow (requires the "enable-glwindow" flag)
  • Groups
    • Group
    • Pack (Horizontal and Vertical)
    • Tabs
    • Scroll
    • Tile
    • Wizard
    • ColorChooser
    • Flex (Column and Row)
    • Grid
  • Text display widgets
    • TextDisplay
    • TextEditor
    • SimpleTerminal
  • Input widgets
    • Input
    • IntInput
    • FloatInput
    • MultilineInput
    • SecretInput
    • FileInput
  • Output widgets
    • Output
    • MultilineOutput
  • Menu widgets
    • MenuBar
    • MenuItem
    • Choice (dropdown list)
    • SysMenuBar (MacOS menu bar which appears at the top of the screen)
  • Valuator widgets
    • Slider
    • NiceSlider
    • ValueSlider
    • Dial
    • LineDial
    • Counter
    • Scrollbar
    • Roller
    • Adjuster
    • ValueInput
    • ValueOutput
    • FillSlider
    • FillDial
    • HorSlider (Horizontal slider)
    • HorFillSlider
    • HorNiceSlider
    • HorValueSlider
  • Browsing widgets
    • Browser
    • SelectBrowser
    • HoldBrowser
    • MultiBrowser
    • FileBrowser
    • CheckBrowser
  • Miscelaneous widgets
    • Spinner
    • Clock (Round and Square)
    • Chart (several chart types are available)
    • Progress (progress bar)
    • Tooltip
    • InputChoice
    • HelpView
  • Table widgets
  • Trees
    • Tree
    • TreeItem

Drawing primitives

(In the draw module)

Surface types:

  • Printer.
  • ImageSurface.
  • SvgFileSurface.

Tutorials

More videos in the playlist here. Some of the demo projects can be found here.

Comments
  • [BUG] Application UI Freezes depending on which Monitor app is launched from

    [BUG] Application UI Freezes depending on which Monitor app is launched from

    Describe the bug

    Simple application with buttons seems to "lock up" when pressing buttons. That is the buttons appearance freezes. Either the button seems to not register the click at all, or it registers the down press but not the up press. The behavior seems to occur %40-%50 of the time the app is run, and sometimes the buttons work as expected. Not receiving any error messages, and the entire app process doesn't seem to freeze (can still drag, resize, and minimize the window), but can no longer interact with the UI.

    Thought it might have been something with my system so I gave my computer a restart but the issue still persists.

    EDIT: Resizing the window seems to cause the button to unfreeze and respond as expected.

    OS: Win 10

    Expected behavior

    Expect button to react normally to clicks.

    The buttons in the below code are not laid out exactly the same as the one's in the screenshots, but they produce the same behavior.

    //fltk = { version = "^1.0.18"}
    use fltk::{app, button::Button, group::*, enums::*, prelude::*, window::Window};
    use std::thread;
    
    fn main(){
        let app = app::App::default();
        let mut wind = Window::default().with_size(500, 200).with_label("Counter");
        wind.make_resizable(true);
        let dummy_button = Button::new(100,100,100,100, "dummy");
        let dummy_button = Button::new(200,100,100,100, "dummy");
        wind.end();
        wind.show();
        app.run().unwrap();
    }
    

    Buttons not reacting to any clicks: failure_1 Button stuck in "down" state: failure_2

    opened by wyhinton 46
  • Cannot Install on Macbook pro m1

    Cannot Install on Macbook pro m1

    So I have a macbook pro m1 and i try to install fltk-rs and the error i am getting is ` Compiling fltk v0.15.6 error: failed to add native library /Users/namorahimi/Documents/Visual Studio Projects/guessing_game/target/debug/build/fltk-sys-790e153c70300d52/out/build/libcfltk.a: file too small to be an archive

    error: aborting due to previous error

    error: could not compile fltk-sys

    To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... error: build failed namorahimi@Namos-MacBook-Pro guessing_game % `

    Does anybody have any idea ?

    opened by ghost 37
  • [BUG] Build failed

    [BUG] Build failed

    I cannot compile even the simplest Hello World code. Imported the dependencies as follow

    [dependencies]
    fltk = "^0.11"
    

    However, the program did not compile.

    • OS:Windows 10 x64
    • Build log:
           Fresh cc v1.0.66
           Fresh unicode-xid v0.2.1
           Fresh lazy_static v1.4.0
           Fresh cmake v0.1.45
           Fresh proc-macro2 v1.0.24
           Fresh libc v0.2.81
           Fresh quote v1.0.7
       Compiling fltk-sys v0.11.5
           Fresh bitflags v1.2.1
         Running `C:\Users\fflea\CLionProjects\VNMapGUI\target\debug\build\fltk-sys-252927e00f15bbd1\build-script-build`
           Fresh syn v1.0.54
           Fresh fltk-derive v0.11.5
    [fltk-sys 0.11.5] cargo:rerun-if-changed=build.rs
    [fltk-sys 0.11.5] cargo:rerun-if-env-changed=CC
    [fltk-sys 0.11.5] cargo:rerun-if-env-changed=CXX
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/CMakeLists.txt
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_widget.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_group.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_input.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_output.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_window.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_button.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_box.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_menu.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_dialog.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_valuator.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_browser.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_misc.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_text.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_image.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_draw.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_table.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_surface.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/include/cfl_printer.h
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_global.hpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_new.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_widget.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_group.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_window.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_button.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_box.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_menu.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_dialog.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_valuator.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_browser.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_misc.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_text.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_image.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_input.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_output.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_draw.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_table.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_tree.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_surface.cpp
    [fltk-sys 0.11.5] cargo:rerun-if-changed=cfltk/src/cfl_printer.cpp
    [fltk-sys 0.11.5] fatal: not a git repository (or any of the parent directories): .git
    [fltk-sys 0.11.5] error: patch failed: CMake/export.cmake:33
    [fltk-sys 0.11.5] error: CMake/export.cmake: patch does not apply
    [fltk-sys 0.11.5] error: patch failed: CMake/options.cmake:115
    [fltk-sys 0.11.5] error: CMake/options.cmake: patch does not apply
    [fltk-sys 0.11.5] error: VERSION: No such file or directory
    [fltk-sys 0.11.5] error: patch failed: src/CMakeLists.txt:300
    [fltk-sys 0.11.5] error: src/CMakeLists.txt: patch does not apply
    [fltk-sys 0.11.5] error: patch failed: src/Fl_lock.cxx:418
    [fltk-sys 0.11.5] error: src/Fl_lock.cxx: patch does not apply
    [fltk-sys 0.11.5] error: patch failed: src/Fl_win32.cxx:586
    [fltk-sys 0.11.5] error: src/Fl_win32.cxx: patch does not apply
    [fltk-sys 0.11.5] error: patch failed: src/config_lib.h:78
    [fltk-sys 0.11.5] error: src/config_lib.h: patch does not apply
    [fltk-sys 0.11.5] error: patch failed: src/drivers/Android/Fl_Android_System_Driver.H:25
    [fltk-sys 0.11.5] error: src/drivers/Android/Fl_Android_System_Driver.H: patch does not apply
    [fltk-sys 0.11.5] error: patch failed: src/drivers/Android/Fl_Android_System_Driver.cxx:24
    [fltk-sys 0.11.5] error: src/drivers/Android/Fl_Android_System_Driver.cxx: patch does not apply
    [fltk-sys 0.11.5] running: "cmake" "C:\\Users\\fflea\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\fltk-sys-0.11.5\\cfltk" "-G" "Visual Studio 16 2019" "-Thost=x64" "-Ax64" "-DOPTION_USE_SYSTEM_LIBPNG=OFF" "-DOPTION_USE_SYSTE
    M_LIBJPEG=OFF" "-DOPTION_USE_SYSTEM_ZLIB=OFF" "-DCFLTK_LINK_IMAGES=ON" "-DOpenGL_GL_PREFERENCE=GLVND" "-DOPTION_USE_GL=OFF" "-DCFLTK_USE_OPENGL=OFF" "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "-DFLTK_BUILD_EXAMPLES=OFF" "-DFLTK_BUILD_TEST
    =OFF" "-DFLTK_BUILD_FLUID=OFF" "-DOPTION_USE_THREADS=ON" "-DOPTION_LARGE_FILE=ON" "-DOPTION_BUILD_HTML_DOCUMENTATION=OFF" "-DOPTION_BUILD_PDF_DOCUMENTATION=OFF" "-DCMAKE_INSTALL_PREFIX=C:\\Users\\fflea\\CLionProjects\\VNMapGUI\\targ
    et\\debug\\build\\fltk-sys-29626eefcff0b61e\\out" "-DCMAKE_C_FLAGS= -nologo -MD -Brepro" "-DCMAKE_C_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMA
    KE_ASM_FLAGS= -nologo -MD -Brepro" "-DCMAKE_ASM_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_BUILD_TYPE=Release"
    [fltk-sys 0.11.5] CMake Error: Could not create named generator Visual Studio 16 2019
    [fltk-sys 0.11.5]
    [fltk-sys 0.11.5] Generators
    [fltk-sys 0.11.5] * Unix Makefiles               = Generates standard UNIX makefiles.
    [fltk-sys 0.11.5]   Ninja                        = Generates build.ninja files.
    [fltk-sys 0.11.5]   Ninja Multi-Config           = Generates build-<Config>.ninja files.
    [fltk-sys 0.11.5]   CodeBlocks - Ninja           = Generates CodeBlocks project files.
    [fltk-sys 0.11.5]   CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
    [fltk-sys 0.11.5]   CodeLite - Ninja             = Generates CodeLite project files.
    [fltk-sys 0.11.5]   CodeLite - Unix Makefiles    = Generates CodeLite project files.
    [fltk-sys 0.11.5]   Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
    [fltk-sys 0.11.5]   Sublime Text 2 - Unix Makefiles
    [fltk-sys 0.11.5]                                = Generates Sublime Text 2 project files.
    [fltk-sys 0.11.5]   Kate - Ninja                 = Generates Kate project files.
    [fltk-sys 0.11.5]   Kate - Unix Makefiles        = Generates Kate project files.
    [fltk-sys 0.11.5]   Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
    [fltk-sys 0.11.5]   Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
    [fltk-sys 0.11.5]
    [fltk-sys 0.11.5] thread 'main' panicked at '
    [fltk-sys 0.11.5] command did not execute successfully, got: exit code: 1
    [fltk-sys 0.11.5]
    [fltk-sys 0.11.5] build script failed, must exit now', C:\Users\fflea\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.45\src\lib.rs:894:5
    [fltk-sys 0.11.5] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    error: failed to run custom build command for `fltk-sys v0.11.5`
    
    Caused by:
      process didn't exit successfully: `C:\Users\fflea\CLionProjects\VNMapGUI\target\debug\build\fltk-sys-252927e00f15bbd1\build-script-build` (exit code: 101)
      --- stdout
      cargo:rerun-if-changed=build.rs
      cargo:rerun-if-env-changed=CC
      cargo:rerun-if-env-changed=CXX
      cargo:rerun-if-changed=cfltk/CMakeLists.txt
      cargo:rerun-if-changed=cfltk/include/cfl.h
      cargo:rerun-if-changed=cfltk/include/cfl_widget.h
      cargo:rerun-if-changed=cfltk/include/cfl_group.h
      cargo:rerun-if-changed=cfltk/include/cfl_input.h
      cargo:rerun-if-changed=cfltk/include/cfl_output.h
      cargo:rerun-if-changed=cfltk/include/cfl_window.h
      cargo:rerun-if-changed=cfltk/include/cfl_button.h
      cargo:rerun-if-changed=cfltk/include/cfl_box.h
      cargo:rerun-if-changed=cfltk/include/cfl_menu.h
      cargo:rerun-if-changed=cfltk/include/cfl_dialog.h
      cargo:rerun-if-changed=cfltk/include/cfl_valuator.h
      cargo:rerun-if-changed=cfltk/include/cfl_browser.h
      cargo:rerun-if-changed=cfltk/include/cfl_misc.h
      cargo:rerun-if-changed=cfltk/include/cfl_text.h
      cargo:rerun-if-changed=cfltk/include/cfl_image.h
      cargo:rerun-if-changed=cfltk/include/cfl_draw.h
      cargo:rerun-if-changed=cfltk/include/cfl_table.h
      cargo:rerun-if-changed=cfltk/include/cfl_surface.h
      cargo:rerun-if-changed=cfltk/include/cfl_printer.h
      cargo:rerun-if-changed=cfltk/src/cfl_global.hpp
      cargo:rerun-if-changed=cfltk/src/cfl_new.cpp
      cargo:rerun-if-changed=cfltk/src/cfl.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_widget.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_group.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_window.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_button.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_box.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_menu.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_dialog.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_valuator.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_browser.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_misc.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_text.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_image.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_input.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_output.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_draw.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_table.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_tree.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_surface.cpp
      cargo:rerun-if-changed=cfltk/src/cfl_printer.cpp
      running: "cmake" "C:\\Users\\fflea\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\fltk-sys-0.11.5\\cfltk" "-G" "Visual Studio 16 2019" "-Thost=x64" "-Ax64" "-DOPTION_USE_SYSTEM_LIBPNG=OFF" "-DOPTION_USE_SYSTEM_LIBJPEG=OFF" "
    -DOPTION_USE_SYSTEM_ZLIB=OFF" "-DCFLTK_LINK_IMAGES=ON" "-DOpenGL_GL_PREFERENCE=GLVND" "-DOPTION_USE_GL=OFF" "-DCFLTK_USE_OPENGL=OFF" "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "-DFLTK_BUILD_EXAMPLES=OFF" "-DFLTK_BUILD_TEST=OFF" "-DFLTK_BU
    ILD_FLUID=OFF" "-DOPTION_USE_THREADS=ON" "-DOPTION_LARGE_FILE=ON" "-DOPTION_BUILD_HTML_DOCUMENTATION=OFF" "-DOPTION_BUILD_PDF_DOCUMENTATION=OFF" "-DCMAKE_INSTALL_PREFIX=C:\\Users\\fflea\\CLionProjects\\VNMapGUI\\target\\debug\\build
    \\fltk-sys-29626eefcff0b61e\\out" "-DCMAKE_C_FLAGS= -nologo -MD -Brepro" "-DCMAKE_C_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_ASM_FLAGS= -n
    ologo -MD -Brepro" "-DCMAKE_ASM_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_BUILD_TYPE=Release"
    
      --- stderr
      fatal: not a git repository (or any of the parent directories): .git
      error: patch failed: CMake/export.cmake:33
      error: CMake/export.cmake: patch does not apply
      error: patch failed: CMake/options.cmake:115
      error: CMake/options.cmake: patch does not apply
      error: VERSION: No such file or directory
      error: patch failed: src/CMakeLists.txt:300
      error: src/CMakeLists.txt: patch does not apply
      error: patch failed: src/Fl_lock.cxx:418
      error: src/Fl_lock.cxx: patch does not apply
      error: patch failed: src/Fl_win32.cxx:586
      error: src/Fl_win32.cxx: patch does not apply
      error: patch failed: src/config_lib.h:78
      error: src/config_lib.h: patch does not apply
      error: patch failed: src/drivers/Android/Fl_Android_System_Driver.H:25
      error: src/drivers/Android/Fl_Android_System_Driver.H: patch does not apply
      error: patch failed: src/drivers/Android/Fl_Android_System_Driver.cxx:24
      error: src/drivers/Android/Fl_Android_System_Driver.cxx: patch does not apply
      CMake Error: Could not create named generator Visual Studio 16 2019
    
      Generators
      * Unix Makefiles               = Generates standard UNIX makefiles.
        Ninja                        = Generates build.ninja files.
        Ninja Multi-Config           = Generates build-<Config>.ninja files.
        CodeBlocks - Ninja           = Generates CodeBlocks project files.
        CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
        CodeLite - Ninja             = Generates CodeLite project files.
        CodeLite - Unix Makefiles    = Generates CodeLite project files.
        Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
        Sublime Text 2 - Unix Makefiles
                                     = Generates Sublime Text 2 project files.
        Kate - Ninja                 = Generates Kate project files.
        Kate - Unix Makefiles        = Generates Kate project files.
        Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
        Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
    
      thread 'main' panicked at '
      command did not execute successfully, got: exit code: 1
    
      build script failed, must exit now', C:\Users\fflea\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.45\src\lib.rs:894:5
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    
    opened by ffleader1 25
  • NativeFileChooser spurious delays in Windows 11 with fltk-bundled flag on msvc

    NativeFileChooser spurious delays in Windows 11 with fltk-bundled flag on msvc

    Describe the bug

    In the beginning, there are three widgets: a button, a TextDisplay, and a Frame that will be filled with an image. After the button is clicked, a FileDialog widget is created for user to select a jpg file, the TextDisplay's content will be set as the path to the selected jpg file, and the Frame will be filled with this image.

    Problem is, after I selected the jpg file, the FileDialog closed, but the window became unresponsive, and it often took 7 seconds for the TextDisplay to show the path. I expect it to show immediately.

    At first the variable last_used_dir is String, it took 7 seconds. Then I tried to use thread for get_img and Arc<Mutex<PathBuf>> for last_used_dir, no difference. further investigation showed that FileDialog::show() cost most of the time.

    update: after remove set_filter(), set_option(), set_title(), and move set_directory() after show(), the FileDialog acts normally most of the time, but still there are aproximately 1/8 chance that the problem presents.

    update 2: Don't know what the underlying problem is, but I tried using native-dialog, the problem is still there.

    To Reproduce

    use std::path::{Path, PathBuf};
    use std::sync::Arc;
    use std::sync::Mutex;
    use std::thread;
    use std::time::Instant;
    
    use anyhow::Error;
    
    use fltk::{
        app,
        app::*,
        button::*,
        dialog::*,
        draw::{draw_rectf, set_draw_color},
        enums::*,
        frame::Frame,
        image::*,
        input::*,
        prelude::*,
        window::DoubleWindow,
        text::{TextDisplay, TextBuffer},
    };
    
    
    
    const MAX_W: u32 = 400;
    const MAX_H: u32 = 400;
    
    #[derive(Clone, Copy)]
    enum Message<'a> {
        SelectImgFile,
        LoadImg,
        ResizeImg(&'a str),
    }
    
    fn main() -> Result<(), Error> {
        let app = App::default();
        let mut wind = DoubleWindow::new(100, 100, 1200, 600, "resize_img");
        let (sender, receiver) = channel::<Message>();
    
        let mut choose_img_button = Button::new(5, 50, 120, 40, "choose_img");
        choose_img_button.emit(sender, Message::SelectImgFile);
        // let mut show_img_path = Input::new(130, 50, 655, 40, "");
        let mut show_img_path = TextDisplay::new(130, 50, 655, 40, "");
        let mut img_frame = Frame::new(40, 150, MAX_W as i32, MAX_H as i32, "");
    
        wind.end();
        wind.make_resizable(true);
        wind.show();
       let last_used_dir = Arc::new(Mutex::new(PathBuf::new()));
    
        while app.wait() {
            match receiver.recv() {
                Some(Message::SelectImgFile) => {
                    let start = Instant::now();
                    let mut last_used_dir_clone = last_used_dir.clone();
                    // this is where the problem lies
                    let img_file = get_img(&mut last_used_dir_clone);
                    let duration = start.elapsed();
                    println!("Time elapsed in get_img() is: {:?}", duration);
    
                    // show_img_path.set_value(img_file.to_str().unwrap());
                    let mut show_img_buf = TextBuffer::default();
    
                    show_img_buf.set_text(img_file.to_str().unwrap());
                    show_img_path.set_buffer(Some(show_img_buf));
    
                    let img_path = Path::new(&img_file);
                    if img_path.exists() {
                        let file_dir = img_path.parent().unwrap();
                        *last_used_dir.lock().unwrap() = PathBuf::from(file_dir);
                        sender.send(Message::ResizeImg(img_file.to_str().unwrap()));
                    }
                }
                _ => {
             }
           }
         }
       Ok(())
    }
    
    
    /// using the native file explorer
    fn get_img(last_used_dir: &mut Arc<Mutex<PathBuf>>) -> PathBuf {
        let mut choose_img = FileDialog::new(FileDialogType::BrowseFile);
        choose_img.set_filter("jpg\t*.jpg");
        // choose_img.set_filter("jpg\t*.{jpg,png,jpeg}");
        choose_img.set_option(fltk::dialog::FileDialogOptions::NoOptions);
        choose_img.set_title("images: ");
        choose_img
            .set_directory(&(*last_used_dir.lock().unwrap()))
            .unwrap();
        // further investigation showed that choose_img.show() cost most of the time
        let start = Instant::now();
        choose_img.show();
        let duration = start.elapsed();
        println!("Time elapsed in choose_img.show() is: {:?}", duration);
    
        let filename = choose_img.filename();
        if filename.exists() {
            let file_dir = filename.parent().unwrap();
            *last_used_dir.lock().unwrap() = std::path::PathBuf::from(file_dir.to_owned());
        };
        choose_img.filename()
    }
    
    // with [native-dialog](https://lib.rs/crates/native-dialog) v 0.6.1
    /*
    fn get_img_native_external(last_used_dir: &mut Arc<Mutex<PathBuf>>) -> PathBuf {
        let path = native_dialog::FileDialog::new()
            .set_location(&((*last_used_dir).lock().unwrap().to_str().unwrap()))
            .add_filter("PNG Image", &["png"])
            .add_filter("JPEG Image", &["jpg", "jpeg"])
            .show_open_single_file()
            .unwrap();
    
        path.unwrap()
    
    }
    */
    

    Expected behavior

    I expect the window stay responsive and the TextDisplay to immediately show the path.

    Desktop info

    • OS: Win11 Pro 22000.376
    • stable-x86_64-pc-windows-msvc
    • Rust v1.57.0

    Additional Info

    # Cargo.toml
    [dependencies]
    fltk = { version = "^1.2", features = ["fltk-bundled"] }
    anyhow = "1"
    
    need more info 
    opened by wellitecho 20
  • fltk::image::*::draw()

    fltk::image::*::draw()

    The bindings are missing the draw function which allows the cx, cy corner coordinates for using a spritesheet to pick images out of. I honestly tried very hard to look through the docs to see if I was missing it somewhere. I did not find it in any of the image structs. I would like to be able to use this, because I want to make a game, and being able to do a sprite sheet is a big step in that direction. I considered using the image crate, but FLTK already has this functionality built in the C++ version. the C++ version is: draw(screen_x, screen_y, image_frame_width, image_frame_height, image_frame_x, image_frame_y) Your bindings only have draw(screen_x, screen_y, image_width, image_height)

    Thanks again for all your efforts, FLTK has been a favorite of mine for years, so having Rust bindings (as well as your great fl2rust) makes many things easier and cleaner than the C++ code! I really like your widget.emit(signal, MySignal::Yeet) way of handling callbacks, it is much nicer than the C++ callback method (2 functions needed to do one thing).

    Keep up the great work!

    opened by 1sra3l 15
  • The FLTK app is not found in task manager and taskbar when window border is set false

    The FLTK app is not found in task manager and taskbar when window border is set false

    The FLTK app is not found in task manager and taskbar when window border is set false. I was trying to create a custom title bar after hiding the default title bar (by setting win.set_border(false)) How should I get the app window shown in taskbar, and task manager while keeping default titlebar hidden? Or is it possible to customize the default titlebar using fltk crate?

    issue

    opened by santokalayil 13
  • [BUG] app event coordinates returned with incorrect values when handling MouseWheel event in GlutWindow

    [BUG] app event coordinates returned with incorrect values when handling MouseWheel event in GlutWindow

    When handling Event::MouseScroll in a GlutWindow, app::event_x()/app::event_y()/app::event_coords() are returning anomalous values.

    Oddly, calling these event coordinate functions inside other arms of the same widg.handle() match statement returns the expected results. Push, Drag, and KeyPress all return event coordinates as expected. Note that I have not tested all the different Event types for this issue.

    I thought this might be a quirky FLTK feature at first, but haven't found any notes on such an issue in the FLTK docs. Additionally since the problem only occurs in a GlutWindow, I'm inclined to believe it is a bug.

    OS: Windows 10

    fltk = { version = "0.16", features = ["enable-glwindow"] }
    speedy2d = { version = "1.0.7", git = "https://github.com/QuantumBadger/Speedy2D", default-features = true }
    gl = "0.14"
    
    use fltk::{
        app,
        enums::Event,
        prelude::{WidgetBase, WidgetExt, GroupExt, WindowExt},
        window::{GlutWindow, Window},
    };
    use speedy2d::GLRenderer;
    
    fn main() {
        let app = app::App::default();
        let wind_size =  500;
        let mut main_win = Window::new(450,450,wind_size, wind_size, "");
        let mut win = GlutWindow::default().with_size(wind_size, wind_size).with_pos(0,0);
        win.end();
        main_win.end();
        main_win.show();
        win.make_current();
    
        
        gl::load_with(|s| win.get_proc_address(s));
        let mut renderer = unsafe { GLRenderer::new_for_current_context((wind_size as u32, wind_size as u32)) }.unwrap();
    
        let mut win_cl = win.clone();
        win.handle(Box::new(move |ev| match ev {
            Event::Push => {
                println!("Pushed");
                dbg!(app::event_x(), app::event_y());
                win_cl.redraw();
    
                true
            },
            Event::MouseWheel=>{
                println!("Scrolled");
                dbg!(app::event_x(), app::event_y());
                win_cl.redraw();
                false
            }
            _ => false,
        }));
        app.run().unwrap();
    }
    

    When performing a push, then a scroll in the exact same location, for me, the event coordinate functions are returning different locations.

    Pushed
    [src\main.rs:27] app::event_x() = 111
    [src\main.rs:27] app::event_y() = 359
    Scrolled
    [src\main.rs:33] app::event_x() = -872
    [src\main.rs:33] app::event_y() = -48
    

    All the code you need to reproduce it is in here I believe, but I put it into thisrepo if that's helpful. Let me know if you can successfully reproduce.

    pinned 
    opened by wyhinton 13
  • Is it possible to populate an input choice widget after compiling?

    Is it possible to populate an input choice widget after compiling?

    I am relatively new to using this crate along with rust in general, but I am working on a program that will read a word from an input text widget which will point to a column in an SQL Server table. Then populate an input choice widget so the user can pick which row they want to select and pull information from there. Along with doing this, I want to add a scroll function to this input choice widget but I do not know if it possible or not. Currently I am using two separate UIs to solve this problem. This may be an issue with using an ODBC command due to it only being allowed to be run in a function that returns "Result<()>", which is causing me to create the input choice widget in the ODBC functions since the add command must be inside of them to receive that information. Does anybody have any ideas on how I can condense my code into one UI?

    question 
    opened by ryanhartmann1 12
  • Regression issue in 1.3.8 - x86_64-pc-windows-gnu

    Regression issue in 1.3.8 - x86_64-pc-windows-gnu

    Describe the bug

    Since 1.3.8 I can no longer cross-compile Windows builds from Linux docker containers. The build now complains about being unable to find the native static library cfltk (fltk-bundled feature, +crt-static in RUSTFLAGS) .

    The problem was observed only with Windows and the x86_64-pc-windows-gnu architecture target

    • No errors observed with 1.3.8 when cross-compiling for Mac OS (x86_64-apple-darwin)
    • Everything is also still fine for Linux (x86_64-unknown-linux-musl and x86_64-unknown-linux-gnu).

    To Reproduce

    You need Docker or Podman to quickly reproduce exactly the issue

    git clone https://github.com/yveszoundi/fltk-rs-issues-windows-gnu
    cd fltk-rs-issues-windows-gnu
    docker run --privileged -v "${PWD}":/src docker.io/uycyjnzgntrn/rust-windows:1.60.0 sh -c "cd /src && RUSTFLAGS='-C target-feature=+crt-static' cargo build --verbose --release --target x86_64-pc-windows-gnu"
    

    Expected behavior

    The code should compile cleanly with 1.3.8 similarly to 1.3.7, I don't know exactly what's different.

    I re-verified that everything was indeed fine in 1.3.7, by forcing a fixed version in my build dependencies: fltk = { version = "=1.3.7", features = ["fltk-bundled"] }

    Screenshots

    Build failures of dangerzone-rust

    cross-compile-error

    Desktop info

    • Build environment: Podman running official Rust docker image
      • Debian bullseye (11)
      • Rust 1.6.0
      • x86_64-pc-windows-gnu architecture target
      • g++-mingw-w64-x86-64 extra package installed via apt install
      • fltk-bundled feature and +crt-static set in RUSTFLAGS
    • Guest machine running the build: Ubuntu jammy (22.04) QEMU virtual machine, podman build containers
    • Host machine: iMac pro running MacOS Monterey (12.4)

    Additional info

    As soon as I realized that 1.3.8 was officially released, I switched back from git master to the latest official release. The build failures were first noticed in dangerzone-rust:

    • Branch: spiral15
    • Build script: ci_cd/windows/build.sh

    Build failures

    No fltk-rs release build failures per say, apparently a behavior change in fltk-sys and/or cfltk

    opened by yveszoundi 11
  • FileDialog disables resizing

    FileDialog disables resizing

    Hello,

    it seems that opening a FileDialog messes with resizing:

    use fltk::{app, prelude::*, window::Window, button::Button, dialog};
    
    fn main() {
        let app = app::App::default();
        let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
        let mut but = Button::new(160, 210, 80, 40, "Click me!");
        wind.end();
        wind.make_resizable(true);
        wind.show();
    
        let mut dlg = dialog::FileDialog::new(dialog::FileDialogType::BrowseFile);
        but.set_callback(move |_| dlg.show());
    
        app.run().unwrap();
    }
    

    This will open a resizable window as expected: before However, as soon as the FileDialog is opened the main window cannot be resized anymore: after

    Desktop info

    ArchLinux(5.16.11), xorg 21.1.3

    Additional info

    I believe this was introduced in 1.2.28.

    opened by ThiNei2l 11
  • [BUG]Custom Event Not Handled in release build of app

    [BUG]Custom Event Not Handled in release build of app

    Hello, and thank you for all the wonderful work going on with this project! One issue I keep running into is the inability to successfully capture a custom event. See this example (taken from the discussion board):

    //fltk = "^1.0"
    //OS: Win10
    
    use fltk::{prelude::*, *};
    use std::rc::Rc;
    use std::cell::RefCell;
    
    pub struct MyEvent;
    
    impl MyEvent {
        const BUTTON_CLICKED: i32 = 40; // values below 30 are reserved
        const FRAME_CHANGED: i32 = 41;
    }
    
    pub struct MyButton {
        but: button::Button,
    }
    
    impl MyButton {
        pub fn new() -> Self {
            let mut but = button::Button::new(160, 200, 80, 40, "Inc");
            but.set_callback(|_| {
                let _ = app::handle_main(MyEvent::BUTTON_CLICKED);
            });
            Self { but }
        }
    }
    
    pub struct MyFrame {
        frame: frame::Frame,
        counter: Rc<RefCell<i32>>,
    }
    
    impl MyFrame {
        pub fn new() -> Self {
            let mut frame = frame::Frame::default().size_of_parent().with_label("0");
            let counter = Rc::from(RefCell::from(0));
            let c = counter.clone();
            frame.handle(move |f, ev| if ev as i32 == MyEvent::BUTTON_CLICKED {
                *c.borrow_mut() += 1;
                f.set_label(&format!("{}", c.borrow()));
                let _ = app::handle_main(MyEvent::FRAME_CHANGED);
                true
            } else {
                false
            });
            Self { frame, counter }
        }
        pub fn count(&self) -> i32 {
            *self.counter.borrow()
        }
    }
    
    pub struct MyWindow {
        win: window::Window,
    }
    
    impl MyWindow {
        pub fn new() -> Self {
            let mut win = window::Window::default().with_size(400, 300);
            let frame = MyFrame::new();
            let but = MyButton::new();
            win.show();
            win.end();
            win.handle(move |_, ev| if ev as i32 == MyEvent::FRAME_CHANGED {
                println!("Frame changed to value {}", frame.count());
                true
            } else {
                false
            });
            Self { win }
        }
    }
    
    fn main() {
        let app = app::App::default();
        let _win = MyWindow::new();
        app.run().unwrap();
    }
    

    The value of counter does not change, and I can't see that BUTTON_CLICKED is captured anywhere. I know we discussed this issue in issue #660, but I'm still not understanding why this example isn't working. Any thoughts?

    opened by wyhinton 11
  • [BUG] window.set_screen_num() when not in fullscreen mode.

    [BUG] window.set_screen_num() when not in fullscreen mode.

    Hello,

    first of all really awesome project!

    But I have a problem with window postitioning on startup. When I create a window in fullscreen mode and set the window.set_scree_num() integer, it will work as expected and the window gets spawned on another display. But this does not work when i leave fullscreen mode or dont go to fullscreen in the first place.

    Is there a way to set the "postition" of the window to another screen?

    opened by kernelPanic0x 2
  • [BUG] <dialog::NativeFileChooserType::BrowseMultiDir> Can't select multiple folders

    [BUG] Can't select multiple folders

    Remember to search before filing a new report

    Searched and found no answer.

    Describe the bug

    dialog::NativeFileChooserType::BrowseMultiDir Can't select multiple folders. behave the same as dialog::NativeFileChooserType::BrowseDir.

    To Reproduce

    use fltk::dialog;
    use std::path::PathBuf;
    
    fn main() {
       let v = select_folders();
    }
    
    fn select_folders() -> Vec<PathBuf> {
        let mut dialog = dialog::NativeFileChooser::new(dialog::NativeFileChooserType::BrowseMultiDir);
        dialog.show();
        dialog.filenames()
    }
    

    Expected behavior

    dialog select multiple folders, then return a vec.

    Screenshots

    IYJ}SLZ4DS`Z 14K5YQBL}N

    Desktop info

    • OS: Windows 10 Pro x64 21H2 19044.1865
    • fltk = "1.3.13"

    Additional info

    dialog::NativeFileChooserType::BrowseMultiFile works fine.

    pinned upstream-fltk 
    opened by ws132 3
  • [BUG] Emojis are not displayed in HoldBrowser (

    [BUG] Emojis are not displayed in HoldBrowser ("X Error of failed request: BadLength (poly request too large or internal Xlib length error)")

    This is not a bug in fltk-rs itself, but in an underlying library (see here); I'm posting it for reference, but also to ask if anybody has any idea of how to workaround it in a non-excessively-complex way via fltks-rs itself (removing font packages is not viable on my system).

    Describe the bug

    HoldBrowser doesn't display entries containing emojis.

    To Reproduce

    Create a HoldBrowser, and add an entry with an emoji; it won't be displayed. An error will be printed in the console, X Error of failed request: BadLength (poly request too large or internal Xlib length error).

    Expected behavior

    The entry (emoji) should be displayed.

    Screenshots

    (skipped)

    Desktop info

    • OS: Ubuntu MATE
    • Version 20.04.4

    Additional info

    (skipped)

    Build failures

    (skipped)

    pinned upstream-fltk 
    opened by 64kramsystem 4
  • If app appears on non-active screen, window resizes

    If app appears on non-active screen, window resizes

    Discussed in https://github.com/fltk-rs/fltk-rs/discussions/777

    Originally posted by wyhinton July 14, 2021 When creating a new Window, it seems like the size of the window can sometimes resize automatically. I assume that FLTK is trying to account for some kind of screen screen scaling? Or maybe this is a Win10 thing? But on the monitor that I captured the GIF, the screen scale is 1.0. The scale on my other 4k monitor is 1.25. Is there anyway to have the window appear as the correct size before it appears?

    This can also sometimes cause widgets to resize strangely.

    use fltk::{
        app, app::*, button::*, enums::*, frame::*, group::*, prelude::*, window::*, widget::*, draw::*,
    };
    //fltk = { version = "1.0.22"}
    fn main(){
        let app = App::default();
        let mut win = Window::new(200, 200, 500, 300, "Pack vs Group Overdraw");
        let mut my_pack= Pack::new(50,50,100,200,"mypack");
        let _button= Button::new(0,0,200,20,"mybutton");
        let _button= Button::new(0,0,200,20,"mybutton");
        let _button= Button::new(0,0,200,20,"mybutton");
        let _button= Button::new(0,0,200,20,"mybutton");
        let mut my_group= Group::new(200,50,100,50,"my group");
        my_group.set_frame(FrameType::FlatBox);
        my_group.set_color(Color::Red);
    
    
        let mut frame = Frame::new(200,100,100,100, "Test");
        frame.set_frame(FrameType::FlatBox);
        frame.set_color(Color::Yellow);
        my_group.end();
    
        let mut frame = Frame::new(250,100,100,100, "Test");
        frame.set_frame(FrameType::FlatBox);
        frame.set_color(Color::Yellow);
        my_pack.end();
        win.end();
        win.show();
        app.run().unwrap();
    }
    

    Capture on the "non active" screen (the one the mouse is NOT over)

    window_resize_issue

    Demonstrating the odd resizing effect for my DnD ToDoList example

    window_resize_issue2

    What the window should look like:

    image

    I'm wondering if this might have something to do with the use of Pack.

    pinned upstream-fltk 
    opened by wyhinton 5
  • Project showcase

    Project showcase

    Some open-source projects using fltk-rs (arranged in alphabetical order): (Please add other projects that you come across)

    Projects

    amp-rs

    AMP “Another Music Player” provides a basic but useful example of Rust/FLTK and the Soloud sound library. image

    atm-raytracer

    A raytracer for panoramas using real-life elevation data image

    ayaya

    Testing tool for the Open Sound Control protocol image

    bitwarden-autotype

    The missing desktop-autotype for Bitwarden

    CDCS

    CDCS is a helper program for modding and the making of Symphony of empires

    CharFind

    An application for finding Unicode characters image

    charcter-maker

    Character Maker for RPG games written in Rust + FLTK image

    corsim

    Simulation of Coronary Angiography image

    crosshair_switcher

    A tool to change your crosshairs and no-explosion scripts on a per-weapon-bases image

    diffscreen

    A toy remote desktop implemented by rust.

    dsam

    Automap DecentSampler / SFZ instruments from a folder of samples image

    egui-fltk-frontend

    FLTK frontend for Egui WGPU backend.

    entrusted

    Entrusted is a document sanitizer tool that converts ”potentially suspicious files” into safe PDFs image

    fal

    FAL is a crossplatform application laucher designed to be fast and customisable

    fe-image-widget

    Image widget support for fltk-egui

    fltk-plot

    An interactive plotting library for Rust image

    freecut

    A cut optimizer software for optimizing rectangular cut pieces from panels along with pdf generation. image

    graphical

    A powerful, and visual tool for graphing mathematical functions and equations

    gravitate-rs

    A SameGame/TileFall-like game written in Rust/FLTK. image

    hammer

    Safe Network - simple front GUI for the CLI image image

    intellivision-emulator

    An intellivision emulator. image

    Library_rs

    A book library interface for issuing books in libraries. image

    L5P-Keyboard-RGB

    Controls the RGB on the keyboard for the Legion 5 Pro from Lenovo. Mostly used for learning a bit of rust. image

    lightron

    The Lightron Web Server is a lightweight web server

    mc_afk_bot

    A simple yet powerful app for leaving a bot AFK in your Minecraft farms image

    MechanicsProgramsRust

    Various applications for mechanics simulations and structural engineering models written in Rust image

    mkv-audio-extractor

    MKV audio extractor is a tool to extract audio in flac format from mkv files. image

    netport

    A GUI address port checker written in Rust image

    niccalc

    Niccalc is a tool that helps to determine the necessary amount of nicotine for an e-cigarette liquid image

    openSIMP

    Open Secure Instant Messaging Protocol (formerly Suschat)

    OpusProto

    Standalone, open-source audio mastering software prototype

    packs

    Simple package browser that parses yay output. image

    pistiflex

    Simple card game built with Rust and FLTK

    rahmen

    Rahmen is a lightweight tool to present images while consuming little resources. It takes a list of files or a pattern, and periodically shows the next image.

    rcas

    A Rust Computer Algebra System image

    rchive

    Open Source compression file manager written in rust for windows.

    rename

    A simple file renamer tool image

    Resters

    A lightweight cross-platform Rest API tester

    retrofilter

    image A simple image processing tool, which allows one to make digital images look a bit "retro"

    RGBReader

    Reads avg of r g b values from image

    rootsmagic-importer

    Imports information from various public family history sites into RootsMagic

    rpg-stat

    Role Playing Game Statistics library written in Rust

    rpn-rs

    Reverse Polish Notation Calculator

    rust_file_crawler

    A GUI version of Rust_File_Crawler image

    rust_hero

    A simple game in Rust image

    RustTaskBarProgress

    A small example which shows how to display progress information on the taskbar button on Windows

    rust_udp_spreadsheet

    Desktop app with UDP sync tables

    rust-voltorb-flip-solver

    An efficient tool for solving Voltorb Flip puzzles image

    seam-carving

    Rust implementation of Seam Carving for Content-Aware Image Resizing

    slackrypt

    A client-server project to share encrypted messages in Slack

    SolariumProcessor

    SolariumProcessor, or SProc, is a simple 16-bit hypothetical processor that implements a basic Instruction Set Architecture. image

    sp-ros

    The ros2 workspace for Sequence Planner with required messages and other nodes

    sudokusolver

    A small application which can solve sudoku puzzles image

    swyh-rs

    A "Stream-What-You-Hear" implementation written in Rust. image

    sysinfo-gui

    A cross-platform system-monitoring gui application based on sysinfo and fltk. image

    tkd-scoreboard

    Scoreboard program for taekwondo competition. image

    tlm

    Track List Manager manages playlists and plays tracks. image

    trueLMAO

    sega megadrive emulator

    VideoAnalysisController

    Video player to analyze (sports) clips controllable by Xbox / PS controllers (or others)

    weather-tray-rs

    A system tray which shows the weather temperature of the selected place using the Open Weather API

    weectrl

    A cross platform library and application for controlling Belkin WeMo switches and Sockets. image

    Weylus

    Weylus turns your tablet or smart phone into a graphic tablet/touch screen for your computer! image

    yabinero

    A Binero game

    zao_ecg_axis

    find the electrocardiographic axis of QRS complex from the Frontal leads. image

    pinned 
    opened by MoAlyousef 5
Releases(1.3.26)
Owner
fltk-rs
fltk-rs
Rust bindings for the FLTK GUI library.

fltk-rs Rust bindings for the FLTK Graphical User Interface library. The fltk crate is a cross-platform lightweight gui library which can be staticall

fltk-rs 1.1k Jan 9, 2023
Simplify generating an fltk gui from a data structure

This crate aims to simplify generating gui from a data structure.

fltk-rs 3 Dec 19, 2021
A lightweight cross-platform system-monitoring fltk gui application based on sysinfo

Sysinfo-gui A lightweight cross-platform system-monitoring fltk gui application based on sysinfo. The UI design is inspired by stacer. The svg icons a

Mohammed Alyousef 22 Dec 31, 2022
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.4k Dec 31, 2022
A smart table widget for fltk-rs

fltk-table A smart table widget for fltk-rs. It aims to reduce the amount of boilerplate required to create a table. Usage [dependencies] fltk = "1.2"

fltk-rs 11 Dec 8, 2022
FLTK frontend for Egui WGPU backend.

Egui FLTK Frontend FLTK Frontend for Egui WGPU Backend On linux Debian/Ubuntu, make sure to install the latest main requirements: sudo apt-get update

Adia Robbie 5 Oct 25, 2022
The bindings to the Nuklear 2D immediate GUI library.

nuklear-rust The bindings to the Nuklear 2D immediate GUI library. Currently beta. Drawing backends: gfx-pre-ll for GFX 3D drawing engine (examples: O

Serhii Plyhun 332 Dec 27, 2022
An easy-to-use, 2D GUI library written entirely in Rust.

Conrod An easy-to-use, 2D GUI library written entirely in Rust. Guide What is Conrod? A Brief Summary Screenshots and Videos Feature Overview Availabl

PistonDevelopers 3.3k Jan 1, 2023
Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust

Relm Asynchronous, GTK+-based, GUI library, inspired by Elm, written in Rust. This library is in beta stage: it has not been thoroughly tested and its

null 2.2k Dec 31, 2022
Clear Coat is a Rust wrapper for the IUP GUI library.

Clear Coat Clear Coat is a Rust wrapper for the IUP GUI library. IUP uses native controls and has Windows and GTK backends. A macOS backend has been o

Jordan Miner 18 Feb 13, 2021
A cross-platform GUI library for Rust, inspired by Elm

Iced A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm. Features Simple, easy-to-use, batteries-included AP

Héctor Ramón 17.5k Jan 2, 2023
A cross-platform GUI library for Rust focused on simplicity and type-safety

A cross-platform GUI library for Rust, inspired by Elm

Héctor Ramón 17.5k Jan 8, 2023
A cross-platform GUI library for Rust, inspired by Elm

Iced A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm. Features Simple, easy-to-use, batteries-included AP

null 17.5k Dec 28, 2022
A single-header ANSI C immediate mode cross-platform GUI library

Nuklear This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed a

Immediate Mode UIs, Nuklear, etc. 6.9k Jan 8, 2023
An idiomatic GUI library inspired by Elm and based on gtk4-rs

An idiomatic GUI library inspired by Elm and based on gtk4-rs. Relm4 is a new version of relm that's built from scratch and is compatible with GTK4 an

Aaron Erhardt 722 Dec 31, 2022
A simple, cross-platform GUI automation module for Rust.

AutoPilot AutoPilot is a Rust port of the Python C extension AutoPy, a simple, cross-platform GUI automation library for Python. For more information,

null 271 Dec 27, 2022
Truly cross platform, truly native. multiple backend GUI for rust

WIP: Sauron-native a rust UI library that conquers all platforms ranging from desktop to mobile devices. An attempt to create a truly native, truly cr

Jovansonlee Cesar 627 Jan 5, 2023
A simple news reading GUI app built in Rust

Headlines [WIP] A native GUI app built with Rust using egui. Uses newsapi.org as the source to fetch news articles. This is a WIP and the current stat

creativcoder 89 Dec 29, 2022
Build GUI applications with minimal dependencies in Rust

winapi-app-windows A crate to build applications' windows in Windows using WinAPI. This would be less confusing if the operating system was called som

Lonami 5 Jul 26, 2022