summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-05-29 20:28:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-05-30 13:54:34 +0900
commit554dd9facf0978b5fac27d6ae1fc802577a00bb8 (patch)
tree4b27b7c809ef4b4f6ad0d0b7d26cec5e608dc833
parentf9a95528b6bac3d9e08ada386cae6e0791d72999 (diff)
edje: Move external_param_set to a efl_part API
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
-rw-r--r--src/Makefile_Edje.am5
-rw-r--r--src/bin/elementary/test_external.c66
-rw-r--r--src/lib/edje/Edje_Common.h13
-rw-r--r--src/lib/edje/Edje_Eo.h6
-rw-r--r--src/lib/edje/Edje_Legacy.h78
-rw-r--r--src/lib/edje/edje_external.c26
-rw-r--r--src/lib/edje/edje_legacy.c58
-rw-r--r--src/lib/edje/edje_object.eo73
-rw-r--r--src/lib/edje/edje_part.c2
-rw-r--r--src/lib/edje/edje_part_external.c126
-rw-r--r--src/lib/edje/edje_private.h6
-rw-r--r--src/lib/edje/edje_types.eot18
-rw-r--r--src/lib/edje/edje_util.c2
-rw-r--r--src/lib/edje/efl_canvas_layout_external.eo78
-rw-r--r--src/lib/edje/efl_canvas_layout_internal.eo1
15 files changed, 439 insertions, 119 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index c2a8549..8f2ae77 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -12,7 +12,9 @@ edje_eolian_priv_files = \
12 lib/edje/efl_canvas_layout_internal.eo \ 12 lib/edje/efl_canvas_layout_internal.eo \
13 lib/edje/efl_canvas_layout_internal_box.eo \ 13 lib/edje/efl_canvas_layout_internal_box.eo \
14 lib/edje/efl_canvas_layout_internal_table.eo \ 14 lib/edje/efl_canvas_layout_internal_table.eo \
15 lib/edje/efl_canvas_layout_internal_swallow.eo 15 lib/edje/efl_canvas_layout_internal_swallow.eo \
16 lib/edje/efl_canvas_layout_external.eo \
17 $(NULL)
16 18
17edje_eolian_c = $(edje_eolian_files:%.eo=%.eo.c) 19edje_eolian_c = $(edje_eolian_files:%.eo=%.eo.c)
18edje_eolian_h = $(edje_eolian_files:%.eo=%.eo.h) \ 20edje_eolian_h = $(edje_eolian_files:%.eo=%.eo.h) \
@@ -95,6 +97,7 @@ lib/edje/edje_var.c \
95lib/edje/edje_signal.c \ 97lib/edje/edje_signal.c \
96lib/edje/edje_part.c \ 98lib/edje/edje_part.c \
97lib/edje/edje_part_helper.h \ 99lib/edje/edje_part_helper.h \
100lib/edje/edje_part_external.c \
98lib/edje/edje_part_swallow.c \ 101lib/edje/edje_part_swallow.c \
99lib/edje/edje_part_table.c \ 102lib/edje/edje_part_table.c \
100lib/edje/edje_part_box.c 103lib/edje/edje_part_box.c
diff --git a/src/bin/elementary/test_external.c b/src/bin/elementary/test_external.c
index cbd0c07..393d7fe 100644
--- a/src/bin/elementary/test_external.c
+++ b/src/bin/elementary/test_external.c
@@ -69,30 +69,43 @@ static Eina_Bool
69_timer_cb(void *data) 69_timer_cb(void *data)
70{ 70{
71 Evas_Object *edje = data; 71 Evas_Object *edje = data;
72 Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb4, *pb5, *pb6, *pb7; 72 Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb5;
73 Edje_External_Param param;
73 double progress; 74 double progress;
75 Eina_Value v;
74 76
75 pb1 = edje_object_part_external_object_get(edje, "ext_pbar1"); 77 pb1 = edje_object_part_external_object_get(edje, "ext_pbar1");
76 pb2 = edje_object_part_external_object_get(edje, "ext_pbar2"); 78 pb2 = edje_object_part_external_object_get(edje, "ext_pbar2");
77 pb3 = edje_object_part_external_object_get(edje, "ext_pbar3"); 79 pb3 = edje_object_part_external_object_get(edje, "ext_pbar3");
78 pb4 = edje_object_part_external_object_get(edje, "ext_pbar4");
79 pb6 = edje_object_part_external_object_get(edje, "ext_pbar6");
80 progress = elm_progressbar_value_get(pb1) + 0.0123; 80 progress = elm_progressbar_value_get(pb1) + 0.0123;
81 81
82 elm_progressbar_value_set(pb1, progress); 82 elm_progressbar_value_set(pb1, progress);
83 elm_progressbar_value_set(pb2, progress); 83 elm_progressbar_value_set(pb2, progress);
84 elm_progressbar_value_set(pb3, progress); 84 elm_progressbar_value_set(pb3, progress);
85 elm_progressbar_value_set(pb4, progress); 85
86 elm_progressbar_value_set(pb6, progress); 86 /* Test external parameter API */
87 param.name = "value";
88 param.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
89 param.d = progress;
90 edje_object_part_external_param_set(edje, "ext_pbar6", &param);
91
92 param.name = "pulsing";
93 param.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
94 param.i = EINA_TRUE;
95 edje_object_part_external_param_set(edje, "ext_pbar7", &param);
96
97 /* Test EO API for external parameters */
98 eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE);
99 eina_value_set(&v, progress);
100 efl_canvas_layout_external_param_set(efl_part(edje, "ext_pbar4"), "value", &v);
101 eina_value_flush(&v);
87 102
88 if (progress < 1.0) 103 if (progress < 1.0)
89 return ECORE_CALLBACK_RENEW; 104 return ECORE_CALLBACK_RENEW;
90 105
91 pb5 = edje_object_part_external_object_get(edje, "ext_pbar5"); 106 pb5 = edje_object_part_external_object_get(edje, "ext_pbar5");
92 pb7 = edje_object_part_external_object_get(edje, "ext_pbar7");
93 elm_progressbar_pulse(pb2, EINA_FALSE); 107 elm_progressbar_pulse(pb2, EINA_FALSE);
94 elm_progressbar_pulse(pb5, EINA_FALSE); 108 elm_progressbar_pulse(pb5, EINA_FALSE);
95 elm_progressbar_pulse(pb7, EINA_FALSE);
96 109
97 bt1 = edje_object_part_external_object_get(edje, "ext_button1"); 110 bt1 = edje_object_part_external_object_get(edje, "ext_button1");
98 bt2 = edje_object_part_external_object_get(edje, "ext_button2"); 111 bt2 = edje_object_part_external_object_get(edje, "ext_button2");
@@ -101,6 +114,17 @@ _timer_cb(void *data)
101 elm_object_disabled_set(bt2, EINA_FALSE); 114 elm_object_disabled_set(bt2, EINA_FALSE);
102 elm_object_disabled_set(bt3, EINA_FALSE); 115 elm_object_disabled_set(bt3, EINA_FALSE);
103 116
117 /* Test external parameter API */
118 param.name = "value";
119 param.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
120 param.d = 0.0;
121 edje_object_part_external_param_set(edje, "ext_pbar6", &param);
122
123 param.name = "pulsing";
124 param.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
125 param.i = EINA_FALSE;
126 edje_object_part_external_param_set(edje, "ext_pbar7", &param);
127
104 return ECORE_CALLBACK_CANCEL; 128 return ECORE_CALLBACK_CANCEL;
105} 129}
106 130
@@ -108,8 +132,11 @@ static void
108_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 132_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
109{ 133{
110 Evas_Object *edje = data; 134 Evas_Object *edje = data;
111 Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb4, *pb5, *pb6, *pb7; 135 Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb5;
136 Edje_External_Param param;
137 Eina_Value v;
112 138
139 /* Test direct API calls on embedded objects */
113 bt1 = edje_object_part_external_object_get(edje, "ext_button1"); 140 bt1 = edje_object_part_external_object_get(edje, "ext_button1");
114 bt2 = edje_object_part_external_object_get(edje, "ext_button2"); 141 bt2 = edje_object_part_external_object_get(edje, "ext_button2");
115 bt3 = edje_object_part_external_object_get(edje, "ext_button3"); 142 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
120 pb1 = edje_object_part_external_object_get(edje, "ext_pbar1"); 147 pb1 = edje_object_part_external_object_get(edje, "ext_pbar1");
121 pb2 = edje_object_part_external_object_get(edje, "ext_pbar2"); 148 pb2 = edje_object_part_external_object_get(edje, "ext_pbar2");
122 pb3 = edje_object_part_external_object_get(edje, "ext_pbar3"); 149 pb3 = edje_object_part_external_object_get(edje, "ext_pbar3");
123 pb4 = edje_object_part_external_object_get(edje, "ext_pbar4");
124 pb5 = edje_object_part_external_object_get(edje, "ext_pbar5"); 150 pb5 = edje_object_part_external_object_get(edje, "ext_pbar5");
125 pb6 = edje_object_part_external_object_get(edje, "ext_pbar6");
126 pb7 = edje_object_part_external_object_get(edje, "ext_pbar7");
127 151
128 elm_progressbar_value_set(pb1, 0.0); 152 elm_progressbar_value_set(pb1, 0.0);
129 elm_progressbar_value_set(pb3, 0.0); 153 elm_progressbar_value_set(pb3, 0.0);
130 elm_progressbar_value_set(pb4, 0.0);
131 elm_progressbar_value_set(pb6, 0.0);
132 154
133 elm_progressbar_pulse(pb2, EINA_TRUE); 155 elm_progressbar_pulse(pb2, EINA_TRUE);
134 elm_progressbar_pulse(pb5, EINA_TRUE); 156 elm_progressbar_pulse(pb5, EINA_TRUE);
135 elm_progressbar_pulse(pb7, EINA_TRUE); 157
158 /* Test external parameter API */
159 param.name = "value";
160 param.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
161 param.d = 0.0;
162 edje_object_part_external_param_set(edje, "ext_pbar6", &param);
163
164 param.name = "pulsing";
165 param.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
166 param.i = EINA_TRUE;
167 edje_object_part_external_param_set(edje, "ext_pbar7", &param);
168
169 /* Test EO API for external parameters */
170 eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE);
171 eina_value_set(&v, 0.0);
172 efl_canvas_layout_external_param_set(efl_part(edje, "ext_pbar4"), "value", &v);
173 eina_value_flush(&v);
136 174
137 ecore_timer_add(0.1, _timer_cb, edje); 175 ecore_timer_add(0.1, _timer_cb, edje);
138} 176}
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index 4152251..baa6846 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -368,6 +368,19 @@ typedef enum _Edje_External_Param_Flags
368 EDJE_EXTERNAL_PARAM_FLAGS_STATE) /**< Convenience flag that sets property as GET, SET and STATE. */ 368 EDJE_EXTERNAL_PARAM_FLAGS_STATE) /**< Convenience flag that sets property as GET, SET and STATE. */
369} Edje_External_Param_Flags; 369} Edje_External_Param_Flags;
370 370
371/** Struct that holds parameters for parts of type EXTERNAL.
372 */
373typedef struct _Edje_External_Param
374{
375 const char *name; /**< The name of the parameter. */
376 Edje_External_Param_Type type; /**< The type of the parameter. This defines
377 * which of the next three variables holds the
378 * value for it. */
379 int i; /**< Used by both integer and boolean */
380 double d; /**< Used by double */
381 const char *s; /**< Used by both string and choice */
382} Edje_External_Param;
383
371/** 384/**
372 * @brief Converts type identifier to string nicer representation. 385 * @brief Converts type identifier to string nicer representation.
373 * 386 *
diff --git a/src/lib/edje/Edje_Eo.h b/src/lib/edje/Edje_Eo.h
index c303ea8..05982fd 100644
--- a/src/lib/edje/Edje_Eo.h
+++ b/src/lib/edje/Edje_Eo.h
@@ -2,3 +2,9 @@
2 2
3#include "edje_object.eo.h" 3#include "edje_object.eo.h"
4#include "edje_edit.eo.h" 4#include "edje_edit.eo.h"
5
6#include "efl_canvas_layout_internal.eo.h"
7#include "efl_canvas_layout_internal_box.eo.h"
8#include "efl_canvas_layout_internal_table.eo.h"
9#include "efl_canvas_layout_internal_swallow.eo.h"
10#include "efl_canvas_layout_external.eo.h"
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index eba6d13..2451171 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -406,6 +406,84 @@ EAPI void edje_object_message_signal_recursive_process(Edje_Object *obj);
406 * @} 406 * @}
407 */ 407 */
408 408
409/**
410 * @ingroup Edje_Object
411 *
412 * @{
413 */
414
415/**
416 * @brief Facility to query the type of the given parameter of the given part.
417 *
418 * @param[in] part The part name
419 * @param[in] param The parameter name to use
420 *
421 * @return @ref EDJE_EXTERNAL_PARAM_TYPE_MAX on errors, or another value from
422 * @ref Edje_External_Param_Type on success.
423 *
424 * @ingroup Edje_Object
425 */
426EAPI Edje_External_Param_Type edje_object_part_external_param_type_get(const Edje_Object *obj, const char *part, const char * param);
427
428/**
429 * @brief Sets the parameter for the external part.
430 *
431 * Parts of type external may carry extra properties that have meanings defined
432 * by the external plugin. For instance, it may be a string that defines a
433 * button label and setting this property will change that label on the fly.
434 *
435 * @note external parts have parameters set when they change states. Those
436 * parameters will never be changed by this function. The interpretation of how
437 * state_set parameters and param_set will interact is up to the external
438 * plugin.
439 *
440 * @note this function will not check if parameter value is valid using
441 * #Edje_External_Param_Info minimum, maximum, valid choices and others.
442 * However these should be checked by the underlying implementation provided by
443 * the external plugin. This is done for performance reasons.
444 *
445 * @param[in] part The part name
446 * @param[in] param The parameter details, including its name, type and actual
447 * value. This pointer should be valid, and the parameter must exist in
448 * #Edje_External_Type.parameters_info, with the exact type, otherwise the
449 * operation will fail and @c false will be returned.
450 *
451 * @return @c true if everything went fine, @c false on errors.
452 *
453 * @ingroup Edje_Object
454 */
455EAPI Eina_Bool edje_object_part_external_param_set(Edje_Object *obj, const char *part, const Edje_External_Param *param);
456
457/**
458 * @brief Gets the parameter for the external part.
459 *
460 * Parts of type external may carry extra properties that have meanings defined
461 * by the external plugin. For instance, it may be a string that defines a
462 * button label. This property can be modified by state parameters, by explicit
463 * calls to edje_object_part_external_param_set() or getting the actual object
464 * with edje_object_part_external_object_get() and calling native functions.
465 *
466 * This function asks the external plugin what is the current value,
467 * independent on how it was set.
468 *
469 * @param[in] part The part name
470 * @param[out] param The parameter details. It is used as both input and output
471 * variable. This pointer should be valid, and the parameter must exist in
472 * #Edje_External_Type.parameters_info, with the exact type, otherwise the
473 * operation will fail and @c false will be returned.
474 *
475 * @return @c true if everything went fine and param members are filled with
476 * information, @c false on errors and param member values are not set or
477 * valid.
478 *
479 * @ingroup Edje_Object
480 */
481EAPI Eina_Bool edje_object_part_external_param_get(const Edje_Object *obj, const char *part, Edje_External_Param *param);
482
483/**
484 * @}
485 */
486
409 /** 487 /**
410 * @deprecated use evas_object_size_hint_min_set() instead. 488 * @deprecated use evas_object_size_hint_min_set() instead.
411 * @brief Sets the object minimum size. 489 * @brief Sets the object minimum size.
diff --git a/src/lib/edje/edje_external.c b/src/lib/edje/edje_external.c
index 8e242f1..b345200 100644
--- a/src/lib/edje/edje_external.c
+++ b/src/lib/edje/edje_external.c
@@ -56,14 +56,12 @@ _edje_object_part_external_object_get(Eo *obj EINA_UNUSED, Edje *ed, const char
56 return rp->typedata.swallow->swallowed_object; 56 return rp->typedata.swallow->swallowed_object;
57} 57}
58 58
59EOLIAN Eina_Bool 59Eina_Bool
60_edje_object_part_external_param_set(Eo *obj, Edje *ed, const char *part, const Edje_External_Param *param) 60_edje_object_part_external_param_set(Edje *ed, const char *part, const Edje_External_Param *param)
61{ 61{
62 Edje_Real_Part *rp; 62 Edje_Real_Part *rp;
63 63
64 if ((!param) || (!param->name)) return EINA_FALSE; 64 if (!ed || !part || !param || !param->name) return EINA_FALSE;
65
66 if ((!ed) || (!part)) return EINA_FALSE;
67 65
68 rp = _edje_real_part_recursive_get(&ed, (char *)part); 66 rp = _edje_real_part_recursive_get(&ed, (char *)part);
69 if (!rp) 67 if (!rp)
@@ -72,19 +70,17 @@ _edje_object_part_external_param_set(Eo *obj, Edje *ed, const char *part, const
72 return EINA_FALSE; 70 return EINA_FALSE;
73 } 71 }
74 72
75 if (_edje_external_param_set(obj, rp, param)) 73 if (_edje_external_param_set(ed->obj, rp, param))
76 return EINA_TRUE; 74 return EINA_TRUE;
77 return EINA_FALSE; 75 return EINA_FALSE;
78} 76}
79 77
80EOLIAN Eina_Bool 78Eina_Bool
81_edje_object_part_external_param_get(Eo *obj, Edje *ed, const char *part, Edje_External_Param *param) 79_edje_object_part_external_param_get(Edje *ed, const char *part, Edje_External_Param *param)
82{ 80{
83 Edje_Real_Part *rp; 81 Edje_Real_Part *rp;
84 82
85 if ((!param) || (!param->name)) return EINA_FALSE; 83 if (!ed || !part || !param || !param->name) return EINA_FALSE;
86
87 if ((!ed) || (!part)) return EINA_FALSE;
88 84
89 rp = _edje_real_part_recursive_get(&ed, (char *)part); 85 rp = _edje_real_part_recursive_get(&ed, (char *)part);
90 if (!rp) 86 if (!rp)
@@ -93,7 +89,7 @@ _edje_object_part_external_param_get(Eo *obj, Edje *ed, const char *part, Edje_E
93 return EINA_FALSE; 89 return EINA_FALSE;
94 } 90 }
95 91
96 return _edje_external_param_get(obj, rp, param); 92 return _edje_external_param_get(ed->obj, rp, param);
97} 93}
98 94
99EOLIAN Evas_Object * 95EOLIAN Evas_Object *
@@ -117,8 +113,8 @@ _edje_object_part_external_content_get(Eo *obj EINA_UNUSED, Edje *ed, const char
117 return _edje_external_content_get(rp->typedata.swallow->swallowed_object, content); 113 return _edje_external_content_get(rp->typedata.swallow->swallowed_object, content);
118} 114}
119 115
120EOLIAN Edje_External_Param_Type 116Edje_External_Param_Type
121_edje_object_part_external_param_type_get(Eo *obj, Edje *ed, const char *part, const char *param) 117_edje_object_part_external_param_type_get(Edje *ed, const char *part, const char *param)
122{ 118{
123 Edje_Real_Part *rp; 119 Edje_Real_Part *rp;
124 Edje_External_Type *type; 120 Edje_External_Type *type;
@@ -137,7 +133,7 @@ _edje_object_part_external_param_type_get(Eo *obj, Edje *ed, const char *part, c
137 type = evas_object_data_get(rp->typedata.swallow->swallowed_object, "Edje_External_Type"); 133 type = evas_object_data_get(rp->typedata.swallow->swallowed_object, "Edje_External_Type");
138 if (!type) 134 if (!type)
139 { 135 {
140 ERR("no external type for object %p", obj); 136 ERR("no external type for object %p", ed->obj);
141 return EDJE_EXTERNAL_PARAM_TYPE_MAX; 137 return EDJE_EXTERNAL_PARAM_TYPE_MAX;
142 } 138 }
143 if (!type->parameters_info) 139 if (!type->parameters_info)
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index 3c9e6d2..cf27351 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -60,3 +60,61 @@ edje_object_message_signal_recursive_process(Edje_Object *obj)
60{ 60{
61 edje_obj_message_signal_process(obj, EINA_TRUE); 61 edje_obj_message_signal_process(obj, EINA_TRUE);
62} 62}
63
64EAPI Eina_Bool
65edje_object_part_external_param_set(Eo *obj, const char *part, const Edje_External_Param *param)
66{
67 Edje *ed = _edje_fetch(obj);
68
69 if (!ed || !param || !part) return EINA_FALSE;
70
71#if 1
72 /* validate EO API - disable for performance */
73 Eina_Value *v;
74 Eina_Bool ok;
75
76 switch (param->type)
77 {
78 case EDJE_EXTERNAL_PARAM_TYPE_INT:
79 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
80 v = eina_value_new(EINA_VALUE_TYPE_INT);
81 eina_value_set(v, param->i);
82 break;
83
84 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
85 v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
86 eina_value_set(v, param->d);
87 break;
88
89 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
90 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
91 v = eina_value_new(EINA_VALUE_TYPE_STRING);
92 eina_value_set(v, param->s);
93 break;
94
95 default: return EINA_FALSE;
96 }
97
98 ok = efl_canvas_layout_external_param_set(efl_part(obj, part), param->name, v);
99 eina_value_free(v);
100
101 return ok;
102
103#else
104 return _edje_object_part_external_param_set(ed, part, param);
105#endif
106}
107
108EAPI Eina_Bool
109edje_object_part_external_param_get(const Eo *obj, const char *part, Edje_External_Param *param)
110{
111 Edje *ed = _edje_fetch(obj);
112 return _edje_object_part_external_param_get(ed, part, param);
113}
114
115EAPI Edje_External_Param_Type
116edje_object_part_external_param_type_get(const Eo *obj, const char *part, const char *param)
117{
118 Edje *ed = _edje_fetch(obj);
119 return _edje_object_part_external_param_type_get(ed, part, param);
120}
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 1d7d1d5..ccb101a 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -1006,19 +1006,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
1006 @in dy: double; [[The y step]] 1006 @in dy: double; [[The y step]]
1007 } 1007 }
1008 } 1008 }
1009 @property part_external_param_type {
1010 get {
1011 [[Facility to query the type of the given parameter of the given part.]]
1012 return: Edje.External.Param_Type(Edje.External.Param_Type.max); [[
1013 @Edje.External.Param_Type.max on errors, or another value
1014 from @Edje.External.Param_Type on success.
1015 ]]
1016 }
1017 keys {
1018 part: string; [[The part name]]
1019 param: string; [[The parameter name to use]]
1020 }
1021 }
1022 @property part_external_object { 1009 @property part_external_object {
1023 get { 1010 get {
1024 [[Gets the object created by this external part. 1011 [[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,
1053 content: string; [[A string identifying which content from the EXTERNAL to get]] 1040 content: string; [[A string identifying which content from the EXTERNAL to get]]
1054 } 1041 }
1055 } 1042 }
1056 @property part_external_param {
1057 set {
1058 [[Sets the parameter for the external part.
1059
1060 Parts of type external may carry extra properties that have
1061 meanings defined by the external plugin. For instance, it may be a
1062 string that defines a button label and setting this property will
1063 change that label on the fly.
1064
1065 Note: external parts have parameters set when they change
1066 states. Those parameters will never be changed by this
1067 function. The interpretation of how state_set parameters and
1068 param_set will interact is up to the external plugin.
1069
1070 Note: this function will not check if parameter value is valid
1071 using #Edje_External_Param_Info minimum, maximum, valid
1072 choices and others. However these should be checked by the
1073 underlying implementation provided by the external
1074 plugin. This is done for performance reasons.]]
1075
1076 return: bool; [[$true if everything went fine, $false on errors.]]
1077 values {
1078 param: ptr(const(Edje.External.Param)); [[The parameter details, including its name, type and
1079 actual value. This pointer should be valid, and the
1080 parameter must exist in
1081 #Edje_External_Type.parameters_info, with the exact type,
1082 otherwise the operation will fail and $false will be
1083 returned.]]
1084 }
1085 }
1086 get {
1087 [[Gets the parameter for the external part.
1088
1089 Parts of type external may carry extra properties that have
1090 meanings defined by the external plugin. For instance, it may be a
1091 string that defines a button label. This property can be modified by
1092 state parameters, by explicit calls to
1093 edje_object_part_external_param_set() or getting the actual object
1094 with edje_object_part_external_object_get() and calling native
1095 functions.
1096
1097 This function asks the external plugin what is the current value,
1098 independent on how it was set.]]
1099
1100 return: bool; [[$true if everything went fine and param members
1101 are filled with information, $false on errors and
1102 param member values are not set or valid.]]
1103 values {
1104 param: Edje.External.Param; [[The parameter details. It is used as both input and
1105 output variable. This pointer should be valid, and the
1106 parameter must exist in
1107 #Edje_External_Type.parameters_info, with the exact type,
1108 otherwise the operation will fail and $false will be
1109 returned.]]
1110 }
1111 }
1112 keys {
1113 part: string; [[The part name]]
1114 }
1115 }
1116 @property text_change_cb { 1043 @property text_change_cb {
1117 set { 1044 set {
1118 [[Sets the object text callback. 1045 [[Sets the object text callback.
diff --git a/src/lib/edje/edje_part.c b/src/lib/edje/edje_part.c
index fe2c23a..c5d2eed 100644
--- a/src/lib/edje/edje_part.c
+++ b/src/lib/edje/edje_part.c
@@ -5,6 +5,7 @@
5PROXY_INIT(box) 5PROXY_INIT(box)
6PROXY_INIT(table) 6PROXY_INIT(table)
7PROXY_INIT(swallow) 7PROXY_INIT(swallow)
8PROXY_INIT(external)
8 9
9void 10void
10_edje_internal_proxy_shutdown(void) 11_edje_internal_proxy_shutdown(void)
@@ -12,6 +13,7 @@ _edje_internal_proxy_shutdown(void)
12 _box_shutdown(); 13 _box_shutdown();
13 _table_shutdown(); 14 _table_shutdown();
14 _swallow_shutdown(); 15 _swallow_shutdown();
16 _external_shutdown();
15} 17}
16 18
17void 19void
diff --git a/src/lib/edje/edje_part_external.c b/src/lib/edje/edje_part_external.c
new file mode 100644
index 0000000..cee7fc0
--- /dev/null
+++ b/src/lib/edje/edje_part_external.c
@@ -0,0 +1,126 @@
1#include "edje_private.h"
2#include "edje_part_helper.h"
3
4#define MY_CLASS EFL_CANVAS_LAYOUT_EXTERNAL_CLASS
5
6PROXY_IMPLEMENTATION(external, EXTERNAL)
7#undef PROXY_IMPLEMENTATION
8
9EOLIAN static Eina_Bool
10_efl_canvas_layout_external_external_param_set(Eo *obj, void *_pd EINA_UNUSED,
11 const char *name, const Eina_Value *value)
12{
13 Edje_External_Param_Type type;
14 Edje_External_Param param = {};
15 const Eina_Value_Type *vtype;
16
17 PROXY_DATA_GET(obj, pd);
18 type = _edje_object_part_external_param_type_get(pd->ed, pd->part, name);
19
20 param.name = name;
21 param.type = type;
22 vtype = eina_value_type_get(value);
23
24 switch (type)
25 {
26 case EDJE_EXTERNAL_PARAM_TYPE_INT:
27 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
28 if (vtype == EINA_VALUE_TYPE_INT)
29 eina_value_get(value, &param.i);
30 else
31 {
32 Eina_Value v2;
33
34 eina_value_setup(&v2, EINA_VALUE_TYPE_INT);
35 eina_value_convert(value, &v2);
36 eina_value_get(&v2, &param.i);
37 eina_value_flush(&v2);
38 }
39 break;
40
41 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
42 if (vtype == EINA_VALUE_TYPE_DOUBLE)
43 eina_value_get(value, &param.d);
44 else
45 {
46 Eina_Value v2;
47
48 eina_value_setup(&v2, EINA_VALUE_TYPE_DOUBLE);
49 eina_value_convert(value, &v2);
50 eina_value_get(&v2, &param.d);
51 eina_value_flush(&v2);
52 }
53 break;
54
55 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
56 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
57 // Should we use eina_value_to_string() here and not complain?
58 if ((vtype != EINA_VALUE_TYPE_STRING) && (vtype != EINA_VALUE_TYPE_STRINGSHARE))
59 {
60 ERR("External parameter '%s' of object '%p' expects a string, "
61 "got a '%s'.", name, pd->ed->obj, eina_value_type_name_get(vtype));
62 RETURN_VAL(EINA_FALSE);
63 }
64 eina_value_get(value, &param.s);
65 break;
66
67 default:
68 ERR("Unsupported type for parameter '%s' of object '%p'", name, pd->ed->obj);
69 RETURN_VAL(EINA_FALSE);
70 }
71
72 RETURN_VAL(_edje_object_part_external_param_set(pd->ed, pd->part, &param));
73}
74
75EOLIAN static Eina_Value *
76_efl_canvas_layout_external_external_param_get(Eo *obj, void *_pd EINA_UNUSED,
77 const char *name)
78{
79 Edje_External_Param param = {};
80 Eina_Value *v;
81
82 PROXY_DATA_GET(obj, pd);
83
84 param.name = name;
85 param.type = _edje_object_part_external_param_type_get(pd->ed, pd->part, name);
86 if (param.type == EDJE_EXTERNAL_PARAM_TYPE_MAX)
87 RETURN_VAL(NULL);
88 if (!_edje_object_part_external_param_get(pd->ed, pd->part, &param))
89 RETURN_VAL(NULL);
90
91 switch (param.type)
92 {
93 case EDJE_EXTERNAL_PARAM_TYPE_INT:
94 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
95 v = eina_value_new(EINA_VALUE_TYPE_INT);
96 eina_value_set(v, param.i);
97 break;
98
99 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
100 v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
101 eina_value_set(v, param.d);
102 break;
103
104 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
105 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
106 v = eina_value_new(EINA_VALUE_TYPE_STRING);
107 eina_value_set(v, param.s);
108 break;
109
110 default:
111 ERR("Unsupported type for parameter '%s' of object '%p'", name, pd->ed->obj);
112 RETURN_VAL(NULL);
113 }
114
115 RETURN_VAL(v);
116}
117
118EOLIAN static Edje_External_Param_Type
119_efl_canvas_layout_external_external_param_type_get(Eo *obj, void *_pd EINA_UNUSED,
120 const char *name)
121{
122 PROXY_DATA_GET(obj, pd);
123 RETURN_VAL(_edje_object_part_external_param_type_get(pd->ed, pd->part, name));
124}
125
126#include "efl_canvas_layout_external.eo.c"
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 2911bc2..e62d59e 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -3120,6 +3120,12 @@ Eo *_edje_swallow_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part
3120Efl_Gfx *_edje_efl_container_content_get(Edje *ed, const char *part); 3120Efl_Gfx *_edje_efl_container_content_get(Edje *ed, const char *part);
3121Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow); 3121Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow);
3122 3122
3123/* part containers: external */
3124Eo *_edje_external_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp);
3125Eina_Bool _edje_object_part_external_param_set(Edje *ed, const char *part, const Edje_External_Param *param);
3126Eina_Bool _edje_object_part_external_param_get(Edje *ed, const char *part, Edje_External_Param *param);
3127Edje_External_Param_Type _edje_object_part_external_param_type_get(Edje *ed, const char *part, const char *param);
3128
3123void _edje_internal_proxy_shutdown(void); 3129void _edje_internal_proxy_shutdown(void);
3124 3130
3125// Svg loader 3131// Svg loader
diff --git a/src/lib/edje/edje_types.eot b/src/lib/edje/edje_types.eot
index 9345af8..9d7478b 100644
--- a/src/lib/edje/edje_types.eot
+++ b/src/lib/edje/edje_types.eot
@@ -113,31 +113,17 @@ enum Edje.Input_Panel.Layout {
113 @since 1.19]] 113 @since 1.19]]
114} 114}
115 115
116/* FIXME: This probably needs to be a more generic enum with a shorter name */
116enum Edje.External.Param_Type { 117enum Edje.External.Param_Type {
117 [[The possible types the parameters of an EXTERNAL part can be.]] 118 [[The possible types the parameters of an EXTERNAL part can be.]]
118
119 int, [[Parameter value is an integer.]] 119 int, [[Parameter value is an integer.]]
120 double, [[Parameter value is a double.]] 120 double, [[Parameter value is a double.]]
121 string, [[Parameter value is a string.]] 121 string, [[Parameter value is a string.]]
122 bool, [[Parameter value is boolean.]] 122 bool, [[Parameter value is boolean.]]
123 choice, [[Parameter value is one of a set of 123 choice, [[Parameter value is one of a set of predefined string choices.]]
124 predefined string choices.]]
125 max [[Sentinel value to indicate last enum field during iteration]] 124 max [[Sentinel value to indicate last enum field during iteration]]
126} 125}
127 126
128struct Edje.External.Param {
129 [[Struct that holds parameters for parts of type EXTERNAL.]]
130 name: string; [[The name of the parameter.]]
131 type: Edje.External.Param_Type; [[The type of the parameter. This defines
132 which of the next three variables holds
133 the value for it.]]
134 // XXX these could be in a union, but eet doesn't support them (or does it?)
135 i: int; [[Used by both integer and boolean]]
136 d: double; [[Used by double]]
137 s: string; [[Used by both string and choice]]
138}
139
140
141struct Edje.Perspective; [[Perspective info for maps inside edje objects]] 127struct Edje.Perspective; [[Perspective info for maps inside edje objects]]
142 128
143enum Edje.Color_Class.Mode { 129enum Edje.Color_Class.Mode {
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 86e3895..6345457 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3689,6 +3689,8 @@ _edje_object_efl_part_part(Eo *obj, Edje *ed, const char *part)
3689 return _edje_table_internal_proxy_get(obj, ed, rp); 3689 return _edje_table_internal_proxy_get(obj, ed, rp);
3690 else if (rp->part->type == EDJE_PART_TYPE_SWALLOW) 3690 else if (rp->part->type == EDJE_PART_TYPE_SWALLOW)
3691 return _edje_swallow_internal_proxy_get(obj, ed, rp); 3691 return _edje_swallow_internal_proxy_get(obj, ed, rp);
3692 else if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
3693 return _edje_external_internal_proxy_get(obj, ed, rp);
3692 else return NULL; /* FIXME/TODO: text & others (color, ...) */ 3694 else return NULL; /* FIXME/TODO: text & others (color, ...) */
3693} 3695}
3694 3696
diff --git a/src/lib/edje/efl_canvas_layout_external.eo b/src/lib/edje/efl_canvas_layout_external.eo
new file mode 100644
index 0000000..0946a87
--- /dev/null
+++ b/src/lib/edje/efl_canvas_layout_external.eo
@@ -0,0 +1,78 @@
1import edje_types;
2
3class Efl.Canvas.Layout.External (Efl.Canvas.Layout_Internal)
4{
5 [[Class representing an external part in Edje layouts.
6
7 @since 1.20
8 ]]
9 data: null;
10 methods {
11 @property external_param {
12 [[This represents a parameter for an external object.
13
14 Parts of type external may carry extra properties that have
15 meanings defined by the external plugin. For instance, it may be a
16 string that defines a button label and setting this property will
17 change that label on the fly.
18
19 Parameters have a $name and a value which can be a boolean, an
20 integer, a floating-point number or a string. Some string parameters
21 only accept a certain set of values, like an enum.
22 ]]
23 set {
24 [[Sets the parameter for the external part.
25
26 Note: external parts have parameters set when they change
27 states. Those parameters will never be changed by this
28 function. The interpretation of how state_set parameters and
29 param_set will interact is up to the external plugin.
30
31 Note: this function will not check if parameter value is valid
32 using minimum, maximum, valid choices and others. However these
33 should be checked by the underlying implementation provided by
34 the external plugin. This is done for performance reasons.
35 ]]
36 return: bool; [[May return $false in case of failure.]]
37 }
38 get {
39 [[Gets the parameter for the external part.
40
41 This function asks the external plugin what is the current value,
42 independent on how it was set. This may return $null in case of
43 failure (eg. no such parameter exists).
44 ]]
45 values {
46 value: own(ptr(generic_value)); [[A pointer to a generic value
47 holding a bool, int, float or string.]]
48 }
49 }
50 keys {
51 name: string; [[The name of the parameter.]]
52 }
53 values {
54 value: const(ptr(generic_value)); [[A pointer to a generic value
55 holding a bool, int, float or string.]]
56 }
57 }
58 @property external_param_type {
59 [[The type of a given parameter for this part (read only).]]
60 get {}
61 keys {
62 name: string; [[The name of the parameter.]]
63 }
64 values {
65 /* FIXME: Type name with "Edje" is no good! */
66 type: Edje.External.Param_Type; [[The type of parameter.]]
67 }
68 }
69 /*
70 external_param_choices {
71 [[Enumerates the possible values a choice-type parameter supports.]]
72 return: own(free(iterator<string>, eina_iterator_free));
73 [[An iterator over the accepted string values. Returns $null if
74 the parameter is not a choice parameter.]]
75 }
76 */
77 }
78}
diff --git a/src/lib/edje/efl_canvas_layout_internal.eo b/src/lib/edje/efl_canvas_layout_internal.eo
index 4fe1344..74a1d3a 100644
--- a/src/lib/edje/efl_canvas_layout_internal.eo
+++ b/src/lib/edje/efl_canvas_layout_internal.eo
@@ -1,3 +1,4 @@
1/* FIXME: Rename to Efl.Canvas.Layout.Part */
1class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx) 2class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx)
2{ 3{
3 [[Common class for part proxy objects for $Efl.Canvas.Layout. 4 [[Common class for part proxy objects for $Efl.Canvas.Layout.