Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : apps/iconbar

Dir     : e17/apps/iconbar/src


Modified Files:
        container.c container.h iconbar.c 


Log Message:


fill policies on container done.
iconbar only does vertical at the moment. need to make it do horiz also.

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/iconbar/src/container.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- container.c 11 Aug 2003 22:14:54 -0000      1.2
+++ container.c 11 Aug 2003 23:40:28 -0000      1.3
@@ -101,74 +101,56 @@
   if (b) *b = cont->padding.b;
 }
 
-void e_container_fit_x_set(Evas_Object *container, int fit_x)
+void e_container_alignment_set(Evas_Object *container, 
+                               Container_Alignment align)
 {
   Container *cont;
   
   cont = _container_fetch(container);
   if (!cont) return;
 
-  cont->fit_x = fit_x;
-
-  _container_elements_fix(cont);
-}
-
-int  e_container_fit_x_get(Evas_Object *container)
-{
-  Container *cont;
-  
-  cont = _container_fetch(container);
-  if (!cont) return 0;
-
-  return cont->fit_x;
-}
-
-void e_container_fit_y_set(Evas_Object *container, int fit_y)
-{
-  Container *cont;
+  if (cont->align == align) return;
   
-  cont = _container_fetch(container);
-  if (!cont) return;
-
-  cont->fit_y = fit_y;
+  cont->align = align;
 
   _container_elements_fix(cont);
+  
 }
 
-int  e_container_fit_y_get(Evas_Object *container)
+Container_Alignment e_container_alignment_get(Evas_Object *container)
 {
   Container *cont;
   
   cont = _container_fetch(container);
   if (!cont) return 0;
 
-  return cont->fit_y;
+  return cont->align;
 }
 
-void e_container_alignment_set(Evas_Object *container, 
-                               Container_Alignment align)
+void e_container_fill_policy_set(Evas_Object *container, 
+                               Container_Fill_Policy fill)
 {
   Container *cont;
   
   cont = _container_fetch(container);
   if (!cont) return;
 
-  if (cont->align == align) return;
+  if (cont->fill == fill) return;
   
-  cont->align = align;
+  cont->fill = fill;
 
   _container_elements_fix(cont);
   
 }
 
-Container_Alignment e_container_alignment_get(Evas_Object *container)
+Container_Fill_Policy e_container_fill_policy_get(Evas_Object *container)
 {
   Container *cont;
   
   cont = _container_fetch(container);
   if (!cont) return 0;
 
-  return cont->align;
+  return cont->fill;
 }
 
 void e_container_scroll_set(Evas_Object *container, int scroll)
@@ -375,7 +357,8 @@
 {
   Evas_List *l;
   double ax, ay, aw, ah; // element area geom
-  double ix, iy;
+  double ix, iy, iw, ih; // new x, y, w, h
+  int num; // number of elements
 
   evas_object_geometry_get(cont->grabber, &ax, &ay, &aw, &ah);
 
@@ -391,10 +374,12 @@
   ix = ax;
   iy = ay;
 
+  num = evas_list_count(cont->elements);
+
   for (l = cont->elements; l; l = l->next)
   {
     Container_Element *el = l->data;
-    double ew, eh; // element size
+    double ew, eh; // old element size
 
     if(!el)
     {
@@ -407,23 +392,97 @@
     /* vertical */
     if (cont->direction)
     {
-      /* FIXME: do other alignments also */
+      if (cont->fill & CONTAINER_FILL_POLICY_FILL)
+      {
+        iw = aw;
+        ih = (ah - cont->spacing * (num - 1) ) / num;
+      }
+      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_X)
+      {
+        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+        {
+          iw = aw;
+          ih = eh * iw/ew;
+        }
+        else
+        {
+          iw = aw;
+          ih = eh;
+        }
+      }
+      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_Y)
+      {
+        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+        {
+          ih = (ah - cont->spacing * (num - 1) ) / num;
+          iw = ew * ih/eh;
+        }
+        else
+        {
+          ih = (ah - cont->spacing * (num - 1) ) / num;
+          iw = ew;
+        }
+      }
+      else
+      {
+        iw = ew;
+        ih = eh;
+      }
 
       if (cont->align == CONTAINER_ALIGN_LEFT)
         ix = ax;
       else if (cont->align == CONTAINER_ALIGN_CENTER)
-        ix = ax + (aw - ew) / 2;
+        ix = ax + (aw - iw) / 2;
       else if (cont->align == CONTAINER_ALIGN_RIGHT)
-        ix = ax + aw - ew;
+        ix = ax + aw - iw;
 
       evas_object_move(el->obj, ix, iy);
+      evas_object_resize(el->obj, iw, ih);
       evas_object_move(el->grabber, ix, iy);
-      iy += eh + cont->spacing;
+      evas_object_resize(el->grabber, iw, ih);
+
+      iy += ih + cont->spacing;
     }
 
     /* horizontal */
     else
     {
+      if (cont->fill & CONTAINER_FILL_POLICY_FILL)
+      {
+        ih = ah;
+        iw = (aw - cont->spacing * (num - 1) ) / num;
+      }
+      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_X)
+      {
+        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+        {
+          ih = ah;
+          iw = ew * ih/eh;
+        }
+        else
+        {
+          ih = ah;
+          iw = ew;
+        }
+      }
+      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_Y)
+      {
+        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+        {
+          iw = (aw - cont->spacing * (num - 1) ) / num;
+          ih = eh * iw/ew;
+        }
+        else
+        {
+          iw = (aw - cont->spacing * (num - 1) ) / num;
+          ih = eh;
+        }
+      }
+      else
+      {
+        iw = ew;
+        ih = eh;
+      }
 
       if (cont->align == CONTAINER_ALIGN_TOP)
         iy = ay;
