edje: Compose external part with real object

This effectively replaces edje_object_part_external_object_get
and allows all function calls except those from Efl.Object.

Is this good enough? Or do we need access to the real object?
This commit is contained in:
Jean-Philippe Andre 2017-05-29 22:47:55 +09:00
parent 9575bc8f8b
commit 8bf347b228
7 changed files with 40 additions and 11 deletions

View File

@ -69,19 +69,17 @@ static Eina_Bool
_timer_cb(void *data)
{
Evas_Object *edje = data;
Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *pb3, *pb5;
Evas_Object *bt1, *bt2, *bt3, *pb1, *pb2, *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");
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);
/* Test external parameter API */
param.name = "value";
@ -100,6 +98,9 @@ _timer_cb(void *data)
efl_canvas_layout_external_param_set(efl_part(edje, "ext_pbar4"), "value", &v);
eina_value_flush(&v);
/* Test EO API for direct function calls */
efl_ui_progress_value_set(efl_part(edje, "ext_pbar3"), progress);
if (progress < 1.0)
return ECORE_CALLBACK_RENEW;
@ -172,6 +173,9 @@ _bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
efl_canvas_layout_external_param_set(efl_part(edje, "ext_pbar4"), "value", &v);
eina_value_flush(&v);
/* Test EO API for direct function calls */
efl_ui_progress_value_set(efl_part(edje, "ext_pbar3"), 0.0);
ecore_timer_add(0.1, _timer_cb, edje);
}

View File

@ -5,7 +5,7 @@
#include "../evas/canvas/evas_box.eo.h"
PROXY_IMPLEMENTATION(box, BOX)
PROXY_IMPLEMENTATION(box, BOX, EINA_FALSE)
#undef PROXY_IMPLEMENTATION
typedef struct _Part_Item_Iterator Part_Item_Iterator;

View File

@ -3,9 +3,18 @@
#define MY_CLASS EFL_CANVAS_LAYOUT_EXTERNAL_CLASS
PROXY_IMPLEMENTATION(external, EXTERNAL)
static void _external_compose(Eo *obj, Edje *ed, const char *part);
PROXY_IMPLEMENTATION(external, EXTERNAL, EINA_TRUE, _external_compose(proxy, ed, rp->part->name))
#undef PROXY_IMPLEMENTATION
static void
_external_compose(Eo *obj, Edje *ed, const char *part)
{
Eo *ext_obj = _edje_object_part_external_object_get(ed, part);
efl_composite_attach(obj, ext_obj);
}
EOLIAN static Eina_Bool
_efl_canvas_layout_external_external_param_set(Eo *obj, void *_pd EINA_UNUSED,
const char *name, const Eina_Value *value)

View File

@ -25,6 +25,10 @@ struct _Part_Item_Iterator
#define RETURN_VOID do { PROXY_UNREF(obj, pd); return; } while(0)
#define PROXY_CALL(a) ({ PROXY_REF(obj, pd); a; })
#ifndef PROXY_ADD_EXTRA_OP
# define PROXY_ADD_EXTRA_OP
#endif
void _edje_real_part_set(Eo *obj, void *ed, void *rp, const char *part);
/* ugly macros to avoid code duplication */
@ -44,7 +48,7 @@ _ ## type ## _shutdown(void); \
#define PROXY_DATA_GET(obj, pd) \
Efl_Canvas_Layout_Internal_Data *pd = efl_data_scope_get(obj, EFL_CANVAS_LAYOUT_INTERNAL_CLASS)
#define PROXY_IMPLEMENTATION(type, TYPE) \
#define PROXY_IMPLEMENTATION(type, TYPE, no_del_cb, ...) \
static Eo * _ ## type ## _proxy = NULL; \
\
static void \
@ -87,7 +91,8 @@ _edje_ ## type ## _internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Ed
} \
proxy = efl_add(MY_CLASS, ed->obj, \
_edje_real_part_set(efl_added, ed, rp, rp->part->name)); \
efl_del_intercept_set(proxy, _ ## type ## _del_cb); \
__VA_ARGS__; \
if (!no_del_cb) efl_del_intercept_set(proxy, _ ## type ## _del_cb); \
return proxy; \
} \
\
@ -102,7 +107,8 @@ _edje_ ## type ## _internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Ed
proxy = _ ## type ## _proxy; \
_ ## type ## _proxy = NULL; \
_edje_real_part_set(proxy, ed, rp, rp->part->name); \
efl_del_intercept_set(proxy, _ ## type ## _del_cb); \
__VA_ARGS__; \
if (!no_del_cb) efl_del_intercept_set(proxy, _ ## type ## _del_cb); \
return proxy; \
}

View File

@ -3,7 +3,7 @@
#include "efl_canvas_layout_internal_swallow.eo.h"
#define MY_CLASS EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_CLASS
PROXY_IMPLEMENTATION(swallow, SWALLOW)
PROXY_IMPLEMENTATION(swallow, SWALLOW, EINA_FALSE)
#undef PROXY_IMPLEMENTATION
/* Swallow parts */

View File

@ -5,7 +5,7 @@
#include "../evas/canvas/evas_table.eo.h"
PROXY_IMPLEMENTATION(table, TABLE)
PROXY_IMPLEMENTATION(table, TABLE, EINA_FALSE)
#undef PROXY_IMPLEMENTATION
typedef struct _Part_Item_Iterator Part_Item_Iterator;

View File

@ -1,9 +1,19 @@
import edje_types;
class Efl.Canvas.Layout.External (Efl.Canvas.Layout_Internal)
class Efl.Canvas.Layout.External (Efl.Canvas.Layout_Internal, Efl.Canvas.Object)
{
[[Class representing an external part in Edje layouts.
An object of this type is an Efl.Part object, which means its lifecycle
is limited to one and only one function call. This being said, since
this special part represents exactly one standard @Efl.Canvas.Object all
the functions of that object can be called on this proxy object.
Thus, it is possible to do the following, in pseudo-C++:
dynamic_cast<efl::Text>(layout.part("title")).text_set("hello");
Or in pseudo-C:
efl_text_set(efl_part(layout, "title"), "hello");
@since 1.20
]]
data: null;