edje: Move external_param_set to a efl_part API
authorJean-Philippe Andre <jp.andre@samsung.com>
Mon, 29 May 2017 11:28:08 +0000 (20:28 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 30 May 2017 04:54:34 +0000 (13:54 +0900)
This adds a new class: Efl.Canvas.Layout.External.
I hate this long name...

This class represents an external part, and for now only
supports param_set/get as well as param_type_get. For now
param_type_get() still returns an Edje_External_Param_Type and
not another more generic type.

TODO: enumerate choices, return object, return content

15 files changed:
src/Makefile_Edje.am
src/bin/elementary/test_external.c
src/lib/edje/Edje_Common.h
src/lib/edje/Edje_Eo.h
src/lib/edje/Edje_Legacy.h
src/lib/edje/edje_external.c
src/lib/edje/edje_legacy.c
src/lib/edje/edje_object.eo
src/lib/edje/edje_part.c
src/lib/edje/edje_part_external.c [new file with mode: 0644]
src/lib/edje/edje_private.h
src/lib/edje/edje_types.eot
src/lib/edje/edje_util.c
src/lib/edje/efl_canvas_layout_external.eo [new file with mode: 0644]
src/lib/edje/efl_canvas_layout_internal.eo

index c2a8549..8f2ae77 100644 (file)
@@ -12,7 +12,9 @@ edje_eolian_priv_files = \
        lib/edje/efl_canvas_layout_internal.eo \
        lib/edje/efl_canvas_layout_internal_box.eo \
        lib/edje/efl_canvas_layout_internal_table.eo \
-       lib/edje/efl_canvas_layout_internal_swallow.eo
+       lib/edje/efl_canvas_layout_internal_swallow.eo \
+       lib/edje/efl_canvas_layout_external.eo \
+       $(NULL)
 
 edje_eolian_c = $(edje_eolian_files:%.eo=%.eo.c)
 edje_eolian_h = $(edje_eolian_files:%.eo=%.eo.h) \
@@ -95,6 +97,7 @@ lib/edje/edje_var.c \
 lib/edje/edje_signal.c \
 lib/edje/edje_part.c \
 lib/edje/edje_part_helper.h \
+lib/edje/edje_part_external.c \
 lib/edje/edje_part_swallow.c \
 lib/edje/edje_part_table.c \
 lib/edje/edje_part_box.c
index cbd0c07..393d7fe 100644 (file)
@@ -69,30 +69,43 @@ static Eina_Bool
 _timer_cb(void *data)
 {
    Evas_Object *edje = data;
-   Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb4, *pb5, *pb6, *pb7;
+   Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb5;
+   Edje_External_Param param;
    double progress;
+   Eina_Value v;
 
    pb1 = edje_object_part_external_object_get(edje, "ext_pbar1");
    pb2 = edje_object_part_external_object_get(edje, "ext_pbar2");
    pb3 = edje_object_part_external_object_get(edje, "ext_pbar3");
-   pb4 = edje_object_part_external_object_get(edje, "ext_pbar4");
-   pb6 = edje_object_part_external_object_get(edje, "ext_pbar6");
    progress = elm_progressbar_value_get(pb1) + 0.0123;
 
    elm_progressbar_value_set(pb1, progress);
    elm_progressbar_value_set(pb2, progress);
    elm_progressbar_value_set(pb3, progress);
-   elm_progressbar_value_set(pb4, progress);
-   elm_progressbar_value_set(pb6, progress);
+
+   /* Test external parameter API */
+   param.name = "value";
+   param.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
+   param.d = progress;
+   edje_object_part_external_param_set(edje, "ext_pbar6", &param);
+
+   param.name = "pulsing";
+   param.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
+   param.i = EINA_TRUE;
+   edje_object_part_external_param_set(edje, "ext_pbar7", &param);
+
+   /* Test EO API for external parameters */
+   eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE);
+   eina_value_set(&v, progress);
+   efl_canvas_layout_external_param_set(efl_part(edje, "ext_pbar4"), "value", &v);
+   eina_value_flush(&v);
 
    if (progress < 1.0)
      return ECORE_CALLBACK_RENEW;
 
    pb5 = edje_object_part_external_object_get(edje, "ext_pbar5");
-   pb7 = edje_object_part_external_object_get(edje, "ext_pbar7");
    elm_progressbar_pulse(pb2, EINA_FALSE);
    elm_progressbar_pulse(pb5, EINA_FALSE);
-   elm_progressbar_pulse(pb7, EINA_FALSE);
 
    bt1 = edje_object_part_external_object_get(edje, "ext_button1");
    bt2 = edje_object_part_external_object_get(edje, "ext_button2");
@@ -101,6 +114,17 @@ _timer_cb(void *data)
    elm_object_disabled_set(bt2, EINA_FALSE);
    elm_object_disabled_set(bt3, EINA_FALSE);
 
+   /* Test external parameter API */
+   param.name = "value";
+   param.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
+   param.d = 0.0;
+   edje_object_part_external_param_set(edje, "ext_pbar6", &param);
+
+   param.name = "pulsing";
+   param.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
+   param.i = EINA_FALSE;
+   edje_object_part_external_param_set(edje, "ext_pbar7", &param);
+
    return ECORE_CALLBACK_CANCEL;
 }
 
