embryo support... started. :)

SVN revision: 9487
This commit is contained in:
Carsten Haitzler 2004-03-26 09:10:05 +00:00
parent 76b6621bba
commit 59a6f2c4b0
13 changed files with 223 additions and 45 deletions

View File

@ -151,6 +151,24 @@ fi
AC_SUBST(eet_cflags)
AC_SUBST(eet_libs)
have_embryo="no";
AC_CHECK_HEADER(Embryo.h,
[ have_embryo="yes" ],
[ have_embryo="no" ]
)
if test "x$have_embryo" = "xyes"; then
if [ test -z "$EMBRYO_CONFIG" ]; then EMBRYO_CONFIG="embryo-config"; fi
embryo_cflags=`$EMBRYO_CONFIG --cflags`
embryo_libs=`$EMBRYO_CONFIG --libs`
else
AC_MSG_ERROR(Cannot find Embryo.h)
exit -1
fi
AC_SUBST(embryo_cflags)
AC_SUBST(embryo_libs)
imlib2_cflags=""
imlib2_libs=""
if test "x$have_edje_cc" = "xyes"; then

View File

@ -207,5 +207,6 @@ data needed.
@todo See src/lib/edje_private.h for a list of FIXME's
@todo Complete documentation of API
@todo Bytecode language for extending programs... but what/how?
*/

View File

@ -12,6 +12,7 @@ export EET_CONFIG=$SKIFF"/"$TARGETCPU"-linux/bin/eet-config"
export FREETYPE_CONFIG=$SKIFF"/"$TARGETCPU"-linux/bin/freetype-config"
export EVAS_CONFIG=$SKIFF"/"$TARGETCPU"-linux/bin/evas-config"
export ECORE_CONFIG=$SKIFF"/"$TARGETCPU"-linux/bin/ecore-config"
export EMBRYO_CONFIG=$SKIFF"/"$TARGETCPU"-linux/bin/embryo-config"
make clean distclean
export CC=/skiff/local/bin/arm-linux-gcc

View File

@ -269,7 +269,7 @@ data_write(void)
}
else
{
fprintf(stderr, "%s: Error. unable to write image part \"%s\" as \"%s\" part entry to %s \n",
fprintf(stderr, "%s: Error. unable to load image for image part \"%s\" as \"%s\" part entry to %s \n",
progname, img->entry, buf, file_out);
ABORT_WRITE(ef, file_out);
}
@ -374,7 +374,37 @@ data_write(void)
char buf[4096];
pc = l->data;
/* FIXME: hack!!!! */
{
FILE *f;
f = fopen("test.amx", "r");
if (f)
{
int size;
void *data;
fseek(f, 0, SEEK_END);
size = ftell(f);
rewind(f);
if (size > 0)
{
int bt;
data = malloc(size);
if (data)
{
fread(data, size, 1, f);
snprintf(buf, sizeof(buf), "scripts/%i", pc->id);
bt = eet_write(ef, buf, data, size, 1);
free(data);
printf("WROTE %i bytes of AMX!\n", bt);
}
}
fclose(f);
}
}
snprintf(buf, sizeof(buf), "collections/%i", pc->id);
bytes = eet_data_write(ef, edd_edje_part_collection, buf, pc, 1);
if (bytes <= 0)

View File

@ -733,10 +733,10 @@ test_setup(char *file, char *name)
de->title = o;
o = edje_object_add(evas);
edje_object_file_set(o, file, name);
// edje_object_signal_callback_add(o, "do_it", "the_source", cb, NULL);
// edje_object_signal_callback_add(o, "mouse,*", "logo", cb, NULL);
edje_object_signal_callback_add(o, "*", "*", cb, NULL);
edje_object_file_set(o, file, name);
edje_object_part_drag_size_set(o, "dragable", 0.01, 0.5);
// edje_object_part_drag_value_set(o, "dragable", 0.5, 0.5);
edje_object_part_drag_step_set(o, "dragable", 0.1, 0.1);

View File

@ -9,6 +9,12 @@
#include <Ecore_Fb.h>
#endif
#include <Eet.h>
#include <Embryo.h>
/* Cache result of program glob matches - this uses up extra ram withthe gain
* of faster program matching if a part has LOTS of programs.
#define EDJE_PROGRAM_CACHE
*/
typedef struct _Edje_File Edje_File;
typedef struct _Edje_Data Edje_Data;
@ -227,11 +233,14 @@ struct _Edje_Part_Collection
} prop;
int references;
#ifdef EDJE_PROGRAM_CACHE
struct {
Evas_Hash *no_matches;
Evas_Hash *matches;
} prog_cache;
#endif
Embryo_Program *script; /* all the embryo script code for this group */
};
struct _Edje_Part
@ -506,6 +515,11 @@ struct _Edje_Calc_Params
struct {
int l, r, t, b;
} border;
struct {
struct {
double x, y; /* text alignment within bounds */
} align;
} text;
};
struct _Edje_Emission

