more fixme's added, more fixed up. external callbakcs are now in. calling
application can emit signals now too. SVN revision: 7051
This commit is contained in:
parent
4521ca1f87
commit
e863599780
|
@ -109,6 +109,12 @@ bg_resize(double w, double h)
|
||||||
|
|
||||||
static Evas_Object *o_edje = NULL;
|
static Evas_Object *o_edje = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
cb (void *data, Evas_Object *o, const char *sig, const char *src)
|
||||||
|
{
|
||||||
|
printf("CALLBACK for %p %p \"%s\" \"%s\"\n", data, o, sig, src);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_setup(char *file, char *name)
|
test_setup(char *file, char *name)
|
||||||
{
|
{
|
||||||
|
@ -116,6 +122,8 @@ test_setup(char *file, char *name)
|
||||||
|
|
||||||
o = edje_add(evas);
|
o = edje_add(evas);
|
||||||
edje_file_set(o, file, name);
|
edje_file_set(o, file, name);
|
||||||
|
edje_signal_callback_add(o, "do_it", "the_source", cb, NULL);
|
||||||
|
edje_signal_callback_add(o, "mouse,*", "logo", cb, NULL);
|
||||||
evas_object_move(o, 10, 10);
|
evas_object_move(o, 10, 10);
|
||||||
evas_object_resize(o, 220, 300);
|
evas_object_resize(o, 220, 300);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
@ -153,7 +161,7 @@ main(int argc, char **argv)
|
||||||
file = argv[1];
|
file = argv[1];
|
||||||
if (argc >= 3) coll = argv[2];
|
if (argc >= 3) coll = argv[2];
|
||||||
/* FIXME: list collections */
|
/* FIXME: list collections */
|
||||||
test_setup(argv[1], coll);
|
test_setup(file, coll);
|
||||||
|
|
||||||
ecore_main_loop_begin();
|
ecore_main_loop_begin();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ extern "C" {
|
||||||
double edje_frametime_get(void);
|
double edje_frametime_get(void);
|
||||||
Evas_Object *edje_add(Evas *evas);
|
Evas_Object *edje_add(Evas *evas);
|
||||||
void edje_file_set(Evas_Object *o, const char *file, const char *part);
|
void edje_file_set(Evas_Object *o, const char *file, const char *part);
|
||||||
|
void edje_signal_callback_add(Evas_Object *o, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data);
|
||||||
|
void *edje_signal_callback_del(Evas_Object *o, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source));
|
||||||
|
void edje_signal_emit(Evas_Object *o, const char *emission, const char *source);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
#include "Edje.h"
|
#include "Edje.h"
|
||||||
#include "edje_private.h"
|
#include "edje_private.h"
|
||||||
|
|
||||||
/* FIXME: ? somehow handle double click? */
|
/* FIXME: edje test need to make in-canvas move & resize controls on edjes */
|
||||||
|
/* FIXME: edje test needs to load multiple edjes */
|
||||||
|
/* FIXME: sub objects need to be added to smart object */
|
||||||
|
/* FIXME: add clicked signal for a mouse up thats a real clicked */
|
||||||
/* FIXME: free stuff - no more leaks */
|
/* FIXME: free stuff - no more leaks */
|
||||||
/* FIXME: ? add numeric params to conditions for progs (ranges etc.) */
|
/* FIXME: dragables have to work */
|
||||||
/* FIXME: dragables havwe to work */
|
|
||||||
/* FIXME: drag start/top signals etc. */
|
/* FIXME: drag start/top signals etc. */
|
||||||
/* FIXME: app has to be able to have callbacks called on signal emits */
|
|
||||||
/* FIXME: app has to be able to emit signals */
|
|
||||||
/* FIXME: named parts need to be able to be "replaced" with new evas objects */
|
/* FIXME: named parts need to be able to be "replaced" with new evas objects */
|
||||||
/* FIXME: need to be able to calculate min & max size of a whole edje */
|
/* FIXME: need to be able to calculate min & max size of a whole edje */
|
||||||
|
/* FIXME: on load don't segv on errors */
|
||||||
|
/* FIXME: add code to list collections in an eet */
|
||||||
|
|
||||||
|
/* FIXME: ? somehow handle double click? */
|
||||||
|
/* FIXME: ? add numeric params to conditions for progs (ranges etc.) */
|
||||||
|
|
||||||
Edje *_edje_fetch(Evas_Object *obj);
|
Edje *_edje_fetch(Evas_Object *obj);
|
||||||
Edje *_edje_add(Evas_Object *obj);
|
Edje *_edje_add(Evas_Object *obj);
|
||||||
|
@ -134,8 +139,8 @@ edje_file_set(Evas_Object *obj, const char *file, const char *part)
|
||||||
|
|
||||||
ed = _edje_fetch(obj);
|
ed = _edje_fetch(obj);
|
||||||
if (!ed) return;
|
if (!ed) return;
|
||||||
if (!file) return;
|
if (!file) file = "";
|
||||||
if (!part) return;
|
if (!part) part = "";
|
||||||
if (((ed->path) && (!strcmp(file, ed->path))) &&
|
if (((ed->path) && (!strcmp(file, ed->path))) &&
|
||||||
(ed->part) && (!strcmp(part, ed->part)))
|
(ed->part) && (!strcmp(part, ed->part)))
|
||||||
return;
|
return;
|
||||||
|
@ -214,6 +219,64 @@ edje_file_set(Evas_Object *obj, const char *file, const char *part)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edje_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
|
||||||
|
{
|
||||||
|
Edje *ed;
|
||||||
|
Edje_Signal_Callback *escb;
|
||||||
|
|
||||||
|
if ((!emission) || (!source) || (!func)) return;
|
||||||
|
ed = _edje_fetch(obj);
|
||||||
|
if (!ed) return;
|
||||||
|
escb = calloc(1, sizeof(Edje_Signal_Callback));
|
||||||
|
escb->signal = strdup(emission);
|
||||||
|
escb->source = strdup(source);
|
||||||
|
escb->func = func;
|
||||||
|
escb->data = data;
|
||||||
|
ed->callbacks = evas_list_append(ed->callbacks, escb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
edje_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source))
|
||||||
|
{
|
||||||
|
Edje *ed;
|
||||||
|
Evas_List *l;
|
||||||
|
|
||||||
|
if ((!emission) || (!source) || (!func)) return NULL;
|
||||||
|
ed = _edje_fetch(obj);
|
||||||
|
if (!ed) return;
|
||||||
|
for (l = ed->callbacks; l; l = l->next)
|
||||||
|
{
|
||||||
|
Edje_Signal_Callback *escb;
|
||||||
|
|
||||||
|
escb = l->data;
|
||||||
|
if ((escb->func == func) &&
|
||||||
|
(!strcmp(escb->signal, emission)) &&
|
||||||
|
(!strcmp(escb->source, source)))
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
data = escb->data;
|
||||||
|
free(escb->signal);
|
||||||
|
free(escb->source);
|
||||||
|
free(escb);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edje_signal_emit(Evas_Object *obj, const char *emission, const char *source)
|
||||||
|
{
|
||||||
|
Edje *ed;
|
||||||
|
|
||||||
|
if ((!emission) || (!source)) return;
|
||||||
|
ed = _edje_fetch(obj);
|
||||||
|
if (!ed) return;
|
||||||
|
_edje_emit(ed, emission, source);
|
||||||
|
}
|
||||||
|
|
||||||
/*** internal calls ***/
|
/*** internal calls ***/
|
||||||
|
|
||||||
/* utility functions we will use a lot */
|
/* utility functions we will use a lot */
|
||||||
|
@ -254,6 +317,7 @@ _edje_del(Edje *ed)
|
||||||
if (ed->path) free(ed->path);
|
if (ed->path) free(ed->path);
|
||||||
if (ed->part) free(ed->part);
|
if (ed->part) free(ed->part);
|
||||||
evas_object_del(ed->clipper);
|
evas_object_del(ed->clipper);
|
||||||
|
printf("FIXME: leak: ed->callbacks\n");
|
||||||
free(ed);
|
free(ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,6 +787,15 @@ _edje_emit(Edje *ed, char *sig, char *src)
|
||||||
(_edje_glob_match(ee->source, pr->source)))
|
(_edje_glob_match(ee->source, pr->source)))
|
||||||
_edje_program_run(ed, pr);
|
_edje_program_run(ed, pr);
|
||||||
}
|
}
|
||||||
|
for (l = ed->callbacks; l; l = l->next)
|
||||||
|
{
|
||||||
|
Edje_Signal_Callback *escb;
|
||||||
|
|
||||||
|
escb = l->data;
|
||||||
|
if ((_edje_glob_match(ee->signal, escb->signal)) &&
|
||||||
|
(_edje_glob_match(ee->source, escb->source)))
|
||||||
|
escb->func(escb->data, ed->obj, ee->signal, ee->source);
|
||||||
|
}
|
||||||
free(ee->signal);
|
free(ee->signal);
|
||||||
free(ee->source);
|
free(ee->source);
|
||||||
free(ee);
|
free(ee);
|
||||||
|
@ -1555,6 +1628,7 @@ _edje_smart_add(Evas_Object * obj)
|
||||||
ed = _edje_add(obj);
|
ed = _edje_add(obj);
|
||||||
if (!ed) return;
|
if (!ed) return;
|
||||||
evas_object_smart_data_set(obj, ed);
|
evas_object_smart_data_set(obj, ed);
|
||||||
|
ed->obj = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -293,6 +293,7 @@ struct _Edje_Part_Description
|
||||||
typedef struct _Edje Edje;
|
typedef struct _Edje Edje;
|
||||||
typedef struct _Edje_Real_Part Edje_Real_Part;
|
typedef struct _Edje_Real_Part Edje_Real_Part;
|
||||||
typedef struct _Edje_Running_Program Edje_Running_Program;
|
typedef struct _Edje_Running_Program Edje_Running_Program;
|
||||||
|
typedef struct _Edje_Signal_Callback Edje_Signal_Callback;
|
||||||
typedef struct _Edje_Calc_Params Edje_Calc_Params;
|
typedef struct _Edje_Calc_Params Edje_Calc_Params;
|
||||||
typedef struct _Edje_Emission Edje_Emission;
|
typedef struct _Edje_Emission Edje_Emission;
|
||||||
|
|
||||||
|
@ -305,11 +306,13 @@ struct _Edje
|
||||||
double x, y, w, h;
|
double x, y, w, h;
|
||||||
unsigned char dirty : 1;
|
unsigned char dirty : 1;
|
||||||
Evas *evas; /* the evas this edje belongs to */
|
Evas *evas; /* the evas this edje belongs to */
|
||||||
|
Evas_Object *obj; /* the smart object */
|
||||||
Evas_Object *clipper; /* a big rect to clip this edje to */
|
Evas_Object *clipper; /* a big rect to clip this edje to */
|
||||||
Edje_File *file; /* the file the data comes form */
|
Edje_File *file; /* the file the data comes form */
|
||||||
Edje_Part_Collection *collection; /* the description being used */
|
Edje_Part_Collection *collection; /* the description being used */
|
||||||
Evas_List *parts; /* private list of parts */
|
Evas_List *parts; /* private list of parts */
|
||||||
Evas_List *actions; /* currently running actions */
|
Evas_List *actions; /* currently running actions */
|
||||||
|
Evas_List *callbacks;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Edje_Real_Part
|
struct _Edje_Real_Part
|
||||||
|
@ -345,6 +348,14 @@ struct _Edje_Running_Program
|
||||||
double start_time;
|
double start_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Edje_Signal_Callback
|
||||||
|
{
|
||||||
|
char *signal;
|
||||||
|
char *source;
|
||||||
|
void (*func) (void *data, Evas_Object *o, const char *emission, const char *source);
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
struct _Edje_Calc_Params
|
struct _Edje_Calc_Params
|
||||||
{
|
{
|
||||||
double x, y, w, h;
|
double x, y, w, h;
|
||||||
|
|
Loading…
Reference in New Issue