diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-02-23 18:51:57 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-02-23 19:21:26 +0100 |
| commit | f288aea10a5691f7fbf12609e22e07b10581fdce (patch) | |
| tree | c1b9f17608b71316c98ec636e2898fb881dd03b1 | |
| parent | a6dc84ac833a8d4ecd7f9369700d3e00334c5df2 (diff) | |
Fix Fl_Group::resize() for groups w/o resizable() (#917)
Improve code comments to clarify which cases are handled in a code
block and why this is done. Subwindows have some special needs.
| -rw-r--r-- | src/Fl_Group.cxx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index c9240fee0..5232f6eaa 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -1,7 +1,7 @@ // // Group widget for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2022 by Bill Spitzak and others. +// Copyright 1998-2024 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -831,17 +831,31 @@ void Fl_Group::resize(int X, int Y, int W, int H) { Fl_Widget::resize(X, Y, W, H); // make new xywh values visible for children - if ((!resizable() || (dw==0 && dh==0 )) && !Fl_Window::is_a_rescale()) { + // Part 1: no resizable() or both width and height didn't change, + // just move the children. + // This case covers also window rescaling where dw == dh == 0. - if (!as_window()) { + if (!resizable() || (dw==0 && dh==0)) { + + if (as_window() && !parent()) // top window + dx = dy = 0; + + // Check if there's anything to do, otherwise don't call resize(). + // Note that subwindows require resize() even if their relative position + // didn't change, at least on macOS, if it's a rescale. + + if (Fl_Window::is_a_rescale() || dx || dy) { Fl_Widget*const* a = array(); - for (int i=children_; i--;) { + for (int i = children_; i--;) { Fl_Widget* o = *a++; o->resize(o->x() + dx, o->y() + dy, o->w(), o->h()); } } + } // End of part 1 + + // Part 2: here we definitely have a resizable() widget, resize children - } else if (children_) { + else if (children_) { // get changes in size/position from the initial size: dx = X - p->x(); @@ -890,7 +904,7 @@ void Fl_Group::resize(int X, int Y, int W, int H) { o->resize(L+dx, T+dy, R-L, B-T); } - } + } // End of part 2: we have a resizable() widget } /** |
