jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e4889ca367b2cde28a8c4bafedd36ec3fc0b3879

commit e4889ca367b2cde28a8c4bafedd36ec3fc0b3879
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Mon Apr 18 13:54:46 2016 +0900

    Ui.Box: Fix flow layout
    
    Set align, fix usage with eo_add(EFL_UI_BOX_FLOW_CLASS).
---
 src/Makefile_Elementary.am              |  1 +
 src/bin/elementary/test_ui_box.c        |  9 ++--
 src/lib/elementary/efl_ui_box.c         | 12 +++--
 src/lib/elementary/efl_ui_box_flow.c    | 94 +++++++++++++++++++++++++++++++++
 src/lib/elementary/efl_ui_box_flow.eo   | 20 +++++--
 src/lib/elementary/efl_ui_box_layout.c  | 56 --------------------
 src/lib/elementary/efl_ui_box_private.h |  3 --
 7 files changed, 124 insertions(+), 71 deletions(-)

diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 8578d6a..c9f9b3a 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -626,6 +626,7 @@ lib_elementary_libelementary_la_SOURCES = \
        lib/elementary/els_tooltip.c \
        lib/elementary/elu_ews_wm.c \
        lib/elementary/efl_ui_box.c \
+       lib/elementary/efl_ui_box_flow.c \
        lib/elementary/efl_ui_box_layout.c \
        lib/elementary/efl_ui_grid.c \
        $(NULL)
diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c
index 2e8bed4..3d5a2c2 100644
--- a/src/bin/elementary/test_ui_box.c
+++ b/src/bin/elementary/test_ui_box.c
@@ -111,7 +111,7 @@ alignv_slider_cb(void *data, const Eo_Event *event)
    return EO_CALLBACK_CONTINUE;
 }
 
-static Efl_Ui_Box_Flow_Params s_flow_params = { 0.5, 0.5, 0, 0 };
+static Efl_Ui_Box_Flow_Params s_flow_params = { 0, 0 };
 static Eina_Bool flow = EINA_FALSE;
 
 static Eina_Bool
@@ -154,15 +154,12 @@ left_check_cb(void *data, const Eo_Event *event)
    Eina_Bool chk = elm_check_selected_get(event->obj);
    if (chk)
      {
-        s_flow_params.align_x = 0;
-        s_flow_params.align_y = 0;
+        efl_pack_align_set(data, 0, 0.5);
      }
    else
      {
-        s_flow_params.align_x = 0.5;
-        s_flow_params.align_y = 0.5;
+        efl_pack_align_set(data, 0.5, 0.5);
      }
-   efl_pack_layout_engine_set(data, flow ? EFL_UI_BOX_FLOW_CLASS : NULL, 
&s_flow_params);
    return EO_CALLBACK_CONTINUE;
 }
 
diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c
index 4e1b7bc..cd9e3e4 100644
--- a/src/lib/elementary/efl_ui_box.c
+++ b/src/lib/elementary/efl_ui_box.c
@@ -1,5 +1,8 @@
 #include "efl_ui_box_private.h"
 
+#define MY_CLASS EFL_UI_BOX_CLASS
+#define MY_CLASS_NAME "Efl.Ui.Box"
+
 /* COPIED FROM ELM_BOX
  * - removed transition stuff (TODO: add back - needs clean API first)
  */
@@ -171,10 +174,10 @@ _efl_ui_box_efl_pack_engine_layout_do(Eo *klass 
EINA_UNUSED,
 }
 
 EOLIAN static Eina_Bool
