edje: cleanup and make limit per description work.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 11 Jul 2012 10:50:30 +0000 (10:50 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 11 Jul 2012 10:50:30 +0000 (10:50 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@73562 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/edje_calc.c
src/lib/edje_private.h

index db2cc7f..baa870b 100644 (file)
@@ -676,66 +676,64 @@ _edje_recalc_do(Edje *ed)
         unsigned char limit;
         int part;
 
-        name = ed->collection->parts[i]->name;
         part = ed->collection->limits.parts[i].part;
+        name = ed->collection->parts[part]->name;
         limit = ed->table_parts[part]->chosen_description->limit;
         switch (limit)
           {
            case 0:
-              ed->collection->limits.parts[i].width = 2;
-              ed->collection->limits.parts[i].height = 2;
+              ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
+              ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
               break;
            case 1:
-              ed->collection->limits.parts[i].height = 2;
+              ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_UNKNOWN;
               break;
            case 2:
-              ed->collection->limits.parts[i].width = 2;
+              ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_UNKNOWN;
               break;
            case 3:
               break;
           }
 
-        if (limit | 1)
+        if ((limit & 1) == 1)
           {
              if (ed->table_parts[part]->w > 0 &&
-                 (ed->collection->limits.parts[i].width <= 0 ||
-                  ed->collection->limits.parts[i].width == 2))
+                 (ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_OVER))
                {
-                  ed->collection->limits.parts[i].width = 1;
+                  ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_OVER;
                   _edje_emit(ed, "limit,width,over", name);
                }
              else if (ed->table_parts[part]->w < 0 &&
-                      ed->collection->limits.parts[i].width >= 0)
+                      ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_BELOW)
                {
-                  ed->collection->limits.parts[i].width = -1;
+                  ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_BELOW;
                   _edje_emit(ed, "limit,width,below", name);
                }
              else if (ed->table_parts[part]->w == 0 &&
-                      ed->collection->limits.parts[i].width != 0)
+                      ed->collection->limits.parts[i].width != EDJE_PART_LIMIT_ZERO)
                {
-                  ed->collection->limits.parts[i].width = 0;
+                  ed->collection->limits.parts[i].width = EDJE_PART_LIMIT_ZERO;
                   _edje_emit(ed, "limit,width,zero", name);
                }
           }
-        if (limit | 2)
+        if ((limit & 2) == 2)
           {
              if (ed->table_parts[part]->h > 0 &&
-                 (ed->collection->limits.parts[i].height <= 0 ||
-                  ed->collection->limits.parts[i].height == 2))
+                 (ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_OVER))
                {
-                  ed->collection->limits.parts[i].height = 1;
+                  ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_OVER;
                   _edje_emit(ed, "limit,height,over", name);
                }
              else if (ed->table_parts[part]->h < 0 &&
-                      ed->collection->limits.parts[i].height >= 0)
+                      ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_BELOW)
                {
-                  ed->collection->limits.parts[i].height = -1;
-                  _edje_emit(ed, "limit,height,beloh", name);
+                  ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_BELOW;
+                  _edje_emit(ed, "limit,height,below", name);
                }
              else if (ed->table_parts[part]->h == 0 &&
-                      ed->collection->limits.parts[i].height != 0)
+                      ed->collection->limits.parts[i].height != EDJE_PART_LIMIT_ZERO)
                {
-                  ed->collection->limits.parts[i].height = 0;
+                  ed->collection->limits.parts[i].height = EDJE_PART_LIMIT_ZERO;
                   _edje_emit(ed, "limit,height,zero", name);
                }
           }
index 3defba1..3407b9c 100644 (file)
@@ -727,12 +727,19 @@ struct _Edje_Pack_Element
    unsigned short   colspan, rowspan;
 };
 
+typedef enum {
+  EDJE_PART_LIMIT_UNKNOWN = 0,
+  EDJE_PART_LIMIT_BELOW,
+  EDJE_PART_LIMIT_ZERO,
+  EDJE_PART_LIMIT_OVER
+} Edje_Part_Limit_State;
+
 struct _Edje_Part_Limit
 {
    int part;
 
-   signed char width; /* -1, 0 or 1 */
-   signed char height; /* -1, 0, or 1 */
+   Edje_Part_Limit_State width; /* -1, 0 or 1 */
+   Edje_Part_Limit_State height; /* -1, 0, or 1 */
 };
 
 /*----------*/