View File

@ -11,6 +11,7 @@ INCLUDES = \
-I$(top_builddir) \
-I$(includedir) \
@eet_cflags@ \
@embryo_cflags@ \
@evas_cflags@ \
@ecore_cflags@
@ -26,6 +27,7 @@ libedje_la_SOURCES = \
edje_calc.c \
edje_callbacks.c \
edje_data.c \
edje_embryo.c \
edje_load.c \
edje_main.c \
edje_program.c \
@ -34,7 +36,7 @@ edje_text.c \
edje_util.c \
edje_private.h
libedje_la_LIBADD = $(LDFLAGS) -lm @evas_libs@ @ecore_libs@ @eet_libs@
libedje_la_LIBADD = $(LDFLAGS) -lm @evas_libs@ @ecore_libs@ @eet_libs@ @embryo_libs@
libedje_la_CPPFLAGS = @edje_def@
libedje_la_DEPENDENCIES = $(top_builddir)/config.h
libedje_la_LDFLAGS = -version-info 0:1:0
@ -42,6 +44,6 @@ libedje_la_LDFLAGS = -version-info 0:1:0
libedje_edit_la_SOURCES = \
edje_edit.c
libedje_edit_la_LIBADD = $(LDFLAGS) -lm @evas_libs@ @ecore_libs@ @eet_libs@ $(top_builddir)/src/lib/libedje.la
libedje_edit_la_LIBADD = $(LDFLAGS) -lm @evas_libs@ @ecore_libs@ @eet_libs@ @embryo_libs@ $(top_builddir)/src/lib/libedje.la
libedje_edit_la_DEPENDENCIES = $(top_builddir)/config.h libedje.la
libedje_edit_la_LDFLAGS = -version-info 0:1:0

View File

@ -591,6 +591,9 @@ _edje_part_recalc_single(Edje *ed,
params->border.r = desc->border.r;
params->border.t = desc->border.t;
params->border.b = desc->border.b;
/* text.align */
params->text.align.x = desc->text.align.x;
params->text.align.y = desc->text.align.y;
}
static void
@ -702,6 +705,9 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep)
p3.border.r = (p1.border.r * (1.0 - pos)) + (p2.border.r * (pos));
p3.border.t = (p1.border.t * (1.0 - pos)) + (p2.border.t * (pos));
p3.border.b = (p1.border.b * (1.0 - pos)) + (p2.border.b * (pos));
p3.text.align.x = (p1.text.align.x * (1.0 - pos)) + (p2.text.align.x * (pos));
p3.text.align.y = (p1.text.align.y * (1.0 - pos)) + (p2.text.align.y * (pos));
}
else
p3 = p1;

View File

