Skip to content

Commit

Permalink
modified resize behavior, as discussed in STR 2032.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Albrecht Schlosser committed Sep 7, 2008
1 parent 2ca9888 commit 84e98c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
29 changes: 16 additions & 13 deletions src/Fl_Group.cxx
Expand Up @@ -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() {
Expand Down Expand Up @@ -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++;
Expand All @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 3 additions & 2 deletions src/Fl_Scroll.cxx
Expand Up @@ -238,14 +238,16 @@ 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();
for (int i=children()-2; i--;) {
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);
Expand All @@ -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) {
Expand Down

0 comments on commit 84e98c0

Please sign in to comment.