Enlightenment CVS committal

Author  : pfritz
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_notebook.c ewl_notebook.h ewl_box.h ewl_box.c 


Log Message:
add ewl_notebook_tabbar_homogeneous_set()
fix homogeneous box

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_notebook.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- ewl_notebook.c      27 Apr 2007 05:01:01 -0000      1.25
+++ ewl_notebook.c      1 Jul 2007 18:45:51 -0000       1.26
@@ -460,6 +460,40 @@
 }
 
 /**
+ * @param n: The Ewl_Notebook to make homogeneous
+ * @param h: Boolean value to set the notebook's homogeneous value
+ * @return Returns no value
+ * @brief Sets the tabs in the notebook to be the same size
+ **/
+void
+ewl_notebook_tabbar_homogeneous_set(Ewl_Notebook *n, unsigned int h)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("n", n);
+       DCHECK_TYPE("n", n, EWL_NOTEBOOK_TYPE);
+
+       ewl_box_homogeneous_set(EWL_BOX(n->body.tabbar), !!h);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param n: The Ewl_Notebook to check for homogeneous
+ * @return Returns the homgeneous value of the notebook @a n
+ * @brief Retrieves the homogeneous value of the notebook
+ **/
+unsigned int
+ewl_notebook_tabbar_homogeneous_get(Ewl_Notebook *n)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("n", n, 0);
+       DCHECK_TYPE_RET("n", n, EWL_NOTEBOOK_TYPE, 0);
+
+       DRETURN_INT(ewl_box_homogeneous_get(EWL_BOX(n->body.tabbar)),
+                       DLEVEL_STABLE);
+}
+
+/**
  * @internal
  * @param c: The container to work with
  * @param w: The widget to work with
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_notebook.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- ewl_notebook.h      4 Mar 2007 00:52:01 -0000       1.17
+++ ewl_notebook.h      1 Jul 2007 18:45:51 -0000       1.18
@@ -76,6 +76,9 @@
 void            ewl_notebook_tabbar_visible_set(Ewl_Notebook *n,
                                                unsigned int visible);
 unsigned int    ewl_notebook_tabbar_visible_get(Ewl_Notebook *n);
+void            ewl_notebook_tabbar_homogeneous_set(Ewl_Notebook *n, 
+                                               unsigned int h);
+unsigned int    ewl_notebook_tabbar_homogeneous_get(Ewl_Notebook *n);
 
 void            ewl_notebook_visible_page_set(Ewl_Notebook *n, 
                                                Ewl_Widget *page);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_box.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_box.h   4 Mar 2007 00:52:01 -0000       1.19
+++ ewl_box.h   1 Jul 2007 18:45:51 -0000       1.20
@@ -68,12 +68,15 @@
 Ewl_Orientation  ewl_box_orientation_get(Ewl_Box *b);
 void            ewl_box_spacing_set(Ewl_Box *b, int spacing);
 void            ewl_box_homogeneous_set(Ewl_Box *b, unsigned int h);
+unsigned int    ewl_box_homogeneous_get(Ewl_Box *b);
 
 /*
  * Internally used callbacks, override at your own risk.
  */
 void ewl_box_cb_child_resize(Ewl_Container *c, Ewl_Widget *w, int size, 
                                                        Ewl_Orientation o);
+void ewl_box_cb_child_homogeneous_resize(Ewl_Container *c, 
+                               Ewl_Widget *w, int size, Ewl_Orientation o);
 void ewl_box_cb_child_show(Ewl_Container *c, Ewl_Widget *w);
 void ewl_box_cb_child_hide(Ewl_Container *c, Ewl_Widget *w);
 void ewl_box_cb_child_homogeneous_show(Ewl_Container *c, Ewl_Widget *w);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_box.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- ewl_box.c   1 Apr 2007 21:48:06 -0000       1.42