@@ -108,8 +132,11 @@ static void
 _bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
 {
    Evas_Object *edje = data;
-   Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb4, *pb5, *pb6, *pb7;
+   Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb5;
+   Edje_External_Param param;
+   Eina_Value v;
 
+   /* Test direct API calls on embedded objects */
    bt1 = edje_object_part_external_object_get(edje, "ext_button1");
    bt2 = edje_object_part_external_object_get(edje, "ext_button2");
    bt3 = edje_object_part_external_object_get(edje, "ext_button3");
@@ -120,19 +147,30 @@ _bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
    pb1 = edje_object_part_external_object_get(edje, "ext_pbar1");
    pb2 = edje_object_part_external_object_get(edje, "ext_pbar2");
    pb3 = edje_object_part_external_object_get(edje, "ext_pbar3");
-   pb4 = edje_object_part_external_object_get(edje, "ext_pbar4");
    pb5 = edje_object_part_external_object_get(edje, "ext_pbar5");
-   pb6 = edje_object_part_external_object_get(edje, "ext_pbar6");
-   pb7 = edje_object_part_external_object_get(edje, "ext_pbar7");
 
    elm_progressbar_value_set(pb1, 0.0);
    elm_progressbar_value_set(pb3, 0.0);
-   elm_progressbar_value_set(pb4, 0.0);
-   elm_progressbar_value_set(pb6, 0.0);
 
    elm_progressbar_pulse(pb2, EINA_TRUE);
    elm_progressbar_pulse(pb5, EINA_TRUE);
-   elm_progressbar_pulse(pb7, EINA_TRUE);
+
+   /* Test external parameter API */
+   param.name = "value";
+   param.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
+   param.d = 0.0;
+   edje_object_part_external_param_set(edje, "ext_pbar6", &param);
+
+   param.name = "pulsing";
+   param.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
+   param.i = EINA_TRUE;
+   edje_object_part_external_param_set(edje, "ext_pbar7", &param);
+
+   /* Test EO API for external parameters */
+   eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE);
+   eina_value_set(&v, 0.0);
+   efl_canvas_layout_external_param_set(efl_part(edje, "ext_pbar4"), "value", &v);
+   eina_value_flush(&v);
 
    ecore_timer_add(0.1, _timer_cb, edje);
 }
index 4152251..baa6846 100644 (file)
@@ -368,6 +368,19 @@ typedef enum _Edje_External_Param_Flags
                                             EDJE_EXTERNAL_PARAM_FLAGS_STATE) /**< Convenience flag that sets property as GET, SET and STATE. */
 } Edje_External_Param_Flags;
 
