Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
2009-12-05 17:22:54 -08:00
|
|
|
#endif
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
#include "Elementary.h"
|
|
|
|
#include "elm_priv.h"
|
2009-12-05 17:22:54 -08:00
|
|
|
|
2013-12-25 20:03:55 -08:00
|
|
|
#undef CRI
|
2012-01-18 08:31:41 -08:00
|
|
|
#undef ERR
|
|
|
|
#undef WRN
|
|
|
|
#undef INF
|
|
|
|
#undef DBG
|
|
|
|
|
2014-01-20 19:08:20 -08:00
|
|
|
#define CRI(...) EINA_LOG_DOM_CRIT(_elm_ext_log_dom, __VA_ARGS__)
|
2012-01-18 08:31:41 -08:00
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR (_elm_ext_log_dom, __VA_ARGS__)
|
|
|
|
#define WRN(...) EINA_LOG_DOM_WARN(_elm_ext_log_dom, __VA_ARGS__)
|
|
|
|
#define INF(...) EINA_LOG_DOM_INFO(_elm_ext_log_dom, __VA_ARGS__)
|
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG (_elm_ext_log_dom, __VA_ARGS__)
|
|
|
|
|
2009-12-05 17:22:54 -08:00
|
|
|
typedef struct {
|
2010-10-21 15:03:43 -07:00
|
|
|
const char *style;
|
2011-12-13 08:47:23 -08:00
|
|
|
Eina_Bool disabled:1;
|
|
|
|
Eina_Bool disabled_exists:1;
|
2009-12-05 17:22:54 -08:00
|
|
|
} Elm_Params;
|
|
|
|
|
2012-01-18 08:31:41 -08:00
|
|
|
extern int _elm_ext_log_dom;
|
|
|
|
|
2011-01-18 20:55:19 -08:00
|
|
|
void external_elm_init(void);
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
void external_signal(void *data, Evas_Object *obj, const char *signal, const char *source);
|
|
|
|
void external_signals_proxy(Evas_Object *obj, Evas_Object *edje, const char *part_name);
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
const char *external_translate(void *data, const char *orig);
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
void external_common_params_free(void *params);
|
2009-12-05 17:22:54 -08:00
|
|
|
void *external_common_params_parse_internal(size_t params_size, void *data, Evas_Object *obj, const Eina_List *params);
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
Evas_Object *external_common_param_icon_get(Evas_Object *obj, const Edje_External_Param *param);
|
2016-02-04 23:13:11 -08:00
|
|
|
Evas_Object *external_common_param_elm_layout_get(Evas_Object *obj, const Edje_External_Param *p);
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
void external_common_icon_param_parse(Evas_Object **icon, Evas_Object *obj, const Eina_List *params);
|
2010-10-22 05:05:45 -07:00
|
|
|
Eina_Bool external_common_param_get(void *data, const Evas_Object *obj, Edje_External_Param *param);
|
|
|
|
Eina_Bool external_common_param_set(void *data, Evas_Object *obj, const Edje_External_Param *param);
|
|
|
|
void external_common_state_set(void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos);
|
|
|
|
void external_common_params_parse(void *mem, void *data, Evas_Object *obj, const Eina_List *params);
|
2009-12-05 17:22:54 -08:00
|
|
|
|
|
|
|
#define DEFINE_EXTERNAL_TYPE(type_name, name) \
|
2010-10-21 15:03:43 -07:00
|
|
|
static Eina_Bool \
|
|
|
|
_external_##type_name##_param_set(void *data, Evas_Object *obj, const Edje_External_Param *param) \
|
|
|
|
{ \
|
|
|
|
if (external_common_param_set(data, obj, param)) \
|
|
|
|
return EINA_TRUE; \
|
|
|
|
return external_##type_name##_param_set(data, obj, param); \
|
|
|
|
} \
|
|
|
|
static Eina_Bool \
|
|
|
|
_external_##type_name##_param_get(void *data, const Evas_Object *obj, Edje_External_Param *param) \
|
|
|
|
{ \
|
|
|
|
if (external_common_param_get(data, obj, param)) \
|
|
|
|
return EINA_TRUE; \
|
|
|
|
return external_##type_name##_param_get(data, obj, param); \
|
|
|
|
} \
|
2009-12-05 17:22:54 -08:00
|
|
|
static const char * \
|
2014-01-06 06:30:02 -08:00
|
|
|
external_##type_name##_label_get(void *data EINA_UNUSED) \
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
{ \
|
2009-12-05 17:22:54 -08:00
|
|
|
return name; \
|
|
|
|
} \
|
|
|
|
\
|
2010-10-21 15:03:43 -07:00
|
|
|
static void \
|
2014-01-06 06:30:02 -08:00
|
|
|
_external_##type_name##_state_set(void *data EINA_UNUSED, Evas_Object *obj, const void *from_params, const void *to_params, float pos EINA_UNUSED) \
|
2010-10-21 15:03:43 -07:00
|
|
|
{ \
|
|
|
|
external_common_state_set(data, obj, from_params, to_params, pos); \
|
|
|
|
external_##type_name##_state_set(data, obj, from_params, to_params, pos); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void * \
|
2014-01-06 06:30:02 -08:00
|
|
|
_external_##type_name##_params_parse(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const Eina_List *params) \
|
2010-10-21 15:03:43 -07:00
|
|
|
{ \
|
|
|
|
void *mem = external_##type_name##_params_parse(data, obj, params); \
|
|
|
|
external_common_params_parse(mem, data, obj, params); \
|
|
|
|
return mem; \
|
|
|
|
} \
|
|
|
|
static void \
|
|
|
|
_external_##type_name##_params_free(void *params) \
|
|
|
|
{ \
|
|
|
|
external_common_params_free(params); \
|
|
|
|
external_##type_name##_params_free(params); \
|
|
|
|
} \
|
|
|
|
\
|
2009-12-05 17:22:54 -08:00
|
|
|
const Edje_External_Type external_##type_name##_type = {\
|
|
|
|
.abi_version = EDJE_EXTERNAL_TYPE_ABI_VERSION, \
|
2009-12-07 17:35:15 -08:00
|
|
|
.module = "elm", \
|
2010-01-25 12:30:39 -08:00
|
|
|
.module_name = "Elementary", \
|
2009-12-05 17:22:54 -08:00
|
|
|
.add = external_##type_name##_add, \
|
2010-10-21 15:03:43 -07:00
|
|
|
.state_set = _external_##type_name##_state_set, \
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
.signal_emit = external_signal, \
|
2010-10-21 15:03:43 -07:00
|
|
|
.param_set = _external_##type_name##_param_set, \
|
|
|
|
.param_get = _external_##type_name##_param_get, \
|
|
|
|
.params_parse = _external_##type_name##_params_parse,\
|
|
|
|
.params_free = _external_##type_name##_params_free, \
|
2009-12-05 17:22:54 -08:00
|
|
|
.label_get = external_##type_name##_label_get, \
|
2010-08-01 10:29:20 -07:00
|
|
|
.content_get = external_##type_name##_content_get, \
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
.description_get = NULL, \
|
|
|
|
.icon_add = external_##type_name##_icon_add, \
|
|
|
|
.preview_add = NULL, \
|
|
|
|
.translate = external_translate, \
|
2009-12-05 17:22:54 -08:00
|
|
|
.parameters_info = external_##type_name##_params, \
|
|
|
|
.data = NULL \
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFINE_EXTERNAL_TYPE_SIMPLE(type_name, name) \
|
|
|
|
static Evas_Object * \
|
2014-01-06 06:30:02 -08:00
|
|
|
external_##type_name##_add(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *edje, const Eina_List *params EINA_UNUSED, const char *part_name) \
|
2010-03-22 14:38:32 -07:00
|
|
|
{ \
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
Evas_Object *parent, *obj; \
|
2011-01-18 20:55:19 -08:00
|
|
|
external_elm_init(); \
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
parent = elm_widget_parent_widget_get(edje); \
|
2010-03-22 14:38:32 -07:00
|
|
|
if (!parent) parent = edje; \
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
obj = elm_##type_name##_add(parent); \
|
|
|
|
external_signals_proxy(obj, edje, part_name); \
|
|
|
|
return obj; \
|
2010-03-22 14:38:32 -07:00
|
|
|
} \
|
|
|
|
\
|
2009-12-05 17:22:54 -08:00
|
|
|
DEFINE_EXTERNAL_TYPE(type_name, name)
|
|
|
|
|
2010-01-22 12:07:47 -08:00
|
|
|
#define DEFINE_EXTERNAL_ICON_ADD(type_name, name) \
|
|
|
|
Evas_Object * \
|
2014-01-06 06:30:02 -08:00
|
|
|
external_##type_name##_icon_add(void *data EINA_UNUSED, Evas *e) { \
|
2010-01-22 12:07:47 -08:00
|
|
|
Evas_Object *ic; \
|
|
|
|
int w = 20, h = 10; \
|
|
|
|
\
|
|
|
|
ic = edje_object_add(e); \
|
|
|
|
edje_object_file_set(ic, PACKAGE_DATA_DIR"/edje_externals/icons.edj", "ico_"name);\
|
|
|
|
evas_object_size_hint_min_set(ic, w, h); \
|
2010-01-25 06:24:15 -08:00
|
|
|
evas_object_size_hint_max_set(ic, w, h); \
|
2010-01-22 12:07:47 -08:00
|
|
|
\
|
|
|
|
return ic; \
|
|
|
|
}
|
2009-12-05 17:22:54 -08:00
|
|
|
|
|
|
|
#define DEFINE_EXTERNAL_COMMON_PARAMS \
|
2011-12-13 08:47:23 -08:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("style", "default"), \
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT("disabled", EINA_FALSE)
|