@@ -441,9 +500,6 @@
     evas_object_geometry_get(el->obj, NULL, NULL, &ew, &eh);
     evas_object_resize(el->grabber, ew, eh);
   }
-
-
-  
 }
 
 double
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/iconbar/src/container.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- container.h 11 Aug 2003 22:14:54 -0000      1.2
+++ container.h 11 Aug 2003 23:40:28 -0000      1.3
@@ -34,12 +34,7 @@
   CONTAINER_FILL_POLICY_KEEP_ASPECT = 0x01,
   CONTAINER_FILL_POLICY_FILL_X = 0x02,
   CONTAINER_FILL_POLICY_FILL_Y = 0x04,
-  CONTAINER_FILL_POLICY_FILL = 
-    CONTAINER_FILL_POLICY_FILL_X | CONTAINER_FILL_POLICY_FILL_Y,
-  CONTAINER_FILL_POLICY_FIT_X = 0x08,
-  CONTAINER_FILL_POLICY_FIT_Y = 0x16,
-  CONTAINER_FILL_POLICY_FIT = 
-    CONTAINER_FILL_POLICY_FIT_X | CONTAINER_FILL_POLICY_FIT_Y
+  CONTAINER_FILL_POLICY_FILL = 0x08 
 };
 
 struct _Container
@@ -59,9 +54,11 @@
   int spacing;          /* space between elements */
 
   int direction;        /* 0 = horizontal or 1 = vertical */
-  int fit_x, fit_y;     /* shrink elements if area is smaller than them */
-  int fill_x, fill_y;   /* make elements fill the container */
+//  int fit_x, fit_y;     /* shrink elements if area is smaller than them */
+//  int fill_x, fill_y;   /* make elements fill the container */
   Container_Alignment align;  /* CONTAINER_ALIGN_LEFT, _CENTER, or _RIGHT */
+  Container_Fill_Policy fill;
+
   int move_button;      /* which button to move elements with? (0 for none) */
 
   int scroll;
@@ -93,14 +90,15 @@
 
 void e_container_direction_set(Evas_Object *container, int direction);
 int  e_container_direction_get(Evas_Object *container);
+
 void e_container_padding_set(Evas_Object *container, double l, double r,
                              double t, double b);
 void e_container_padding_get(Evas_Object *container, double *l, double *r,
                              double *t, double *b);
-void e_container_fit_x_set(Evas_Object *container, int fit_x);
-int  e_container_fit_x_get(Evas_Object *container);
-void e_container_fit_y_set(Evas_Object *container, int fit_y);
-int  e_container_fit_y_get(Evas_Object *container);
+
+void e_container_fill_policy_set(Evas_Object *container,
+                                 Container_Fill_Policy fill);
+Container_Fill_Policy  e_container_fill_policy_get(Evas_Object *container);
 
 void e_container_alignment_set(Evas_Object *container,
                                Container_Alignment align);
@@ -110,7 +108,7 @@
 int  e_container_scroll_get(Evas_Object *container);
 
 void    e_container_spacing_set(Evas_Object *container,
-                                        int spacing);
+                                int spacing);
 int  e_container_spacing_get(Evas_Object *container);
 
 /* element adding/removing */
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/iconbar/src/iconbar.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- iconbar.c   11 Aug 2003 22:14:54 -0000      1.2
+++ iconbar.c   11 Aug 2003 23:40:28 -0000      1.3
@@ -75,6 +75,8 @@
   edje_object_part_swallow(ib->gui, "icons", ib->cont); //was clip
   e_container_spacing_set(ib->cont, 5);
   e_container_alignment_set(ib->cont, CONTAINER_ALIGN_CENTER);
+  e_container_fill_policy_set(ib->cont, CONTAINER_FILL_POLICY_FILL_X |
+                                        CONTAINER_FILL_POLICY_KEEP_ASPECT);
   e_container_callback_order_change_set(ib->cont, write_out_order, ib);
 
   edje_object_signal_callback_add(ib->gui, "mouse,*", "*", cb_iconbar, ib);




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to