@ -0,0 +1,95 @@
#include "Edje.h"
#include "edje_private.h"
#define CHKPARAM(n) if (params[0] != (sizeof(Embryo_Cell) * (n))) return 0;
/**** All the api exported to edje scripts ****/
/* tst() */
static Embryo_Cell
_edje_embryo_fn_tst(Embryo_Program *ep, Embryo_Cell *params)
{
Edje *ed;
/* params[0] = number of bytes of params passed */
ed = embryo_program_data_get(ep);
printf("EDJE DEBUG: Embryo code detected for \"%s\":\"%s\"\n",
ed->path, ed->part);
return 7;
}
/* emit(sig[], src[]) */
static Embryo_Cell
_edje_embryo_fn_emit(Embryo_Program *ep, Embryo_Cell *params)
{
Edje *ed;
Embryo_Cell *cptr;
char *sig, *src;
int l;
CHKPARAM(2);
ed = embryo_program_data_get(ep);
cptr = embryo_data_address_get(ep, params[1]);
l = embryo_data_string_length_get(ep, cptr);
sig = alloca(l + 1);
embryo_data_string_get(ep, cptr, sig);
cptr = embryo_data_address_get(ep, params[2]);
l = embryo_data_string_length_get(ep, cptr);
src = alloca(l + 1);
embryo_data_string_get(ep, cptr, src);
_edje_emit(ed, sig, src);
return 0;
}
void
_edje_embryo_script_init(Edje *ed)
{
Embryo_Program *ep;
if (!ed) return;
if (!ed->collection) return;
if (!ed->collection->script) return;
ep = ed->collection->script;
embryo_program_data_set(ep, ed);
/* first advertise all the edje "script" calls */
embryo_program_native_call_add(ep, "tst", _edje_embryo_fn_tst);
embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit);
embryo_program_vm_push(ep); /* neew a new vm to run in */
/* by default always call main() to init stuff */
if (embryo_program_run(ep, EMBRYO_FUNCTION_MAIN) != EMBRYO_PROGRAM_OK)
/* FIXME: debugging hack!!!! */
{
printf("EDJE DEBUG: Run of main() failed. Reason:\n");
printf("%s\n", embryo_error_string_get(embryo_program_error_get(ep)));
}
else
{
printf("EDJE DEBUG: main() returned %i\n",
embryo_program_return_value_get(ep));
}
}
void
_edje_embryo_script_shutdown(Edje *ed)
{
if (!ed) return;
if (!ed->collection) return;
if (!ed->collection->script) return;
if (embryo_program_recursion_get(ed->collection->script) > 0) return;
embryo_program_vm_pop(ed->collection->script);
embryo_program_free(ed->collection->script);
ed->collection->script = NULL;
}
void
_edje_embryo_script_reset(Edje *ed)
{
if (!ed) return;
if (!ed->collection) return;
if (!ed->collection->script) return;
if (embryo_program_recursion_get(ed->collection->script) > 0) return;
embryo_program_vm_reset(ed->collection->script);
}

View File

