Listener widget for fltk-rs

Overview

fltk-evented

This crate provides a Listener widget which can basically wrap any fltk-rs widget (implementing WidgetBase and WidgetExt) and provides an on_ interface.

Usage

fltk = "1.2"
fltk-evented = "0.1"

Example

use fltk::{
    app, button,
    enums::{Color, FrameType},
    prelude::*,
    window,
};
use fltk_evented::Listener;

fn main() {
    let app = app::App::default();
    let mut wind = window::Window::default().with_size(400, 300);
    wind.set_color(Color::White);
    let mut but: Listener<_> = button::Button::new(160, 210, 80, 35, "Click me!").into();
    but.set_frame(FrameType::FlatBox);
    but.set_color(Color::Cyan);
    but.set_selection_color(Color::Cyan.darker());
    but.clear_visible_focus();
    wind.end();
    wind.show();

    but.on_hover(|b| {
        b.set_color(Color::Cyan.lighter().lighter());
    });

    but.on_leave(|b| {
        b.set_color(Color::Cyan);
    });

    but.on_click(|b| {
        println!("Clicked");
        b.set_label_color(Color::White);
    });

    but.on_release(move |b| {
        wind.set_label("Button Released!");
        b.set_label_color(Color::Black);
    });

    app.run().unwrap();
}
You might also like...
Example crate using fltk-build

white-frame This is just an example showing the use of fltk-build to create native C/C++ FLTK and cfltk modules for fltk-rs. This repo contains 2 exam

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

Gravitate A SameGame/TileFall-like game written in Rust/FLTK. Tested on Linux and Windows. gravitate.exe is a precompiled Windows binary that should r

Rust bindings for the FLTK GUI library.
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

A lightweight cross-platform system-monitoring fltk gui application based on sysinfo
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

A menu widget for tui-rs ecosystem

tui-menu A menu widget for tui-rs ecosystem. Features Sub menu groups. Intuitive movement. Item's data is generic as long as it Cloneable. Try cargo r

Slippy map (openstreetmap) widget for egui
Slippy map (openstreetmap) widget for egui

Slippy maps widget for egui. Limitations There are couple of limitations when using this library. Some of them will might probably be lifted at some p

Simple yet powerful multi-line text editor widget for tui-rs and ratatui
Simple yet powerful multi-line text editor widget for tui-rs and ratatui

tui-textarea tui-textarea is a simple yet powerful text editor widget like textarea in HTML for tui-rs and ratatui. Multi-line text editor can be ea

Bevy plugin for a simple single-line text input widget.
Bevy plugin for a simple single-line text input widget.

bevy_simple_text_input An unambitious single-line text input widget for bevy_ui. Usage See examples/basic.rs. Alternatives If you need more features,

A powerful desktop widget app for windows, built with Vue and Tauri.
A powerful desktop widget app for windows, built with Vue and Tauri.

DashboardX Widgets A powerful desktop widget app for windows, built with Vue and Tauri. Still in development Currently only runs on windows (uses nati

Hotkey widget for egui!
Hotkey widget for egui!

egui-keybind, a hotkey library for egui crates.io | docs.rs | examples | changelogs This library provides a simple egui widget for keybindings (hotkey

A Ratatui widget to turn any image to a splash screen in your terminal ✨
A Ratatui widget to turn any image to a splash screen in your terminal ✨

ratatui-splash-screen A Ratatui widget to turn any image to a splash screen in your terminal ✨ See the demo of gpg-tui for a real world example. Featu

A widget library built on top of bevy_ui.
A widget library built on top of bevy_ui.

Sickle UI A widget library built on top of bevy's internal bevy_ui. Example If you clone the repository, you can simply build and run the main example

Comments
  • app crashes(freezes) with Dialogs

    app crashes(freezes) with Dialogs

    Hello, I have a modal dialog launched from event Button(btn):

    while app.wait() {
           if btn.triggered() {
               info!("btn triggered");
               ConnectDialog::default();
               ..................
           }
          if hold_browser.triggered() {
               info!("hold_browser triggered");
               if hold_browser.value() != 0 {.......}
          }
    

    If I use only the event Button(btn), all is ok. But, if I interact with hold_browser event and attempt to launch the dialog again, the app crashes and stay freezes!.

    This is my dialog, taked it from examples.

            win.end();
            win.make_modal(true);
            win.show();
            ok.set_callback({
                let mut win = win.clone();
                move |_| {
                    win.hide();
                }
            });
            while win.shown() {
                app::wait();
            }
    

    If I remove the dialog, everything is ok.

    opened by realtica 6
  • High usage of CPU

    High usage of CPU

    Hello,

    Kernel:  5.10.0-11-amd64
    Distro: Debian GNU/Linux 11 (bullseye)
    CPU: AMD Ryzen 7 5800U with Radeon Graphics (16)
    

    With a regular button the CPU usage is 0.5% with firefox open. But with: let mut btn: Listener<_> = button::Button::default().with_label("Connect").into(); The CPU usage increase and stay to 10%, what is happening?

    opened by realtica 1
Owner
fltk-rs
fltk-rs
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
This is a demo Library of fltk-rs, which is used to learn various new gadgets of experimental fltk-rs.

fltk-rs Demo This is a demo Library of fltk-rs, which is used to learn various new gadgets of experimental fltk-rs. Demos demo9 Demo9 is an applicatio

WumaCoder 6 Dec 28, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Rustcat is a port listener that can be used for different purposes.

⚙️ Rustcat ⚙️ -- Basic Netcat Alternative -- About Rustcat is a port listener that can be used for different purposes.

Robiot 489 Dec 28, 2022
GPIO reader, writer and listener

Unbothered gpio Everything is unwrapped under the hood for the precious prettiness of your code. It's more than a simple Rust crate, it's a philosophy

null 0 Nov 7, 2021
Rust-based linux reverse shell listener.

Catch Rust-based linux reverse shell listener. Installation TODO: fix this installation guide, but this kinda works: mkdir /opt/catch/ cd /opt/catch/

Jazz 3 Aug 8, 2024
Rust bindings for the FLTK GUI library.

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

Mohammed Alyousef 1.1k Jan 9, 2023
A theming crate for fltk-rs

fltk-theme A theming crate for fltk-rs, based on work by Remy Oukaour and Greg Ercolano, and schemes developed by the NTK GUI library. Usage [dependen

null 53 Dec 27, 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
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