-_efl_ui_box_efl_pack_layout_engine_set(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data 
*pd,
+_efl_ui_box_efl_pack_layout_engine_set(Eo *obj, Efl_Ui_Box_Data *pd,
                                        const Eo_Class *klass, const void *data)
 {
-   pd->layout_engine = klass ? klass : MY_CLASS;
+   pd->layout_engine = klass ? klass : eo_class_get(obj);
    pd->layout_data = data;
    efl_pack_layout_request(obj);
    _sizing_eval(obj, pd);
@@ -272,7 +275,7 @@ _efl_ui_box_eo_base_constructor(Eo *obj, Efl_Ui_Box_Data 
*pd)
    elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER);
 
    pd->orient = EFL_ORIENT_RIGHT;
-   pd->layout_engine = MY_CLASS;
+   pd->layout_engine = eo_class_get(obj);
    pd->align.h = 0.5;
    pd->align.v = 0.5;
 
@@ -561,6 +564,8 @@ _efl_ui_box_efl_pack_padding_get(Eo *obj, Efl_Ui_Box_Data 
*pd, double *h, double
 EOLIAN static void
 _efl_ui_box_efl_pack_pack_align_set(Eo *obj, Efl_Ui_Box_Data *pd, double h, 
double v)
 {
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
    if (h < 0) h = -1;
    if (v < 0) v = -1;
    if (h > 1) h = 1;
@@ -568,6 +573,7 @@ _efl_ui_box_efl_pack_pack_align_set(Eo *obj, 
Efl_Ui_Box_Data *pd, double h, doub
    pd->align.h = h;
    pd->align.v = v;
 
+   evas_object_box_align_set(wd->resize_obj, h, v);
    efl_pack_layout_request(obj);
 }
 
diff --git a/src/lib/elementary/efl_ui_box_flow.c 
b/src/lib/elementary/efl_ui_box_flow.c
new file mode 100644
index 0000000..e3db254
--- /dev/null
+++ b/src/lib/elementary/efl_ui_box_flow.c
@@ -0,0 +1,94 @@
+#include "efl_ui_box_private.h"
+
+#define MY_CLASS EFL_UI_BOX_FLOW_CLASS
+
+typedef struct _Efl_Ui_Box_Flow_Data Efl_Ui_Box_Flow_Data;
+
+struct _Efl_Ui_Box_Flow_Data
+{
+   Efl_Ui_Box_Flow_Params params;
+};
+
+EOLIAN static Eo *
+_efl_ui_box_flow_eo_base_constructor(Eo *obj, Efl_Ui_Box_Flow_Data *pd)
+{
+   eo_constructor(eo_super(obj, MY_CLASS));
+   efl_pack_layout_engine_set(obj, MY_CLASS, &pd->params);
+   return obj;
+}
+
+EOLIAN static void
+_efl_ui_box_flow_box_flow_homogenous_set(Eo *obj EINA_UNUSED, 
Efl_Ui_Box_Flow_Data *pd, Eina_Bool val)
+{
+   pd->params.homogenous = val;
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_box_flow_box_flow_homogenous_get(Eo *obj EINA_UNUSED, 
Efl_Ui_Box_Flow_Data *pd)
+{
+   return pd->params.homogenous;
+}
+
+EOLIAN static void
+_efl_ui_box_flow_box_flow_max_size_set(Eo *obj EINA_UNUSED, 
Efl_Ui_Box_Flow_Data *pd, Eina_Bool val)
+{
+   pd->params.max_size = val;
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_box_flow_box_flow_max_size_get(Eo *obj EINA_UNUSED, 
Efl_Ui_Box_Flow_Data *pd)
+{
+   return pd->params.max_size;
+}
+
+EOLIAN static void
+_efl_ui_box_flow_efl_pack_engine_layout_do(Eo_Class *klass EINA_UNUSED,
+                                           void *_pd EINA_UNUSED,
+                                           Eo *obj, const void *data)
+{
+   void (*func)(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data);
+   const Efl_Ui_Box_Flow_Params *params = data;
+   Evas_Object_Box_Data *bd;
+   Efl_Ui_Box_Data *pd;
+   Eina_Bool homo = EINA_FALSE, maxsize = EINA_FALSE;
+
+   EINA_SAFETY_ON_FALSE_RETURN(eo_isa(obj, EFL_UI_BOX_CLASS));
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+   bd = eo_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS);
+   pd = eo_data_scope_get(obj, EFL_UI_BOX_CLASS);
+
+   if (params)
+     {
+        homo = params->homogenous;
+        maxsize = params->max_size;
+     }
+
+   if (_horiz(pd->orient))
+     {
+        if (homo)
+          {
+             if (maxsize)
+               func = evas_object_box_layout_homogeneous_max_size_horizontal;
+             else
+               func = evas_object_box_layout_homogeneous_horizontal;
+          }
+        else
+          func = evas_object_box_layout_flow_horizontal;
+     }
+   else
+     {
+        if (homo)
+          {
+             if (maxsize)
+               func = evas_object_box_layout_homogeneous_max_size_vertical;
+             else
+               func = evas_object_box_layout_homogeneous_vertical;
+          }
+        else
+          func = evas_object_box_layout_flow_vertical;
+     }
+
+   func(wd->resize_obj, bd, NULL);
+}
+
+#include "efl_ui_box_flow.eo.c"
diff --git a/src/lib/elementary/efl_ui_box_flow.eo 
b/src/lib/elementary/efl_ui_box_flow.eo
index 8cb78dc..9357a8e 100644
--- a/src/lib/elementary/efl_ui_box_flow.eo
+++ b/src/lib/elementary/efl_ui_box_flow.eo
@@ -1,7 +1,5 @@
 struct Efl.Ui.Box_Flow_Params {
    [[Extra parameters for Box_Flow layout. Can be omitted.]]
-   align_x: double;
-   align_y: double;
    homogenous: bool;
    max_size: bool;
 }
@@ -10,8 +8,24 @@ class Efl.Ui.Box_Flow (Efl.Ui.Box, Efl.Pack_Engine)
 {
    [[A custom layout engine for @Efl.Ui.Box.]]
    legacy_prefix: null;
-   data: null;
+   methods {
+      @property box_flow_homogenous {
+         set {}
+         get {}
+         values {
+            val: bool;
+         }
+      }
+      @property box_flow_max_size {
+         set {}
+         get {}
+         values {
+            val: bool;
+         }
+      }
+   }
    implements {
+      Eo.Base.constructor;
       Efl.Pack_Engine.layout_do;
    }
 }
diff --git a/src/lib/elementary/efl_ui_box_layout.c 
b/src/lib/elementary/efl_ui_box_layout.c
index 2d81c17..4b0b329 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -258,59 +258,3 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, 
Evas_Object_Box_Data *bd)
         evas_object_geometry_set(item->obj, x, y, w, h);
      }
 }
-
-EOLIAN static void
-_efl_ui_box_flow_efl_pack_engine_layout_do(Eo_Class *klass EINA_UNUSED,
-                                           void *_pd EINA_UNUSED,
-                                           Eo *obj, const void *data)
-{
-   void (*func)(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data);
-   const Efl_Ui_Box_Flow_Params *params = data;
-   double ax = 0.5, ay = 0.5;
-   Evas_Object_Box_Data *bd;
-   Efl_Ui_Box_Data *pd;
-   Eina_Bool homo = EINA_FALSE, maxsize = EINA_FALSE;
-
-   EINA_SAFETY_ON_FALSE_RETURN(eo_isa(obj, EFL_UI_BOX_CLASS));
-   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
-   bd = eo_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS);
-   pd = eo_data_scope_get(obj, EFL_UI_BOX_CLASS);
-
-   // FIXME: I wonder how this data will work with bindings? (lifetime, etc...)
-   if (params)
-     {
-        ax = params->align_x;
-        ay = params->align_y;
-        homo = params->homogenous;
-        maxsize = params->max_size;
-     }
-
-   if (_horiz(pd->orient))
-     {
-        if (homo)
-          {
-             if (maxsize)
-               func = evas_object_box_layout_homogeneous_max_size_horizontal;
-             else
-               func = evas_object_box_layout_homogeneous_horizontal;
-          }
-        else
-          func = evas_object_box_layout_flow_horizontal;
-     }
-   else
-     {
-        if (homo)
-          {
-             if (maxsize)
-               func = evas_object_box_layout_homogeneous_max_size_vertical;
-             else
-               func = evas_object_box_layout_homogeneous_vertical;
-          }
-        else
-          func = evas_object_box_layout_flow_vertical;
-     }
-
-   func(wd->resize_obj, bd, NULL);
-}
-
-#include "efl_ui_box_flow.eo.c"
diff --git a/src/lib/elementary/efl_ui_box_private.h 
b/src/lib/elementary/efl_ui_box_private.h
index 234f7b1..39a7a64 100644
--- a/src/lib/elementary/efl_ui_box_private.h
+++ b/src/lib/elementary/efl_ui_box_private.h
@@ -13,9 +13,6 @@
 // FIXME: stop using Evas.Box
 #include <../evas/canvas/evas_box.eo.h>
 
-#define MY_CLASS EFL_UI_BOX_CLASS
-#define MY_CLASS_NAME "Efl.Ui.Box"
-
 // FIXME: stop using evas box
 void _efl_ui_box_custom_layout(Efl_Ui_Box *box, Evas_Object_Box_Data *priv);
 

-- 


Reply via email to