@ -4,7 +4,9 @@
static Evas_Hash *_edje_file_hash = NULL;
static void _edje_collection_free_part_description_free(Edje_Part_Description *desc);
#ifdef EDJE_PROGRAM_CACHE
static int _edje_collection_free_prog_cache_matches_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
#endif
/* API Routines */
int
@ -184,6 +186,7 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
_edje_ref(ed);
_edje_block(ed);
_edje_freeze(ed);
if (ed->collection->script) _edje_embryo_script_init(ed);
_edje_emit(ed, "load", "");
for (l = ed->parts; l; l = l->next)
{
@ -403,6 +406,8 @@ _edje_file_add(Edje *ed)
if (id >= 0)
{
char buf[256];
int size;
void *data;
snprintf(buf, sizeof(buf), "collections/%i", id);
if (!ef) ef = eet_open(ed->path, EET_FILE_MODE_READ);
@ -421,6 +426,13 @@ _edje_file_add(Edje *ed)
}
ed->collection->references = 1;
ed->file->collection_hash = evas_hash_add(ed->file->collection_hash, ed->part, ed->collection);
snprintf(buf, sizeof(buf), "scripts/%i", id);
data = eet_read(ef, buf, &size);
if (data)
{
ed->collection->script = embryo_program_new(data, size);
free(data);
}
}
else
{
@ -444,6 +456,7 @@ _edje_file_del(Edje *ed)
ed->collection->references--;
if (ed->collection->references <= 0)
{
_edje_embryo_script_shutdown(ed);
ed->file->collection_hash = evas_hash_del(ed->file->collection_hash, ed->part, ed->collection);
_edje_collection_free(ed, ed->collection);
}
@ -621,6 +634,7 @@ _edje_collection_free(Edje *ed, Edje_Part_Collection *ec)
}
free(ep);
}
#ifdef EDJE_PROGRAM_CACHE
if (ec->prog_cache.no_matches) evas_hash_free(ec->prog_cache.no_matches);
if (ec->prog_cache.matches)
{
@ -629,6 +643,7 @@ _edje_collection_free(Edje *ed, Edje_Part_Collection *ec)
NULL);
evas_hash_free(ec->prog_cache.matches);
}
#endif
free(ec);
}
@ -651,6 +666,7 @@ _edje_collection_free_part_description_free(Edje_Part_Description *desc)
free(desc);
}
#ifdef EDJE_PROGRAM_CACHE
static int
_edje_collection_free_prog_cache_matches_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
{
@ -659,3 +675,4 @@ _edje_collection_free_prog_cache_matches_free_cb(Evas_Hash *hash, const char *ke
hash = NULL;
fdata = NULL;
}
#endif

View File

@ -11,6 +11,7 @@
#include <Ecore_Fb.h>
#endif
#include <Eet.h>
#include <Embryo.h>
#include <math.h>
#include <fnmatch.h>
@ -26,40 +27,7 @@
*
* more example edje files
*
* ? programs need to be able to cycle part states given a list of states
* ? programs can do multiple actions from one signal
* ? programs need to be able to set/get/add/sub and compare variables
* ie:
* action, INT "active_state" = INT 1;
* ...
* action, INT "hidden" = INT 10;
* ...
* action, STR "my_string" = STR "some content here";
* ...
* action, INT "count" += INT 10;
* ...
* action, INT "count" -= INT 10;
* action, INT "count" += MOUSE_X "this_part";
* ...
* action, INT "count" *= INT "another_variable";
* action, INT "count" -= INT 10;
* action, INT "count" /= INT 2;
* ...
*
* if, INT "active_state" == 1;
* ...
* if, MOUSE_X "" > 1;
* or, MOUSE_X "this_part" > 50;
* or, MOUSE_X_REL "this_part" <= 0.5;
* and, STATE "this_part" == "clicked";
* and, STATE_VAL "this_part" == 0.0;
* ...
*
* if, INT "active_state" != 0;
* and, INT "hidden" < 10;
* or, STR "my_string" == "smelly";
* ...
*
* ? add containering (hbox, vbox, table, wrapping multi-line hbox & vbox)
* ? text entry widget (single line only)
* ? reduce linked list walking and list_nth calls
@ -88,4 +56,8 @@ extern Evas_List *_edje_animators;
extern Edje_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST];
extern Evas_List *_edje_edjes;
void _edje_embryo_script_init (Edje *ed);
void _edje_embryo_script_shutdown (Edje *ed);
void _edje_embryo_script_reset (Edje *ed);
#endif

View File

