forked from enlightenment/efl
Make the Edje Smart inheritable.
Pretty much moving some things around and extending the smart class to allow overloading some common functions. Edje_Edit will make use of this. SVN revision: 47841
This commit is contained in:
parent
57c16867e2
commit
3c61844af1
|
@ -3642,7 +3642,7 @@ edje_edit_state_external_param_bool_get(Evas_Object *obj, const char *part, cons
|
||||||
EINA_LIST_FOREACH(pd->external_params, l, p)
|
EINA_LIST_FOREACH(pd->external_params, l, p)
|
||||||
if (!strcmp(p->name, param))
|
if (!strcmp(p->name, param))
|
||||||
{
|
{
|
||||||
if (p->type != EDJE_EXTERNAL_PARAM_TYPE_INT)
|
if (p->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
if (val)
|
if (val)
|
||||||
*val = p->i;
|
*val = p->i;
|
||||||
|
|
|
@ -10,7 +10,6 @@ static Eina_Bool _edje_file_collection_hash_foreach(const Eina_Hash *hash, const
|
||||||
#ifdef EDJE_PROGRAM_CACHE
|
#ifdef EDJE_PROGRAM_CACHE
|
||||||
static Eina_Bool _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
static Eina_Bool _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||||
#endif
|
#endif
|
||||||
static int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path);
|
|
||||||
static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
|
static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
|
||||||
static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
|
static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
|
||||||
|
|
||||||
|
@ -33,7 +32,12 @@ static Eina_List *_edje_swallows_collect(Edje *ed);
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
|
edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
|
||||||
{
|
{
|
||||||
return _edje_object_file_set_internal(obj, file, group, NULL);
|
Edje *ed;
|
||||||
|
|
||||||
|
ed = _edje_fetch(obj);
|
||||||
|
if (!ed)
|
||||||
|
return EINA_FALSE;
|
||||||
|
return ed->api->file_set(obj, file, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXDOC: Verify/expand doc. */
|
/* FIXDOC: Verify/expand doc. */
|
||||||
|
@ -272,7 +276,7 @@ _edje_programs_patterns_init(Edje *ed)
|
||||||
ssp->sources_patterns = edje_match_programs_source_init(ssp->globing);
|
ssp->sources_patterns = edje_match_programs_source_init(ssp->globing);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path)
|
_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path)
|
||||||
{
|
{
|
||||||
Edje *ed;
|
Edje *ed;
|
||||||
|
|
|
@ -200,25 +200,6 @@ edje_shutdown(void)
|
||||||
|
|
||||||
/* Private Routines */
|
/* Private Routines */
|
||||||
|
|
||||||
Edje *
|
|
||||||
_edje_add(Evas_Object *obj)
|
|
||||||
{
|
|
||||||
Edje *ed;
|
|
||||||
|
|
||||||
ed = calloc(1, sizeof(Edje));
|
|
||||||
if (!ed) return NULL;
|
|
||||||
ed->evas = evas_object_evas_get(obj);
|
|
||||||
ed->clipper = evas_object_rectangle_add(ed->evas);
|
|
||||||
evas_object_smart_member_add(ed->clipper, obj);
|
|
||||||
evas_object_color_set(ed->clipper, 255, 255, 255, 255);
|
|
||||||
evas_object_move(ed->clipper, -10000, -10000);
|
|
||||||
evas_object_resize(ed->clipper, 20000, 20000);
|
|
||||||
evas_object_pass_events_set(ed->clipper, 1);
|
|
||||||
ed->have_objects = 1;
|
|
||||||
ed->references = 1;
|
|
||||||
return ed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_edje_del(Edje *ed)
|
_edje_del(Edje *ed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,6 +111,26 @@ EAPI extern int _edje_default_log_dom ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Inheritable Edje Smart API. For now private so only Edje Edit makes
|
||||||
|
* use of this, but who knows what will be possible in the future */
|
||||||
|
#define EDJE_SMART_API_VERSION 1
|
||||||
|
|
||||||
|
typedef struct _Edje_Smart_Api Edje_Smart_Api;
|
||||||
|
|
||||||
|
struct _Edje_Smart_Api
|
||||||
|
{
|
||||||
|
Evas_Smart_Class base;
|
||||||
|
int version;
|
||||||
|
Eina_Bool (*file_set)(Evas_Object *obj, const char *file, const char *group);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Basic macro to init the Edje Smart API */
|
||||||
|
#define EDJE_SMART_API_INIT(smart_class_init) {smart_class_init, EDJE_SMART_API_VERSION, NULL}
|
||||||
|
|
||||||
|
#define EDJE_SMART_API_INIT_NULL EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NULL)
|
||||||
|
#define EDJE_SMART_API_INIT_VERSION EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_VERSION)
|
||||||
|
#define EDJE_SMART_API_INIT_NAME_VERSION(name) EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name))
|
||||||
|
|
||||||
/* increment this when the EET data descriptors have changed and old
|
/* increment this when the EET data descriptors have changed and old
|
||||||
* EETs cannot be loaded/used correctly anymore.
|
* EETs cannot be loaded/used correctly anymore.
|
||||||
*/
|
*/
|
||||||
|
@ -766,6 +786,7 @@ typedef struct _Edje_Signals_Sources_Patterns Edje_Signals_Sources_Patterns;
|
||||||
|
|
||||||
struct _Edje
|
struct _Edje
|
||||||
{
|
{
|
||||||
|
const Edje_Smart_Api *api;
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *group;
|
const char *group;
|
||||||
const char *parent;
|
const char *parent;
|
||||||
|
@ -1247,6 +1268,8 @@ void _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed);
|
||||||
void _edje_edd_init(void);
|
void _edje_edd_init(void);
|
||||||
void _edje_edd_shutdown(void);
|
void _edje_edd_shutdown(void);
|
||||||
|
|
||||||
|
int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path);
|
||||||
|
|
||||||
void _edje_file_add(Edje *ed);
|
void _edje_file_add(Edje *ed);
|
||||||
void _edje_file_del(Edje *ed);
|
void _edje_file_del(Edje *ed);
|
||||||
void _edje_file_free(Edje_File *edf);
|
void _edje_file_free(Edje_File *edf);
|
||||||
|
@ -1254,8 +1277,9 @@ void _edje_file_cache_shutdown(void);
|
||||||
void _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec);
|
void _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec);
|
||||||
void _edje_collection_free_part_description_free(Edje_Part_Description *desc, Eina_Bool free_strings);
|
void _edje_collection_free_part_description_free(Edje_Part_Description *desc, Eina_Bool free_strings);
|
||||||
|
|
||||||
|
void _edje_object_smart_set(Edje_Smart_Api *sc);
|
||||||
|
const Edje_Smart_Api * _edje_object_smart_class_get(void);
|
||||||
|
|
||||||
Edje *_edje_add(Evas_Object *obj);
|
|
||||||
void _edje_del(Edje *ed);
|
void _edje_del(Edje *ed);
|
||||||
void _edje_ref(Edje *ed);
|
void _edje_ref(Edje *ed);
|
||||||
void _edje_unref(Edje *ed);
|
void _edje_unref(Edje *ed);
|
||||||
|
|
|
@ -15,6 +15,9 @@ static void _edje_smart_clip_set(Evas_Object * obj, Evas_Object * clip);
|
||||||
static void _edje_smart_clip_unset(Evas_Object * obj);
|
static void _edje_smart_clip_unset(Evas_Object * obj);
|
||||||
static void _edje_smart_calculate(Evas_Object * obj);
|
static void _edje_smart_calculate(Evas_Object * obj);
|
||||||
|
|
||||||
|
static Eina_Bool _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group);
|
||||||
|
|
||||||
|
static Edje_Smart_Api _edje_smart_class = EDJE_SMART_API_INIT_NAME_VERSION("edje");
|
||||||
static Evas_Smart *_edje_smart = NULL;
|
static Evas_Smart *_edje_smart = NULL;
|
||||||
|
|
||||||
Eina_List *_edje_edjes = NULL;
|
Eina_List *_edje_edjes = NULL;
|
||||||
|
@ -33,38 +36,79 @@ edje_object_add(Evas *evas)
|
||||||
{
|
{
|
||||||
if (!_edje_smart)
|
if (!_edje_smart)
|
||||||
{
|
{
|
||||||
static const Evas_Smart_Class sc =
|
_edje_object_smart_set(&_edje_smart_class);
|
||||||
{
|
_edje_smart = evas_smart_class_new((Evas_Smart_Class *)&_edje_smart_class);
|
||||||
"edje",
|
|
||||||
EVAS_SMART_CLASS_VERSION,
|
|
||||||
_edje_smart_add,
|
|
||||||
_edje_smart_del,
|
|
||||||
_edje_smart_move,
|
|
||||||
_edje_smart_resize,
|
|
||||||
_edje_smart_show,
|
|
||||||
_edje_smart_hide,
|
|
||||||
_edje_smart_color_set,
|
|
||||||
_edje_smart_clip_set,
|
|
||||||
_edje_smart_clip_unset,
|
|
||||||
_edje_smart_calculate,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
_edje_smart = evas_smart_class_new(&sc);
|
|
||||||
}
|
}
|
||||||
return evas_object_smart_add(evas, _edje_smart);
|
return evas_object_smart_add(evas, _edje_smart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_edje_object_smart_set(Edje_Smart_Api *sc)
|
||||||
|
{
|
||||||
|
if (!sc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sc->base.add = _edje_smart_add;
|
||||||
|
sc->base.del = _edje_smart_del;
|
||||||
|
sc->base.move = _edje_smart_move;
|
||||||
|
sc->base.resize = _edje_smart_resize;
|
||||||
|
sc->base.show = _edje_smart_show;
|
||||||
|
sc->base.hide = _edje_smart_hide;
|
||||||
|
sc->base.color_set = _edje_smart_color_set;
|
||||||
|
sc->base.clip_set = _edje_smart_clip_set;
|
||||||
|
sc->base.clip_unset = _edje_smart_clip_unset;
|
||||||
|
sc->base.calculate = _edje_smart_calculate;
|
||||||
|
sc->base.member_add = NULL;
|
||||||
|
sc->base.member_del = NULL;
|
||||||
|
sc->file_set = _edje_smart_file_set;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Edje_Smart_Api *
|
||||||
|
_edje_object_smart_class_get(void)
|
||||||
|
{
|
||||||
|
static const Edje_Smart_Api *class = NULL;
|
||||||
|
|
||||||
|
if (class)
|
||||||
|
return class;
|
||||||
|
|
||||||
|
_edje_object_smart_set(&_edje_smart_class);
|
||||||
|
class = &_edje_smart_class;
|
||||||
|
|
||||||
|
return class;
|
||||||
|
}
|
||||||
|
|
||||||
/* Private Routines */
|
/* Private Routines */
|
||||||
static void
|
static void
|
||||||
_edje_smart_add(Evas_Object *obj)
|
_edje_smart_add(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
Edje *ed;
|
Edje *ed;
|
||||||
|
|
||||||
ed = _edje_add(obj);
|
ed = evas_object_smart_data_get(obj);
|
||||||
|
if (!ed)
|
||||||
|
{
|
||||||
|
const Evas_Smart *smart;
|
||||||
|
const Evas_Smart_Class *sc;
|
||||||
|
|
||||||
|
ed = calloc(1, sizeof(Edje));
|
||||||
if (!ed) return;
|
if (!ed) return;
|
||||||
|
|
||||||
|
smart = evas_object_smart_smart_get(obj);
|
||||||
|
sc = evas_smart_class_get(smart);
|
||||||
|
ed->api = (const Edje_Smart_Api *)sc;
|
||||||
|
|
||||||
evas_object_smart_data_set(obj, ed);
|
evas_object_smart_data_set(obj, ed);
|
||||||
|
}
|
||||||
|
|
||||||
|
ed->evas = evas_object_evas_get(obj);
|
||||||
|
ed->clipper = evas_object_rectangle_add(ed->evas);
|
||||||
|
evas_object_smart_member_add(ed->clipper, obj);
|
||||||
|
evas_object_color_set(ed->clipper, 255, 255, 255, 255);
|
||||||
|
evas_object_move(ed->clipper, -10000, -10000);
|
||||||
|
evas_object_resize(ed->clipper, 20000, 20000);
|
||||||
|
evas_object_pass_events_set(ed->clipper, 1);
|
||||||
|
ed->have_objects = 1;
|
||||||
|
ed->references = 1;
|
||||||
|
|
||||||
evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
|
evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
|
||||||
ed->obj = obj;
|
ed->obj = obj;
|
||||||
_edje_edjes = eina_list_append(_edje_edjes, obj);
|
_edje_edjes = eina_list_append(_edje_edjes, obj);
|
||||||
|
@ -273,3 +317,9 @@ _edje_smart_calculate(Evas_Object *obj)
|
||||||
if (!ed) return;
|
if (!ed) return;
|
||||||
_edje_recalc_do(ed);
|
_edje_recalc_do(ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_edje_smart_file_set(Evas_Object *obj, const char *file, const char *group)
|
||||||
|
{
|
||||||
|
return _edje_object_file_set_internal(obj, file, group, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -4337,11 +4337,9 @@ Edje *
|
||||||
_edje_fetch(const Evas_Object *obj)
|
_edje_fetch(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
Edje *ed;
|
Edje *ed;
|
||||||
char *type;
|
|
||||||
|
|
||||||
type = (char *)evas_object_type_get(obj);
|
if (!evas_object_smart_type_check(obj, "edje"))
|
||||||
if (!type) return NULL;
|
return NULL;
|
||||||
if (strcmp(type, "edje")) return NULL;
|
|
||||||
ed = evas_object_smart_data_get(obj);
|
ed = evas_object_smart_data_get(obj);
|
||||||
if ((ed) && (ed->delete_me)) return NULL;
|
if ((ed) && (ed->delete_me)) return NULL;
|
||||||
return ed;
|
return ed;
|
||||||
|
|
Loading…
Reference in New Issue