+/** Struct that holds parameters for parts of type EXTERNAL.
+ */
+typedef struct _Edje_External_Param
+{
+  const char *name; /**< The name of the parameter. */
+  Edje_External_Param_Type type; /**< The type of the parameter. This defines
+                                  * which of the next three variables holds the
+                                  * value for it. */
+  int i; /**< Used by both integer and boolean */
+  double d; /**< Used by double */
+  const char *s; /**< Used by both string and choice */
+} Edje_External_Param;
+
 /**
  * @brief Converts type identifier to string nicer representation.
  *
index c303ea8..05982fd 100644 (file)
@@ -2,3 +2,9 @@
 
 #include "edje_object.eo.h"
 #include "edje_edit.eo.h"
+
+#include "efl_canvas_layout_internal.eo.h"
+#include "efl_canvas_layout_internal_box.eo.h"
+#include "efl_canvas_layout_internal_table.eo.h"
+#include "efl_canvas_layout_internal_swallow.eo.h"
+#include "efl_canvas_layout_external.eo.h"
index eba6d13..2451171 100644 (file)
@@ -406,6 +406,84 @@ EAPI void edje_object_message_signal_recursive_process(Edje_Object *obj);
  * @}
  */
 
+/**
+ * @ingroup Edje_Object
+ *
+ * @{
+ */
+
+/**
+ * @brief Facility to query the type of the given parameter of the given part.
+ *
+ * @param[in] part The part name
+ * @param[in] param The parameter name to use
+ *
+ * @return @ref EDJE_EXTERNAL_PARAM_TYPE_MAX on errors, or another value from
+ * @ref Edje_External_Param_Type on success.
+ *
+ * @ingroup Edje_Object
+ */
+EAPI Edje_External_Param_Type edje_object_part_external_param_type_get(const Edje_Object *obj, const char *part, const char * param);
+
+/**
+ * @brief Sets the parameter for the external part.
+ *
+ * Parts of type external may carry extra properties that have meanings defined
+ * by the external plugin. For instance, it may be a string that defines a
+ * button label and setting this property will change that label on the fly.
+ *
+ * @note external parts have parameters set when they change states. Those
+ * parameters will never be changed by this function. The interpretation of how
+ * state_set parameters and param_set will interact is up to the external
+ * plugin.
+ *
+ * @note this function will not check if parameter value is valid using
+ * #Edje_External_Param_Info minimum, maximum, valid choices and others.
+ * However these should be checked by the underlying implementation provided by
+ * the external plugin. This is done for performance reasons.
+ *
+ * @param[in] part The part name
+ * @param[in] param The parameter details, including its name, type and actual
+ * value. This pointer should be valid, and the parameter must exist in
+ * #Edje_External_Type.parameters_info, with the exact type, otherwise the
+ * operation will fail and @c false will be returned.
+ *
+ * @return @c true if everything went fine, @c false on errors.
+ *
+ * @ingroup Edje_Object
+ */
+EAPI Eina_Bool edje_object_part_external_param_set(Edje_Object *obj, const char *part, const Edje_External_Param *param);
+
+/**
+ * @brief Gets the parameter for the external part.
+ *
+ * Parts of type external may carry extra properties that have meanings defined
+ * by the external plugin. For instance, it may be a string that defines a
+ * button label. This property can be modified by state parameters, by explicit
+ * calls to edje_object_part_external_param_set() or getting the actual object
+ * with edje_object_part_external_object_get() and calling native functions.
+ *
+ * This function asks the external plugin what is the current value,
+ * independent on how it was set.
+ *
+ * @param[in] part The part name
+ * @param[out] param The parameter details. It is used as both input and output
+ * variable. This pointer should be valid, and the parameter must exist in
+ * #Edje_External_Type.parameters_info, with the exact type, otherwise the
+ * operation will fail and @c false will be returned.
+ *
+ * @return @c true if everything went fine and param members are filled with
+ * information, @c false on errors and param member values are not set or
+ * valid.
+ *
+ * @ingroup Edje_Object
+ */
+EAPI Eina_Bool edje_object_part_external_param_get(const Edje_Object *obj, const char *part, Edje_External_Param *param);
+
+/**
+ * @}
+ */
+
  /**
  * @deprecated use evas_object_size_hint_min_set() instead.
  * @brief Sets the object minimum size.
index 8e242f1..b345200 100644 (file)
@@ -56,14 +56,12 @@ _edje_object_part_external_object_get(Eo *obj EINA_UNUSED, Edje *ed, const char
    return rp->typedata.swallow->swallowed_object;
 }
 
-EOLIAN Eina_Bool
-_edje_object_part_external_param_set(Eo *obj, Edje *ed, const char *part, const Edje_External_Param *param)
+Eina_Bool
+_edje_object_part_external_param_set(Edje *ed, const char *part, const Edje_External_Param *param)
 {
    Edje_Real_Part *rp;
 
-   if ((!param) || (!param->name)) return EINA_FALSE;
-
-   if ((!ed) || (!part)) return EINA_FALSE;
+   if (!ed || !part || !param || !param->name) return EINA_FALSE;
 
    rp = _edje_real_part_recursive_get(&ed, (char *)part);
    if (!rp)
@@ -72,19 +70,17 @@ _edje_object_part_external_param_set(Eo *obj, Edje *ed, const char *part, const
         return EINA_FALSE;
      }
 
-   if (_edje_external_param_set(obj, rp, param))
+   if (_edje_external_param_set(ed->obj, rp, param))
      return EINA_TRUE;
    return EINA_FALSE;
 }
 
-EOLIAN Eina_Bool
-_edje_object_part_external_param_get(Eo *obj, Edje *ed, const char *part, Edje_External_Param *param)
+Eina_Bool
+_edje_object_part_external_param_get(Edje *ed, const char *part, Edje_External_Param *param)
 {
    Edje_Real_Part *rp;
 
-   if ((!param) || (!param->name)) return EINA_FALSE;
-
-   if ((!ed) || (!part)) return EINA_FALSE;
+   if (!ed || !part || !param || !param->name) return EINA_FALSE;
 
    rp = _edje_real_part_recursive_get(&ed, (char *)part);
    if (!rp)
@@ -93,7 +89,7 @@ _edje_object_part_external_param_get(Eo *obj, Edje *ed, const char *part, Edje_E
         return EINA_FALSE;
      }
 
-   return _edje_external_param_get(obj, rp, param);
+   return _edje_external_param_get(ed->obj, rp, param);
 }
 
 EOLIAN Evas_Object *
@@ -117,8 +113,8 @@ _edje_object_part_external_content_get(Eo *obj EINA_UNUSED, Edje *ed, const char
    return _edje_external_content_get(rp->typedata.swallow->swallowed_object, content);
 }
 
-EOLIAN Edje_External_Param_Type
-_edje_object_part_external_param_type_get(Eo *obj, Edje *ed, const char *part, const char *param)
+Edje_External_Param_Type
+_edje_object_part_external_param_type_get(Edje *ed, const char *part, const char *param)
 {
    Edje_Real_Part *rp;
    Edje_External_Type *type;
@@ -137,7 +133,7 @@ _edje_object_part_external_param_type_get(Eo *obj, Edje *ed, const char *part, c
    type = evas_object_data_get(rp->typedata.swallow->swallowed_object, "Edje_External_Type");
    if (!type)
      {
-        ERR("no external type for object %p", obj);
+        ERR("no external type for object %p", ed->obj);
         return EDJE_EXTERNAL_PARAM_TYPE_MAX;
      }
    if (!type->parameters_info)
index 3c9e6d2..cf27351 100644 (file)
@@ -60,3 +60,61 @@ edje_object_message_signal_recursive_process(Edje_Object *obj)
 {
    edje_obj_message_signal_process(obj, EINA_TRUE);
 }
+
+EAPI Eina_Bool
+edje_object_part_external_param_set(Eo *obj, const char *part, const Edje_External_Param *param)
+{
+   Edje *ed = _edje_fetch(obj);
+
+   if (!ed || !param || !part) return EINA_FALSE;
+
+#if 1
+   /* validate EO API - disable for performance */
+   Eina_Value *v;
+   Eina_Bool ok;
+
+   switch (param->type)
+     {
+      case EDJE_EXTERNAL_PARAM_TYPE_INT:
+      case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
+        v = eina_value_new(EINA_VALUE_TYPE_INT);
+        eina_value_set(v, param->i);
+        break;
+
+      case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
+        v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
+        eina_value_set(v, param->d);
+        break;
+
+      case EDJE_EXTERNAL_PARAM_TYPE_STRING:
+      case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
+        v = eina_value_new(EINA_VALUE_TYPE_STRING);
+        eina_value_set(v, param->s);
+        break;
+
+      default: return EINA_FALSE;
+     }
+
+   ok = efl_canvas_layout_external_param_set(efl_part(obj, part), param->name, v);
+   eina_value_free(v);
+
+   return ok;
+
+#else
+   return _edje_object_part_external_param_set(ed, part, param);
+#endif
+}
+
+EAPI Eina_Bool
+edje_object_part_external_param_get(const Eo *obj, const char *part, Edje_External_Param *param)
+{
+   Edje *ed = _edje_fetch(obj);
+   return _edje_object_part_external_param_get(ed, part, param);
+}
+
+EAPI Edje_External_Param_Type
+edje_object_part_external_param_type_get(const Eo *obj, const char *part, const char *param)
+{
+   Edje *ed = _edje_fetch(obj);
+   return _edje_object_part_external_param_type_get(ed, part, param);
+}
index 1d7d1d5..ccb101a 100644 (file)
@@ -1006,19 +1006,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
             @in dy: double; [[The y step]]
          }
       }
