Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        progress.c 


Log Message:
Progressbars - Simplify, increase height to fit text, if needed.

===================================================================
RCS file: /cvs/e/e16/e/src/progress.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- progress.c  26 Nov 2006 11:11:14 -0000      1.37
+++ progress.c  3 Dec 2006 14:33:50 -0000       1.38
@@ -34,7 +34,7 @@
    EObj               *p_win;
    int                 w, h;
    int                 value;
-   ImageClass         *ic, *inc, *ipc;
+   ImageClass         *ic;
    TextClass          *tc, *tnc;
 };
 
@@ -45,13 +45,31 @@
 ProgressbarCreate(const char *name, int w, int h)
 {
    Progressbar        *p;
-   int                 x, y;
+   int                 x, y, tw, th;
+   EImageBorder       *pad;
 
    p = Ecalloc(1, sizeof(Progressbar));
    pnum++;
    plist = Erealloc(plist, pnum * sizeof(Progressbar *));
    plist[pnum - 1] = p;
 
+   p->ic = ImageclassFind("PROGRESS_BAR", 1);
+   if (p->ic)
+      ImageclassIncRefcount(p->ic);
+
+   p->tc = TextclassFind("PROGRESS_TEXT", 1);
+   if (p->tc)
+      TextclassIncRefcount(p->tc);
+
+   p->tnc = TextclassFind("PROGRESS_TEXT_NUMBER", 1);
+   if (p->tnc)
+      TextclassIncRefcount(p->tnc);
+
+   pad = ImageclassGetPadding(p->ic);
+   TextSize(p->tc, 0, 0, 0, name, &tw, &th, 0);
+   if (h < th + pad->top + pad->bottom)
+      h = th + pad->top + pad->bottom;
+
    p->w = w;
    p->h = h;
    p->value = 0;
@@ -72,26 +90,6 @@
    p->n_win->fade = 0;
    p->p_win->fade = 0;
 
-   p->ic = ImageclassFind("PROGRESS_BAR", 1);
-   if (p->ic)
-      ImageclassIncRefcount(p->ic);
-
-   p->inc = ImageclassFind("PROGRESS_BAR", 1);
-   if (p->inc)
-      ImageclassIncRefcount(p->inc);
-
-   p->ipc = ImageclassFind("PROGRESS_BAR", 1);
-   if (p->ipc)
-      ImageclassIncRefcount(p->ipc);
-
-   p->tc = TextclassFind("PROGRESS_TEXT", 1);
-   if (p->tc)
-      TextclassIncRefcount(p->tc);
-
-   p->tnc = TextclassFind("PROGRESS_TEXT_NUMBER", 1);
-   if (p->tnc)
-      TextclassIncRefcount(p->tnc);
-
    return p;
 }
 
@@ -127,10 +125,6 @@
 
    if (p->ic)
       ImageclassDecRefcount(p->ic);
-   if (p->inc)
-      ImageclassDecRefcount(p->inc);
-   if (p->ipc)
-      ImageclassDecRefcount(p->ipc);
 
    if (p->tc)
       TextclassDecRefcount(p->tc);
@@ -171,11 +165,10 @@
    Esnprintf(s, sizeof(s), "%i%%", p->value);
 
    EobjResize(p->p_win, w, p->h);
-   ImageclassApply(p->inc, p->p_win->win, w, p->h, 1, 0, STATE_NORMAL,
-                  ST_SOLID);
+   ImageclassApply(p->ic, p->p_win->win, w, p->h, 1, 0, STATE_NORMAL, 
ST_SOLID);
    EobjShapeUpdate(p->p_win, 0);
 
-   pad = ImageclassGetPadding(p->inc);
+   pad = ImageclassGetPadding(p->ic);
    EClearWindow(p->n_win->win);
    TextDraw(p->tnc, p->n_win->win, None, 0, 0, STATE_CLICKED, s,
            pad->left, pad->top, p->h * 5 - (pad->left + pad->right),
@@ -194,16 +187,15 @@
 
    ImageclassApply(p->ic, p->win->win, p->w - (p->h * 5), p->h, 0, 0,
                   STATE_NORMAL, ST_SOLID);
-   ImageclassApply(p->inc, p->n_win->win, (p->h * 5), p->h, 0, 0, 
STATE_CLICKED,
-                  ST_SOLID);
-   ImageclassApply(p->ipc, p->p_win->win, 1, p->h, 1, 0, STATE_NORMAL,
-                  ST_SOLID);
+   ImageclassApply(p->ic, p->n_win->win, (p->h * 5), p->h, 0, 0,
+                  STATE_CLICKED, ST_SOLID);
+   ImageclassApply(p->ic, p->p_win->win, 1, p->h, 1, 0, STATE_NORMAL, 
ST_SOLID);
 
    EobjMap(p->win, 0);
    EobjMap(p->n_win, 0);
    EobjMap(p->p_win, 0);
 
-   pad = ImageclassGetPadding(p->inc);
+   pad = ImageclassGetPadding(p->ic);
    TextDraw(p->tc, p->win->win, None, 0, 0, STATE_NORMAL, EobjGetName(p->win),
            pad->left, pad->top, p->w - (p->h * 5) - (pad->left + pad->right),
            p->h - (pad->top + pad->bottom), p->h - (pad->top + pad->bottom),



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to