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...
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

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 crossplatform lightweight gui library which can be statically

A theming crate for fltk-rs
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

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

Simplify generating an fltk gui from a data structure
Simplify generating an fltk gui from a data structure

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

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

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

shuo 3 Nov 30, 2022
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

Piotr 13 Jun 14, 2023
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

Linda_pp 126 Jul 12, 2023
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,

Rob Parrett 9 Oct 3, 2023
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

DashboardX Widgets 3 Oct 25, 2023