summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-11-03 18:53:18 +0100
committerMatthias Melcher <github@matthiasm.com>2024-11-03 18:53:18 +0100
commit5ac570c338942e5363ac2c19e3b1abeaf736b19c (patch)
tree5620f6f2d88cfb5e0fc330ded34943d312a7726b
parent6f6a375fcae95d044df0a4fb68c39f8e1ee50ef3 (diff)
Fixes Fl_Tile resizing for "sudden" size changes: #1102
Enlarging and reducing wdth and height needed to be treated seprately when the bottom right corner of the resizable would overshoot the final size of the tile.
-rw-r--r--src/Fl_Tile.cxx29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/Fl_Tile.cxx b/src/Fl_Tile.cxx
index 142b286bb..0eb7e0a70 100644
--- a/src/Fl_Tile.cxx
+++ b/src/Fl_Tile.cxx
@@ -585,7 +585,7 @@ void Fl_Tile::resize(int X,int Y,int W,int H) {
c->position(c->x()+dx, c->y()+dy);
}
}
- // check the bounding box of all children at minimum size
+ // check the current bounding box of all children
init_sizes();
Fl_Rect *p = bounds();
int bbr = X, bbb = Y;
@@ -605,11 +605,34 @@ void Fl_Tile::resize(int X,int Y,int W,int H) {
// perform the actual resize within a safe range
if ((dw!=0) || (dh!=0)) {
Fl_Widget *r = resizable();
+ // Find the target right and bottom position of the resizable child.
+ int trr = 0, trb = 0;
+ if (r) {
+ trr = r->x() + r->w() - dw;
+ trb = r->y() + r->h() - dh;
+ }
+ // Grow width and/or height of tile and adjust all children as needed.
+ if ((dw < 0) && (dh < 0)) {
+ move_intersection(bbr, bbb, bbr-dw, bbb-dh);
+ } else if (dw < 0) {
+ move_intersection(bbr, bbb, bbr-dw, bbb);
+ } else if (dh < 0) {
+ move_intersection(bbr, bbb, bbr, bbb-dh);
+ }
+ // Fix the resizable child, trying to keep its size plus all other
+ // widgets within their limits.
if (r) {
int rr = r->x() + r->w(), rb = r->y() + r->h();
- move_intersection(rr, rb, rr-dw, rb-dh);
+ move_intersection(rr, rb, trr, trb);
+ }
+ // Shrink width and/or height of tile and adjust all children as needed.
+ if ((dw > 0) && (dh > 0)) {
+ move_intersection(bbr, bbb, bbr-dw, bbb-dh);
+ } else if (dw > 0) {
+ move_intersection(bbr, bbb, bbr-dw, bbb);
+ } else if (dh > 0) {
+ move_intersection(bbr, bbb, bbr, bbb-dh);
}
- move_intersection(bbr, bbb, bbr-dw, bbb-dh);
init_sizes();
}
// resize the tile itself