summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKateryna Fesyna <k.fesyna@samsung.com>2014-11-14 07:01:52 +0100
committerCedric BAIL <cedric@osg.samsung.com>2014-11-14 07:03:25 +0100
commitcccd1b25d42c47d6adc36dcde542908b4460a5b6 (patch)
tree8dc2587a43a7bbce2c05557a1431f7fa8e426650
parent35ac38e880f2bdb180d260c9e35037883b97ec1c (diff)
edje: add formating for floating point numbers in EDC.
Summary: this commit contains calculation of format string for floating point numbers in order to print them with at least one symbol after point. (For example: 'relateve: 1.0 0.45;') @fix Reviewers: cedric, Hermet, raster, reutskiy.v.v Reviewed By: reutskiy.v.v Subscribers: cedric, reutskiy.v.v Differential Revision: https://phab.enlightenment.org/D1653 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/edje/edje_edit.c103
1 files changed, 87 insertions, 16 deletions
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 987266393f..0ba19055dc 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -10046,6 +10046,35 @@ _edje_generate_source_of_program(Evas_Object *obj, const char *program, Eina_Str
10046 return ret; 10046 return ret;
10047} 10047}
10048 10048
10049static void
10050_edje_source_with_double_values_append(const char *param_name, char val_num, double val1, double val2, Eina_Strbuf *buf, Eina_Bool *ret_value)
10051{
10052 Eina_Strbuf *string;
10053 Eina_Bool ret = EINA_TRUE;
10054
10055 if ((val_num != 1) && (val_num != 2))
10056 {
10057 *ret_value = EINA_FALSE;
10058 return;
10059 }
10060
10061 string = eina_strbuf_new();
10062 if (param_name)
10063 eina_strbuf_append_printf(string, "%s:", param_name);
10064 eina_strbuf_append_printf(string,
10065 (val1 == (int)val1) ? " %.1f" : " %g",
10066 val1);
10067 if (val_num == 2)
10068 eina_strbuf_append_printf(string,
10069 (val2 == (int)val2) ? " %.1f" : " %g",
10070 val2);
10071 eina_strbuf_append(string, ";\n");
10072 BUF_APPEND(eina_strbuf_string_get(string));
10073
10074 *ret_value = ret;
10075 eina_strbuf_free(string);
10076}
10077
10049static Eina_Bool 10078static Eina_Bool
10050_edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *state, double value, Eina_Strbuf *buf) 10079_edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *state, double value, Eina_Strbuf *buf)
10051{ 10080{
@@ -10055,7 +10084,8 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10055 10084
10056 GET_PD_OR_RETURN(EINA_FALSE); 10085 GET_PD_OR_RETURN(EINA_FALSE);
10057 10086
10058 BUF_APPENDF(I4"description { state: \"%s\" %g;\n", pd->state.name, pd->state.value); 10087 BUF_APPENDF(I4"description { state: \"%s\"", pd->state.name);
10088 _edje_source_with_double_values_append(NULL, 1, pd->state.value, 0, buf, &ret);
10059 //TODO Support inherit 10089 //TODO Support inherit
10060 10090
10061 if (!pd->visible) 10091 if (!pd->visible)
@@ -10084,7 +10114,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10084 } 10114 }
10085 10115
10086 if (pd->align.x != 0.5 || pd->align.y != 0.5) 10116 if (pd->align.x != 0.5 || pd->align.y != 0.5)
10087 BUF_APPENDF(I5"align: %g %g;\n", TO_DOUBLE(pd->align.x), TO_DOUBLE(pd->align.y)); 10117 _edje_source_with_double_values_append(I5"align", 2,
10118 TO_DOUBLE(pd->align.x),
10119 TO_DOUBLE(pd->align.y),
10120 buf, &ret);
10088 10121
10089 //TODO Support fixed 10122 //TODO Support fixed
10090 10123
@@ -10093,13 +10126,19 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10093 if (pd->max.w != -1 || pd->max.h != -1) 10126 if (pd->max.w != -1 || pd->max.h != -1)
10094 BUF_APPENDF(I5"max: %d %d;\n", pd->max.w, pd->max.h); 10127 BUF_APPENDF(I5"max: %d %d;\n", pd->max.w, pd->max.h);
10095 if ((pd->minmul.have) && (pd->minmul.w != 1 || pd->minmul.h != 1)) 10128 if ((pd->minmul.have) && (pd->minmul.w != 1 || pd->minmul.h != 1))
10096 BUF_APPENDF(I5"minmul: %g %g;\n", TO_DOUBLE(pd->minmul.w), TO_DOUBLE(pd->minmul.h)); 10129 _edje_source_with_double_values_append(I5"minmul", 2,
10130 TO_DOUBLE(pd->minmul.w),
10131 TO_DOUBLE(pd->minmul.h),
10132 buf, &ret);
10097 10133
10098 if (pd->step.x && pd->step.y) 10134 if (pd->step.x && pd->step.y)
10099 BUF_APPENDF(I5"step: %d %d;\n", TO_INT(pd->step.x), TO_INT(pd->step.y)); 10135 BUF_APPENDF(I5"step: %d %d;\n", TO_INT(pd->step.x), TO_INT(pd->step.y));
10100 10136
10101 if (pd->aspect.min || pd->aspect.max) 10137 if (pd->aspect.min || pd->aspect.max)
10102 BUF_APPENDF(I5"aspect: %g %g;\n", TO_DOUBLE(pd->aspect.min), TO_DOUBLE(pd->aspect.max)); 10138 _edje_source_with_double_values_append(I5"aspect", 2,
10139 TO_DOUBLE(pd->aspect.min),
10140 TO_DOUBLE(pd->aspect.max),
10141 buf, &ret);
10103 if (pd->aspect.prefer) 10142 if (pd->aspect.prefer)
10104 BUF_APPENDF(I5"aspect_preference: %s;\n", prefers[(int) pd->aspect.prefer]); 10143 BUF_APPENDF(I5"aspect_preference: %s;\n", prefers[(int) pd->aspect.prefer]);
10105 10144
@@ -10134,7 +10173,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10134 { 10173 {
10135 BUF_APPEND(I5"rel1 {\n"); 10174 BUF_APPEND(I5"rel1 {\n");
10136 if (pd->rel1.relative_x || pd->rel1.relative_y) 10175 if (pd->rel1.relative_x || pd->rel1.relative_y)
10137 BUF_APPENDF(I6"relative: %g %g;\n", TO_DOUBLE(pd->rel1.relative_x), TO_DOUBLE(pd->rel1.relative_y)); 10176 _edje_source_with_double_values_append(I6"relative", 2,
10177 TO_DOUBLE(pd->rel1.relative_x),
10178 TO_DOUBLE(pd->rel1.relative_y),
10179 buf, &ret);
10138 if (pd->rel1.offset_x || pd->rel1.offset_y) 10180 if (pd->rel1.offset_x || pd->rel1.offset_y)
10139 BUF_APPENDF(I6"offset: %d %d;\n", pd->rel1.offset_x, pd->rel1.offset_y); 10181 BUF_APPENDF(I6"offset: %d %d;\n", pd->rel1.offset_x, pd->rel1.offset_y);
10140 if (pd->rel1.id_x != -1 && pd->rel1.id_x == pd->rel1.id_y) 10182 if (pd->rel1.id_x != -1 && pd->rel1.id_x == pd->rel1.id_y)
@@ -10156,7 +10198,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10156 { 10198 {
10157 BUF_APPEND(I5"rel2 {\n"); 10199 BUF_APPEND(I5"rel2 {\n");
10158 if (TO_DOUBLE(pd->rel2.relative_x) != 1.0 || TO_DOUBLE(pd->rel2.relative_y) != 1.0) 10200 if (TO_DOUBLE(pd->rel2.relative_x) != 1.0 || TO_DOUBLE(pd->rel2.relative_y) != 1.0)
10159 BUF_APPENDF(I6"relative: %g %g;\n", TO_DOUBLE(pd->rel2.relative_x), TO_DOUBLE(pd->rel2.relative_y)); 10201 _edje_source_with_double_values_append(I6"relative", 2,
10202 TO_DOUBLE(pd->rel2.relative_x),
10203 TO_DOUBLE(pd->rel2.relative_y),
10204 buf, &ret);
10160 if (pd->rel2.offset_x != -1 || pd->rel2.offset_y != -1) 10205 if (pd->rel2.offset_x != -1 || pd->rel2.offset_y != -1)
10161 BUF_APPENDF(I6"offset: %d %d;\n", pd->rel2.offset_x, pd->rel2.offset_y); 10206 BUF_APPENDF(I6"offset: %d %d;\n", pd->rel2.offset_x, pd->rel2.offset_y);
10162 if (pd->rel2.id_x != -1 && pd->rel2.id_x == pd->rel2.id_y) 10207 if (pd->rel2.id_x != -1 && pd->rel2.id_x == pd->rel2.id_y)
@@ -10216,11 +10261,17 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10216 if (pd->map.rot.id_center != -1) 10261 if (pd->map.rot.id_center != -1)
10217 BUF_APPENDF(I7"center: \"%s\";\n", _edje_part_name_find(ed, pd->map.rot.id_center)); 10262 BUF_APPENDF(I7"center: \"%s\";\n", _edje_part_name_find(ed, pd->map.rot.id_center));
10218 if (TO_DOUBLE(pd->map.rot.x) != 0.0) 10263 if (TO_DOUBLE(pd->map.rot.x) != 0.0)
10219 BUF_APPENDF(I7"x: %g;\n", TO_DOUBLE(pd->map.rot.x)); 10264 _edje_source_with_double_values_append(I7"x", 1,
10265 TO_DOUBLE(pd->map.rot.x),
10266 0.0, buf, &ret);
10220 if (TO_DOUBLE(pd->map.rot.y) != 0.0) 10267 if (TO_DOUBLE(pd->map.rot.y) != 0.0)
10221 BUF_APPENDF(I7"y: %g;\n", TO_DOUBLE(pd->map.rot.y)); 10268 _edje_source_with_double_values_append(I7"y", 1,
10269 TO_DOUBLE(pd->map.rot.y),
10270 0.0, buf, &ret);
10222 if (TO_DOUBLE(pd->map.rot.z) != 0.0) 10271 if (TO_DOUBLE(pd->map.rot.z) != 0.0)
10223 BUF_APPENDF(I7"z: %g;\n", TO_DOUBLE(pd->map.rot.z)); 10272 _edje_source_with_double_values_append(I7"z", 1,
10273 TO_DOUBLE(pd->map.rot.z),
10274 0.0, buf, &ret);
10224 10275
10225 BUF_APPEND(I6"}\n"); 10276 BUF_APPEND(I6"}\n");
10226 } 10277 }
@@ -10281,7 +10332,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10281 { 10332 {
10282 BUF_APPEND(I6"origin {\n"); 10333 BUF_APPEND(I6"origin {\n");
10283 if (img->image.fill.pos_rel_x || img->image.fill.pos_rel_y) 10334 if (img->image.fill.pos_rel_x || img->image.fill.pos_rel_y)
10284 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(img->image.fill.pos_rel_x), TO_DOUBLE(img->image.fill.pos_rel_y)); 10335 _edje_source_with_double_values_append(I7"relative", 2,
10336 TO_DOUBLE(img->image.fill.pos_rel_x),
10337 TO_DOUBLE(img->image.fill.pos_rel_y),
10338 buf, &ret);
10285 if (img->image.fill.pos_abs_x || img->image.fill.pos_abs_y) 10339 if (img->image.fill.pos_abs_x || img->image.fill.pos_abs_y)
10286 BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.pos_abs_x, img->image.fill.pos_abs_y); 10340 BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.pos_abs_x, img->image.fill.pos_abs_y);
10287 BUF_APPEND(I6"}\n"); 10341 BUF_APPEND(I6"}\n");
@@ -10292,7 +10346,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10292 { 10346 {
10293 BUF_APPEND(I6"size {\n"); 10347 BUF_APPEND(I6"size {\n");
10294 if (img->image.fill.rel_x != 1.0 || img->image.fill.rel_y != 1.0) 10348 if (img->image.fill.rel_x != 1.0 || img->image.fill.rel_y != 1.0)
10295 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(img->image.fill.rel_x), TO_DOUBLE(img->image.fill.rel_y)); 10349 _edje_source_with_double_values_append(I7"relative", 2,
10350 TO_DOUBLE(img->image.fill.rel_x),
10351 TO_DOUBLE(img->image.fill.rel_y),
10352 buf, &ret);
10296 if (img->image.fill.abs_x || img->image.fill.abs_y) 10353 if (img->image.fill.abs_x || img->image.fill.abs_y)
10297 BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.abs_x, img->image.fill.abs_y); 10354 BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.abs_x, img->image.fill.abs_y);
10298 BUF_APPEND(I6"}\n"); 10355 BUF_APPEND(I6"}\n");
@@ -10331,7 +10388,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10331 { 10388 {
10332 BUF_APPEND(I6"origin {\n"); 10389 BUF_APPEND(I6"origin {\n");
10333 if (pro->proxy.fill.pos_rel_x || pro->proxy.fill.pos_rel_y) 10390 if (pro->proxy.fill.pos_rel_x || pro->proxy.fill.pos_rel_y)
10334 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(pro->proxy.fill.pos_rel_x), TO_DOUBLE(pro->proxy.fill.pos_rel_y)); 10391 _edje_source_with_double_values_append(I7"relative", 2,
10392 TO_DOUBLE(pro->proxy.fill.pos_rel_x),
10393 TO_DOUBLE(pro->proxy.fill.pos_rel_y),
10394 buf, &ret);
10335 if (pro->proxy.fill.pos_abs_x || pro->proxy.fill.pos_abs_y) 10395 if (pro->proxy.fill.pos_abs_x || pro->proxy.fill.pos_abs_y)
10336 BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.pos_abs_x, pro->proxy.fill.pos_abs_y); 10396 BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.pos_abs_x, pro->proxy.fill.pos_abs_y);
10337 BUF_APPEND(I6"}\n"); 10397 BUF_APPEND(I6"}\n");
@@ -10342,7 +10402,10 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10342 { 10402 {
10343 BUF_APPEND(I6"size {\n"); 10403 BUF_APPEND(I6"size {\n");
10344 if (pro->proxy.fill.rel_x != 1.0 || pro->proxy.fill.rel_y != 1.0) 10404 if (pro->proxy.fill.rel_x != 1.0 || pro->proxy.fill.rel_y != 1.0)
10345 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(pro->proxy.fill.rel_x), TO_DOUBLE(pro->proxy.fill.rel_y)); 10405 _edje_source_with_double_values_append(I7"relative", 2,
10406 TO_DOUBLE(pro->proxy.fill.rel_x),
10407 TO_DOUBLE(pro->proxy.fill.rel_y),
10408 buf, &ret);
10346 if (pro->proxy.fill.abs_x || pro->proxy.fill.abs_y) 10409 if (pro->proxy.fill.abs_x || pro->proxy.fill.abs_y)
10347 BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.abs_x, pro->proxy.fill.abs_y); 10410 BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.abs_x, pro->proxy.fill.abs_y);
10348 BUF_APPEND(I6"}\n"); 10411 BUF_APPEND(I6"}\n");
@@ -10386,11 +10449,16 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
10386 if (txt->text.max_x || txt->text.max_y) 10449 if (txt->text.max_x || txt->text.max_y)
10387 BUF_APPENDF(I6"max: %d %d;\n", txt->text.max_x, txt->text.max_y); 10450 BUF_APPENDF(I6"max: %d %d;\n", txt->text.max_x, txt->text.max_y);
10388 if (TO_DOUBLE(txt->text.align.x) != 0.5 || TO_DOUBLE(txt->text.align.y) != 0.5) 10451 if (TO_DOUBLE(txt->text.align.x) != 0.5 || TO_DOUBLE(txt->text.align.y) != 0.5)
10389 BUF_APPENDF(I6"align: %g %g;\n", TO_DOUBLE(txt->text.align.x), TO_DOUBLE(txt->text.align.y)); 10452 _edje_source_with_double_values_append(I6"align", 2,
10453 TO_DOUBLE(txt->text.align.x),
10454 TO_DOUBLE(txt->text.align.y),
10455 buf, &ret);
10390 //TODO Support source 10456 //TODO Support source
10391 //TODO Support text_source 10457 //TODO Support text_source
10392 if (txt->text.ellipsis) 10458 if (txt->text.ellipsis)
10393 BUF_APPENDF(I6"ellipsis: %g;\n", txt->text.ellipsis); 10459 _edje_source_with_double_values_append(I6"ellipsis", 1,
10460 txt->text.ellipsis,
10461 0.0, buf, &ret);
10394 BUF_APPEND(I5"}\n"); 10462 BUF_APPEND(I5"}\n");
10395 } 10463 }
10396 10464
@@ -10576,7 +10644,10 @@ _edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf)
10576 item->padding.t, item->padding.b); 10644 item->padding.t, item->padding.b);
10577 10645
10578 if (TO_DOUBLE(item->align.x) != 0.5 || TO_DOUBLE(item->align.y) != 0.5) 10646 if (TO_DOUBLE(item->align.x) != 0.5 || TO_DOUBLE(item->align.y) != 0.5)
10579 BUF_APPENDF(I7"align: %g %g;\n", TO_DOUBLE(item->align.x), TO_DOUBLE(item->align.y)); 10647 _edje_source_with_double_values_append(I7"align", 2,
10648 TO_DOUBLE(item->align.x),
10649 TO_DOUBLE(item->align.y),
10650 buf, &ret);
10580 10651
10581 if (edje_edit_part_type_get(obj, part) == EDJE_PART_TYPE_TABLE) 10652 if (edje_edit_part_type_get(obj, part) == EDJE_PART_TYPE_TABLE)
10582 BUF_APPENDF(I7"position: %d %d;\n", item->col, item->row); 10653 BUF_APPENDF(I7"position: %d %d;\n", item->col, item->row);