+++ ewl_box.c   1 Jul 2007 18:45:51 -0000       1.43
@@ -271,40 +271,92 @@
 void
 ewl_box_homogeneous_set(Ewl_Box *b, unsigned int h)
 {
+       Ewl_Container *c;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("b", b);
        DCHECK_TYPE("b", b, EWL_BOX_TYPE);
 
-       if (b->homogeneous == h)
+       if (b->homogeneous == !!h)
                DRETURN(DLEVEL_STABLE);
 
-       b->homogeneous = h;
+       b->homogeneous = !!h;
+       c = EWL_CONTAINER(b);
 
        if (h) {
                ewl_callback_del(EWL_WIDGET(b), EWL_CALLBACK_CONFIGURE,
                                ewl_box_cb_configure);
                ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_CONFIGURE,
                                ewl_box_cb_configure_homogeneous, NULL);
-               ewl_container_show_notify_set(EWL_CONTAINER(b),
+               ewl_container_show_notify_set(c,
                                          ewl_box_cb_child_homogeneous_show);
-               ewl_container_hide_notify_set(EWL_CONTAINER(b),
+               ewl_container_hide_notify_set(c,
                                          ewl_box_cb_child_homogeneous_show);
+               ewl_container_resize_notify_set(c,
+                                         ewl_box_cb_child_homogeneous_resize);
+               /*
+                * calculate the new preferred size, we use here the show cb
+                * since it does exactly what we need to do
+                */
+               ewl_box_cb_child_homogeneous_show(c, NULL);
        }
        else {
+               int nodes, space;
+
                ewl_callback_del(EWL_WIDGET(b), EWL_CALLBACK_CONFIGURE,
                                ewl_box_cb_configure_homogeneous);
                ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_CONFIGURE,
                                ewl_box_cb_configure, NULL);
-               ewl_container_show_notify_set(EWL_CONTAINER(b),
+               ewl_container_show_notify_set(c,
                                          ewl_box_cb_child_show);
-               ewl_container_hide_notify_set(EWL_CONTAINER(b),
+               ewl_container_hide_notify_set(c,
                                          ewl_box_cb_child_hide);
+               ewl_container_resize_notify_set(c,
+                                         ewl_box_cb_child_resize);
+               /*
+                * calculate the new preferred size
+                */
+               nodes = ecore_dlist_nodes(c->children) - 1;
+               space = (nodes > 1) ? b->spacing : 0;
+               if (b->orientation == EWL_ORIENTATION_HORIZONTAL) {
+                       ewl_container_largest_prefer(c, 
+                                               EWL_ORIENTATION_VERTICAL);
+                       ewl_container_sum_prefer(c,
+                                               EWL_ORIENTATION_HORIZONTAL);
+                       ewl_object_preferred_inner_w_set(EWL_OBJECT(b),
+                                       PREFERRED_W(b) + space * nodes);
+               }
+               else {
+                       ewl_container_largest_prefer(c, 
+                                               EWL_ORIENTATION_HORIZONTAL);
+                       ewl_container_sum_prefer(c,
+                                               EWL_ORIENTATION_VERTICAL);
+                       ewl_object_preferred_inner_h_set(EWL_OBJECT(b),
+                                       PREFERRED_H(b) + space * nodes);
+               }
        }
 
+       ewl_widget_configure(EWL_WIDGET(b));
+
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 /**
+ * @param b: the box to retrieve layout
+ * @return Returns the homogeneous layout  value of the box @a b.
+ * @brief Retrieves the layout of the box
+ */
+unsigned int
+ewl_box_homogeneous_get(Ewl_Box *b)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("b", b, 0);
+       DCHECK_TYPE_RET("b", b, EWL_BOX_TYPE, 0);
+
+       DRETURN_INT(b->homogeneous, DLEVEL_STABLE);
+}
+
+/**
  * @param b: the box to change the spacing
  * @param s: the spacing to put between the child widgets
  * @return Returns no value.
@@ -855,8 +907,7 @@
        DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE);
 
        numc = ecore_dlist_nodes(c->children);
-       numc--;
-       if (numc)
+       if (numc > 1)
                space = EWL_BOX(c)->spacing;
 
        ewl_container_largest_prefer(c, EWL_ORIENTATION_HORIZONTAL);
@@ -915,6 +966,38 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/**
+ * @internal
+ * @param c: The Ewl_Container containing the widget
+ * @param w: The widget being resized
+ * @param size: The size of the widget
+ * @param o: The orientation of the widget
+ * @return Returns no value
+ * @brief The container resize callback used by the box 
+ */
+void
+ewl_box_cb_child_homogeneous_resize(Ewl_Container *c, Ewl_Widget *w 
__UNUSED__, 
+                       int size __UNUSED__, Ewl_Orientation o)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("c", c);
+       DCHECK_TYPE("c", c, EWL_BOX_TYPE);
+
+       /*
+        * If the change is in the orientation direction, we do the same
+        * like in the show cb
+        */
+       if (EWL_BOX(c)->orientation == o)
+               ewl_box_cb_child_homogeneous_show(c, NULL);
+
+       /*
+        * Find the new largest widget in the alignment direction
+        */
+       else
+               ewl_container_largest_prefer(c, o);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
 /**
  * @internal
  * @param c: The Ewl_Container containing the widget



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to