use fltk::{app, draw::*, enums::*, frame::Frame, group::Group, prelude::*, window::Window, button::*};
fn main() {
let app = app::App::default();
let mut wind = Window::default()
.with_size(400, 300)
.with_label("Group Background Color");
wind.make_resizable(true);
let mut group = Group::new(0, 0, 400, 300, None);
let mut button= Button::new(100,200,50,20,"animate");
//frame we want to see
let mut frame = Frame::new(0, 0, 100, 100, "redraw parent");
frame.set_color(Color::Magenta);
frame.set_frame(FrameType::BorderFrame);
group.end();
// group.draw(move |widg| {
// //background fill
// draw_rect_fill(widg.x(), widg.y(), widg.width(), widg.height(), Color::Red);
// //draw the children after drawing the background fill color
// widg.draw_children();
// });
wind.end();
wind.show();
button.set_callback(move |_| {
let mut frame = frame.clone();
std::thread::spawn(move || {
for i in 0..1000 {
app::sleep(0.05);
frame.resize(frame.x()+10, frame.y(), frame.width(), frame.height());
dbg!(frame.x(), frame.y(), frame.width(), frame.height());
//Only Redraws the Widget, frame does not show
// frame.redraw();
//Redraws as expected, but redraws all children
frame.parent().unwrap().redraw();
dbg!("thread working!");
}
});
});
app.run().unwrap();
}