From aa00aba5c19aa87922d12cc6664a78aa7ff56b85 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 6 Apr 2004 18:32:52 +0000 Subject: [PATCH] FLUID's Layout functionality did not move child widgets when laying out group widgets (STR #319) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3301 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 + fluid/Fl_Type.h | 7 ++- fluid/align_widget.cxx | 110 +++++++++++++++++++++++++++++++++++------ 3 files changed, 102 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index 7ffcde77f..be2dc10ab 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.5rc1 - Documentation updates (STR #245, STR #250, STR #277, STR #281, STR #328, STR #338) + - FLUID's Layout functionality did not move child + widgets when laying out group widgets (STR #319) - FLUID's Layout->Center In Group functionality did not properly handle widgets that were children of a Fl_Window widget (STR #318) diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 30a898608..ee119660b 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -1,5 +1,5 @@ // -// "$Id: Fl_Type.h,v 1.5.2.11.2.11 2004/03/11 05:17:11 easysw Exp $" +// "$Id: Fl_Type.h,v 1.5.2.11.2.12 2004/04/06 18:32:52 easysw Exp $" // // Widget type header file for the Fast Light Tool Kit (FLTK). // @@ -315,18 +315,21 @@ public: class igroup : public Fl_Group { public: void resize(int,int,int,int); + void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); } igroup(int X,int Y,int W,int H) : Fl_Group(X,Y,W,H) {Fl_Group::current(0);} }; class itabs : public Fl_Tabs { public: void resize(int,int,int,int); + void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); } itabs(int X,int Y,int W,int H) : Fl_Tabs(X,Y,W,H) {} }; class iwizard : public Fl_Wizard { public: void resize(int,int,int,int); + void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); } iwizard(int X,int Y,int W,int H) : Fl_Wizard(X,Y,W,H) {} }; @@ -596,5 +599,5 @@ int storestring(const char *n, const char * & p, int nostrip=0); extern int include_H_from_C; // -// End of "$Id: Fl_Type.h,v 1.5.2.11.2.11 2004/03/11 05:17:11 easysw Exp $". +// End of "$Id: Fl_Type.h,v 1.5.2.11.2.12 2004/04/06 18:32:52 easysw Exp $". // diff --git a/fluid/align_widget.cxx b/fluid/align_widget.cxx index ad5544610..dcadf1410 100644 --- a/fluid/align_widget.cxx +++ b/fluid/align_widget.cxx @@ -1,5 +1,5 @@ // -// "$Id: align_widget.cxx,v 1.1.2.5 2004/04/06 17:38:36 easysw Exp $" +// "$Id: align_widget.cxx,v 1.1.2.6 2004/04/06 18:32:52 easysw Exp $" // // alignment code for the Fast Light Tool Kit (FLTK). // @@ -57,7 +57,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize(left, w->y(), w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(left, w->y(), w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(left, w->y(), w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -81,7 +87,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize((center2-w->w())/2, w->y(), w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize((center2-w->w())/2, w->y(), w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize((center2-w->w())/2, w->y(), w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -102,7 +114,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize(right-w->w(), w->y(), w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(right-w->w(), w->y(), w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(right-w->w(), w->y(), w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -122,7 +140,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize(w->x(), top, w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(w->x(), top, w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(w->x(), top, w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -146,7 +170,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize(w->x(), (center2-w->h())/2, w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(w->x(), (center2-w->h())/2, w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(w->x(), (center2-w->h())/2, w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -167,7 +197,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize( w->x(), bot-w->h(), w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize( w->x(), bot-w->h(), w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize( w->x(), bot-w->h(), w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -195,7 +231,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); cnt++; @@ -225,7 +267,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); cnt++; @@ -249,7 +297,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize( w->x(), w->y(), wdt, w->h()); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(w->x(), w->y(), wdt, w->h()); + } else { + // Otherwise, just do the widget... + w->resize(w->x(), w->y(), wdt, w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -269,7 +323,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize( w->x(), w->y(), w->w(), hgt); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize( w->x(), w->y(), w->w(), hgt); + } else { + // Otherwise, just do the widget... + w->resize( w->x(), w->y(), w->w(), hgt); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -291,7 +351,13 @@ void align_widget_cb(Fl_Widget*, long how) if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; - w->resize( w->x(), w->y(), wdt, hgt); + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize( w->x(), w->y(), wdt, hgt); + } else { + // Otherwise, just do the widget... + w->resize( w->x(), w->y(), wdt, hgt); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -307,7 +373,14 @@ void align_widget_cb(Fl_Widget*, long how) if (w->window() == p) center2 = p->w(); else center2 = 2*p->x()+p->w(); - w->resize((center2-w->w())/2, w->y(), w->w(), w->h()); + + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize((center2-w->w())/2, w->y(), w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize((center2-w->w())/2, w->y(), w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -322,7 +395,14 @@ void align_widget_cb(Fl_Widget*, long how) if (w->window() == p) center2 = p->h(); else center2 = 2*p->y()+p->h(); - w->resize(w->x(), (center2-w->h())/2, w->w(), w->h()); + + if (o->next && o->next->level > o->level && !o->next->selected) { + // When resizing a group, make sure we also move the children... + ((igroup *)w)->full_resize(w->x(), (center2-w->h())/2, w->w(), w->h()); + } else { + // Otherwise, just do the widget... + w->resize(w->x(), (center2-w->h())/2, w->w(), w->h()); + } w->redraw(); if (w->window()) w->window()->redraw(); } @@ -332,6 +412,6 @@ void align_widget_cb(Fl_Widget*, long how) // -// End of "$Id: align_widget.cxx,v 1.1.2.5 2004/04/06 17:38:36 easysw Exp $". +// End of "$Id: align_widget.cxx,v 1.1.2.6 2004/04/06 18:32:52 easysw Exp $". //