fltk-rs / fltk-table

A smart table widget for fltk-rs
MIT License
16 stars 4 forks source link

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

Closed jlgerber closed 2 years ago

jlgerber commented 2 years ago

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?

MoAlyousef commented 2 years ago

Regarding exposing the table field, fltk_table::SmartTable basically auto derefs into an fltk::table::Table. You just have to import the TableExt trait and you can use any of the table methods.

use fltk::prelude::TableExt;
let mut table = fltk_table::SmartTable::default();
table.set_col_width_all(200); // or table.set_col_width(some_column, 200);

I'm not sure what you mean by padding? Do you mean between cells? I don't think FLTK supports that.

jlgerber commented 2 years ago

Yes. I just noticed the Deref and DerefMut impls. I should have looked first. Sorry for the noise.

By padding I mean padding in the "box model" sense. I guess I should look into adding the request to the c++ project. Layout is the one area where FLTK shows its age. However, it looks like this may get addressed somewhat in 1.4

On an unrelated note, I worked at Digital Domain for years, where FLTK was written for Nuke, so I am quite amused by the fact that I am now writing FLTK code for Rust. What's old is new again, as they say...

Thank you for all of the work on the Rust port. Rust really needs a good GUI toolkit, and this is one of the most reliable ones available.

MoAlyousef commented 2 years ago

Thank you. That’s nice to hear :)