Fix ctrl/+/- in cube demo

- Fl_Grid: force layout() on resize() - needed for GL subwindows

- test/cube.cxx:
  - use end() in constructor of class cube_box
  - ensure not to change the current group when adding a button
This commit is contained in:
Albrecht Schlosser 2023-10-19 20:16:01 +02:00
parent 143a18ee11
commit 757b5c1227
2 changed files with 7 additions and 3 deletions

View File

@ -587,7 +587,7 @@ void Fl_Grid::remove_cell(int row, int col) {
void Fl_Grid::resize(int X, int Y, int W, int H) {
old_size = Fl_Rect(x(), y(), w(), h());
Fl_Widget::resize(X, Y, W, H);
need_layout(1);
layout();
}
/**

View File

@ -53,6 +53,7 @@ public:
double size;
double speed;
cube_box(int x,int y,int w,int h,const char *l=0) : Fl_Gl_Window(x,y,w,h,l) {
end();
lasttime = 0.0;
box(FL_DOWN_FRAME);
}
@ -138,13 +139,16 @@ void show_info_cb(Fl_Widget*, void*) {
}
// overlay a button onto an OpenGL window (cube_box)
// but don't change the current group Fl_Group::current()
void overlay_button(cube_box *cube) {
cube->begin();
Fl_Group *curr = Fl_Group::current();
Fl_Group::current(0);
Fl_Widget *w = new Fl_Button(10, 10, 120, 30, "FLTK over GL");
w->color(FL_FREE_COLOR);
w->box(FL_BORDER_BOX);
w->callback(show_info_cb);
cube->end();
cube->add(w);
Fl_Group::current(curr);
}
#endif // HAVE_GL