[patch] resize progress indicators dynamically
Hello, this patch resizes the progress indicators as needed. I don't like the constant "+ 4". Any ideas? Regards, Johannes diff -r 0a8a112b8e48 src/ui.cc --- a/src/ui.cc Mon Dec 17 14:07:38 2007 +0100 +++ b/src/ui.cc Mon Dec 17 19:33:53 2007 +0100 @@ -409,18 +409,24 @@ PackedGroup *UI::make_location() */ PackedGroup *UI::make_progress_bars(int wide, int thin_up) { + int width, height; + ProgBox = new PackedGroup(0,0,0,0); ProgBox->begin(); // Images - IProg = new InvisibleBox(0,0,pr_w,0, + IProg = new InvisibleBox(0,0,0,0, wide ? "Images\n0 of 0" : "0 of 0"); IProg->box(thin_up ? THIN_UP_BOX : EMBOSSED_BOX); IProg->labelcolor(GRAY10); + IProg->measure_label(width, height); + IProg->resize(width + 4, height + 4); // Page - PProg = new InvisibleBox(0,0,pr_w,0, + PProg = new InvisibleBox(0,0,0,0, wide ? "Page\n0.0KB" : "0.0KB"); PProg->box(thin_up ? THIN_UP_BOX : EMBOSSED_BOX); PProg->labelcolor(GRAY10); + PProg->measure_label(width, height); + PProg->resize(width + 4, height + 4); ProgBox->type(PackedGroup::ALL_CHILDREN_VERTICAL); ProgBox->end(); @@ -471,24 +477,24 @@ Group *UI::make_panel(int ww) if (PanelSize == P_tiny) { if (Small_Icons) - xpos = 0, bw = 22, bh = 22, fh = 0, lh = 22, lbl = 0, pr_w = 45; + xpos = 0, bw = 22, bh = 22, fh = 0, lh = 22, lbl = 0; else - xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0, pr_w = 45; + xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0; } else if (PanelSize == P_small) { if (Small_Icons) - xpos = 0, bw = 20, bh = 20, fh = 0, lh = 20, lbl = 0, pr_w = 45; + xpos = 0, bw = 20, bh = 20, fh = 0, lh = 20, lbl = 0; else - xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0, pr_w = 45; + xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0; } else if (PanelSize == P_medium) { if (Small_Icons) - xpos = 0, bw = 42, bh = 36, fh = 0, lh = 22, lbl = 1, pr_w = 60; + xpos = 0, bw = 42, bh = 36, fh = 0, lh = 22, lbl = 1; else - xpos = 0, bw = 45, bh = 45, fh = 0, lh = 28, lbl = 1, pr_w = 60; + xpos = 0, bw = 45, bh = 45, fh = 0, lh = 28, lbl = 1; } else { // P_large if (Small_Icons) - xpos = 0, bw = 42, bh = 36, fh = 22, lh = 22, lbl = 1, pr_w = 60; + xpos = 0, bw = 42, bh = 36, fh = 22, lh = 22, lbl = 1; else - xpos = 0, bw = 45, bh = 45, fh = 28, lh = 28, lbl = 1, pr_w = 60; + xpos = 0, bw = 45, bh = 45, fh = 28, lh = 28, lbl = 1; } if (PanelSize == P_tiny) { @@ -767,6 +773,7 @@ void UI::set_page_prog(size_t nbytes, in void UI::set_page_prog(size_t nbytes, int cmd) { char str[32]; + int width, height; if (cmd == 0) { PProg->deactivate(); @@ -779,6 +786,8 @@ void UI::set_page_prog(size_t nbytes, in str[0] = '\0'; } PProg->copy_label(str); + PProg->measure_label(width, height); + PProg->resize(width + 4, height + 4); PProg->redraw_label(); } } @@ -790,6 +799,7 @@ void UI::set_img_prog(int n_img, int t_i void UI::set_img_prog(int n_img, int t_img, int cmd) { char str[32]; + int width, height; if (cmd == 0) { IProg->deactivate(); @@ -802,6 +812,8 @@ void UI::set_img_prog(int n_img, int t_i str[0] = '\0'; } IProg->copy_label(str); + IProg->measure_label(width, height); + IProg->resize(width + 4, height + 4); IProg->redraw_label(); } } diff -r 0a8a112b8e48 src/ui.hh --- a/src/ui.hh Mon Dec 17 14:07:38 2007 +0100 +++ b/src/ui.hh Mon Dec 17 19:33:53 2007 +0100 @@ -48,7 +48,7 @@ class UI : public fltk::Window { int MainIdx; // Panel customization variables int PanelSize, CuteColor, Small_Icons; - int xpos, bw, bh, fh, lh, lbl, pr_w; + int xpos, bw, bh, fh, lh, lbl; // TODO: Hack for fullscreen mode int Panel_h, Status_h;
On Mon, Dec 17, 2007 at 07:37:58PM +0100, Johannes Hofmann wrote:
Hello,
this patch resizes the progress indicators as needed. I don't like the constant "+ 4". Any ideas?
Yes, I committed a modified version that handles padding by subclassing InvisibleBox. -- Cheers Jorge.-
On Tue, Dec 18, 2007 at 10:28:37PM -0300, Jorge Arellano Cid wrote:
On Mon, Dec 17, 2007 at 07:37:58PM +0100, Johannes Hofmann wrote:
Hello,
this patch resizes the progress indicators as needed. I don't like the constant "+ 4". Any ideas?
Yes, I committed a modified version that handles padding by subclassing InvisibleBox.
Great! That's much cleaner. BTW why did you call it NewProgressBox instead of just ProgressBox? Cheers, Johannes
-- Cheers Jorge.-
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
On Wed, Dec 19, 2007 at 05:01:45PM +0100, Johannes Hofmann wrote:
On Tue, Dec 18, 2007 at 10:28:37PM -0300, Jorge Arellano Cid wrote:
On Mon, Dec 17, 2007 at 07:37:58PM +0100, Johannes Hofmann wrote:
Hello,
this patch resizes the progress indicators as needed. I don't like the constant "+ 4". Any ideas?
Yes, I committed a modified version that handles padding by subclassing InvisibleBox.
Great! That's much cleaner. BTW why did you call it NewProgressBox instead of just ProgressBox?
Modified widgets in UI are using the "New" prefix. This helps to tell from a native FLTK widget. This is not written in stone though! -- Cheers Jorge.-
participants (2)
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de