6 releases

0.2.0 Mar 18, 2023
0.1.4 Sep 24, 2022
0.1.3 Apr 11, 2022
0.1.2 Mar 28, 2022

#30 in #widgets

Download history 31/week @ 2022-12-08 10/week @ 2022-12-15 19/week @ 2022-12-22 13/week @ 2022-12-29 12/week @ 2023-01-05 12/week @ 2023-01-12 17/week @ 2023-01-19 14/week @ 2023-01-26 26/week @ 2023-02-02 20/week @ 2023-02-09 40/week @ 2023-02-16 19/week @ 2023-02-23 12/week @ 2023-03-02 11/week @ 2023-03-09 26/week @ 2023-03-16 19/week @ 2023-03-23

69 downloads per month

MIT license

9KB
133 lines

fltk-grid

A grid widget for fltk-rs.

Usage

[dependencies]
fltk = "1.3"
fltk-grid = "0.2"

Basically, the crate contains a single type Grid which has 4 main non-constructor methods:

  • set_layout(): specifies the number of rows and columns of the grid.
  • insert(): specifies the widget to be inserted, along with in which cell (row, column). The values can be a range (0..1).
  • insert_ext(): adds to insert the row span and column span.
  • resize(): determines how the grid is resized.
  • debug(): shows the cell outline and their numbering, useful for prototyping.
use fltk::{prelude::*, *};
use fltk_grid::Grid;

fn main() {
    let a = app::App::default().with_scheme(app::Scheme::Gtk);
    let mut win = window::Window::default().with_size(500, 300);
    let mut grid = Grid::default_fill();
    grid.debug(false); // set to true to show cell outlines and numbers
    grid.set_layout(5, 5); // 5 rows, 5 columns
    grid.insert(&mut button::Button::default(), 0, 1); // widget, row, col
    grid.insert(&mut button::Button::default(), 2..3, 1..4); // widget, row range, col range
    // or
    // grid.insert_ext(&mut button::Button::default(), 2, 1, 3, 1); // widget, row, col, row_span, col_span
    win.end();
    win.show();
    a.run().unwrap();
}

Example

Run cargo run --example form

image

Setting Grid::debug(true):

image

Dependencies

~12MB
~278K SLoC