A smart table widget for fltk-rs

Related tags

GUI fltk-table
Overview

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-table = "0.1"

Example

use fltk::{
    app, enums,
    prelude::{GroupExt, WidgetExt},
    window,
};
use fltk_table::{SmartTable, TableOpts};

fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gtk);
    let mut wind = window::Window::default().with_size(800, 600);

    /// We pass the rows and columns thru the TableOpts field
    let mut table = SmartTable::default()
    .with_size(790, 590)
    .center_of_parent()
    .with_opts(TableOpts {
        rows: 30,
        cols: 15,
        editable: true,
        ..Default::default()
    });
    
    // the default is false
    table.editable(true);

    wind.end();
    wind.show();

    // Just filling the vec with some values
    for i in 0..30 {
        for j in 0..15 {
            table.set_cell_value(i, j, &(i + j).to_string());
        }
    }

    // set the value at the row,column 4,5 to "another", notice that indices start at 0
    table.set_cell_value(3, 4, "another");

    assert_eq!(table.cell_value(3, 4), "another");

    // To avoid closing the window on hitting the escape key
    wind.set_callback(move |_| {
        if app::event() == enums::Event::Close {
            app.quit();
        }
    });

    app.run().unwrap();
}

You can retrieve a copy of the data using the SmartTable::data() method.

The TableOpts struct also takes styling elements for cells and headers:

let mut table = SmartTable::default(TableOpts {
        rows: 30,
        cols: 15,
        cell_selection_color: Color::Red.inactive(),
        header_frame: FrameType::FlatBox,
        header_color: Color::BackGround.lighter(),
        cell_border_color: Color::White,
        ..Default::default()
    });

image

The row/column header strings can also be changed using the set_row_header_value() and set_col_header_value() methods, which take an index to the required row/column.

Comments
  • SmartTable seems to create a spurious input widget

    SmartTable seems to create a spurious input widget

    I just want a read-only table whose values I can set programmatically. The only user interaction I want is for the user to be able to scroll and double click (or use arrow or page up/down and press space or enter) to choose a row.

    But right now I get the 3 column x 100 row table I want plus an unwanted input widget. How can I get rid of this input widget? charfind.zip The project I'm working on that shows the problem is attached. Thanks!

    opened by mark-summerfield 6
  • Displayed row numbers conventionally start at 1 not 0

    Displayed row numbers conventionally start at 1 not 0

    Although internally we expect row numbers to start at 0, the row numbers displayed by a table conventionally start at 1. This should at least be an option.

    opened by mark-summerfield 3
  • how does one (re)set the size of a cell?

    how does one (re)set the size of a cell?

    creating and populating a smart table is straightforward. However, I do not see any way of setting the size of a cell. I would love a helper method that would reset the size of a cell based on the contents of the cell. And / or a helper method to resize all the cells in a column or whole table to fit their contents. Also some control over padding would be nice.

    Is making the table field public a viable solution?

    opened by jlgerber 3
  • API issues

    API issues

    append_empty_row() accepts a string but what is the string for?

    Suggestions;

    • append(Vec<&str>) -- appends a new row and puts each string into the corresponding colum; should throw an error if the vec's length is != number of columns
    • clear() -- delete all rows & columns in the table (but ideally leaving the headers)
    • row_count() -> usize
    • column_count() -> usize

    Even with the existing API I can't see how to clear a table of all its rows and then append new rows one by one.

    Just to let you know: I now realise I should be using one of the browser widgets for my purpose, so I won't be using the fltk_table, at least not in the application I'm working on now.

    opened by mark-summerfield 2
  • WidgetExt not implemented for SmartTable

    WidgetExt not implemented for SmartTable

    When trying to make the table resizable within a pack, I get the following error:

    the trait bound `SmartTable: fltk::prelude::WidgetExt` is not satisfied
      --> src/main.rs:75:20
       |
    75 |     pack.resizable(&table);
       |          --------- ^^^^^^ the trait `fltk::prelude::WidgetExt` is not implemented for `SmartTable`
       |          |
       |          required by a bound introduced by this call
    

    I see that WidgetExt is implemented for Table and TableRow...

    opened by jlgerber 1
  • Appending a row to an empty table panics

    Appending a row to an empty table panics

    Running the following code panics:

    let mut table = SmartTable::default_fill()
        .with_opts(TableOpts {
            rows: 0,
            cols: 10,
            editable: false,
            ..Default::default()
        });
    table.append_empty_row("");
    

    The problem seems to be that the code tries to determine the number of columns by getting the length of the vector in the first row of the data (data[0].len()) but data is empty in an empty table.

    I can work around it by getting and locking data_ref(), but I thought I should report this anyway.

    opened by vstojkovic 0
  • Possible dead locking when spawning dialogs in the same app

    Possible dead locking when spawning dialogs in the same app

    Hello, I'm trying to change the number of cols and rows at runtime, with:

                    table.set_opts(TableOpts {
                        cell_align: enums::Align::Wrap,
                        editable: false,
                        rows: 55,
                        cols: 66,
                        ..Default::default()
                    });
    
    

    Is there any other way to change those? I've tried with: table.set_rows(55); But, not working.

    opened by realtica 5
  • checkbox + boolean support

    checkbox + boolean support

    I have been playing with this crate and while it is relatively easy to use, I think more data types should be supported.

    In particular booleans should be accepted cell value with a check box or something to toggle.

    From a user perspective, If I were to have a something in a table that can be true or false, it would be better for the user to say click the checkbox and have the program set it to be true.

    However, with the current state of things, with every cell expected to be a string value, I can only simplify things down to Y/N, even though I thought I saw that tables in FLTK can render these properly.

    opened by bryceac 2
Owner
fltk-rs
fltk-rs
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
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
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
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
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
Easy pretty print your Rust struct into single element or table

Easy pretty print your Rust struct into single element or table

Adrien Carreira 4 Oct 1, 2021
Typesafe opinionated abstractions for developing Cairo 1.0 smart contracts

Suna Built with auditless/cairo-template Typesafe opinionated abstractions for developing Cairo 1.0 smart contracts. Originally created to facilitate

Auditless 12 Apr 2, 2023
Listener widget for fltk-rs

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

fltk-rs 7 Dec 30, 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
OBKV Table Client is Rust Library that can be used to access table data from OceanBase storage layer.

OBKV Table Client is Rust Library that can be used to access table data from OceanBase storage layer. Its access method is different from JDBC, it skips the SQL parsing layer, so it has significant performance advantage.

OceanBase 4 Nov 14, 2022
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
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

null 4 Dec 19, 2023
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