@ -697,11 +697,14 @@ _edje_emit(Edje *ed, char *sig, char *src)
if (ed->collection)
{
Edje_Part_Collection *ec;
#ifdef EDJE_PROGRAM_CACHE
char *tmps;
#endif
int l1, l2;
int done;
ec = ed->collection;
#ifdef EDJE_PROGRAM_CACHE
l1 = strlen(ee->signal);
l2 = strlen(ee->source);
tmps = malloc(l1 + l2 + 2);
@ -712,8 +715,10 @@ _edje_emit(Edje *ed, char *sig, char *src)
tmps[l1] = '\377';
strcpy(&(tmps[l1 + 1]), ee->source);
}
#endif
done = 0;
#ifdef EDJE_PROGRAM_CACHE
if (tmps)
{
Evas_List *matches;
@ -741,10 +746,13 @@ _edje_emit(Edje *ed, char *sig, char *src)
done = 1;
}
}
#endif
if (!done)
{
#ifdef EDJE_PROGRAM_CACHE
int matched = 0;
Evas_List *matches = NULL;
#endif
for (l = ed->collection->programs; l; l = l->next)
{
@ -756,19 +764,26 @@ _edje_emit(Edje *ed, char *sig, char *src)
(_edje_glob_match(ee->signal, pr->signal)) &&
(_edje_glob_match(ee->source, pr->source)))
{
#ifdef EDJE_PROGRAM_CACHE
matched++;
#endif
_edje_program_run(ed, pr, 0);
if (_edje_block_break(ed))
{
#ifdef EDJE_PROGRAM_CACHE
if (tmps) free(tmps);
evas_list_free(matches);
#endif
if (!ed->dont_clear_signals)
_edje_emit(ed, NULL, NULL);
goto break_prog;
}
#ifdef EDJE_PROGRAM_CACHE
matches = evas_list_append(matches, pr);
#endif
}
}
#ifdef EDJE_PROGRAM_CACHE
if (tmps)
{
if (matched == 0)
@ -778,17 +793,22 @@ _edje_emit(Edje *ed, char *sig, char *src)
ec->prog_cache.matches =
evas_hash_add(ec->prog_cache.matches, tmps, matches);
}
#endif
}
_edje_emit_cb(ed, ee->signal, ee->source);
if (_edje_block_break(ed))
{
#ifdef EDJE_PROGRAM_CACHE
if (tmps) free(tmps);
#endif
if (!ed->dont_clear_signals)
_edje_emit(ed, NULL, NULL);
goto break_prog;
}
#ifdef EDJE_PROGRAM_CACHE
if (tmps) free(tmps);
tmps = NULL;
#endif
}
_edje_emission_free(ee);

View File

@ -322,7 +322,9 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
(ep->text.cache.in_h == sh) &&
(ep->text.cache.in_str) &&
(text) &&
(!strcmp(ep->text.cache.in_str, text)))
(!strcmp(ep->text.cache.in_str, text)) &&
(chosen_desc->text.align.x == params->text.align.x) &&
(chosen_desc->text.align.y == params->text.align.y))
{
text = ep->text.cache.out_str;
size = ep->text.cache.out_size;
@ -415,17 +417,17 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
evas_object_text_font_set(ep->object, font, size);
evas_object_text_text_set(ep->object, text);
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
p = ((sw - tw) * chosen_desc->text.align.x);
p = ((sw - tw) * params->text.align.x);
c1 = -1;
c2 = -1;
/* chop chop */
if (tw > sw)
{
if (chosen_desc->text.align.x != 0.0)
if (params->text.align.x != 0.0)
c1 = evas_object_text_char_coords_get(ep->object,
-p, th / 2,
NULL, NULL, NULL, NULL);
if (chosen_desc->text.align.x != 1.0)
if (params->text.align.x != 1.0)
c2 = evas_object_text_char_coords_get(ep->object,
-p + sw, th / 2,
NULL, NULL, NULL, NULL);
@ -539,8 +541,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
evas_object_text_font_set(ep->object, font, size);
evas_object_text_text_set(ep->object, text);
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
ep->offset.x = ox + ((sw - tw) * chosen_desc->text.align.x);
ep->offset.y = oy + ((sh - th) * chosen_desc->text.align.y);
ep->offset.x = ox + ((sw - tw) * params->text.align.x);
ep->offset.y = oy + ((sh - th) * params->text.align.y);
evas_object_move(ep->object,
ed->x + params->x + ep->offset.x,
ed->y + params->y + ep->offset.y);