aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2011-03-09 14:18:58 -0300
committerJorge Arellano Cid <jcid@dillo.org>2011-03-09 14:18:58 -0300
commitf8ec6ac86bcc3b9edda3b5edc30d436c3dae839a (patch)
tree1a0951c1baf7ae38edd3437811f210643eada1b9
parent8edebf4f7e3775f3242ac257741c3fc1510f2d79 (diff)
Added CustGroup class (it repositions child widgets when others are hidden)
-rw-r--r--src/ui.cc59
-rw-r--r--src/ui.hh76
2 files changed, 86 insertions, 49 deletions
diff --git a/src/ui.cc b/src/ui.cc
index 25f1fb01..bee1d937 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -81,43 +81,6 @@ static struct iconset *icons = &standard_icons;
*/
//----------------------------------------------------------------------------
-/*
- * Used to reposition group's widgets when some of them are hidden
- */
-class Fl_CustGroup : public Fl_Group {
-public:
- Fl_CustGroup(int x,int y,int w ,int h,const char *l = 0) :
- Fl_Group(x,y,w,h,l) { };
- void rearrange(void) {
- int n = children(), xpos = 0, r_x1, r_i = -1, i;
-
- init_sizes();
- for (i = 0; i < n; ++i) {
- if (child(i) == resizable()) {
- r_i = i;
- r_x1 = xpos;
- break;
- }
- if (child(i)->visible()) {
- child(i)->position(xpos, child(i)->y());
- xpos += child(i)->w();
- }
- }
- if (r_i < 0)
- return;
- xpos = w();
- for (i = n - 1; i > r_i; --i) {
- if (child(i)->visible()) {
- xpos -= child(i)->w();
- child(i)->position(xpos, child(i)->y());
- }
- }
- child(r_i)->resize(r_x1, child(r_i)->y(), xpos-r_x1, child(r_i)->h());
- redraw();
- }
-};
-
-//----------------------------------------------------------------------------
/*
* (Used to avoid certain shortcuts in the location bar)
@@ -419,14 +382,13 @@ static void bugmeter_cb(Fl_Widget *wid, void *data)
/*
* Make a generic navigation button
*/
-Fl_Button *UI::make_button(const char *label,
- Fl_Image *img, Fl_Image *deimg,
+Fl_Button *UI::make_button(const char *label, Fl_Image *img, Fl_Image *deimg,
int b_n, int start)
{
if (start)
p_xpos = 0;
- Fl_Button *b = new Fl_Button(p_xpos, p_ypos, bw, bh, (lbl) ? label : NULL);
+ Fl_Button *b = new Fl_Button(p_xpos, 0, bw, bh, (lbl) ? label : NULL);
if (img)
b->image(img);
if (deimg)
@@ -563,7 +525,7 @@ Fl_Widget *UI::make_filemenu_button()
void UI::make_panel(int ww)
{
Fl_Widget *w;
- Fl_CustGroup *g1;
+ CustGroup *g1;
Fl_Group *g2, *g3;
Fl_Pack *pg;
@@ -600,9 +562,10 @@ void UI::make_panel(int ww)
else
bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1;
}
+ nh = bh, sh = 24;
if (PanelSize == P_tiny) {
- g1 = new Fl_CustGroup(0,0,ww,bh);
+ g1 = new CustGroup(0,0,ww,bh);
// Toolbar
make_toolbar(ww,bh);
make_filemenu_button();
@@ -625,7 +588,8 @@ void UI::make_panel(int ww)
//pg = make_location();
pg->size(ww,lh);
} else {
- g2 = new Fl_CustGroup(0,0,ww,lh);
+ g2 = new CustGroup(0,0,ww,lh);
+ p_xpos = 0;
make_filemenu_button();
make_location(ww);
g2->resizable(Location);
@@ -633,13 +597,11 @@ void UI::make_panel(int ww)
}
// Toolbar
- //p_ypos += g2->y();
p_ypos = 0;
- //g3 = new Fl_Group(0,fh+lh,ww,bh);
- g3 = new Fl_Group(0,p_ypos,ww,bh);
+ g3 = new CustGroup(0,0,ww,bh);
g3->begin();
make_toolbar(ww,bh);
- w = new Fl_Box(p_xpos,p_ypos,ww-p_xpos-2*pw,bh,"i n v i s i b l e");
+ w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh,"i n v i s i b l e");
w->box(FL_THIN_UP_BOX);
g3->resizable(w);
p_xpos = ww - 2*pw;
@@ -719,7 +681,8 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) :
make_panel(ww);
// Render area
- Main = new Fl_Group(0,50,ww,wh-70,"Welcome...");
+ int mh = wh - (lh+bh+sh);
+ Main = new Fl_Group(0,0,0,mh,"Welcome...");
Main->box(FL_FLAT_BOX);
Main->color(FL_GRAY_RAMP + 3);
Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
diff --git a/src/ui.hh b/src/ui.hh
index 64251e6a..b2c69f8e 100644
--- a/src/ui.hh
+++ b/src/ui.hh
@@ -37,6 +37,80 @@ typedef enum {
class CustProgressBox;
class CustTabGroup;
+
+// Class definition ----------------------------------------------------------
+/*
+ * Used to reposition group's widgets when some of them are hidden
+ */
+class CustGroup : public Fl_Group {
+public:
+ CustGroup(int x,int y,int w ,int h,const char *l = 0) :
+ Fl_Group(x,y,w,h,l) { };
+ void rearrange(void) {
+ int n = children(), xpos = 0, r_x1, r_i = -1, i;
+
+ init_sizes();
+ for (i = 0; i < n; ++i) {
+ if (child(i) == resizable()) {
+ r_i = i;
+ r_x1 = xpos;
+ break;
+ }
+ if (child(i)->visible()) {
+ child(i)->position(xpos, child(i)->y());
+ xpos += child(i)->w();
+ }
+ }
+ if (r_i < 0)
+ return;
+ xpos = w();
+ for (i = n - 1; i > r_i; --i) {
+ if (child(i)->visible()) {
+ xpos -= child(i)->w();
+ child(i)->position(xpos, child(i)->y());
+ }
+ }
+ child(r_i)->resize(r_x1, child(r_i)->y(), xpos-r_x1, child(r_i)->h());
+ redraw();
+ }
+ void rearrange_y(void) {
+ int n = children(), pos = 0, r_pos, r_i = -1, i;
+
+ printf("children = %d\n", n);
+ init_sizes();
+ for (i = 0; i < n; ++i) {
+ if (child(i) == resizable()) {
+ r_i = i;
+ r_pos = pos;
+ break;
+ }
+ if (child(i)->visible()) {
+ printf("child[%d] x=%d y=%d w=%d h=%d\n",
+ i, child(i)->x(), pos, child(i)->w(), child(i)->h());
+ child(i)->position(child(i)->x(), pos);
+ pos += child(i)->h();
+ }
+ }
+ if (r_i < 0)
+ return;
+ pos = h();
+ for (i = n - 1; i > r_i; --i) {
+ if (child(i)->visible()) {
+ pos -= child(i)->h();
+ printf("child[%d] x=%d y=%d w=%d h=%d\n",
+ i, child(i)->x(), pos, child(i)->w(), child(i)->h());
+ child(i)->position(child(i)->x(), pos);
+ }
+ }
+ child(r_i)->resize(child(r_i)->x(), r_pos, child(r_i)->w(), pos-r_pos);
+ printf("resizable child[%d] x=%d y=%d w=%d h=%d\n",
+ r_i, child(r_i)->x(), r_pos, child(r_i)->w(), child(r_i)->h());
+ child(r_i)->hide();
+ redraw();
+ }
+};
+
+
//
// UI class definition -------------------------------------------------------
//
@@ -56,7 +130,7 @@ class UI : public Fl_Pack {
int MainIdx;
// Panel customization variables
int PanelSize, CuteColor, Small_Icons;
- int p_xpos, p_ypos, bw, bh, fh, lh, pw, lbl;
+ int p_xpos, p_ypos, bw, bh, fh, lh, nh, sh, pw, lbl;
UIPanelmode Panelmode;
Findbar *findbar;