-      @property part_external_param_type {
-         get {
-            [[Facility to query the type of the given parameter of the given part.]]
-            return: Edje.External.Param_Type(Edje.External.Param_Type.max); [[
-               @Edje.External.Param_Type.max on errors, or another value
-               from @Edje.External.Param_Type on success.
-            ]]
-         }
-         keys {
-            part: string; [[The part name]]
-            param: string; [[The parameter name to use]]
-         }
-      }
       @property part_external_object {
          get {
             [[Gets the object created by this external part.
@@ -1053,66 +1040,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
             content: string; [[A string identifying which content from the EXTERNAL to get]]
          }
       }
-      @property part_external_param {
-         set {
-            [[Sets the parameter for the external part.
-
-              Parts of type external may carry extra properties that have
-              meanings defined by the external plugin. For instance, it may be a
-              string that defines a button label and setting this property will
-              change that label on the fly.
-
-              Note: external parts have parameters set when they change
-              states. Those parameters will never be changed by this
-              function. The interpretation of how state_set parameters and
-              param_set will interact is up to the external plugin.
-
-              Note: this function will not check if parameter value is valid
-              using #Edje_External_Param_Info minimum, maximum, valid
-              choices and others. However these should be checked by the
-              underlying implementation provided by the external
-              plugin. This is done for performance reasons.]]
-
-            return: bool; [[$true if everything went fine, $false on errors.]]
-            values {
-               param: ptr(const(Edje.External.Param)); [[The parameter details, including its name, type and
-                                                     actual value. This pointer should be valid, and the
-                                                     parameter must exist in
-                                                     #Edje_External_Type.parameters_info, with the exact type,
-                                                     otherwise the operation will fail and $false will be
-                                                     returned.]]
-            }
-         }
-         get {
-            [[Gets the parameter for the external part.
-
-              Parts of type external may carry extra properties that have
-              meanings defined by the external plugin. For instance, it may be a
-              string that defines a button label. This property can be modified by
-              state parameters, by explicit calls to
-              edje_object_part_external_param_set() or getting the actual object
-              with edje_object_part_external_object_get() and calling native
-              functions.
-
-              This function asks the external plugin what is the current value,
-              independent on how it was set.]]
-
-            return: bool; [[$true if everything went fine and param members
-                            are filled with information, $false on errors and
-                            param member values are not set or valid.]]
-            values {
-               param: Edje.External.Param; [[The parameter details. It is used as both input and
-                                             output variable. This pointer should be valid, and the
-                                             parameter must exist in
-                                             #Edje_External_Type.parameters_info, with the exact type,
-                                             otherwise the operation will fail and $false will be
-                                             returned.]]
-            }
-         }
-         keys {
-            part: string; [[The part name]]
-         }
-      }
       @property text_change_cb {
          set {
             [[Sets the object text callback.
index fe2c23a..c5d2eed 100644 (file)
@@ -5,6 +5,7 @@
 PROXY_INIT(box)
 PROXY_INIT(table)
 PROXY_INIT(swallow)
+PROXY_INIT(external)
 
 void
 _edje_internal_proxy_shutdown(void)
@@ -12,6 +13,7 @@ _edje_internal_proxy_shutdown(void)
    _box_shutdown();
    _table_shutdown();
    _swallow_shutdown();
+   _external_shutdown();
 }
 
 void
diff --git a/src/lib/edje/edje_part_external.c b/src/lib/edje/edje_part_external.c
new file mode 100644 (file)
index 0000000..cee7fc0
--- /dev/null
@@ -0,0 +1,126 @@
+#include "edje_private.h"
+#include "edje_part_helper.h"
+
+#define MY_CLASS EFL_CANVAS_LAYOUT_EXTERNAL_CLASS
+
+PROXY_IMPLEMENTATION(external, EXTERNAL)
+#undef PROXY_IMPLEMENTATION
+
+EOLIAN static Eina_Bool
+_efl_canvas_layout_external_external_param_set(Eo *obj, void *_pd EINA_UNUSED,
+                                               const char *name, const Eina_Value *value)
+{
+   Edje_External_Param_Type type;
+   Edje_External_Param param = {};
+   const Eina_Value_Type *vtype;
+
+   PROXY_DATA_GET(obj, pd);
+   type = _edje_object_part_external_param_type_get(pd->ed, pd->part, name);
+
+   param.name = name;
+   param.type = type;
+   vtype = eina_value_type_get(value);
+
+   switch (type)
+     {
+      case EDJE_EXTERNAL_PARAM_TYPE_INT:
+      case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
+        if (vtype == EINA_VALUE_TYPE_INT)
+          eina_value_get(value, &param.i);
+        else
+          {
+             Eina_Value v2;
+
+             eina_value_setup(&v2, EINA_VALUE_TYPE_INT);
+             eina_value_convert(value, &v2);
+             eina_value_get(&v2, &param.i);
+             eina_value_flush(&v2);
+          }
+        break;
+
+      case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
+        if (vtype == EINA_VALUE_TYPE_DOUBLE)
+          eina_value_get(value, &param.d);
+        else
+          {
+             Eina_Value v2;
+
+             eina_value_setup(&v2, EINA_VALUE_TYPE_DOUBLE);
+             eina_value_convert(value, &v2);
+             eina_value_get(&v2, &param.d);
+             eina_value_flush(&v2);
+          }
+        break;
+
+      case EDJE_EXTERNAL_PARAM_TYPE_STRING:
+      case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
+        // Should we use eina_value_to_string() here and not complain?
+        if ((vtype != EINA_VALUE_TYPE_STRING) && (vtype != EINA_VALUE_TYPE_STRINGSHARE))
+          {
+             ERR("External parameter '%s' of object '%p' expects a string, "
+                 "got a '%s'.", name, pd->ed->obj, eina_value_type_name_get(vtype));
+             RETURN_VAL(EINA_FALSE);
+          }
+        eina_value_get(value, &param.s);
+        break;
+
+      default:
+        ERR("Unsupported type for parameter '%s' of object '%p'", name, pd->ed->obj);
+        RETURN_VAL(EINA_FALSE);
+     }
+
+   RETURN_VAL(_edje_object_part_external_param_set(pd->ed, pd->part, &param));
+}
+
+EOLIAN static Eina_Value *
+_efl_canvas_layout_external_external_param_get(Eo *obj, void *_pd EINA_UNUSED,
+                                               const char *name)
+{
+   Edje_External_Param param = {};
+   Eina_Value *v;
+
+   PROXY_DATA_GET(obj, pd);
+
+   param.name = name;
+   param.type = _edje_object_part_external_param_type_get(pd->ed, pd->part, name);
+   if (param.type == EDJE_EXTERNAL_PARAM_TYPE_MAX)
+     RETURN_VAL(NULL);
+   if (!_edje_object_part_external_param_get(pd->ed, pd->part, &param))
+     RETURN_VAL(NULL);
+
+   switch (param.type)
+     {
+      case EDJE_EXTERNAL_PARAM_TYPE_INT:
+      case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
+        v = eina_value_new(EINA_VALUE_TYPE_INT);
+        eina_value_set(v, param.i);
+        break;
+
+      case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
+        v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
+        eina_value_set(v, param.d);
+        break;
+
+      case EDJE_EXTERNAL_PARAM_TYPE_STRING:
+      case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
+        v = eina_value_new(EINA_VALUE_TYPE_STRING);
+        eina_value_set(v, param.s);
+        break;
+
+      default:
+        ERR("Unsupported type for parameter '%s' of object '%p'", name, pd->ed->obj);
+        RETURN_VAL(NULL);
+     }
+
+   RETURN_VAL(v);
+}
+
+EOLIAN static Edje_External_Param_Type
+_efl_canvas_layout_external_external_param_type_get(Eo *obj, void *_pd EINA_UNUSED,
+                                                    const char *name)
+{
+   PROXY_DATA_GET(obj, pd);
+   RETURN_VAL(_edje_object_part_external_param_type_get(pd->ed, pd->part, name));
+}
+
+#include "efl_canvas_layout_external.eo.c"
index 2911bc2..e62d59e 100644 (file)
@@ -3120,6 +3120,12 @@ Eo *_edje_swallow_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part
 Efl_Gfx *_edje_efl_container_content_get(Edje *ed, const char *part);
 Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow);
 
+/* part containers: external */
+Eo *_edje_external_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp);
+Eina_Bool _edje_object_part_external_param_set(Edje *ed, const char *part, const Edje_External_Param *param);
+Eina_Bool _edje_object_part_external_param_get(Edje *ed, const char *part, Edje_External_Param *param);
+Edje_External_Param_Type _edje_object_part_external_param_type_get(Edje *ed, const char *part, const char *param);
+
 void _edje_internal_proxy_shutdown(void);
 
 // Svg loader
index 9345af8..9d7478b 100644 (file)
@@ -113,31 +113,17 @@ enum Edje.Input_Panel.Layout {
                       @since 1.19]]
 }
 
+/* FIXME: This probably needs to be a more generic enum with a shorter name */
 enum Edje.External.Param_Type {
    [[The possible types the parameters of an EXTERNAL part can be.]]
-
    int, [[Parameter value is an integer.]]
    double, [[Parameter value is a double.]]
    string, [[Parameter value is a string.]]
    bool, [[Parameter value is boolean.]]
-   choice, [[Parameter value is one of a set of
-             predefined string choices.]]
+   choice, [[Parameter value is one of a set of predefined string choices.]]
    max [[Sentinel value to indicate last enum field during iteration]]
 }
 
-struct Edje.External.Param {
-   [[Struct that holds parameters for parts of type EXTERNAL.]]
-   name: string; [[The name of the parameter.]]
-   type: Edje.External.Param_Type; [[The type of the parameter. This defines
-                                     which of the next three variables holds
-                                     the value for it.]]
-   // XXX these could be in a union, but eet doesn't support them (or does it?)
-   i: int; [[Used by both integer and boolean]]
-   d: double; [[Used by double]]
-   s: string; [[Used by both string and choice]]
-}
-
-
 struct Edje.Perspective; [[Perspective info for maps inside edje objects]]
 
 enum Edje.Color_Class.Mode {
index 86e3895..6345457 100644 (file)
@@ -3689,6 +3689,8 @@ _edje_object_efl_part_part(Eo *obj, Edje *ed, const char *part)
      return _edje_table_internal_proxy_get(obj, ed, rp);
    else if (rp->part->type == EDJE_PART_TYPE_SWALLOW)
      return _edje_swallow_internal_proxy_get(obj, ed, rp);
+   else if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
+     return _edje_external_internal_proxy_get(obj, ed, rp);
    else return NULL; /* FIXME/TODO: text & others (color, ...) */
 }
 
diff --git a/src/lib/edje/efl_canvas_layout_external.eo b/src/lib/edje/efl_canvas_layout_external.eo
new file mode 100644 (file)
index 0000000..0946a87
--- /dev/null
@@ -0,0 +1,78 @@
+import edje_types;
+
+class Efl.Canvas.Layout.External (Efl.Canvas.Layout_Internal)
+{
+   [[Class representing an external part in Edje layouts.
+
+     @since 1.20
+   ]]
+   data: null;
+   methods {
+      @property external_param {
+         [[This represents a parameter for an external object.
+
+           Parts of type external may carry extra properties that have
+           meanings defined by the external plugin. For instance, it may be a
+           string that defines a button label and setting this property will
+           change that label on the fly.
+
+           Parameters have a $name and a value which can be a boolean, an
+           integer, a floating-point number or a string. Some string parameters
+           only accept a certain set of values, like an enum.
+         ]]
+         set {
+            [[Sets the parameter for the external part.
+
+              Note: external parts have parameters set when they change
+              states. Those parameters will never be changed by this
+              function. The interpretation of how state_set parameters and
+              param_set will interact is up to the external plugin.
+
+              Note: this function will not check if parameter value is valid
+              using minimum, maximum, valid choices and others. However these
+              should be checked by the underlying implementation provided by
+              the external plugin. This is done for performance reasons.
+            ]]
+            return: bool; [[May return $false in case of failure.]]
+         }
+         get {
+            [[Gets the parameter for the external part.
+
+              This function asks the external plugin what is the current value,
+              independent on how it was set. This may return $null in case of
+              failure (eg. no such parameter exists).
+            ]]
+            values {
+               value: own(ptr(generic_value)); [[A pointer to a generic value
+                  holding a bool, int, float or string.]]
+            }
+         }
+         keys {
+            name: string; [[The name of the parameter.]]
+         }
+         values {
+            value: const(ptr(generic_value)); [[A pointer to a generic value
+               holding a bool, int, float or string.]]
+         }
+      }
+      @property external_param_type {
+         [[The type of a given parameter for this part (read only).]]
+         get {}
+         keys {
+            name: string; [[The name of the parameter.]]
+         }
+         values {
+            /* FIXME: Type name with "Edje" is no good! */
+            type: Edje.External.Param_Type; [[The type of parameter.]]
+         }
+      }
+      /*
+      external_param_choices {
+         [[Enumerates the possible values a choice-type parameter supports.]]
+         return: own(free(iterator<string>, eina_iterator_free));
+            [[An iterator over the accepted string values. Returns $null if
+              the parameter is not a choice parameter.]]
+      }
+      */
+   }
+}
index 4fe1344..74a1d3a 100644 (file)
@@ -1,3 +1,4 @@
+/* FIXME: Rename to Efl.Canvas.Layout.Part */
 class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx)
 {
    [[Common class for part proxy objects for $Efl.Canvas.Layout.