summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-05 19:40:24 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-07 17:33:18 +0900
commita25b212baca1afc0e2a5e0e85061493967bba4ff (patch)
tree03caa156a08b0d33aeac68ec3049462a73fb437a
parent08f2624e6a0421962fbd2e05cb37beb7b23befd7 (diff)
Evas filters: Add support for proxies in Edje
They will be defined with the following syntax: buffer:buf(src=part);
-rw-r--r--src/bin/edje/edje_cc_handlers.c61
-rw-r--r--src/lib/edje/edje_data.c1
-rw-r--r--src/lib/edje/edje_private.h4
-rw-r--r--src/lib/edje/edje_text.c21
4 files changed, 84 insertions, 3 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index cf82202614..f3b706b343 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -7314,6 +7314,13 @@ static void
7314st_collections_group_parts_part_description_text_filter(void) 7314st_collections_group_parts_part_description_text_filter(void)
7315{ 7315{
7316 Edje_Part_Description_Text *ed; 7316 Edje_Part_Description_Text *ed;
7317 Eina_List *sources = NULL;
7318 Eina_Stringshare *name;
7319 char *token, *code;
7320 Eina_Bool valid = EINA_TRUE;
7321
7322 static const char *allowed_name_chars =
7323 "abcdefghijklmnopqrstuvwxyzABCDEFGHJIKLMNOPQRSTUVWXYZ0123456789_";
7317 7324
7318 check_arg_count(1); 7325 check_arg_count(1);
7319 7326
@@ -7325,8 +7332,62 @@ st_collections_group_parts_part_description_text_filter(void)
7325 } 7332 }
7326 7333
7327 ed = (Edje_Part_Description_Text*) current_desc; 7334 ed = (Edje_Part_Description_Text*) current_desc;
7335 ed->text.filter_sources = NULL;
7328 7336
7329 ed->text.filter.str = parse_str(0); 7337 ed->text.filter.str = parse_str(0);
7338 if (!ed->text.filter.str) return;
7339
7340 // Parse list of buffers that have a source
7341 // note: does not support comments
7342 code = strdup(ed->text.filter.str);
7343 for (token = strtok(code, ";"); token; token = strtok(NULL, ";"))
7344 {
7345 size_t len;
7346
7347 len = strspn(token, " \n\t");
7348 token += len;
7349
7350 if (!strncasecmp("buffer", token, 6))
7351 {
7352 // note: a valid string won't necessary compile at runtime
7353
7354 token = strchr(token, ':');
7355 if (!token)
7356 {
7357 valid = EINA_FALSE;
7358 break;
7359 }
7360 token = strchr(token, '(');
7361 if (!token)
7362 {
7363 valid = EINA_FALSE;
7364 break;
7365 }
7366 token = strcasestr(token, "src");
7367 if (!token) continue;
7368 token += 3;
7369 len = strspn(token, " =\n\t");
7370 if (!len || !token[len])
7371 {
7372 valid = EINA_FALSE;
7373 break;
7374 }
7375 token += len;
7376 len = strspn(token, allowed_name_chars);
7377 if (!len || !token[len])
7378 {
7379 valid = EINA_FALSE;
7380 break;
7381 }
7382 token[len] = '\0';
7383 name = eina_stringshare_add(token);
7384
7385 sources = eina_list_append(sources, name);
7386 }
7387 }
7388 free(code);
7389
7390 if (valid) ed->text.filter_sources = sources;
7330} 7391}
7331 7392
7332 7393
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index d48f8070dc..3a11cff0ae 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -806,6 +806,7 @@ _edje_edd_init(void)
806 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.id_text_source", text.id_text_source, EET_T_INT); 806 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.id_text_source", text.id_text_source, EET_T_INT);
807 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.elipsis", text.elipsis, EET_T_DOUBLE); 807 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.elipsis", text.elipsis, EET_T_DOUBLE);
808 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.filter", text.filter, EET_T_STRING); 808 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.filter", text.filter, EET_T_STRING);
809 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.filter_sources", text.filter_sources);
809 810
810 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text); 811 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text);
811 eddc.func.mem_free = mem_free_textblock; 812 eddc.func.mem_free = mem_free_textblock;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index c4b9df11b0..a057d8e659 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1176,6 +1176,7 @@ struct _Edje_Part_Description_Spec_Text
1176 Edje_String font; /* if a specific font is asked for */ 1176 Edje_String font; /* if a specific font is asked for */
1177 Edje_String repch; /* replacement char for password mode entry */ 1177 Edje_String repch; /* replacement char for password mode entry */
1178 Edje_String filter; /* special effects */ 1178 Edje_String filter; /* special effects */
1179 Eina_List *filter_sources; /* proxy sources for special effects */
1179 1180
1180 Edje_Alignment align; /* text alignment within bounds */ 1181 Edje_Alignment align; /* text alignment within bounds */
1181 Edje_Color color3; 1182 Edje_Color color3;
@@ -1532,6 +1533,7 @@ struct _Edje_Real_Part_Text
1532 const char *font; // 4 1533 const char *font; // 4
1533 const char *style; // 4 1534 const char *style; // 4
1534 const char *filter; // 4 1535 const char *filter; // 4
1536 Eina_List *filter_sources; // 4
1535 Edje_Position offset; // 8 1537 Edje_Position offset; // 8
1536 short size; // 2 1538 short size; // 2
1537 struct { 1539 struct {
@@ -1544,7 +1546,7 @@ struct _Edje_Real_Part_Text
1544 const char *out_str; // 4 1546 const char *out_str; // 4
1545 FLOAT_T align_x, align_y; // 16 1547 FLOAT_T align_x, align_y; // 16
1546 } cache; 1548 } cache;
1547}; // 76 1549}; // 84
1548// FIXME make text a potiner to struct and alloc at end 1550// FIXME make text a potiner to struct and alloc at end
1549// if part type is TEXT move common members textblock + 1551// if part type is TEXT move common members textblock +
1550// text to front and have smaller struct for textblock 1552// text to front and have smaller struct for textblock
diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c
index dd9f80b55f..2d3a38d463 100644
--- a/src/lib/edje/edje_text.c
+++ b/src/lib/edje/edje_text.c
@@ -169,7 +169,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
169 char *font2 = NULL; 169 char *font2 = NULL;
170 char *sfont = NULL; 170 char *sfont = NULL;
171 int size; 171 int size;
172 const char *filter; 172 const char *filter, *source_name;
173 Eina_List *filter_sources = NULL, *prev_sources = NULL, *li;
173 Evas_Coord tw, th; 174 Evas_Coord tw, th;
174 Evas_Coord sw, sh; 175 Evas_Coord sw, sh;
175 int inlined_font = 0, free_text = 0; 176 int inlined_font = 0, free_text = 0;
@@ -188,6 +189,12 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
188 if (ep->typedata.text->font) font = ep->typedata.text->font; 189 if (ep->typedata.text->font) font = ep->typedata.text->font;
189 if (ep->typedata.text->size > 0) size = ep->typedata.text->size; 190 if (ep->typedata.text->size > 0) size = ep->typedata.text->size;
190 if (ep->typedata.text->filter) filter = ep->typedata.text->filter; 191 if (ep->typedata.text->filter) filter = ep->typedata.text->filter;
192 if (ep->typedata.text->filter_sources != chosen_desc->text.filter_sources)
193 {
194 prev_sources = ep->typedata.text->filter_sources;
195 filter_sources = chosen_desc->text.filter_sources;
196 ep->typedata.text->filter_sources = chosen_desc->text.filter_sources;
197 }
191 198
192 if (ep->typedata.text->text_source) 199 if (ep->typedata.text->text_source)
193 { 200 {
@@ -421,9 +428,19 @@ arrange_text:
421 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); 428 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
422 eo_do(ep->object, 429 eo_do(ep->object,
423 evas_obj_text_font_set(font, size), 430 evas_obj_text_font_set(font, size),
424 evas_obj_text_filter_program_set(filter),
425 evas_obj_text_text_set(text)); 431 evas_obj_text_text_set(text));
426 part_get_geometry(ep, &tw, &th); 432 part_get_geometry(ep, &tw, &th);
433
434 /* filters */
435 EINA_LIST_FOREACH(prev_sources, li, source_name)
436 eo_do(ep->object, evas_obj_text_filter_source_set(source_name, NULL));
437 EINA_LIST_FOREACH(filter_sources, li, source_name)
438 {
439 Edje_Real_Part *rp = _edje_real_part_get(ed, source_name);
440 eo_do(ep->object, evas_obj_text_filter_source_set(source_name, rp ? rp->object : NULL));
441 }
442 eo_do(ep->object, evas_obj_text_filter_program_set(filter));
443
427 /* Handle alignment */ 444 /* Handle alignment */
428 { 445 {
429 FLOAT_T align_x; 446 FLOAT_T align_x;