From 84e98c0ce9e66b194c5982c841a0fd03e8022047 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 7 Sep 2008 11:22:14 +0000 Subject: modified resize behavior, as discussed in STR 2032. Fl_Group.cxx: resizes itself before changing its children Fl_Scroll.cxx: similar change git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6192 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Group.cxx | 29 ++++++++++++++++------------- src/Fl_Scroll.cxx | 5 +++-- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index c5656e615..43f6d8d07 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -420,8 +420,8 @@ void Fl_Group::remove(Fl_Widget &o) { // sizes array stores the initial positions of widgets as // left,right,top,bottom quads. The first quad is the group, the // second is the resizable (clipped to the group), and the -// rest are the children. This is a convienent order for the -// algorithim. If you change this be sure to fix Fl_Tile which +// rest are the children. This is a convenient order for the +// algorithm. If you change this be sure to fix Fl_Tile which // also uses this array! void Fl_Group::init_sizes() { @@ -463,11 +463,18 @@ int *Fl_Group::sizes() { void Fl_Group::resize(int X, int Y, int W, int H) { - if (!resizable() || W==w() && H==h() ) { + int dx = X-x(); + int dy = Y-y(); + int dw = W-w(); + int dh = H-h(); + + int *p = sizes(); // save initial sizes and positions + + Fl_Widget::resize(X,Y,W,H); // make new xywh values visible for children + + if (!resizable() || dw==0 && dh==0 ) { if (type() < FL_WINDOW) { - int dx = X-x(); - int dy = Y-y(); Fl_Widget*const* a = array(); for (int i=children_; i--;) { Fl_Widget* o = *a++; @@ -477,13 +484,11 @@ void Fl_Group::resize(int X, int Y, int W, int H) { } else if (children_) { - int *p = sizes(); - // get changes in size/position from the initial size: - int dx = X - p[0]; - int dw = W - (p[1]-p[0]); - int dy = Y - p[2]; - int dh = H - (p[3]-p[2]); + dx = X - p[0]; + dw = W - (p[1]-p[0]); + dy = Y - p[2]; + dh = H - (p[3]-p[2]); if (type() >= FL_WINDOW) dx = dy = 0; p += 4; @@ -528,8 +533,6 @@ void Fl_Group::resize(int X, int Y, int W, int H) { o->resize(XX+dx, YY+dy, R-XX, B-YY); } } - - Fl_Widget::resize(X,Y,W,H); } void Fl_Group::draw_children() { diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx index 44661fbb4..701aa2dd3 100644 --- a/src/Fl_Scroll.cxx +++ b/src/Fl_Scroll.cxx @@ -238,6 +238,8 @@ void Fl_Scroll::draw() { void Fl_Scroll::resize(int X, int Y, int W, int H) { int dx = X-x(), dy = Y-y(); + int dw = W-w(), dh = H-h(); + Fl_Widget::resize(X,Y,W,H); // resize _before_ moving children around fix_scrollbar_order(); // move all the children: Fl_Widget*const* a = array(); @@ -245,7 +247,7 @@ void Fl_Scroll::resize(int X, int Y, int W, int H) { Fl_Object* o = *a++; o->position(o->x()+dx, o->y()+dy); } - if (w()==W && h()==H) { + if (dw==0 && dh==0) { char pad = (scrollbar.visible() && hscrollbar.visible()); char al = (scrollbar.align()&FL_ALIGN_LEFT!=0); char at = (scrollbar.align()&FL_ALIGN_TOP!=0); @@ -255,7 +257,6 @@ void Fl_Scroll::resize(int X, int Y, int W, int H) { // FIXME recalculation of scrollbars needs to be moved out fo "draw()" (STR #1895) redraw(); // need full recalculation of scrollbars } - Fl_Widget::resize(X,Y,W,H); } void Fl_Scroll::scroll_to(int X, int Y) { -- cgit v1.2.3