FLTK logo

[fltk.general] Scrollable Table Not Rendering Child Widgets Correctly

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Scrollable Table Not Rendering Child Widgets Correctly Webb Hinton Jun 11, 2021  
  Hello all,

I'm experiencing an issue when using the table widget. If you add enough widgets to make the table widget turn into a scrollable table, then it seems like the buttons do not render correctly. When you push on a button in the table, the button seems to redraw in the correct location. 

Steps to reproduce:
  • Create a Table Widget
  • Put enough buttons in it to make the scroll bars appear 
  • Click on the buttons in the table
I cant' tell if this is a bug, or just the way FLTK works, like I need to tell the Table to draw the widget in a certain way or something like that. 

Here's the rust code, so you can see that I'm not doing anything especially abnormal to create this effect:

use fltk::{prelude::*, *, image::*};

fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gtk);
    let mut wind = window::Window::default().with_size(402, 275);
    let mut table = table::Table::default().size_of(&wind);

    table.set_rows(8);
    table.set_cols(5);
    table.set_row_height_all(90);
    table.set_col_width_all(80);

    table.end();

    let mut img = SvgImage::load("search-24px.svg").unwrap();

    table.draw_cell(move |t, ctx, row, col, x, y, w, h| {
        if let table::TableContext::Cell = ctx {
            img.scale(w, h - 20, true, false);
            let mut button = button::Button::new(x, y, w, h, None);
            button.set_label(&format!("Image {}", row + col));
            button.set_align(enums::Align::Bottom | enums::Align::Inside);
            button.set_frame(enums::FrameType::FlatBox);
            button.set_image(Some(img.clone()));
            button.set_callback(|b| println!("Selected: {}", b.label()));
            t.add(&button);
        }
    });

    wind.make_resizable(true);
    wind.end();
    wind.show();

    while table.children() == 0 {
        app::wait();
    }

    app::redraw();

    app.run().unwrap();
}


custom_event_issue_1.gif

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/600a6d97-452e-4529-ad5f-88aeafea3b60n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.