From 1b587fd598a8ee227002cf3737c12d9fa128a151 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Mon, 7 Jul 2003 07:55:18 +0000 Subject: [PATCH] work has been done while i've been away. i just need to put this in cvs. many fixem's have been fixed. text parts work fully now, ALONG with all their respective effect modes, fits, alignments and "chopping". a few more api calls have been added and cleaned up. you'll need to update eet too for this to work. SVN revision: 7113 --- legacy/edje/data/src/e_logo.edc | 273 +++++++------ legacy/edje/data/src/test.edc | 5 +- legacy/edje/src/bin/edje.h | 1 + legacy/edje/src/bin/edje_cc.h | 2 +- legacy/edje/src/bin/edje_cc_handlers.c | 37 +- legacy/edje/src/bin/edje_cc_out.c | 11 +- legacy/edje/src/bin/edje_cc_parse.c | 4 +- legacy/edje/src/bin/edje_main.c | 79 ++-- legacy/edje/src/lib/Edje.h | 10 +- legacy/edje/src/lib/Makefile.am | 1 + legacy/edje/src/lib/edje_calc.c | 33 +- legacy/edje/src/lib/edje_callbacks.c | 39 +- legacy/edje/src/lib/edje_data.c | 111 ++---- legacy/edje/src/lib/edje_load.c | 37 +- legacy/edje/src/lib/edje_main.c | 1 + legacy/edje/src/lib/edje_private.h | 95 +++-- legacy/edje/src/lib/edje_program.c | 91 ++++- legacy/edje/src/lib/edje_smart.c | 78 +++- legacy/edje/src/lib/edje_text.c | 519 +++++++++++++++++++++++++ legacy/edje/src/lib/edje_util.c | 82 +++- 20 files changed, 1196 insertions(+), 313 deletions(-) create mode 100644 legacy/edje/src/lib/edje_text.c diff --git a/legacy/edje/data/src/e_logo.edc b/legacy/edje/data/src/e_logo.edc index 1521a925fd..bff469964f 100644 --- a/legacy/edje/data/src/e_logo.edc +++ b/legacy/edje/data/src/e_logo.edc @@ -1,127 +1,127 @@ images { - image, "bg.png" LOSSY 98; - image, "e.png" LOSSY 98; + image, "bg.png" LOSSY 95; + image, "e.png" LOSSY 95; // used for anim - image, "e001.png" LOSSY 98; - image, "e002.png" LOSSY 98; - image, "e003.png" LOSSY 98; - image, "e004.png" LOSSY 98; - image, "e005.png" LOSSY 98; - image, "e006.png" LOSSY 98; - image, "e007.png" LOSSY 98; - image, "e008.png" LOSSY 98; - image, "e009.png" LOSSY 98; - image, "e010.png" LOSSY 98; - image, "e011.png" LOSSY 98; - image, "e012.png" LOSSY 98; - image, "e013.png" LOSSY 98; - image, "e014.png" LOSSY 98; - image, "e015.png" LOSSY 98; - image, "e016.png" LOSSY 98; - image, "e017.png" LOSSY 98; - image, "e018.png" LOSSY 98; - image, "e019.png" LOSSY 98; - image, "e020.png" LOSSY 98; - image, "e021.png" LOSSY 98; - image, "e022.png" LOSSY 98; - image, "e023.png" LOSSY 98; - image, "e024.png" LOSSY 98; - image, "e025.png" LOSSY 98; - image, "e026.png" LOSSY 98; - image, "e027.png" LOSSY 98; - image, "e028.png" LOSSY 98; - image, "e029.png" LOSSY 98; - image, "e030.png" LOSSY 98; - image, "e031.png" LOSSY 98; - image, "e032.png" LOSSY 98; - image, "e033.png" LOSSY 98; - image, "e034.png" LOSSY 98; - image, "e035.png" LOSSY 98; - image, "e036.png" LOSSY 98; - image, "e037.png" LOSSY 98; - image, "e038.png" LOSSY 98; - image, "e039.png" LOSSY 98; - image, "e040.png" LOSSY 98; - image, "e041.png" LOSSY 98; - image, "e042.png" LOSSY 98; - image, "e043.png" LOSSY 98; - image, "e044.png" LOSSY 98; - image, "e045.png" LOSSY 98; - image, "e046.png" LOSSY 98; - image, "e047.png" LOSSY 98; - image, "e048.png" LOSSY 98; - image, "e049.png" LOSSY 98; - image, "e050.png" LOSSY 98; - image, "e051.png" LOSSY 98; - image, "e052.png" LOSSY 98; - image, "e053.png" LOSSY 98; - image, "e054.png" LOSSY 98; - image, "e055.png" LOSSY 98; - image, "e056.png" LOSSY 98; - image, "e057.png" LOSSY 98; - image, "e058.png" LOSSY 98; - image, "e059.png" LOSSY 98; - image, "e060.png" LOSSY 98; - image, "e061.png" LOSSY 98; - image, "e062.png" LOSSY 98; - image, "e063.png" LOSSY 98; - image, "e064.png" LOSSY 98; - image, "e065.png" LOSSY 98; - image, "e066.png" LOSSY 98; - image, "e067.png" LOSSY 98; - image, "e068.png" LOSSY 98; - image, "e069.png" LOSSY 98; - image, "e070.png" LOSSY 98; - image, "e071.png" LOSSY 98; - image, "e072.png" LOSSY 98; - image, "e073.png" LOSSY 98; - image, "e074.png" LOSSY 98; - image, "e075.png" LOSSY 98; - image, "e076.png" LOSSY 98; - image, "e077.png" LOSSY 98; - image, "e078.png" LOSSY 98; - image, "e079.png" LOSSY 98; - image, "e080.png" LOSSY 98; - image, "e081.png" LOSSY 98; - image, "e082.png" LOSSY 98; - image, "e083.png" LOSSY 98; - image, "e084.png" LOSSY 98; - image, "e085.png" LOSSY 98; - image, "e086.png" LOSSY 98; - image, "e087.png" LOSSY 98; - image, "e088.png" LOSSY 98; - image, "e089.png" LOSSY 98; - image, "e090.png" LOSSY 98; - image, "e091.png" LOSSY 98; - image, "e092.png" LOSSY 98; - image, "e093.png" LOSSY 98; - image, "e094.png" LOSSY 98; - image, "e095.png" LOSSY 98; - image, "e096.png" LOSSY 98; - image, "e097.png" LOSSY 98; - image, "e098.png" LOSSY 98; - image, "e099.png" LOSSY 98; - image, "e100.png" LOSSY 98; - image, "e101.png" LOSSY 98; - image, "e102.png" LOSSY 98; - image, "e103.png" LOSSY 98; - image, "e104.png" LOSSY 98; - image, "e105.png" LOSSY 98; - image, "e106.png" LOSSY 98; - image, "e107.png" LOSSY 98; - image, "e108.png" LOSSY 98; - image, "e109.png" LOSSY 98; - image, "e110.png" LOSSY 98; - image, "e111.png" LOSSY 98; - image, "e112.png" LOSSY 98; - image, "e113.png" LOSSY 98; - image, "e114.png" LOSSY 98; - image, "e115.png" LOSSY 98; - image, "e116.png" LOSSY 98; - image, "e117.png" LOSSY 98; - image, "e118.png" LOSSY 98; - image, "e119.png" LOSSY 98; - image, "e120.png" LOSSY 98; + image, "e001.png" LOSSY 95; + image, "e002.png" LOSSY 95; + image, "e003.png" LOSSY 95; + image, "e004.png" LOSSY 95; + image, "e005.png" LOSSY 95; + image, "e006.png" LOSSY 95; + image, "e007.png" LOSSY 95; + image, "e008.png" LOSSY 95; + image, "e009.png" LOSSY 95; + image, "e010.png" LOSSY 95; + image, "e011.png" LOSSY 95; + image, "e012.png" LOSSY 95; + image, "e013.png" LOSSY 95; + image, "e014.png" LOSSY 95; + image, "e015.png" LOSSY 95; + image, "e016.png" LOSSY 95; + image, "e017.png" LOSSY 95; + image, "e018.png" LOSSY 95; + image, "e019.png" LOSSY 95; + image, "e020.png" LOSSY 95; + image, "e021.png" LOSSY 95; + image, "e022.png" LOSSY 95; + image, "e023.png" LOSSY 95; + image, "e024.png" LOSSY 95; + image, "e025.png" LOSSY 95; + image, "e026.png" LOSSY 95; + image, "e027.png" LOSSY 95; + image, "e028.png" LOSSY 95; + image, "e029.png" LOSSY 95; + image, "e030.png" LOSSY 95; + image, "e031.png" LOSSY 95; + image, "e032.png" LOSSY 95; + image, "e033.png" LOSSY 95; + image, "e034.png" LOSSY 95; + image, "e035.png" LOSSY 95; + image, "e036.png" LOSSY 95; + image, "e037.png" LOSSY 95; + image, "e038.png" LOSSY 95; + image, "e039.png" LOSSY 95; + image, "e040.png" LOSSY 95; + image, "e041.png" LOSSY 95; + image, "e042.png" LOSSY 95; + image, "e043.png" LOSSY 95; + image, "e044.png" LOSSY 95; + image, "e045.png" LOSSY 95; + image, "e046.png" LOSSY 95; + image, "e047.png" LOSSY 95; + image, "e048.png" LOSSY 95; + image, "e049.png" LOSSY 95; + image, "e050.png" LOSSY 95; + image, "e051.png" LOSSY 95; + image, "e052.png" LOSSY 95; + image, "e053.png" LOSSY 95; + image, "e054.png" LOSSY 95; + image, "e055.png" LOSSY 95; + image, "e056.png" LOSSY 95; + image, "e057.png" LOSSY 95; + image, "e058.png" LOSSY 95; + image, "e059.png" LOSSY 95; + image, "e060.png" LOSSY 95; + image, "e061.png" LOSSY 95; + image, "e062.png" LOSSY 95; + image, "e063.png" LOSSY 95; + image, "e064.png" LOSSY 95; + image, "e065.png" LOSSY 95; + image, "e066.png" LOSSY 95; + image, "e067.png" LOSSY 95; + image, "e068.png" LOSSY 95; + image, "e069.png" LOSSY 95; + image, "e070.png" LOSSY 95; + image, "e071.png" LOSSY 95; + image, "e072.png" LOSSY 95; + image, "e073.png" LOSSY 95; + image, "e074.png" LOSSY 95; + image, "e075.png" LOSSY 95; + image, "e076.png" LOSSY 95; + image, "e077.png" LOSSY 95; + image, "e078.png" LOSSY 95; + image, "e079.png" LOSSY 95; + image, "e080.png" LOSSY 95; + image, "e081.png" LOSSY 95; + image, "e082.png" LOSSY 95; + image, "e083.png" LOSSY 95; + image, "e084.png" LOSSY 95; + image, "e085.png" LOSSY 95; + image, "e086.png" LOSSY 95; + image, "e087.png" LOSSY 95; + image, "e088.png" LOSSY 95; + image, "e089.png" LOSSY 95; + image, "e090.png" LOSSY 95; + image, "e091.png" LOSSY 95; + image, "e092.png" LOSSY 95; + image, "e093.png" LOSSY 95; + image, "e094.png" LOSSY 95; + image, "e095.png" LOSSY 95; + image, "e096.png" LOSSY 95; + image, "e097.png" LOSSY 95; + image, "e098.png" LOSSY 95; + image, "e099.png" LOSSY 95; + image, "e100.png" LOSSY 95; + image, "e101.png" LOSSY 95; + image, "e102.png" LOSSY 95; + image, "e103.png" LOSSY 95; + image, "e104.png" LOSSY 95; + image, "e105.png" LOSSY 95; + image, "e106.png" LOSSY 95; + image, "e107.png" LOSSY 95; + image, "e108.png" LOSSY 95; + image, "e109.png" LOSSY 95; + image, "e110.png" LOSSY 95; + image, "e111.png" LOSSY 95; + image, "e112.png" LOSSY 95; + image, "e113.png" LOSSY 95; + image, "e114.png" LOSSY 95; + image, "e115.png" LOSSY 95; + image, "e116.png" LOSSY 95; + image, "e117.png" LOSSY 95; + image, "e118.png" LOSSY 95; + image, "e119.png" LOSSY 95; + image, "e120.png" LOSSY 95; } collections { @@ -147,6 +147,35 @@ collections { border, 12 12 12 12; } } + part { + name, "text"; + type, TEXT; + effect, SOFT_SHADOW; + description { + state, "default" 0.0; + rel1 { + relative, 1.0 0.0; + offset, 0 0; + to, "logo"; + } + rel2 { + relative, 2.0, 1.0; + offset, -64, -1; + to, "logo"; + } + color, 255 255 255 255; +// color2, 0 0 255 255; + color3, 0 0 0 32; + text { + text, "This is a longer test string"; + font, "Vera-Bold"; + size, 8; + fit, 0 0; +// min, 1 1; + align, 0.0 0.5; + } + } + } /* part { name, "clip"; diff --git a/legacy/edje/data/src/test.edc b/legacy/edje/data/src/test.edc index e8779950ca..73ad8fba26 100644 --- a/legacy/edje/data/src/test.edc +++ b/legacy/edje/data/src/test.edc @@ -22,6 +22,10 @@ collections name, "background"; // IMAGE, RECTANGLE, TEXT // type, IMAGE; +// for text only really +// NONE, PLAIN, OUTLINE, SOFT_OUTLINE, SHADOW, SOFT_SHADOW, OUTLINE_SHADOW, +// OUTLINE_SOFT_SHADOW +// effect, NONE; mouse_events, 0; // clip_to "p1"; // color_class, "default"; @@ -87,7 +91,6 @@ collections // text, "test text"; // font, "Vera"; // size, 12; -// effect, PLAIN; // fit, 0 0; // min, 1 1; // align 0.5 0.5; diff --git a/legacy/edje/src/bin/edje.h b/legacy/edje/src/bin/edje.h index 68035596ad..ddc6323273 100644 --- a/legacy/edje/src/bin/edje.h +++ b/legacy/edje/src/bin/edje.h @@ -3,6 +3,7 @@ #include #include +#include #include /* ... only for testing */ #include diff --git a/legacy/edje/src/bin/edje_cc.h b/legacy/edje/src/bin/edje_cc.h index 9201bfddb0..2983f78e5a 100644 --- a/legacy/edje/src/bin/edje_cc.h +++ b/legacy/edje/src/bin/edje_cc.h @@ -49,7 +49,7 @@ int parse_enum(int n, ...); int parse_int(int n); int parse_int_range(int n, int f, int t); double parse_float(int n); -double parse_float_range(int n, int f, int t); +double parse_float_range(int n, double f, double t); int object_handler_num(void); int statement_handler_num(void); diff --git a/legacy/edje/src/bin/edje_cc_handlers.c b/legacy/edje/src/bin/edje_cc_handlers.c index 2b38aed1a3..6834dcc01a 100644 --- a/legacy/edje/src/bin/edje_cc_handlers.c +++ b/legacy/edje/src/bin/edje_cc_handlers.c @@ -15,6 +15,7 @@ static void ob_collections_group_parts(void); static void ob_collections_group_parts_part(void); static void st_collections_group_parts_part_name(void); static void st_collections_group_parts_part_type(void); +static void st_collections_group_parts_part_effect(void); static void st_collections_group_parts_part_mouse_events(void); static void st_collections_group_parts_part_clip_to_id(void); static void st_collections_group_parts_part_color_class(void); @@ -51,7 +52,6 @@ static void st_collections_group_parts_part_description_color3(void); static void st_collections_group_parts_part_description_text_text(void); static void st_collections_group_parts_part_description_text_font(void); static void st_collections_group_parts_part_description_text_size(void); -static void st_collections_group_parts_part_description_text_effect(void); static void st_collections_group_parts_part_description_text_fit(void); static void st_collections_group_parts_part_description_text_min(void); static void st_collections_group_parts_part_description_text_align(void); @@ -76,6 +76,7 @@ New_Statement_Handler statement_handlers[] = {"collections.group.name", st_collections_group_name}, {"collections.group.parts.part.name", st_collections_group_parts_part_name}, {"collections.group.parts.part.type", st_collections_group_parts_part_type}, + {"collections.group.parts.part.effect", st_collections_group_parts_part_effect}, {"collections.group.parts.part.mouse_events", st_collections_group_parts_part_mouse_events}, {"collections.group.parts.part.clip_to", st_collections_group_parts_part_clip_to_id}, {"collections.group.parts.part.color_class", st_collections_group_parts_part_color_class}, @@ -110,7 +111,6 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.text.text", st_collections_group_parts_part_description_text_text}, {"collections.group.parts.part.description.text.font", st_collections_group_parts_part_description_text_font}, {"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size}, - {"collections.group.parts.part.description.text.effect", st_collections_group_parts_part_description_text_effect}, {"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit}, {"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min}, {"collections.group.parts.part.description.text.align", st_collections_group_parts_part_description_text_align}, @@ -135,6 +135,7 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part", ob_collections_group_parts_part}, {"collections.group.parts.part.name", NULL}, {"collections.group.parts.part.type", NULL}, + {"collections.group.parts.part.effect", NULL}, {"collections.group.parts.part.mouse_events", NULL}, {"collections.group.parts.part.clip_to", NULL}, {"collections.group.parts.part.color_class", NULL}, @@ -178,7 +179,6 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.description.text.text", NULL}, {"collections.group.parts.part.description.text.font", NULL}, {"collections.group.parts.part.description.text.size", NULL}, - {"collections.group.parts.part.description.text.effect", NULL}, {"collections.group.parts.part.description.text.fit", NULL}, {"collections.group.parts.part.description.text.min", NULL}, {"collections.group.parts.part.description.text.align", NULL}, @@ -445,6 +445,8 @@ ob_collections_group_parts_part_description(void) ed->color3.g = 0; ed->color3.b = 0; ed->color3.a = 128; + ed->text.align.x = 0.5; + ed->text.align.y = 0.5; } static void @@ -614,8 +616,8 @@ st_collections_group_parts_part_description_rel1_relative(void) ep = evas_list_data(evas_list_last(pc->parts)); ed = ep->default_desc; if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc)); - ed->rel1.relative_x = parse_float_range(0, 0.0, 1.0); - ed->rel1.relative_y = parse_float_range(1, 0.0, 1.0); + ed->rel1.relative_x = parse_float(0); + ed->rel1.relative_y = parse_float(1); } static void @@ -664,8 +666,8 @@ st_collections_group_parts_part_description_rel2_relative(void) ep = evas_list_data(evas_list_last(pc->parts)); ed = ep->default_desc; if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc)); - ed->rel2.relative_x = parse_float_range(0, 0.0, 1.0); - ed->rel2.relative_y = parse_float_range(1, 0.0, 1.0); + ed->rel2.relative_x = parse_float(0); + ed->rel2.relative_y = parse_float(1); } static void @@ -931,7 +933,7 @@ st_collections_group_parts_part_description_text_size(void) } static void -st_collections_group_parts_part_description_text_effect(void) +st_collections_group_parts_part_effect(void) { Edje_Part_Collection *pc; Edje_Part *ep; @@ -939,15 +941,16 @@ st_collections_group_parts_part_description_text_effect(void) pc = evas_list_data(evas_list_last(edje_collections)); ep = evas_list_data(evas_list_last(pc->parts)); - ed = ep->default_desc; - if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc)); - ed->text.effect = parse_enum(0, - "NONE", EDJE_TEXT_EFFECT_NONE, - "PLAIN", EDJE_TEXT_EFFECT_PLAIN, - "OUTLINE", EDJE_TEXT_EFFECT_OUTLINE, - "SHADOW", EDJE_TEXT_EFFECT_SHADOW, - "SHADOW_OUTLINE", EDJE_TEXT_EFFECT_OUTLINE_SHADOW, - NULL); + ep->effect = parse_enum(0, + "NONE", EDJE_TEXT_EFFECT_NONE, + "PLAIN", EDJE_TEXT_EFFECT_PLAIN, + "OUTLINE", EDJE_TEXT_EFFECT_OUTLINE, + "SOFT_OUTLINE", EDJE_TEXT_EFFECT_SOFT_OUTLINE, + "SHADOW", EDJE_TEXT_EFFECT_SHADOW, + "SOFT_SHADOW", EDJE_TEXT_EFFECT_SOFT_SHADOW, + "OUTLINE_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SHADOW, + "OUTLINE_SOFT_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW, + NULL); } static void diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index 7682e89224..f1cb53c53e 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -137,8 +137,15 @@ data_write(void) } if (verbose) { - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\"\n", - progname, bytes, (bytes + 512) / 1024, buf, img->entry); + struct stat st; + + if (stat(imlib_image_get_filename(), &st) != 0) + st.st_size = 0; + printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]\n", + progname, bytes, (bytes + 512) / 1024, buf, img->entry, + 100 - (100 * (double)bytes) / ((double)(im_w * im_h * 4)), + 100 - (100 * (double)bytes) / ((double)(st.st_size)) + ); } imlib_image_put_back_data(im_data); imlib_free_image(); diff --git a/legacy/edje/src/bin/edje_cc_parse.c b/legacy/edje/src/bin/edje_cc_parse.c index 2f2e7516bb..9664470c56 100644 --- a/legacy/edje/src/bin/edje_cc_parse.c +++ b/legacy/edje/src/bin/edje_cc_parse.c @@ -476,7 +476,7 @@ parse_float(int n) } double -parse_float_range(int n, int f, int t) +parse_float_range(int n, double f, double t) { char *str; double i; @@ -491,7 +491,7 @@ parse_float_range(int n, int f, int t) i = atof(str); if ((i < f) || (i > t)) { - fprintf(stderr, "%s: Error. %s:%i integer %i out of range of %3.3f to %3.3f inclusive\n", + fprintf(stderr, "%s: Error. %s:%i float %3.3f out of range of %3.3f to %3.3f inclusive\n", progname, file_in, line, i, f, t); exit(-1); } diff --git a/legacy/edje/src/bin/edje_main.c b/legacy/edje/src/bin/edje_main.c index db78ad3ca5..dbcc615511 100644 --- a/legacy/edje/src/bin/edje_main.c +++ b/legacy/edje/src/bin/edje_main.c @@ -6,11 +6,33 @@ static void main_resize(Ecore_Evas *ee); static int main_signal_exit(void *data, int ev_type, void *ev); static void main_delete_request(Ecore_Evas *ee); -void bg_setup(void); -void bg_resize(double w, double h); +void bg_setup(void); +void bg_resize(double w, double h); +static void bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info); -void test_setup(char *file, char *name); -void test_reize(double w, double h); +void test_setup(char *file, char *name); +void test_reize(double w, double h); +typedef struct _Demo_Edje Demo_Edje; + +struct _Demo_Edje +{ + Evas_Object *edje; + Evas_Object *left; + Evas_Object *right; + Evas_Object *top; + Evas_Object *bottom; + Evas_Object *title; + Evas_Object *title_clip; + Evas_Object *image; + int down_top : 1; + int down_bottom : 1; + int hdir; + int vdir; +}; + +static Evas_List *edjes = NULL; +static Evas_Object *o_bg = NULL; +static Evas_Object *o_shadow = NULL; double start_time = 0.0; Ecore_Evas *ecore_evas = NULL; @@ -49,10 +71,8 @@ main_start(int argc, char **argv) ecore_evas_name_class_set(ecore_evas, "edje", "main"); ecore_evas_show(ecore_evas); evas = ecore_evas_get(ecore_evas); -// evas_image_cache_set(evas, 1024 * 1024); -// evas_font_cache_set(evas, 256 * 1024); - evas_image_cache_set(evas, 0); - evas_font_cache_set(evas, 0); + evas_image_cache_set(evas, 8 * 1024 * 1024); + evas_font_cache_set(evas, 1 * 1024 * 1024); evas_font_path_append(evas, DAT"data/test/fonts"); return 1; } @@ -87,9 +107,6 @@ main_delete_request(Ecore_Evas *ee) ecore_main_loop_quit(); } -static Evas_Object *o_bg = NULL; -static Evas_Object *o_shadow = NULL; - void bg_setup(void) { @@ -104,6 +121,8 @@ bg_setup(void) evas_object_image_fill_set(o, 0, 0, 128, 128); evas_object_pass_events_set(o, 1); evas_object_show(o); + evas_object_focus_set(o, 1); + evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, bg_key_down, NULL); o_bg = o; o = evas_object_image_add(evas); @@ -126,25 +145,27 @@ bg_resize(double w, double h) evas_object_image_fill_set(o_shadow, 0, 0, w, h); } -typedef struct _Demo_Edje Demo_Edje; - -struct _Demo_Edje +static void +bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info) { - Evas_Object *edje; - Evas_Object *left; - Evas_Object *right; - Evas_Object *top; - Evas_Object *bottom; - Evas_Object *title; - Evas_Object *title_clip; - Evas_Object *image; - int down_top : 1; - int down_bottom : 1; - int hdir; - int vdir; -}; - -static Evas_List *edjes = NULL; + Evas_Event_Key_Down *ev; + + ev = (Evas_Event_Key_Down *)event_info; + { + Evas_List *l; + + for (l = edjes; l; l = l->next) + { + Demo_Edje *de; + + de = l->data; + if (!strcmp(ev->keyname, "p")) edje_play_set(de->edje, 1); + else if (!strcmp(ev->keyname, "o")) edje_play_set(de->edje, 0); + else if (!strcmp(ev->keyname, "a")) edje_animation_set(de->edje, 1); + else if (!strcmp(ev->keyname, "s")) edje_animation_set(de->edje, 0); + } + } +} static void cb (void *data, Evas_Object *o, const char *sig, const char *src); diff --git a/legacy/edje/src/lib/Edje.h b/legacy/edje/src/lib/Edje.h index 4bcc1529bc..97fd650ec8 100644 --- a/legacy/edje/src/lib/Edje.h +++ b/legacy/edje/src/lib/Edje.h @@ -19,8 +19,14 @@ extern "C" { 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); - - void edje_part_geometry_get(Evas_Object *o, char *part, double *x, double *y, double *w, double *h); + void edje_play_set(Evas_Object *obj, int play); + int edje_play_get(Evas_Object *obj); + void edje_animation_set(Evas_Object *obj, int on); + int edje_animation_get(Evas_Object *obj); + int edje_part_exists(Evas_Object *obj, const char *part); + void edje_part_geometry_get(Evas_Object *o, const char *part, double *x, double *y, double *w, double *h); + void edje_part_text_set(Evas_Object *o, const char *part, const char *text); + const char *edje_part_text_get(Evas_Object *obj, const char *part); #ifdef __cplusplus } diff --git a/legacy/edje/src/lib/Makefile.am b/legacy/edje/src/lib/Makefile.am index 65b49a726e..a2462cf7c8 100644 --- a/legacy/edje/src/lib/Makefile.am +++ b/legacy/edje/src/lib/Makefile.am @@ -23,6 +23,7 @@ edje_load.c \ edje_main.c \ edje_program.c \ edje_smart.c \ +edje_text.c \ edje_util.c \ edje_private.h diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c index 1955b9edd1..223c4e43cf 100644 --- a/legacy/edje/src/lib/edje_calc.c +++ b/legacy/edje/src/lib/edje_calc.c @@ -337,26 +337,20 @@ _edje_part_recalc_single(Edje *ed, size = chosen_desc->text.size; if (ep->text.text) text = ep->text.text; if (ep->text.font) font = ep->text.font; - if (ep->text.size) size = ep->text.size; + if (ep->text.size > 0) size = ep->text.size; evas_object_text_font_set(ep->object, font, size); if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) { evas_object_text_text_set(ep->object, text); evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); if (chosen_desc->text.min_x) - { - minw = tw; - /* FIXME: account for effect */ - /* for now just add 2 */ - minw += 2; - } + minw = tw + + _edje_text_styles[ep->part->effect].pad.l + + _edje_text_styles[ep->part->effect].pad.r; if (chosen_desc->text.min_y) - { - minh = th; - /* FIXME: account for effect */ - /* for now just add 2 */ - minw += 2; - } + minw = th + + _edje_text_styles[ep->part->effect].pad.t + + _edje_text_styles[ep->part->effect].pad.b; } } /* adjust for min size */ @@ -507,7 +501,6 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep) { _edje_part_recalc_single(ed, ep, ep->param2.description, chosen_desc, ep->param2.rel1_to, ep->param2.rel2_to, ep->param2.confine_to, &p2); - /* FIXME: pos isnt just linear - depends on tween method */ pos = ep->description_pos; /* visible is special */ @@ -569,11 +562,13 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep) { evas_object_move(ep->object, ed->x + p3.x, ed->y + p3.y); evas_object_resize(ep->object, p3.w, p3.h); + evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a); + if (p3.visible) evas_object_show(ep->object); + else evas_object_hide(ep->object); } else if (ep->part->type == EDJE_PART_TYPE_TEXT) { - /* FIXME: if text object calculate text now */ - /* FIXME: set other colors */ + _edje_text_recalc_apply(ed, ep, &p3, chosen_desc); } else if (ep->part->type == EDJE_PART_TYPE_IMAGE) { @@ -610,10 +605,10 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep) snprintf(buf, sizeof(buf), "images/%i", image_id); evas_object_image_file_set(ep->object, ed->file->path, buf); + evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a); + if (p3.visible) evas_object_show(ep->object); + else evas_object_hide(ep->object); } - if (p3.visible) evas_object_show(ep->object); - else evas_object_hide(ep->object); - evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a); ep->x = p3.x; ep->y = p3.y; diff --git a/legacy/edje/src/lib/edje_callbacks.c b/legacy/edje/src/lib/edje_callbacks.c index 9a02d27eb3..740ccad4d8 100644 --- a/legacy/edje/src/lib/edje_callbacks.c +++ b/legacy/edje/src/lib/edje_callbacks.c @@ -41,7 +41,25 @@ _edje_mouse_down_cb(void *data, Evas * e, Evas_Object * obj, void *event_info) ed = data; rp = evas_object_data_get(obj, "real_part"); if (!rp) return; - snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button); + if (ecore_event_current_type_get() == ECORE_X_EVENT_MOUSE_BUTTON_DOWN) + { + Ecore_X_Event_Mouse_Button_Down *evx; + + evx = ecore_event_current_event_get(); + if (evx) + { + if (evx->triple_click) + snprintf(buf, sizeof(buf), "mouse,down,%i,triple", ev->button); + else if (evx->double_click) + snprintf(buf, sizeof(buf), "mouse,down,%i,double", ev->button); + else + snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button); + } + else + snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button); + } + else + snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button); if (rp->clicked_button == 0) { rp->clicked_button = ev->button; @@ -144,15 +162,18 @@ _edje_timer_cb(void *data) ed = animl->data; _edje_freeze(ed); animl = evas_list_remove(animl, animl->data); - for (l = ed->actions; l; l = l->next) - newl = evas_list_append(newl, l->data); - while (newl) + if (!ed->paused) { - Edje_Running_Program *runp; - - runp = newl->data; - newl = evas_list_remove(newl, newl->data); - _edje_program_run_iterate(runp, t); + for (l = ed->actions; l; l = l->next) + newl = evas_list_append(newl, l->data); + while (newl) + { + Edje_Running_Program *runp; + + runp = newl->data; + newl = evas_list_remove(newl, newl->data); + _edje_program_run_iterate(runp, t); + } } _edje_thaw(ed); _edje_unref(ed); diff --git a/legacy/edje/src/lib/edje_data.c b/legacy/edje/src/lib/edje_data.c index d9ea400d65..0f68d3dd3a 100644 --- a/legacy/edje/src/lib/edje_data.c +++ b/legacy/edje/src/lib/edje_data.c @@ -13,86 +13,61 @@ Eet_Data_Descriptor *_edje_edd_edje_part = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_description = NULL; Eet_Data_Descriptor *_edje_edd_edje_part_image_id = NULL; +#define NEWD(str, typ) \ + eet_data_descriptor_new(str, sizeof(typ), \ + (void *(*) (void *))evas_list_next, \ + (void *(*) (void *, void *))evas_list_append, \ + (void *(*) (void *))evas_list_data, \ + (void *(*) (void *))evas_list_free, \ + (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach, \ + (void *(*) (void *, const char *, void *))evas_hash_add, \ + (void (*) (void *))evas_hash_free) + void _edje_edd_setup(void) { /* image directory */ _edje_edd_edje_image_directory_entry = - eet_data_descriptor_new("Edje_Image_Directory_Entry", - sizeof(Edje_Image_Directory_Entry), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Image_Directory_Entry", + Edje_Image_Directory_Entry); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "entry", entry, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT); _edje_edd_edje_image_directory = - eet_data_descriptor_new("Edje_Image_Directory", - sizeof(Edje_Image_Directory), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Image_Directory", + Edje_Image_Directory); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_image_directory, Edje_Image_Directory, "entries", entries, _edje_edd_edje_image_directory_entry); /* collection directory */ _edje_edd_edje_part_collection_directory_entry = - eet_data_descriptor_new("Edje_Part_Collection_Directory_Entry", - sizeof(Edje_Part_Collection_Directory_Entry), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Part_Collection_Directory_Entry", + Edje_Part_Collection_Directory_Entry); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "entry", entry, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "id", id, EET_T_INT); _edje_edd_edje_part_collection_directory = - eet_data_descriptor_new("Edje_Part_Collection_Directory", - sizeof(Edje_Part_Collection_Directory), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Part_Collection_Directory", + Edje_Part_Collection_Directory); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_collection_directory, Edje_Part_Collection_Directory, "entries", entries, _edje_edd_edje_part_collection_directory_entry); /* the main file directory */ _edje_edd_edje_file = - eet_data_descriptor_new("Edje_File", - sizeof(Edje_File), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_File", + Edje_File); EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory); EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "collection_dir", collection_dir, _edje_edd_edje_part_collection_directory); /* parts & programs - loaded induvidually */ _edje_edd_edje_program_target = - eet_data_descriptor_new("Edje_Program_Target", - sizeof(Edje_Program_Target), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Program_Target", + Edje_Program_Target); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program_target, Edje_Program_Target, "id", id, EET_T_INT); _edje_edd_edje_program = - eet_data_descriptor_new("Edje_Program", - sizeof(Edje_Program), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Program", + Edje_Program); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "id", id, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "name", name, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "signal", signal, EET_T_STRING); @@ -109,23 +84,13 @@ _edje_edd_setup(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "after", after, EET_T_INT); _edje_edd_edje_part_image_id = - eet_data_descriptor_new("Edje_Part_Image_Id", - sizeof(Edje_Part_Image_Id), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Part_Image_Id", + Edje_Part_Image_Id); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT); _edje_edd_edje_part_description = - eet_data_descriptor_new("Edje_Part_Description", - sizeof(Edje_Part_Description), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Part_Description", + Edje_Part_Description); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "state.name", state.name, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "state.value", state.value, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "visible", visible, EET_T_CHAR); @@ -186,7 +151,6 @@ _edje_edd_setup(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.text", text.text, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.font", text.font, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.size", text.size, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.effect", text.effect, EET_T_CHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_x", text.fit_x, EET_T_CHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_y", text.fit_y, EET_T_CHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_x", text.min_x, EET_T_CHAR); @@ -195,16 +159,12 @@ _edje_edd_setup(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.align.y", text.align.y, EET_T_DOUBLE); _edje_edd_edje_part = - eet_data_descriptor_new("Edje_Part", - sizeof(Edje_Part), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Part", + Edje_Part); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "name", name, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "id", id, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "type", type, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "effect", effect, EET_T_CHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "mouse_events", mouse_events, EET_T_CHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "clip_to_id", clip_to_id, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "color_class", color_class, EET_T_STRING); @@ -213,13 +173,8 @@ _edje_edd_setup(void) EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part, Edje_Part, "other_desc", other_desc, _edje_edd_edje_part_description); _edje_edd_edje_part_collection = - eet_data_descriptor_new("Edje_Part_Collection", - sizeof(Edje_Part_Collection), - evas_list_next, - evas_list_append, - evas_list_data, - evas_hash_foreach, - evas_hash_add); + NEWD("Edje_Part_Collection", + Edje_Part_Collection); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs", programs, _edje_edd_edje_program); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_collection, Edje_Part_Collection, "parts", parts, _edje_edd_edje_part); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT); diff --git a/legacy/edje/src/lib/edje_load.c b/legacy/edje/src/lib/edje_load.c index 78e69d147c..c26dc29786 100644 --- a/legacy/edje/src/lib/edje_load.c +++ b/legacy/edje/src/lib/edje_load.c @@ -35,8 +35,10 @@ edje_file_set(Evas_Object *obj, const char *file, const char *part) ep = l->data; rp = calloc(1, sizeof(Edje_Real_Part)); if (!rp) return; + rp->part = ep; ed->parts = evas_list_append(ed->parts, rp); rp->param1.description = ep->default_desc; + _edje_text_part_on_add(ed, rp); if (ep->type == EDJE_PART_TYPE_RECTANGLE) rp->object = evas_object_rectangle_add(ed->evas); else if (ep->type == EDJE_PART_TYPE_IMAGE) @@ -76,7 +78,6 @@ edje_file_set(Evas_Object *obj, const char *file, const char *part) evas_object_pass_events_set(rp->object, 1); evas_object_clip_set(rp->object, ed->clipper); evas_object_show(rp->object); - rp->part = ep; } for (l = ed->parts; l; l = l->next) { @@ -87,6 +88,7 @@ edje_file_set(Evas_Object *obj, const char *file, const char *part) rp->param1.rel1_to = evas_list_nth(ed->parts, rp->param1.description->rel1.id); if (rp->param1.description->rel2.id >= 0) rp->param1.rel2_to = evas_list_nth(ed->parts, rp->param1.description->rel2.id); + _edje_text_part_on_add_clippers(ed, rp); if (rp->part->clip_to_id >= 0) { rp->clip_to = evas_list_nth(ed->parts, rp->part->clip_to_id); @@ -207,9 +209,12 @@ _edje_file_del(Edje *ed) Edje_Real_Part *rp; rp = ed->parts->data; + _edje_text_part_on_del(ed, rp); evas_object_del(rp->object); if (rp->text.text) free(rp->text.text); if (rp->text.font) free(rp->text.font); + if (rp->text.cache.in_str) free(rp->text.cache.in_str); + if (rp->text.cache.out_str) free(rp->text.cache.out_str); free(rp); ed->parts = evas_list_remove(ed->parts, ed->parts->data); } @@ -245,7 +250,35 @@ _edje_file_del(Edje *ed) void _edje_file_free(Edje_File *edf) { - printf("FIXME: leak Edje_File!\n"); + if (edf->path) free(edf->path); + if (edf->image_dir) + { + while (edf->image_dir->entries) + { + Edje_Image_Directory_Entry *ie; + + ie = edf->image_dir->entries->data; + edf->image_dir->entries = evas_list_remove(edf->image_dir->entries, ie); + if (ie->entry) free(ie->entry); + free(ie); + } + free(edf->image_dir); + } + if (edf->collection_dir) + { + while (edf->collection_dir->entries) + { + Edje_Part_Collection_Directory_Entry *ce; + + ce = edf->collection_dir->entries->data; + edf->collection_dir->entries = evas_list_remove(edf->collection_dir->entries, ce); + if (ce->entry) free(ce->entry); + free(ce); + } + free(edf->collection_dir); + } + if (edf->collection_hash) evas_hash_free(edf->collection_hash); + free(edf); } void diff --git a/legacy/edje/src/lib/edje_main.c b/legacy/edje/src/lib/edje_main.c index e1fb85f6c3..46dc870835 100644 --- a/legacy/edje/src/lib/edje_main.c +++ b/legacy/edje/src/lib/edje_main.c @@ -9,6 +9,7 @@ edje_init(void) if (initted) return; initted = 1; _edje_edd_setup(); + _edje_text_init(); } Edje * diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index c966065bd7..b3ff00ff1a 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -5,41 +5,47 @@ #include #include +#include #include #include #include /* FIXME: + * * free stuff - no more leaks + * * dragables have to work * drag start/top signals etc. * drag needs to have signals with relative pos as arg. * drag vals should be 0.0 -> 1.0 if drag is confined. "rest" pos = 0.0. * query dragable for its relative pos value - * text parts need to work + * * text and color classes need to work - * reduce linked list walking and list_nth calls + * * named parts need to be able to be "replaced" with new evas objects * part replacement with object callbacks should be possible + * * real part size and "before min/max limit" sizes need to be stored per part * need to be able to calculate min & max size of a whole edje + * * need to be able to list collections in an eet file + * * externally sourced images need to be supported in edje_cc and edje - * part queries for geometry etc. - * need to be able to "pause" edjes from API - * need to be able to force anim times to 0.0 from API to turn off animation + * * need to detect relative part loops * need to detect clip_to part loops + * * edje_cc should be able to force lossy, lossless, min and max quality and compression of encoded images * edje_cc needs to prune out unused images * edje_cc might need an option for limiting number of tween images + * * audit edje for corrupt/bad input files + * + * ? reduce linked list walking and list_nth calls * ? add containering (hbox, vbox, table, wrapping multi-line hbox & vbox) - * ? somehow handle double click? * ? add numeric params to conditions for progs (ranges etc.) - * ? containering for multiple children? (hbox, vbox, table, wrapping list) -*/ + */ /* HOW THIS ALL WORKS: @@ -103,12 +109,15 @@ typedef struct _Edje_Part_Description Edje_Part_Description; #define EDJE_PART_TYPE_IMAGE 3 #define EDJE_PART_TYPE_LAST 4 -#define EDJE_TEXT_EFFECT_NONE 0 -#define EDJE_TEXT_EFFECT_PLAIN 1 -#define EDJE_TEXT_EFFECT_OUTLINE 2 -#define EDJE_TEXT_EFFECT_SHADOW 3 -#define EDJE_TEXT_EFFECT_OUTLINE_SHADOW 4 -#define EDJE_TEXT_EFFECT_LAST 5 +#define EDJE_TEXT_EFFECT_NONE 0 +#define EDJE_TEXT_EFFECT_PLAIN 1 +#define EDJE_TEXT_EFFECT_OUTLINE 2 +#define EDJE_TEXT_EFFECT_SOFT_OUTLINE 3 +#define EDJE_TEXT_EFFECT_SHADOW 4 +#define EDJE_TEXT_EFFECT_SOFT_SHADOW 5 +#define EDJE_TEXT_EFFECT_OUTLINE_SHADOW 6 +#define EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW 7 +#define EDJE_TEXT_EFFECT_LAST 8 #define EDJE_ACTION_TYPE_NONE 0 #define EDJE_ACTION_TYPE_STATE_SET 1 @@ -218,6 +227,7 @@ struct _Edje_Part char *name; /* the name if any of the part */ int id; /* its id number */ unsigned char type; /* what type (image, rect, text) */ + unsigned char effect; /* 0 = plain... */ unsigned char mouse_events; /* it will affect/respond to mouse events */ int clip_to_id; /* the part id to clip this one to */ char *color_class; /* how to modify the color */ @@ -307,7 +317,6 @@ struct _Edje_Part_Description int size; /* 0 = use user set size */ - unsigned char effect; /* 0 = plain... */ unsigned char fit_x; /* resize font size down to fit in x dir */ unsigned char fit_y; /* resize font size down to fit in y dir */ unsigned char min_x; /* if text size should be part min size */ @@ -334,6 +343,7 @@ typedef struct _Edje_Signal_Callback Edje_Signal_Callback; typedef struct _Edje_Calc_Params Edje_Calc_Params; typedef struct _Edje_Emission Edje_Emission; typedef struct _Edje_Pending_Program Edje_Pending_Program; +typedef struct _Ejde_Text_Style Ejde_Text_Style; struct _Edje { @@ -342,12 +352,15 @@ struct _Edje int layer; double x, y, w, h; - unsigned char dirty : 1; - unsigned char recalc : 1; - unsigned char walking_callbacks : 1; - unsigned char delete_callbacks : 1; - unsigned char just_added_callbacks : 1; - unsigned char have_objects : 1; + unsigned short dirty : 1; + unsigned short recalc : 1; + unsigned short walking_callbacks : 1; + unsigned short delete_callbacks : 1; + unsigned short just_added_callbacks : 1; + unsigned short have_objects : 1; + unsigned short paused : 1; + unsigned short no_anim : 1; + double paused_at; 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 */ @@ -364,7 +377,11 @@ struct _Edje struct _Edje_Real_Part { int x, y, w, h; + struct { + int x, y; + } offset; Evas_Object *object; + Evas_List *extra_objects; unsigned char calculated : 1; unsigned char dirty : 1; unsigned char still_in : 1; @@ -377,6 +394,13 @@ struct _Edje_Real_Part char *text; char *font; int size; + struct { + double in_w, in_h; + int in_size; + char *in_str; + char *out_str; + int out_size; + } cache; } text; double description_pos; struct { @@ -437,6 +461,22 @@ struct _Edje_Pending_Program Ecore_Timer *timer; }; +struct _Ejde_Text_Style +{ + struct { + unsigned char x, y; + } offset; + struct { + unsigned char l, r, t, b; + } pad; + int num; + struct { + unsigned char color; /* 0 = color, 1, 2 = color2, color3 */ + char x, y; /* offset */ + unsigned char alpha; + } members[32]; +}; + void _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, double pos); void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char *d1, double v1, char *d2, double v2); void _edje_recalc(Edje *ed); @@ -469,6 +509,12 @@ void _edje_program_end(Edje *ed, Edje_Running_Program *runp); void _edje_program_run(Edje *ed, Edje_Program *pr, int force); void _edje_emit(Edje *ed, char *sig, char *src); +void _edje_text_init(void); +void _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep); +void _edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep); +void _edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep); +void _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *params, Edje_Part_Description *chosen_desc); + Edje *_edje_fetch(Evas_Object *obj); int _edje_glob_match(char *str, char *glob); int _edje_freeze(Edje *ed); @@ -487,8 +533,9 @@ extern Eet_Data_Descriptor *_edje_edd_edje_part; extern Eet_Data_Descriptor *_edje_edd_edje_part_description; extern Eet_Data_Descriptor *_edje_edd_edje_part_image_id; -extern int _edje_anim_count; -extern Ecore_Timer *_edje_timer; -extern Evas_List *_edje_animators; +extern int _edje_anim_count; +extern Ecore_Timer *_edje_timer; +extern Evas_List *_edje_animators; +extern Ejde_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST]; #endif diff --git a/legacy/edje/src/lib/edje_program.c b/legacy/edje/src/lib/edje_program.c index 96d2c32071..153da6d031 100644 --- a/legacy/edje/src/lib/edje_program.c +++ b/legacy/edje/src/lib/edje_program.c @@ -98,6 +98,95 @@ edje_signal_emit(Evas_Object *obj, const char *emission, const char *source) _edje_emit(ed, (char *)emission, (char *)source); } +void +edje_play_set(Evas_Object *obj, int play) +{ + Edje *ed; + double t; + Evas_List *l; + + ed = _edje_fetch(obj); + if (!ed) return; + if (play) + { + if (!ed->paused) return; + ed->paused = 0; + t = ecore_time_get() - ed->paused_at; + for (l = ed->actions; l; l = l->next) + { + Edje_Running_Program *runp; + + runp = l->data; + runp->start_time += t; + } + } + else + { + if (ed->paused) return; + ed->paused = 1; + ed->paused_at = ecore_time_get(); + } +} + +int +edje_play_get(Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return 0; + if (ed->paused) return 0; + return 1; +} + +void +edje_animation_set(Evas_Object *obj, int on) +{ + Edje *ed; + Evas_List *l; + + ed = _edje_fetch(obj); + if (!ed) return; + ed->no_anim = !on; + _edje_freeze(ed); + if (!on) + { + Evas_List *newl = NULL; + + for (l = ed->actions; l; l = l->next) + newl = evas_list_append(newl, l->data); + while (newl) + { + Edje_Running_Program *runp; + + runp = newl->data; + newl = evas_list_remove(newl, newl->data); + _edje_program_run_iterate(runp, runp->start_time + runp->program->tween.time); + } + } + else + { + _edje_emit(ed, "load", ""); + if (evas_object_visible_get(obj)) + { + evas_object_hide(obj); + evas_object_show(obj); + } + } + _edje_thaw(ed); +} + +int +edje_animation_get(Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return 0; + if (ed->no_anim) return 0; + return 1; +} + /* Private Routines */ int @@ -244,7 +333,7 @@ _edje_program_run(Edje *ed, Edje_Program *pr, int force) _edje_emit(ed, "program,start", pr->name); if (pr->action == EDJE_ACTION_TYPE_STATE_SET) { - if (pr->tween.time > 0.0) + if ((pr->tween.time > 0.0) && (!ed->no_anim)) { Edje_Running_Program *runp; diff --git a/legacy/edje/src/lib/edje_smart.c b/legacy/edje/src/lib/edje_smart.c index e6675b7d0a..29e73945ff 100644 --- a/legacy/edje/src/lib/edje_smart.c +++ b/legacy/edje/src/lib/edje_smart.c @@ -85,6 +85,18 @@ _edje_smart_layer_set(Evas_Object * obj, int layer) Edje_Real_Part *ep; ep = l->data; + if (ep->extra_objects) + { + Evas_List *el; + + for (el = ep->extra_objects; el; el = el->next) + { + Evas_Object *o; + + o = el->data; + evas_object_layer_set(o, ed->layer); + } + } evas_object_layer_set(ep->object, ed->layer); } snprintf(buf, sizeof(buf), "layer,set,%i", layer); @@ -104,6 +116,18 @@ _edje_smart_raise(Evas_Object * obj) Edje_Real_Part *ep; ep = l->data; + if (ep->extra_objects) + { + Evas_List *el; + + for (el = ep->extra_objects; el; el = el->next) + { + Evas_Object *o; + + o = el->data; + evas_object_raise(o); + } + } evas_object_raise(ep->object); } _edje_emit(ed, "raise", ""); @@ -123,6 +147,18 @@ _edje_smart_lower(Evas_Object * obj) ep = l->data; evas_object_lower(ep->object); + if (ep->extra_objects) + { + Evas_List *el; + + for (el = ep->extra_objects; el; el = el->next) + { + Evas_Object *o; + + o = el->data; + evas_object_lower(o); + } + } } _edje_emit(ed, "lower", ""); } @@ -141,6 +177,18 @@ _edje_smart_stack_above(Evas_Object * obj, Evas_Object * above) ep = l->data; evas_object_stack_above(ep->object, above); + if (ep->extra_objects) + { + Evas_List *el; + + for (el = evas_list_last(ep->extra_objects); el; el = el->prev) + { + Evas_Object *o; + + o = el->data; + evas_object_stack_above(o, above); + } + } } _edje_emit(ed, "stack_above", ""); } @@ -158,6 +206,18 @@ _edje_smart_stack_below(Evas_Object * obj, Evas_Object * below) Edje_Real_Part *ep; ep = l->data; + if (ep->extra_objects) + { + Evas_List *el; + + for (el = ep->extra_objects; el; el = el->next) + { + Evas_Object *o; + + o = el->data; + evas_object_stack_below(o, below); + } + } evas_object_stack_below(ep->object, below); } _edje_emit(ed, "stack_below", ""); @@ -180,9 +240,25 @@ _edje_smart_move(Evas_Object * obj, double x, double y) for (l = ed->parts; l; l = l->next) { Edje_Real_Part *ep; + double ox, oy; ep = l->data; - evas_object_move(ep->object, ed->x + ep->x, ed->y + ep->y); + evas_object_geometry_get(ep->object, &ox, &oy, NULL, NULL); + evas_object_move(ep->object, ed->x + ep->x + ep->offset.x, ed->y + ep->y +ep->offset.y); + if (ep->extra_objects) + { + Evas_List *el; + + for (el = ep->extra_objects; el; el = el->next) + { + Evas_Object *o; + double oox, ooy; + + o = el->data; + evas_object_geometry_get(o, &oox, &ooy, NULL, NULL); + evas_object_move(o, ed->x + ep->x + ep->offset.x + (oox - ox), ed->y + ep->y + ep->offset.y + (ooy - oy)); + } + } } _edje_emit(ed, "move", ""); } diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c new file mode 100644 index 0000000000..1ac3b18057 --- /dev/null +++ b/legacy/edje/src/lib/edje_text.c @@ -0,0 +1,519 @@ +#include "Edje.h" +#include "edje_private.h" + +Ejde_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST]; + +void +_edje_text_init(void) +{ + int i, j, n; + const vals[5][5] = + { + {0, 1, 2, 1, 0}, + {1, 3, 4, 3, 1}, + {2, 4, 5, 4, 2}, + {1, 3, 4, 3, 1}, + {0, 1, 2, 1, 0} + }; + + memset(_edje_text_styles, 0, sizeof(_edje_text_styles)); + + _edje_text_styles[EDJE_TEXT_EFFECT_NONE].num = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_NONE].members[0].alpha = 255; + + _edje_text_styles[EDJE_TEXT_EFFECT_PLAIN].num = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_PLAIN].members[0].alpha = 255; + + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].offset.x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].offset.y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.l = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.r = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.t = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.b = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].num = 5; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[0].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].x = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].y = -1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].x = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].x = -1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].y = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].y = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].alpha = 255; + + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].offset.x = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].offset.y = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.l = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.r = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.t = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.b = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].num = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[0].alpha = 255; + for (j = 0; j < 5; j++) + { + for (i = 0; i < 5; i++) + { + if (((i == 2) && (j == 2)) || (vals[i][j] == 0)) continue; + n = _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].num; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].x = i - 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].y = j - 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].alpha = vals[i][j] * 50; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].num = n + 1; + } + } + + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].pad.r = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].pad.b = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].num = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[0].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].color = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].alpha = 255; + + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].offset.x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].offset.y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.l = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.r = 3; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.t = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.b = 3; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].num = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[0].alpha = 255; + for (j = 0; j < 5; j++) + { + for (i = 0; i < 5; i++) + { + if (vals[i][j] == 0) continue; + n = _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].num; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].color = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].x = i - 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].y = j - 1; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].alpha = vals[i][j] * 50; + _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].num = n + 1; + } + } + + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].offset.x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].offset.y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.l = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.r = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.t = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.b = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].num = 6; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[0].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].color = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].x = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].y = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].x = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].y = -1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].x = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].x = -1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].y = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].y = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].alpha = 255; + + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].offset.x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].offset.y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.l = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.r = 3; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.t = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.b = 3; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[0].alpha = 255; + for (j = 0; j < 5; j++) + { + for (i = 0; i < 5; i++) + { + if (vals[i][j] == 0) continue; + n = _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].color = 2; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].x = i - 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].y = j - 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].alpha = vals[i][j] * 50; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num = n + 1; + } + } + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].x = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].y = -1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].x = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].y = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].x = -1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].y = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].color = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].x = 1; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].y = 0; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].alpha = 255; + _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num += 4; +} + +void +_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep) +{ + int i; + + if (ep->part->type != EDJE_PART_TYPE_TEXT) return; + if (ep->part->effect >= EDJE_TEXT_EFFECT_LAST) return; + for (i = 1; i < _edje_text_styles[ep->part->effect].num; i++) + { + Evas_Object *o; + + o = evas_object_text_add(ed->evas); + evas_object_smart_member_add(o, ed->obj); + evas_object_pass_events_set(o, 1); + evas_object_clip_set(o, ed->clipper); + evas_object_show(o); + ep->extra_objects = evas_list_append(ep->extra_objects, o); + } +} + +void +_edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep) +{ + Evas_List *l; + + for (l = ep->extra_objects; l; l = l->next) + { + Evas_Object *o; + + o = l->data; + if (ep->part->clip_to_id >= 0) + { + ep->clip_to = evas_list_nth(ed->parts, ep->part->clip_to_id); + if (ep->clip_to) + { + evas_object_pass_events_set(ep->clip_to->object, 1); + evas_object_clip_set(o, ep->clip_to->object); + } + } + + } +} + +void +_edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep) +{ + while (ep->extra_objects) + { + Evas_Object *o; + + o = ep->extra_objects->data; + ep->extra_objects = evas_list_remove(ep->extra_objects, o); + evas_object_del(o); + } +} + +void +_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, + Edje_Calc_Params *params, + Edje_Part_Description *chosen_desc) +{ + char *text; + char *font; + int size; + double tw, th; + double ox, oy, sw, sh; + char *buf = NULL; + + text = chosen_desc->text.text; + font = chosen_desc->text.font; + size = chosen_desc->text.size; + if (ep->text.text) text = ep->text.text; + if (ep->text.font) font = ep->text.font; + if (ep->text.size > 0) size = ep->text.size; + ox = _edje_text_styles[ep->part->effect].offset.x; + oy = _edje_text_styles[ep->part->effect].offset.y; + sw = params->w - (_edje_text_styles[ep->part->effect].pad.l + _edje_text_styles[ep->part->effect].pad.r); + sh = params->h - (_edje_text_styles[ep->part->effect].pad.t + _edje_text_styles[ep->part->effect].pad.b); + if ((ep->text.cache.in_size == size) && + (ep->text.cache.in_w == sw) && + (ep->text.cache.in_h == sh) && + (ep->text.cache.in_str) && + (text) && + (!strcmp(ep->text.cache.in_str, text))) + { + text = ep->text.cache.out_str; + size = ep->text.cache.out_size; + goto arrange_text; + } + if (ep->text.cache.in_str) free(ep->text.cache.in_str); + ep->text.cache.in_str = strdup(text); + ep->text.cache.in_size = size; + if (chosen_desc->text.fit_x) + { + 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); + if (tw > sw) + { + int psize; + + psize = size; + while ((tw > sw) && (size > 0)) + { + psize = size; + size = (size * sw) / tw; + if ((psize - size) <= 0) size = psize - 1; + evas_object_text_font_set(ep->object, font, size); + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + } + } + else if (tw < sw) + { + int psize; + + psize = size; + while ((tw < sw) && (size > 0)) + { + psize = size; + size = (size * sw) / tw; + if ((psize - size) >= 0) size = psize + 1; + evas_object_text_font_set(ep->object, font, size); + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + } + size = psize; + } + } + if (chosen_desc->text.fit_y) + { + size = sh; + 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); + if (th < sh) + { + int dif; + + dif = (th - sh) / 4; + if (dif < 1) dif = 1; + while ((th < sh) && (sw > 0.0)) + { + size += dif; + evas_object_text_font_set(ep->object, font, size); + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + } + size -= dif; + } + else if (th > sh) + { + int dif; + + dif = (th - sh) / 4; + if (dif < 1) dif = 1; + while ((th < sh) && (sw >= 0.0)) + { + size -= dif; + evas_object_text_font_set(ep->object, font, size); + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + } + } + } + if (size < 1) size = 1; + if (!chosen_desc->text.fit_x) + { + double p; + int c1, c2; + int loop; + int orig_len; + + 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); + c1 = -1; + c2 = -1; + /* chop chop */ + if (tw > sw) + { + if (chosen_desc->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) + c2 = evas_object_text_char_coords_get(ep->object, + -p + sw, th / 2, + NULL, NULL, NULL, NULL); + if ((c1 < 0) && (c2 < 0)) + { + c1 = 0; + c2 = 0; + } + } + loop = 0; + buf = malloc(strlen(text) + 1 + 3 + 3); + orig_len = strlen(text); + while (((c1 >= 0) || (c2 >= 0)) && (tw > sw)) + { + loop++; + if (sw <= 0.0) + { + buf[0] = 0; + break; + } + if ((c1 >= 0) && (c2 >= 0)) + { + if ((loop & 0x1)) + { + if (c1 >= 0) + c1 = evas_string_char_next_get(text, c1, NULL); + } + else + { + if (c2 >= 0) + { + c2 = evas_string_char_prev_get(text, c2, NULL); + if (c2 < 0) + { + buf[0] = 0; + break; + } + } + } + } + else + { + if (c1 >= 0) + c1 = evas_string_char_next_get(text, c1, NULL); + else if (c2 >= 0) + { + c2 = evas_string_char_prev_get(text, c2, NULL); + if (c2 < 0) + { + buf[0] = 0; + break; + } + } + } + if ((c1 >= 0) && (c2 >= 0)) + { + if (c1 >= c2) + { + buf[0] = 0; + break; + } + } + else + { + if (c1 >= orig_len) + { + buf[0] = 0; + break; + } + else if (c2 == 0) + { + buf[0] = 0; + break; + } + } + buf[0] = 0; + if (c1 >= 0) + { + strcpy(buf, "..."); + if (c2 >= 0) + { + strncat(buf, text + c1, c2 - c1); + strcat(buf, "..."); + } + else + strcat(buf, text + c1); + } + else + { + if (c2 >= 0) + { + strncpy(buf, text, c2); + buf[c2] = 0; + strcat(buf, "..."); + } + else strcpy(buf, text); + } + evas_object_text_text_set(ep->object, buf); + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + } + if (loop > 0) text = buf; + } + if (ep->text.cache.out_str) free(ep->text.cache.out_str); + ep->text.cache.out_str = strdup(text); + ep->text.cache.in_w = sw; + ep->text.cache.in_h = sh; + ep->text.cache.out_size = size; + + arrange_text: + + 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); + evas_object_move(ep->object, + ed->x + params->x + ep->offset.x, + ed->y + params->y + ep->offset.y); + evas_object_color_set(ep->object, + params->color.r, + params->color.g, + params->color.b, + (params->color.a * (_edje_text_styles[ep->part->effect].members[0].alpha + 1)) / 256); + if (params->visible) evas_object_show(ep->object); + else evas_object_hide(ep->object); + { + Evas_List *l; + int i; + + for (i = 1, l = ep->extra_objects; l; l = l->next, i++) + { + Evas_Object *o; + + o = l->data; + evas_object_text_font_set(o, font, size); + evas_object_text_text_set(o, text); + evas_object_move(o, + ed->x + params->x + ep->offset.x + _edje_text_styles[ep->part->effect].members[i].x, + ed->y + params->y + ep->offset.y + _edje_text_styles[ep->part->effect].members[i].y); + if (_edje_text_styles[ep->part->effect].members[i].color == 0) + evas_object_color_set(o, + params->color.r, + params->color.g, + params->color.b, + (params->color.a * (_edje_text_styles[ep->part->effect].members[i].alpha + 1)) / 256); + else if (_edje_text_styles[ep->part->effect].members[i].color == 1) + evas_object_color_set(o, + params->color2.r, + params->color2.g, + params->color2.b, + (params->color2.a * (_edje_text_styles[ep->part->effect].members[i].alpha + 1)) / 256); + else if (_edje_text_styles[ep->part->effect].members[i].color == 2) + evas_object_color_set(o, + params->color3.r, + params->color3.g, + params->color3.b, + (params->color3.a * (_edje_text_styles[ep->part->effect].members[i].alpha + 1)) / 256); + if (params->visible) evas_object_show(o); + else evas_object_hide(o); + } + } + if (buf) free(buf); +} diff --git a/legacy/edje/src/lib/edje_util.c b/legacy/edje/src/lib/edje_util.c index 59741e7c39..2c747f7e3c 100644 --- a/legacy/edje/src/lib/edje_util.c +++ b/legacy/edje/src/lib/edje_util.c @@ -1,13 +1,31 @@ #include "Edje.h" #include "edje_private.h" -void -edje_part_geometry_get(Evas_Object *o, char *part, double *x, double *y, double *w, double *h ) +int +edje_part_exists(Evas_Object *obj, const char *part) { Evas_List *l; Edje *ed; - ed = _edje_fetch(o); + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return 0; + for (l = ed->parts; l; l = l->next) + { + Edje_Real_Part *rp; + + rp = l->data; + if (!strcmp(rp->part->name, part)) return 1; + } + return 0; +} + +void +edje_part_geometry_get(Evas_Object *obj, const char *part, double *x, double *y, double *w, double *h ) +{ + Evas_List *l; + Edje *ed; + + ed = _edje_fetch(obj); if ((!ed) || (!part)) { if (x) *x = 0; @@ -36,6 +54,64 @@ edje_part_geometry_get(Evas_Object *o, char *part, double *x, double *y, double if (h) *h = 0; } +void +edje_part_text_set(Evas_Object *obj, const char *part, const char *text) +{ + Evas_List *l; + Edje *ed; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + for (l = ed->parts; l; l = l->next) + { + Edje_Real_Part *rp; + + rp = l->data; + if (!strcmp(rp->part->name, part)) + { + if (rp->part->type == EDJE_PART_TYPE_TEXT) + { + if (((rp->text.text) && (text)) || + ((!rp->text.text) && (!text))) + return; + if ((rp->text.text) && (text) && + (!strcmp(rp->text.text, text))) + return; + if (rp->text.text) free(rp->text.text); + rp->text.text = strdup(text); + ed->dirty = 1; + rp->dirty = 1; + _edje_recalc(ed); + } + return; + } + } +} + +const char * +edje_part_text_get(Evas_Object *obj, const char *part) +{ + Evas_List *l; + Edje *ed; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + for (l = ed->parts; l; l = l->next) + { + Edje_Real_Part *rp; + + rp = l->data; + if (!strcmp(rp->part->name, part)) + { + if (rp->part->type == EDJE_PART_TYPE_TEXT) + return evas_object_text_text_get(rp->object); + else + return NULL; + } + } + return NULL; +} + Edje * _edje_fetch(Evas_Object *obj) {