summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Fl_Tile.cxx58
1 files changed, 49 insertions, 9 deletions
diff --git a/src/Fl_Tile.cxx b/src/Fl_Tile.cxx
index 5fc015e62..a8f24e67e 100644
--- a/src/Fl_Tile.cxx
+++ b/src/Fl_Tile.cxx
@@ -565,19 +565,59 @@ void Fl_Tile::drag_intersection(int oldx, int oldy, int newx, int newy) {
void Fl_Tile::resize(int X,int Y,int W,int H) {
if (size_range_) {
- int dw = w() - W, dh = h() - H;
- Fl_Widget *r = resizable();
- if (r) {
- int rr = r->x() + r->w(), rb = r->y() + r->h();
- move_intersection(rr, rb, rr-dw, rb-dh);
+ // -- handle size_range style resizing
+ int dx = X - x();
+ int dy = Y - y();
+ int dw = w() - W;
+ int dh = h() - H;
+ // -- if the size does not change, Group resize will suffice
+ if ((dw==0) && (dh==0)) {
+ Fl_Group::resize(X, Y, W, H);
+ init_sizes();
+ redraw();
+ return;
}
- int tr = x() + w(), tb = y() + h();
- move_intersection(tr, tb, tr-dw, tb-dh);
+ // -- if the position changes, move all widgets first
+ if ((dx!=0) || (dy!=0)) {
+ for (int i = 0; i < children(); i++) {
+ Fl_Widget *c = child(i);
+ c->position(c->x()+dx, c->y()+dy);
+ }
+ }
+ // check the bounding box of all children at minimum size
init_sizes();
+ Fl_Rect *p = bounds();
+ int bbr = X, bbb = Y;
+ for (int i = 0; i < children(); i++) {
+ // find the current bounding box
+ bbr = fl_max(bbr, p[i+2].r());
+ bbb = fl_max(bbb, p[i+2].b());
+ }
+ // fix the dw to the maximum difference possible
+ int r2 = X+W;
+ request_shrink_r(bbr, r2, NULL);
+ dw = bbr - r2;
+ // fix the dh to the maximum difference possible
+ int b2 = Y+H;
+ request_shrink_b(bbb, b2, NULL);
+ dh = bbb - b2;
+ printf("%d %d %d %d %d %d\n", X, Y, W, H, dw, dh);
+ // perform the actual resize within a safe range
+ if ((dw!=0) || (dh!=0)) {
+ Fl_Widget *r = resizable();
+ if (r) {
+ int rr = r->x() + r->w(), rb = r->y() + r->h();
+ move_intersection(rr, rb, rr-dw, rb-dh);
+ }
+ int tr = x() + w(), tb = y() + h();
+ move_intersection(bbr, bbb, bbr-dw, bbb-dh);
+ init_sizes();
+ }
+ // resize the tile itself
if (Fl_Window::is_a_rescale())
- Fl_Group::resize(X,Y,W,H);
+ Fl_Group::resize(X, Y, W, H);
else
- Fl_Widget::resize(X,Y,W,H);
+ Fl_Widget::resize(X, Y, W, H);
return;
}