From 0708c1832ff84b46018a68ccb646fc53ebc78968 Mon Sep 17 00:00:00 2001 From: kakaroto Date: Wed, 12 Sep 2012 02:38:48 +0000 Subject: [PATCH] Edje: edje_codegen uses errno so we should include it git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@76484 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 6 + NEWS | 1 + src/bin/edje_codegen.c | 1 + src/lib/edje_box_layout.c | 61 ++++--- src/lib/edje_calc.c | 245 +++++++++++++++---------- src/lib/edje_edit.c | 56 +++--- src/lib/edje_entry.c | 453 ++++++++++++++++++++++++++++++++++++---------- src/lib/edje_external.c | 33 +++- src/lib/edje_load.c | 209 +++++++++++++-------- src/lib/edje_private.h | 102 ++++++----- src/lib/edje_program.c | 86 ++++++--- src/lib/edje_smart.c | 22 ++- src/lib/edje_text.c | 88 ++++----- src/lib/edje_util.c | 339 ++++++++++++++++++++-------------- 14 files changed, 1122 insertions(+), 580 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f6f29c..45f76ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -612,3 +612,9 @@ * O(1) lookup when generating alias of group. * O(1) access time for parameters in edje_cc_handler. * Recycle and use less memory during load time. + +2012-09-11 Carsten Haitzler (The Rasterman) + + * Improve memory footrpint by cutting core edje real part + struct down by less than half its size and making some parts allocated + extra only if the type needs it. diff --git a/NEWS b/NEWS index 66c2bfb..d1a219f 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Additions: Improvements: * Check the number of parameter for image in edc. + * Less memory used per part in an edje file (about 25% less). * O(1) lookup used when searching Part_Lookup in edje_cc. * O(1) lookup when generating alias of group. * O(1) access time for parameters in edje_cc_handler. diff --git a/src/bin/edje_codegen.c b/src/bin/edje_codegen.c index 60ed8ce..b90b065 100644 --- a/src/bin/edje_codegen.c +++ b/src/bin/edje_codegen.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/src/lib/edje_box_layout.c b/src/lib/edje_box_layout.c index 3585046..8867fe0 100644 --- a/src/lib/edje_box_layout.c +++ b/src/lib/edje_box_layout.c @@ -155,45 +155,48 @@ _edje_box_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Calc_Params #if 0 int min_w, min_h; #endif + if ((ep->type != EDJE_RP_TYPE_CONTAINER) || + (!ep->typedata.container)) return; + if ((ep->param2) && (ep->description_pos != ZERO)) { Edje_Part_Description_Box *param2_desc = (Edje_Part_Description_Box *)ep->param2->description; - if (ep->anim->end.layout == NULL) + if (ep->typedata.container->anim->end.layout == NULL) { - _edje_box_layout_find_all(param2_desc->box.layout, param2_desc->box.alt_layout, &ep->anim->end.layout, &ep->anim->end.data, &ep->anim->end.free_data); - ep->anim->end.padding.x = param2_desc->box.padding.x; - ep->anim->end.padding.y = param2_desc->box.padding.y; - ep->anim->end.align.x = param2_desc->box.align.x; - ep->anim->end.align.y = param2_desc->box.align.y; + _edje_box_layout_find_all(param2_desc->box.layout, param2_desc->box.alt_layout, &ep->typedata.container->anim->end.layout, &ep->typedata.container->anim->end.data, &ep->typedata.container->anim->end.free_data); + ep->typedata.container->anim->end.padding.x = param2_desc->box.padding.x; + ep->typedata.container->anim->end.padding.y = param2_desc->box.padding.y; + ep->typedata.container->anim->end.align.x = param2_desc->box.align.x; + ep->typedata.container->anim->end.align.y = param2_desc->box.align.y; priv = evas_object_smart_data_get(ep->object); if (priv == NULL) return; - evas_object_box_padding_set(ep->object, ep->anim->start.padding.x, ep->anim->start.padding.y); - evas_object_box_align_set(ep->object, TO_DOUBLE(ep->anim->start.align.x), TO_DOUBLE(ep->anim->start.align.y)); - ep->anim->start.layout(ep->object, priv, ep->anim->start.data); - _edje_box_layout_calculate_coords(ep->object, priv, ep->anim); - ep->anim->start_progress = 0.0; + evas_object_box_padding_set(ep->object, ep->typedata.container->anim->start.padding.x, ep->typedata.container->anim->start.padding.y); + evas_object_box_align_set(ep->object, TO_DOUBLE(ep->typedata.container->anim->start.align.x), TO_DOUBLE(ep->typedata.container->anim->start.align.y)); + ep->typedata.container->anim->start.layout(ep->object, priv, ep->typedata.container->anim->start.data); + _edje_box_layout_calculate_coords(ep->object, priv, ep->typedata.container->anim); + ep->typedata.container->anim->start_progress = 0.0; } evas_object_smart_changed(ep->object); } else { - ep->anim->end.layout = NULL; + ep->typedata.container->anim->end.layout = NULL; } - if (ep->description_pos < 0.01 || !ep->anim->start.layout) + if (ep->description_pos < 0.01 || !ep->typedata.container->anim->start.layout) { - _edje_box_layout_find_all(chosen_desc->box.layout, chosen_desc->box.alt_layout, &ep->anim->start.layout, &ep->anim->start.data, &ep->anim->start.free_data); - ep->anim->start.padding.x = chosen_desc->box.padding.x; - ep->anim->start.padding.y = chosen_desc->box.padding.y; - ep->anim->start.align.x = chosen_desc->box.align.x; - ep->anim->start.align.y = chosen_desc->box.align.y; + _edje_box_layout_find_all(chosen_desc->box.layout, chosen_desc->box.alt_layout, &ep->typedata.container->anim->start.layout, &ep->typedata.container->anim->start.data, &ep->typedata.container->anim->start.free_data); + ep->typedata.container->anim->start.padding.x = chosen_desc->box.padding.x; + ep->typedata.container->anim->start.padding.y = chosen_desc->box.padding.y; + ep->typedata.container->anim->start.align.x = chosen_desc->box.align.x; + ep->typedata.container->anim->start.align.y = chosen_desc->box.align.y; evas_object_smart_changed(ep->object); } - ep->anim->progress = ep->description_pos; + ep->typedata.container->anim->progress = ep->description_pos; if (evas_object_smart_need_recalculate_get(ep->object)) { @@ -213,12 +216,14 @@ Eina_Bool _edje_box_layout_add_child(Edje_Real_Part *rp, Evas_Object *child_obj) { Edje_Transition_Animation_Data *tad; + + if ((rp->type != EDJE_RP_TYPE_CONTAINER) || + (!rp->typedata.container)) return EINA_FALSE; tad = calloc(1, sizeof(Edje_Transition_Animation_Data)); - if (!tad) - return EINA_FALSE; + if (!tad) return EINA_FALSE; tad->obj = child_obj; - rp->anim->objs = eina_list_append(rp->anim->objs, tad); - rp->anim->recalculate = EINA_TRUE; + rp->typedata.container->anim->objs = eina_list_append(rp->typedata.container->anim->objs, tad); + rp->typedata.container->anim->recalculate = EINA_TRUE; return EINA_TRUE; } @@ -228,15 +233,17 @@ _edje_box_layout_remove_child(Edje_Real_Part *rp, Evas_Object *child_obj) Eina_List *l; Edje_Transition_Animation_Data *tad; - EINA_LIST_FOREACH(rp->anim->objs, l, tad) + if ((rp->type != EDJE_RP_TYPE_CONTAINER) || + (!rp->typedata.container)) return; + EINA_LIST_FOREACH(rp->typedata.container->anim->objs, l, tad) { if (tad->obj == child_obj) { free(eina_list_data_get(l)); - rp->anim->objs = eina_list_remove_list(rp->anim->objs, l); - rp->anim->recalculate = EINA_TRUE; + rp->typedata.container->anim->objs = eina_list_remove_list(rp->typedata.container->anim->objs, l); + rp->typedata.container->anim->recalculate = EINA_TRUE; break; } } - rp->anim->recalculate = EINA_TRUE; + rp->typedata.container->anim->recalculate = EINA_TRUE; } diff --git a/src/lib/edje_calc.c b/src/lib/edje_calc.c index 6bebaf8..7045c1e 100644 --- a/src/lib/edje_calc.c +++ b/src/lib/edje_calc.c @@ -510,11 +510,14 @@ _edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State { Edje_Part_Description_External *external; - external = (Edje_Part_Description_External*) state->description; - + if ((ep->type != EDJE_RP_TYPE_SWALLOW) || + (!ep->typedata.swallow)) return; + + external = (Edje_Part_Description_External*)state->description; + if (state->external_params) - _edje_external_parsed_params_free(ep->swallowed_object, state->external_params); - state->external_params = _edje_external_params_parse(ep->swallowed_object, external->external_params); + _edje_external_parsed_params_free(ep->typedata.swallow->swallowed_object, state->external_params); + state->external_params = _edje_external_params_parse(ep->typedata.swallow->swallowed_object, external->external_params); } } } @@ -549,16 +552,24 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl memset(ep->param2, 0, sizeof(Edje_Real_Part_State)); } else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) - _edje_external_parsed_params_free(ep->swallowed_object, - ep->param2->external_params); + { + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) + _edje_external_parsed_params_free(ep->typedata.swallow->swallowed_object, + ep->param2->external_params); + } ep->param2->external_params = NULL; } else if (ep->param2) { if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) - _edje_external_parsed_params_free(ep->swallowed_object, - ep->param2->external_params); + { + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) + _edje_external_parsed_params_free(ep->typedata.swallow->swallowed_object, + ep->param2->external_params); + } if (ep->param2) free(ep->param2->set); eina_mempool_free(_edje_real_part_state_mp, ep->param2); @@ -912,11 +923,15 @@ _edje_part_recalc_single_aspect(Edje *ed, evas_object_image_size_get(ep->object, &w, &h); amin = amax = DIV(FROM_INT(w), FROM_INT(h)); } - if ((ep->swallow_params.aspect.w > 0) && - (ep->swallow_params.aspect.h > 0)) - amin = amax = - DIV(FROM_INT(ep->swallow_params.aspect.w), - FROM_INT(ep->swallow_params.aspect.h)); + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) + { + if ((ep->typedata.swallow->swallow_params.aspect.w > 0) && + (ep->typedata.swallow->swallow_params.aspect.h > 0)) + amin = amax = + DIV(FROM_INT(ep->typedata.swallow->swallow_params.aspect.w), + FROM_INT(ep->typedata.swallow->swallow_params.aspect.h)); + } want_x = FROM_INT(params->x); want_w = new_w = FROM_INT(params->w); @@ -926,24 +941,28 @@ _edje_part_recalc_single_aspect(Edje *ed, if ((amin > ZERO) && (amax > ZERO)) { apref = desc->aspect.prefer; - if (ep->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE) + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) { - switch (ep->swallow_params.aspect.mode) + if (ep->typedata.swallow->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE) { - case EDJE_ASPECT_CONTROL_NEITHER: - apref = EDJE_ASPECT_PREFER_NONE; - break; - case EDJE_ASPECT_CONTROL_HORIZONTAL: - apref = EDJE_ASPECT_PREFER_HORIZONTAL; - break; - case EDJE_ASPECT_CONTROL_VERTICAL: - apref = EDJE_ASPECT_PREFER_VERTICAL; - break; - case EDJE_ASPECT_CONTROL_BOTH: - apref = EDJE_ASPECT_PREFER_BOTH; - break; - default: - break; + switch (ep->typedata.swallow->swallow_params.aspect.mode) + { + case EDJE_ASPECT_CONTROL_NEITHER: + apref = EDJE_ASPECT_PREFER_NONE; + break; + case EDJE_ASPECT_CONTROL_HORIZONTAL: + apref = EDJE_ASPECT_PREFER_HORIZONTAL; + break; + case EDJE_ASPECT_CONTROL_VERTICAL: + apref = EDJE_ASPECT_PREFER_VERTICAL; + break; + case EDJE_ASPECT_CONTROL_BOTH: + apref = EDJE_ASPECT_PREFER_BOTH; + break; + default: + break; + } } } switch (apref) @@ -1141,6 +1160,9 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, int *minw, int *minh, int *maxw, int *maxh) { + if ((ep->type != EDJE_RP_TYPE_TEXT) || + (!ep->typedata.text)) + return; if (chosen_desc) { Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; @@ -1152,14 +1174,14 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, if (chosen_desc->text.id_source >= 0) { - ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size]; + ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size]; - tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.style); + tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->typedata.text->source->chosen_description)->text.style); if (tmp) style = tmp; } else { - ep->text.source = NULL; + ep->typedata.text->source = NULL; tmp = edje_string_get(&chosen_desc->text.style); if (tmp) style = tmp; @@ -1167,16 +1189,16 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, if (chosen_desc->text.id_text_source >= 0) { - ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size]; - text = edje_string_get(&((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text); + ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size]; + text = edje_string_get(&((Edje_Part_Description_Text*)ep->typedata.text->text_source->chosen_description)->text.text); - if (ep->text.text_source->text.text) text = ep->text.text_source->text.text; + if (ep->typedata.text->text_source->typedata.text->text) text = ep->typedata.text->text_source->typedata.text->text; } else { - ep->text.text_source = NULL; + ep->typedata.text->text_source = NULL; text = edje_string_get(&chosen_desc->text.text); - if (ep->text.text) text = ep->text.text; + if (ep->typedata.text->text) text = ep->typedata.text->text; } EINA_LIST_FOREACH(ed->file->styles, l, stl) @@ -1829,8 +1851,12 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, { *minw = desc->min.w; if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw)); - if (ep->swallow_params.min.w > desc->min.w) - *minw = ep->swallow_params.min.w; + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) + { + if (ep->typedata.swallow->swallow_params.min.w > desc->min.w) + *minw = ep->typedata.swallow->swallow_params.min.w; + } if (ep->edje->calc_only) { @@ -1841,22 +1867,12 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, } } - /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */ - if ((ep->swallow_params.max.w <= 0) || - (ep->swallow_params.max.w == EDJE_INF_MAX_W)) + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) { - *maxw = desc->max.w; - if (*maxw > 0) - { - if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); - if (*maxw < 1) *maxw = 1; - } - } - else - { - if (desc->max.w <= 0) - *maxw = ep->swallow_params.max.w; - else + /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */ + if ((ep->typedata.swallow->swallow_params.max.w <= 0) || + (ep->typedata.swallow->swallow_params.max.w == EDJE_INF_MAX_W)) { *maxw = desc->max.w; if (*maxw > 0) @@ -1864,8 +1880,31 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); if (*maxw < 1) *maxw = 1; } - if (ep->swallow_params.max.w < *maxw) - *maxw = ep->swallow_params.max.w; + } + else + { + if (desc->max.w <= 0) + *maxw = ep->typedata.swallow->swallow_params.max.w; + else + { + *maxw = desc->max.w; + if (*maxw > 0) + { + if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (*maxw < 1) *maxw = 1; + } + if (ep->typedata.swallow->swallow_params.max.w < *maxw) + *maxw = ep->typedata.swallow->swallow_params.max.w; + } + } + } + else + { + *maxw = desc->max.w; + if (*maxw > 0) + { + if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (*maxw < 1) *maxw = 1; } } if ((ep->edje->calc_only) && (desc->minmul.have) && @@ -1877,8 +1916,12 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *minh = desc->min.h; if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh)); - if (ep->swallow_params.min.h > desc->min.h) - *minh = ep->swallow_params.min.h; + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) + { + if (ep->typedata.swallow->swallow_params.min.h > desc->min.h) + *minh = ep->typedata.swallow->swallow_params.min.h; + } if (ep->edje->calc_only) { @@ -1889,22 +1932,12 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, } } - /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */ - if ((ep->swallow_params.max.h <= 0) || - (ep->swallow_params.max.h == EDJE_INF_MAX_H)) - { - *maxh = desc->max.h; - if (*maxh > 0) - { - if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); - if (*maxh < 1) *maxh = 1; - } - } - else + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) { - if (desc->max.h <= 0) - *maxh = ep->swallow_params.max.h; - else + /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */ + if ((ep->typedata.swallow->swallow_params.max.h <= 0) || + (ep->typedata.swallow->swallow_params.max.h == EDJE_INF_MAX_H)) { *maxh = desc->max.h; if (*maxh > 0) @@ -1912,8 +1945,31 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); if (*maxh < 1) *maxh = 1; } - if (ep->swallow_params.max.h < *maxh) - *maxh = ep->swallow_params.max.h; + } + else + { + if (desc->max.h <= 0) + *maxh = ep->typedata.swallow->swallow_params.max.h; + else + { + *maxh = desc->max.h; + if (*maxh > 0) + { + if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (*maxh < 1) *maxh = 1; + } + if (ep->typedata.swallow->swallow_params.max.h < *maxh) + *maxh = ep->typedata.swallow->swallow_params.max.h; + } + } + } + else + { + *maxh = desc->max.h; + if (*maxh > 0) + { + if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (*maxh < 1) *maxh = 1; } } if ((ep->edje->calc_only) && (desc->minmul.have) && @@ -2300,7 +2356,11 @@ _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj case EDJE_PART_TYPE_GROUP: case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_EXTERNAL: - evas_object_image_source_set(ep->object, pp->swallowed_object); + if ((pp->type == EDJE_RP_TYPE_SWALLOW) && + (pp->typedata.swallow)) + { + evas_object_image_source_set(ep->object, pp->typedata.swallow->swallowed_object); + } break; case EDJE_PART_TYPE_SPACER: /* FIXME: detect that at compile time and prevent it */ @@ -2443,23 +2503,25 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta if (ep->part->scale && ep->part->type == EDJE_PART_TYPE_GROUP && - ep->swallowed_object) + ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) && + ep->typedata.swallow->swallowed_object) { - edje_object_scale_set(ep->swallowed_object, TO_DOUBLE(ed->scale)); + edje_object_scale_set(ep->typedata.swallow->swallowed_object, TO_DOUBLE(ed->scale)); if (ep->description_pos > FROM_DOUBLE(0.5) && ep->param2) { - edje_object_update_hints_set(ep->swallowed_object, ep->param2->description->min.limit); + edje_object_update_hints_set(ep->typedata.swallow->swallowed_object, ep->param2->description->min.limit); } else { - edje_object_update_hints_set(ep->swallowed_object, ep->param1.description->min.limit); + edje_object_update_hints_set(ep->typedata.swallow->swallowed_object, ep->param1.description->min.limit); } - if (edje_object_update_hints_get(ep->swallowed_object)) + if (edje_object_update_hints_get(ep->typedata.swallow->swallowed_object)) { Edje *ted; - ted = _edje_fetch(ep->swallowed_object); + ted = _edje_fetch(ep->typedata.swallow->swallowed_object); _edje_recalc_do(ted); } } @@ -2631,7 +2693,6 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y, confine_to, p1, pos); - #ifdef EDJE_CALC_CACHE if (flags == FLAG_XY) ep->param1.state = ed->state; @@ -2931,7 +2992,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta /* visibility and color have no meaning on SWALLOW and GROUP part. */ evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y); evas_object_resize(ep->object, pf->w, pf->h); - + if (ep->nested_smart) { /* Move, Resize all nested parts */ /* Not really needed but will improve the bounding box evaluation done by Evas */ @@ -2990,25 +3051,27 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta break; } - if (ep->swallowed_object) + if (((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) && + (ep->typedata.swallow->swallowed_object)) { //// the below really is wrong - swallow color shouldn't affect swallowed object //// color - the edje color as a WHOLE should though - and that should be //// done via the clipper anyway. this created bugs when objects had their //// colro set and were swallowed - then had their color changed. - // evas_object_color_set(ep->swallowed_object, + // evas_object_color_set(ep->typedata.swallow->swallowed_object, // (pf->color.r * pf->color.a) / 255, // (pf->color.g * pf->color.a) / 255, // (pf->color.b * pf->color.a) / 255, // pf->color.a); if (pf->visible) { - evas_object_move(ep->swallowed_object, ed->x + pf->x, ed->y + pf->y); - evas_object_resize(ep->swallowed_object, pf->w, pf->h); - evas_object_show(ep->swallowed_object); + evas_object_move(ep->typedata.swallow->swallowed_object, ed->x + pf->x, ed->y + pf->y); + evas_object_resize(ep->typedata.swallow->swallowed_object, pf->w, pf->h); + evas_object_show(ep->typedata.swallow->swallowed_object); } - else evas_object_hide(ep->swallowed_object); - mo = ep->swallowed_object; + else evas_object_hide(ep->typedata.swallow->swallowed_object); + mo = ep->typedata.swallow->swallowed_object; } else mo = ep->object; if (chosen_desc->map.on && ep->part->type != EDJE_PART_TYPE_SPACER) diff --git a/src/lib/edje_edit.c b/src/lib/edje_edit.c index 65ea50b..c807f1b 100644 --- a/src/lib/edje_edit.c +++ b/src/lib/edje_edit.c @@ -351,28 +351,28 @@ _edje_real_part_free(Edje_Real_Part *rp) evas_object_del(rp->object); } - if (rp->swallowed_object) + if (rp->typedata.swallow->swallowed_object) { - evas_object_smart_member_del(rp->swallowed_object); - evas_object_event_callback_del(rp->swallowed_object, + evas_object_smart_member_del(rp->typedata.swallow->swallowed_object); + evas_object_event_callback_del(rp->typedata.swallow->swallowed_object, EVAS_CALLBACK_FREE, _edje_object_part_swallow_free_cb); - evas_object_clip_unset(rp->swallowed_object); - evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); + evas_object_clip_unset(rp->typedata.swallow->swallowed_object); + evas_object_data_del(rp->typedata.swallow->swallowed_object, "\377 edje.swallowing_part"); if (rp->part->mouse_events) - _edje_callbacks_del(rp->swallowed_object, rp->edje); + _edje_callbacks_del(rp->typedata.swallow->swallowed_object, rp->edje); if (rp->part->type == EDJE_PART_TYPE_GROUP || rp->part->type == EDJE_PART_TYPE_EXTERNAL) - evas_object_del(rp->swallowed_object); + evas_object_del(rp->typedata.swallow->swallowed_object); - rp->swallowed_object = NULL; + rp->typedata.swallow->swallowed_object = NULL; } - if (rp->text.text) eina_stringshare_del(rp->text.text); - if (rp->text.font) eina_stringshare_del(rp->text.font); - if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str); - if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str); + if (rp->typedata.text->text) eina_stringshare_del(rp->typedata.text->text); + if (rp->typedata.text->font) eina_stringshare_del(rp->typedata.text->font); + if (rp->typedata.text->cache.in_str) eina_stringshare_del(rp->typedata.text->cache.in_str); + if (rp->typedata.text->cache.out_str) eina_stringshare_del(rp->typedata.text->cache.out_str); if (rp->custom) { @@ -2230,8 +2230,8 @@ edje_edit_part_del(Evas_Object *obj, const char* part) if (i == id) continue; //don't check the deleted id real = ed->table_parts[i]; - if (real->text.source == rp) real->text.source = NULL; - if (real->text.text_source == rp) real->text.text_source = NULL; + if (real->typedata.text->source == rp) real->typedata.text->source = NULL; + if (real->typedata.text->text_source == rp) real->typedata.text->text_source = NULL; if (real->param1.rel1_to_x == rp) real->param1.rel1_to_x = NULL; if (real->param1.rel1_to_y == rp) real->param1.rel1_to_y = NULL; @@ -2376,8 +2376,8 @@ edje_edit_part_restack_below(Evas_Object *obj, const char* part) _edje_parts_id_switch(ed, rp, prev); evas_object_stack_below(rp->object, prev->object); - if (rp->swallowed_object) - evas_object_stack_above(rp->swallowed_object, rp->object); + if (rp->typedata.swallow->swallowed_object) + evas_object_stack_above(rp->typedata.swallow->swallowed_object, rp->object); _edje_edit_flag_script_dirty(eed, EINA_TRUE); @@ -2412,8 +2412,8 @@ edje_edit_part_restack_above(Evas_Object *obj, const char* part) _edje_parts_id_switch(ed, rp, next); evas_object_stack_above(rp->object, next->object); - if (rp->swallowed_object) - evas_object_stack_above(rp->swallowed_object, rp->object); + if (rp->typedata.swallow->swallowed_object) + evas_object_stack_above(rp->typedata.swallow->swallowed_object, rp->object); _edje_edit_flag_script_dirty(eed, EINA_TRUE); @@ -2508,8 +2508,8 @@ edje_edit_part_clip_to_set(Evas_Object *obj, const char *part, const char *clip_ } evas_object_clip_set(rp->object, ed->base.clipper); - if (rp->swallowed_object) - evas_object_clip_set(rp->swallowed_object, ed->base.clipper); + if (rp->typedata.swallow->swallowed_object) + evas_object_clip_set(rp->typedata.swallow->swallowed_object, ed->base.clipper); rp->part->clip_to_id = -1; rp->clip_to = NULL; @@ -2537,8 +2537,8 @@ edje_edit_part_clip_to_set(Evas_Object *obj, const char *part, const char *clip_ evas_object_pass_events_set(rp->clip_to->object, 1); evas_object_pointer_mode_set(rp->clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB); evas_object_clip_set(rp->object, rp->clip_to->object); - if (rp->swallowed_object) - evas_object_clip_set(rp->swallowed_object, rp->clip_to->object); + if (rp->typedata.swallow->swallowed_object) + evas_object_clip_set(rp->typedata.swallow->swallowed_object, rp->clip_to->object); edje_object_calc_force(obj); @@ -2683,11 +2683,11 @@ edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source _edje_if_string_free(ed, rp->part->source); - if (rp->swallowed_object) + if (rp->typedata.swallow->swallowed_object) { _edje_real_part_swallow_clear(rp); - evas_object_del(rp->swallowed_object); - rp->swallowed_object = NULL; + evas_object_del(rp->typedata.swallow->swallowed_object); + rp->typedata.swallow->swallowed_object = NULL; } if (source) { @@ -3197,7 +3197,7 @@ edje_edit_state_add(Evas_Object *obj, const char *part, const char *name, double pi++; } if (external->external_params) - rp->param1.external_params = _edje_external_params_parse(rp->swallowed_object, external->external_params); + rp->param1.external_params = _edje_external_params_parse(rp->typedata.swallow->swallowed_object, external->external_params); } } else if (rp->part->type == EDJE_PART_TYPE_BOX) @@ -4126,10 +4126,10 @@ edje_edit_state_external_param_set(Evas_Object *obj, const char *part, const cha if (!found) external->external_params = eina_list_append(external->external_params, p); - _edje_external_parsed_params_free(rp->swallowed_object, + _edje_external_parsed_params_free(rp->typedata.swallow->swallowed_object, rp->param1.external_params); rp->param1.external_params = \ - _edje_external_params_parse(rp->swallowed_object, + _edje_external_params_parse(rp->typedata.swallow->swallowed_object, external->external_params); diff --git a/src/lib/edje_entry.c b/src/lib/edje_entry.c index 3307e34..ae2c217 100644 --- a/src/lib/edje_entry.c +++ b/src/lib/edje_entry.c @@ -98,9 +98,11 @@ _edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emiss Entry *en; rp = data; - if (!rp || !rp->entry_data || !rp->edje || !rp->edje->obj) return; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + if (!rp || !rp->typedata.text->entry_data || !rp->edje || !rp->edje->obj) return; - en = rp->entry_data; + en = rp->typedata.text->entry_data; if (!en || !en->imf_context) return; if (evas_object_focus_get(rp->edje->obj)) @@ -118,9 +120,11 @@ _edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emis Entry *en; rp = data; - if (!rp || !rp->entry_data) return; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + if (!rp || !rp->typedata.text->entry_data) return; - en = rp->entry_data; + en = rp->typedata.text->entry_data; if (!en || !en->imf_context) return; ecore_imf_context_reset(en->imf_context); @@ -142,8 +146,9 @@ _edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v #ifdef HAVE_ECORE_IMF rp = ed->focused_part; if (!rp) return; - - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) return; @@ -169,7 +174,9 @@ _edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, #ifdef HAVE_ECORE_IMF if (!rp) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) return; @@ -635,7 +642,9 @@ _edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UN int ignored; Entry *en; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) && (en->select_allow)) return; @@ -667,7 +676,9 @@ _edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS int ignored; Entry *en; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; ignored = rp->part->ignore_flags & ev->event_flags; if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) && (en->select_allow)) @@ -699,7 +710,9 @@ _edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UN int ignored; Entry *en; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) && (en->select_allow)) return; @@ -1182,7 +1195,9 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v Eina_Bool cursor_changed; int old_cur_pos; if (!rp) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) return; @@ -1693,7 +1708,9 @@ _edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi Entry *en; if (!rp) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) return; @@ -1721,7 +1738,9 @@ _edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, Edje_Real_Part *rp = data; Entry *en; if (!rp) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _edje_entry_imf_cursor_info_set(en); } @@ -1740,7 +1759,9 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS Eina_Bool shift; if (!rp) return; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return; @@ -1971,7 +1992,9 @@ _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) return; if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return; @@ -2076,7 +2099,9 @@ _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS Evas_Coord x, y, w, h; Evas_Textblock_Cursor *tc; if (!rp) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return; @@ -2233,9 +2258,11 @@ _edje_entry_real_part_init(Edje_Real_Part *rp) const Ecore_IMF_Context_Info *ctx_info; #endif + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; en = calloc(1, sizeof(Entry)); if (!en) return; - rp->entry_data = en; + rp->typedata.text->entry_data = en; en->rp = rp; evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp); @@ -2341,9 +2368,13 @@ done: void _edje_entry_real_part_shutdown(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; - rp->entry_data = NULL; + rp->typedata.text->entry_data = NULL; _sel_clear(en->cursor, rp->object, en); _anchors_clear(en->cursor, rp->object, en); #ifdef HAVE_ECORE_IMF @@ -2385,8 +2416,12 @@ void _edje_entry_real_part_configure(Edje_Real_Part *rp) { Evas_Coord x, y, w, h, xx, yy, ww, hh; - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor_Type cur_type; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; switch (rp->part->cursor_mode) { @@ -2422,7 +2457,11 @@ _edje_entry_real_part_configure(Edje_Real_Part *rp) const char * _edje_entry_selection_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; // get selection - convert to markup if ((!en->selection) && (en->have_selection)) @@ -2434,7 +2473,11 @@ _edje_entry_selection_get(Edje_Real_Part *rp) const char * _edje_entry_text_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; // get text - convert to markup return evas_object_textblock_text_markup_get(rp->object); @@ -2443,7 +2486,11 @@ _edje_entry_text_get(Edje_Real_Part *rp) void _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _edje_entry_imf_context_reset(rp); // set text as markup @@ -2465,7 +2512,11 @@ _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text) void _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; Evas_Textblock_Cursor *end_cur; if (!en) return; end_cur = evas_object_textblock_cursor_new(rp->object); @@ -2484,7 +2535,11 @@ _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text) void _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _edje_entry_imf_context_reset(rp); @@ -2505,7 +2560,11 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text) void _edje_entry_set_cursor_start(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _curs_start(en->cursor, rp->object, en); @@ -2515,7 +2574,11 @@ _edje_entry_set_cursor_start(Edje_Real_Part *rp) void _edje_entry_set_cursor_end(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _curs_end(en->cursor, rp->object, en); @@ -2525,7 +2588,11 @@ _edje_entry_set_cursor_end(Edje_Real_Part *rp) void _edje_entry_select_none(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _sel_clear(en->cursor, rp->object, en); } @@ -2533,7 +2600,11 @@ _edje_entry_select_none(Edje_Real_Part *rp) void _edje_entry_select_all(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _edje_entry_imf_context_reset(rp); @@ -2552,7 +2623,11 @@ _edje_entry_select_all(Edje_Real_Part *rp) void _edje_entry_select_begin(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _edje_entry_imf_context_reset(rp); @@ -2570,7 +2645,11 @@ _edje_entry_select_begin(Edje_Real_Part *rp) void _edje_entry_select_extend(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; _edje_entry_imf_context_reset(rp); _sel_extend(en->cursor, rp->object, en); @@ -2583,10 +2662,13 @@ _edje_entry_select_extend(Edje_Real_Part *rp) const Eina_List * _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor) { - Entry *en = rp->entry_data; + Entry *en; Eina_List *l; Anchor *an; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; EINA_LIST_FOREACH(en->anchors, l, an) { @@ -2600,10 +2682,13 @@ _edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor) const Eina_List * _edje_entry_anchors_list(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; Eina_List *l, *anchors = NULL; Anchor *an; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; if (!en->anchorlist) { @@ -2622,10 +2707,13 @@ _edje_entry_anchors_list(Edje_Real_Part *rp) Eina_Bool _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) { - Entry *en = rp->entry_data; + Entry *en; Eina_List *l; Anchor *an; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; if (!en) return EINA_FALSE; EINA_LIST_FOREACH(en->anchors, l, an) { @@ -2642,10 +2730,13 @@ _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord * const Eina_List * _edje_entry_items_list(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; Eina_List *l, *items = NULL; Anchor *an; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; if (!en->itemlist) { @@ -2665,8 +2756,12 @@ void _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) { Evas_Coord x, y, w, h, xx, yy, ww, hh; - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor_Type cur_type; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; switch (rp->part->cursor_mode) { @@ -2696,8 +2791,15 @@ _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord * void _edje_entry_user_insert(Edje_Real_Part *rp, const char *text) { - Entry *en = rp->entry_data; + Entry *en; Edje_Entry_Change_Info *info = calloc(1, sizeof(*info)); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; + info = calloc(1, sizeof(*info)); + if (!info) return; info->insert = EINA_TRUE; info->change.insert.plain_length = 1; info->change.insert.content = eina_stringshare_add(text); @@ -2726,7 +2828,12 @@ _edje_entry_user_insert(Edje_Real_Part *rp, const char *text) void _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT) return; en->select_allow = allow; @@ -2735,14 +2842,24 @@ _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow) Eina_Bool _edje_entry_select_allow_get(const Edje_Real_Part *rp) { - const Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; return en->select_allow; } void _edje_entry_select_abort(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (en->selecting) { en->selecting = EINA_FALSE; @@ -2756,7 +2873,11 @@ _edje_entry_select_abort(Edje_Real_Part *rp) void * _edje_entry_imf_context_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; #ifdef HAVE_ECORE_IMF @@ -2769,7 +2890,11 @@ _edje_entry_imf_context_get(Edje_Real_Part *rp) void _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) @@ -2784,7 +2909,11 @@ _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type Edje_Text_Autocapital_Type _edje_entry_autocapital_type_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; + en = rp->typedata.text->entry_data; if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; #ifdef HAVE_ECORE_IMF @@ -2798,8 +2927,11 @@ _edje_entry_autocapital_type_get(Edje_Real_Part *rp) void _edje_entry_prediction_allow_set(Edje_Real_Part *rp, Eina_Bool prediction) { - Entry *en = rp->entry_data; - + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; en->prediction_allow = prediction; #ifdef HAVE_ECORE_IMF @@ -2811,17 +2943,23 @@ _edje_entry_prediction_allow_set(Edje_Real_Part *rp, Eina_Bool prediction) Eina_Bool _edje_entry_prediction_allow_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; if (!en) return EINA_FALSE; - return en->prediction_allow; } void _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled) { - Entry *en = rp->entry_data; - + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; en->input_panel_enable = enabled; #ifdef HAVE_ECORE_IMF @@ -2833,17 +2971,23 @@ _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled) Eina_Bool _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; if (!en) return EINA_FALSE; - return en->input_panel_enable; } void _edje_entry_input_panel_show(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; - + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2854,8 +2998,11 @@ _edje_entry_input_panel_show(Edje_Real_Part *rp) void _edje_entry_input_panel_hide(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; - + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2866,8 +3013,11 @@ _edje_entry_input_panel_hide(Edje_Real_Part *rp) void _edje_entry_input_panel_language_set(Edje_Real_Part *rp, Edje_Input_Panel_Lang lang) { - Entry *en = rp->entry_data; - + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; en->input_panel_lang = lang; #ifdef HAVE_ECORE_IMF @@ -2879,9 +3029,12 @@ _edje_entry_input_panel_language_set(Edje_Real_Part *rp, Edje_Input_Panel_Lang l Edje_Input_Panel_Lang _edje_entry_input_panel_language_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EDJE_INPUT_PANEL_LANG_AUTOMATIC; + en = rp->typedata.text->entry_data; if (!en) return EDJE_INPUT_PANEL_LANG_AUTOMATIC; - return en->input_panel_lang; } @@ -2893,7 +3046,11 @@ void _edje_entry_input_panel_imdata_set(Edje_Real_Part *rp, const void *data __UNUSED__, int len __UNUSED__) #endif { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2909,7 +3066,11 @@ void _edje_entry_input_panel_imdata_get(Edje_Real_Part *rp, void *data __UNUSED__, int *len __UNUSED__) #endif { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2925,7 +3086,11 @@ void _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel_Return_Key_Type return_key_type __UNUSED__) #endif { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2936,7 +3101,11 @@ _edje_entry_input_panel_return_key_type_set(Edje_Real_Part *rp, Edje_Input_Panel Edje_Input_Panel_Return_Key_Type _edje_entry_input_panel_return_key_type_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + en = rp->typedata.text->entry_data; if (!en) return EDJE_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2953,7 +3122,11 @@ void _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool disabled __UNUSED__) #endif { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2964,7 +3137,11 @@ _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bool di Eina_Bool _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; if (!en) return EINA_FALSE; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -2976,9 +3153,12 @@ _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp) static Evas_Textblock_Cursor * _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; + en = rp->typedata.text->entry_data; if (!en) return NULL; - switch (cur) { case EDJE_CURSOR_MAIN: @@ -3012,8 +3192,14 @@ _cursor_get(Edje_Real_Part *rp, Edje_Cursor cur) Eina_Bool _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; + if (!c) return EINA_FALSE; _edje_entry_imf_context_reset(rp); @@ -3022,7 +3208,7 @@ _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) { return EINA_FALSE; } - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); _edje_emit(rp->edje, "cursor,changed", rp->part->name); @@ -3033,8 +3219,13 @@ _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) Eina_Bool _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; if (!c) return EINA_FALSE; _edje_entry_imf_context_reset(rp); @@ -3045,7 +3236,7 @@ _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur) else return EINA_FALSE; } ok: - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); @@ -3057,10 +3248,15 @@ ok: Eina_Bool _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; int ln; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; if (!c) return EINA_FALSE; _edje_entry_imf_context_reset(rp); @@ -3079,7 +3275,7 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) else evas_textblock_cursor_line_char_last(c); } - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); @@ -3091,10 +3287,15 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) Eina_Bool _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; int ln; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; if (!c) return EINA_FALSE; _edje_entry_imf_context_reset(rp); @@ -3112,7 +3313,7 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) else evas_textblock_cursor_line_char_last(c); } - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); _edje_emit(rp->edje, "cursor,changed", rp->part->name); @@ -3123,14 +3324,19 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) void _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (!c) return; _edje_entry_imf_context_reset(rp); evas_textblock_cursor_paragraph_first(c); - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); _edje_emit(rp->edje, "cursor,changed", rp->part->name); @@ -3140,14 +3346,19 @@ _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) void _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (!c) return; _edje_entry_imf_context_reset(rp); - _curs_end(c, rp->object, rp->entry_data); - _sel_update(c, rp->object, rp->entry_data); + _curs_end(c, rp->object, rp->typedata.text->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); @@ -3158,16 +3369,20 @@ _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) void _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c; Evas_Textblock_Cursor *d; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; c = _cursor_get(rp, cur); if (!c) return; d = _cursor_get(rp, dst); if (!d) return; evas_textblock_cursor_copy(c, d); - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_context_reset(rp); _edje_entry_imf_cursor_info_set(en); @@ -3178,13 +3393,18 @@ _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) void _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (!c) return; _edje_entry_imf_context_reset(rp); evas_textblock_cursor_line_char_first(c); - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); @@ -3195,12 +3415,17 @@ _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) void _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (!c) return; _edje_entry_imf_context_reset(rp); evas_textblock_cursor_line_char_last(c); - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); _edje_emit(rp->edje, "cursor,changed", rp->part->name); @@ -3253,8 +3478,13 @@ _edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur) void _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) { - Entry *en = rp->entry_data; + Entry *en; Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; if (!c) return; /* Abort if cursor position didn't really change */ if (evas_textblock_cursor_pos_get(c) == pos) @@ -3262,7 +3492,7 @@ _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) _edje_entry_imf_context_reset(rp); evas_textblock_cursor_pos_set(c, pos); - _sel_update(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->typedata.text->entry_data); _edje_entry_imf_cursor_info_set(en); _edje_emit(rp->edje, "cursor,changed", rp->part->name); @@ -3280,7 +3510,11 @@ _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur) void _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -3293,7 +3527,11 @@ _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout l Edje_Input_Panel_Layout _edje_entry_input_panel_layout_get(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EDJE_INPUT_PANEL_LAYOUT_INVALID; + en = rp->typedata.text->entry_data; if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -3306,7 +3544,11 @@ _edje_entry_input_panel_layout_get(Edje_Real_Part *rp) void _edje_entry_imf_context_reset(Edje_Real_Part *rp) { - Entry *en = rp->entry_data; + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; if (!en) return; #ifdef HAVE_ECORE_IMF if (en->imf_context) @@ -3337,11 +3579,14 @@ _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNU { Edje *ed = data; Edje_Real_Part *rp = ed->focused_part; - Entry *en; + Entry *en = NULL; const char *str; if (!rp) return EINA_FALSE; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + else + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return EINA_FALSE; @@ -3363,13 +3608,15 @@ _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, v { Edje *ed = data; Edje_Real_Part *rp = ed->focused_part; - Entry *en; + Entry *en = NULL; char *commit_str = event_info; int start_pos; if ((!rp)) return; - - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + else + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return; @@ -3436,7 +3683,7 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UN { Edje *ed = data; Edje_Real_Part *rp = ed->focused_part; - Entry *en; + Entry *en = NULL; int cursor_pos; int preedit_start_pos, preedit_end_pos; char *preedit_string; @@ -3448,7 +3695,10 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UN if ((!rp)) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + else + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return; @@ -3570,13 +3820,16 @@ _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx _ { Edje *ed = data; Edje_Real_Part *rp = ed->focused_part; - Entry *en; + Entry *en = NULL; Ecore_IMF_Event_Delete_Surrounding *ev = event_info; Evas_Textblock_Cursor *del_start, *del_end; int cursor_pos; if ((!rp) || (!ev)) return; - en = rp->entry_data; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + else + en = rp->typedata.text->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) return; diff --git a/src/lib/edje_external.c b/src/lib/edje_external.c index 8bf6256..9497c7b 100644 --- a/src/lib/edje_external.c +++ b/src/lib/edje_external.c @@ -47,7 +47,9 @@ edje_object_part_external_object_get(const Evas_Object *obj, const char *part) rp->part->name); return NULL; } - return rp->swallowed_object; + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + return rp->typedata.swallow->swallowed_object; } EAPI Eina_Bool @@ -111,8 +113,9 @@ edje_object_part_external_content_get(const Evas_Object *obj, const char *part, ERR("no part '%s'", part); return EINA_FALSE; } - - return _edje_external_content_get(rp->swallowed_object, content); + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + return _edje_external_content_get(rp->typedata.swallow->swallowed_object, content); } EAPI Edje_External_Param_Type @@ -132,7 +135,9 @@ edje_object_part_external_param_type_get(const Evas_Object *obj, const char *par ERR("no part '%s'", part); return EDJE_EXTERNAL_PARAM_TYPE_MAX; } - type = evas_object_data_get(rp->swallowed_object, "Edje_External_Type"); + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return EDJE_EXTERNAL_PARAM_TYPE_MAX; + type = evas_object_data_get(rp->typedata.swallow->swallowed_object, "Edje_External_Type"); if (!type) { ERR("no external type for object %p", obj); @@ -409,7 +414,11 @@ _edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *s Eina_Bool _edje_external_param_set(Evas_Object *obj, Edje_Real_Part *rp, const Edje_External_Param *param) { - Evas_Object *swallowed_object = rp->swallowed_object; + Evas_Object *swallowed_object; + + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return EINA_FALSE; + swallowed_object = rp->typedata.swallow->swallowed_object; Edje_External_Type *type = evas_object_data_get(swallowed_object, "Edje_External_Type"); if (!type) { @@ -438,7 +447,11 @@ _edje_external_param_set(Evas_Object *obj, Edje_Real_Part *rp, const Edje_Extern Eina_Bool _edje_external_param_get(const Evas_Object *obj, Edje_Real_Part *rp, Edje_External_Param *param) { - Evas_Object *swallowed_object = rp->swallowed_object; + Evas_Object *swallowed_object; + + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return EINA_FALSE; + swallowed_object = rp->typedata.swallow->swallowed_object; Edje_External_Type *type = evas_object_data_get(swallowed_object, "Edje_External_Type"); if (!type) { @@ -508,8 +521,10 @@ _edje_external_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Part_Description_External *ext; void *params1, *params2 = NULL; - if (!ep->swallowed_object) return; - type = evas_object_data_get(ep->swallowed_object, "Edje_External_Type"); + if ((ep->type != EDJE_RP_TYPE_SWALLOW) || + (!ep->typedata.swallow)) return; + if (!ep->typedata.swallow->swallowed_object) return; + type = evas_object_data_get(ep->typedata.swallow->swallowed_object, "Edje_External_Type"); if ((!type) || (!type->state_set)) return; @@ -526,7 +541,7 @@ _edje_external_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, ep->param2->external_params : ext->external_params; } - type->state_set(type->data, ep->swallowed_object, + type->state_set(type->data, ep->typedata.swallow->swallowed_object, params1, params2, ep->description_pos); } diff --git a/src/lib/edje_load.c b/src/lib/edje_load.c index f7a023a..323ec7e 100644 --- a/src/lib/edje_load.c +++ b/src/lib/edje_load.c @@ -454,6 +454,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g for (n = 0; n < ed->collection->parts_count; n++) { Edje_Part *ep; + Eina_Bool memerr = EINA_FALSE; ep = ed->collection->parts[n]; @@ -494,6 +495,41 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g rp->drag->step.x = FROM_INT(ep->dragable.step_x); rp->drag->step.y = FROM_INT(ep->dragable.step_y); } + // allow part type specific data - this keeps real_part smaller + switch (ep->type) + { + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + rp->type = EDJE_RP_TYPE_TEXT; + rp->typedata.text = calloc(1, sizeof(Edje_Real_Part_Text)); + if (!rp->typedata.text) memerr = EINA_TRUE; + break; + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_EXTERNAL: + rp->type = EDJE_RP_TYPE_SWALLOW; + rp->typedata.swallow = calloc(1, sizeof(Edje_Real_Part_Swallow)); + if (!rp->typedata.swallow) memerr = EINA_TRUE; + break; + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + rp->type = EDJE_RP_TYPE_CONTAINER; + rp->typedata.container = calloc(1, sizeof(Edje_Real_Part_Container)); + if (!rp->typedata.container) memerr = EINA_TRUE; + break; + default: + break; + } + + if (memerr) + { + if (rp->drag) free(rp->drag); + ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; + eina_mempool_free(_edje_real_part_mp, rp); + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 0; + } rp->edje = ed; _edje_ref(rp->edje); @@ -539,7 +575,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g case EDJE_PART_TYPE_BOX: sources = eina_list_append(sources, rp); rp->object = evas_object_box_add(ed->base.evas); - rp->anim = _edje_box_layout_anim_new(rp->object); + rp->typedata.container->anim = _edje_box_layout_anim_new(rp->object); break; case EDJE_PART_TYPE_TABLE: sources = eina_list_append(sources, rp); @@ -679,10 +715,14 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g rp->events_to = NULL; } - rp->swallow_params.min.w = 0; - rp->swallow_params.min.h = 0; - rp->swallow_params.max.w = -1; - rp->swallow_params.max.h = -1; + if ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) + { + rp->typedata.swallow->swallow_params.min.w = 0; + rp->typedata.swallow->swallow_params.min.h = 0; + rp->typedata.swallow->swallow_params.max.w = -1; + rp->typedata.swallow->swallow_params.max.h = -1; + } if (rp->part->type == EDJE_PART_TYPE_TEXT || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) @@ -697,10 +737,14 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g text->text.id_text_source = -1; } - if (text->text.id_source >= 0) - rp->text.source = ed->table_parts[text->text.id_source % ed->table_parts_size]; - if (text->text.id_text_source >= 0) - rp->text.text_source = ed->table_parts[text->text.id_text_source % ed->table_parts_size]; + if ((rp->type == EDJE_RP_TYPE_TEXT) && + (rp->typedata.text)) + { + if (text->text.id_source >= 0) + rp->typedata.text->source = ed->table_parts[text->text.id_source % ed->table_parts_size]; + if (text->text.id_text_source >= 0) + rp->typedata.text->text_source = ed->table_parts[text->text.id_text_source % ed->table_parts_size]; + } if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) { _edje_entry_real_part_init(rp); @@ -881,39 +925,43 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g } else { - pack_it->parent = rp; - - _edje_object_pack_item_hints_set(child_obj, pack_it); - if (pack_it->name) - evas_object_name_set(child_obj, pack_it->name); - - if (rp->part->type == EDJE_PART_TYPE_BOX) - { - _edje_real_part_box_append(rp, child_obj); - evas_object_data_set(child_obj, "\377 edje.box_item", pack_it); - } - else if (rp->part->type == EDJE_PART_TYPE_TABLE) - { - _edje_real_part_table_pack(rp, child_obj, pack_it->col, pack_it->row, pack_it->colspan, pack_it->rowspan); - evas_object_data_set(child_obj, "\377 edje.table_item", pack_it); - } - _edje_subobj_register(ed, child_obj); - evas_object_show(child_obj); - rp->items = eina_list_append(rp->items, child_obj); - - if (item_count > 0) - { - pack_it = *curr_item; - source = pack_it->source; - curr_item++; - item_count--; - } - else - { - source = NULL; - curr_item = NULL; - pack_it = NULL; - } + if ((rp->type == EDJE_RP_TYPE_CONTAINER) && + (rp->typedata.container)) + { + pack_it->parent = rp; + + _edje_object_pack_item_hints_set(child_obj, pack_it); + if (pack_it->name) + evas_object_name_set(child_obj, pack_it->name); + + if (rp->part->type == EDJE_PART_TYPE_BOX) + { + _edje_real_part_box_append(rp, child_obj); + evas_object_data_set(child_obj, "\377 edje.box_item", pack_it); + } + else if (rp->part->type == EDJE_PART_TYPE_TABLE) + { + _edje_real_part_table_pack(rp, child_obj, pack_it->col, pack_it->row, pack_it->colspan, pack_it->rowspan); + evas_object_data_set(child_obj, "\377 edje.table_item", pack_it); + } + _edje_subobj_register(ed, child_obj); + evas_object_show(child_obj); + rp->typedata.container->items = eina_list_append(rp->typedata.container->items, child_obj); + + if (item_count > 0) + { + pack_it = *curr_item; + source = pack_it->source; + curr_item++; + item_count--; + } + else + { + source = NULL; + curr_item = NULL; + pack_it = NULL; + } + } } } } @@ -1227,38 +1275,53 @@ _edje_file_del(Edje *ed) _edje_callbacks_focus_del(rp->object, ed); evas_object_del(rp->object); } - if (rp->swallowed_object) - { - /* Objects swallowed by the app do not get deleted, - but those internally swallowed (GROUP type) do. */ - switch (rp->part->type) - { - case EDJE_PART_TYPE_EXTERNAL: - _edje_external_parsed_params_free(rp->swallowed_object, rp->param1.external_params); - if (rp->param2) - _edje_external_parsed_params_free(rp->swallowed_object, rp->param2->external_params); - case EDJE_PART_TYPE_GROUP: - evas_object_del(rp->swallowed_object); - default: - break; - } - _edje_real_part_swallow_clear(rp); - rp->swallowed_object = NULL; - } - if (rp->items) - { - /* evas_box/table handles deletion of objects */ - rp->items = eina_list_free(rp->items); - } - if (rp->anim) + if ((rp->type == EDJE_RP_TYPE_CONTAINER) && + (rp->typedata.container)) + { + if (rp->typedata.container->items) + { + /* evas_box/table handles deletion of objects */ + rp->typedata.container->items = eina_list_free(rp->typedata.container->items); + } + if (rp->typedata.container->anim) + { + _edje_box_layout_free_data(rp->typedata.container->anim); + rp->typedata.container->anim = NULL; + } + free(rp->typedata.container); + } + else if ((rp->type == EDJE_RP_TYPE_TEXT) && + (rp->typedata.text)) + { + if (rp->typedata.text->text) eina_stringshare_del(rp->typedata.text->text); + if (rp->typedata.text->font) eina_stringshare_del(rp->typedata.text->font); + if (rp->typedata.text->cache.in_str) eina_stringshare_del(rp->typedata.text->cache.in_str); + if (rp->typedata.text->cache.out_str) eina_stringshare_del(rp->typedata.text->cache.out_str); + free(rp->typedata.text); + } + else if ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) { - _edje_box_layout_free_data(rp->anim); - rp->anim = NULL; + if (rp->typedata.swallow->swallowed_object) + { + /* Objects swallowed by the app do not get deleted, + but those internally swallowed (GROUP type) do. */ + switch (rp->part->type) + { + case EDJE_PART_TYPE_EXTERNAL: + _edje_external_parsed_params_free(rp->typedata.swallow->swallowed_object, rp->param1.external_params); + if (rp->param2) + _edje_external_parsed_params_free(rp->typedata.swallow->swallowed_object, rp->param2->external_params); + case EDJE_PART_TYPE_GROUP: + evas_object_del(rp->typedata.swallow->swallowed_object); + default: + break; + } + _edje_real_part_swallow_clear(rp); + rp->typedata.swallow->swallowed_object = NULL; + } + free(rp->typedata.swallow); } - if (rp->text.text) eina_stringshare_del(rp->text.text); - if (rp->text.font) eina_stringshare_del(rp->text.font); - if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str); - if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str); if (rp->custom) { @@ -1281,7 +1344,7 @@ _edje_file_del(Edje *ed) if (rp->custom) free(rp->custom->set); eina_mempool_free(_edje_real_part_state_mp, rp->custom); - + _edje_unref(rp->edje); eina_mempool_free(_edje_real_part_mp, rp); } diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index c4c5191..d4cc4e4 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -325,6 +325,9 @@ typedef struct _Edje_Part_Box_Animation Edje_Part_Box_Animation; typedef struct _Edje_Part_Limit Edje_Part_Limit; typedef struct _Edje Edje; +typedef struct _Edje_Real_Part_Text Edje_Real_Part_Text; +typedef struct _Edje_Real_Part_Swallow Edje_Real_Part_Swallow; +typedef struct _Edje_Real_Part_Container Edje_Real_Part_Container; typedef struct _Edje_Real_Part_State Edje_Real_Part_State; typedef struct _Edje_Real_Part_Drag Edje_Real_Part_Drag; typedef struct _Edje_Real_Part_Set Edje_Real_Part_Set; @@ -1308,75 +1311,86 @@ struct _Edje_Real_Part_Drag Edje_Real_Part *confine_to; // 4 }; // 104 -struct _Edje_Real_Part +#define EDJE_RP_TYPE_NONE 0 +#define EDJE_RP_TYPE_TEXT 1 +#define EDJE_RP_TYPE_CONTAINER 2 +#define EDJE_RP_TYPE_SWALLOW 3 + +struct _Edje_Real_Part_Text +{ + void *entry_data; // 4 + Edje_Real_Part *source; // 4 + Edje_Real_Part *text_source; // 4 + const char *text; // 4 + const char *font; // 4 + const char *style; // 4 + Edje_Position offset; // 8 + short size; // 2 + struct { + unsigned char fit_x, fit_y; // 2 + short in_size; // 2 + short out_size; // 2 + float elipsis; // 4 + Evas_Coord in_w, in_h; // 8 + const char *in_str; // 4 + const char *out_str; // 4 + FLOAT_T align_x, align_y; // 16 + } cache; +}; // 76 +// FIXME make text a potiner to struct and alloc at end +// if part type is TEXT move common members textblock + +// text to front and have smaller struct for textblock + +struct _Edje_Real_Part_Container { - Edje *edje; // 4 - Edje_Part *part; // 4 - Evas_Object *object; // 4 - Evas_Object *nested_smart; // 4 - int x, y, w, h; // 16 - Edje_Rectangle req; // 16 - Eina_List *items; // 4 //FIXME: only if table/box Edje_Part_Box_Animation *anim; // 4 //FIXME: Used only if box - void *entry_data; // 4 // FIXME: move to entry section +}; - Evas_Object *swallowed_object; // 4 // FIXME: move with swallow_params data +struct _Edje_Real_Part_Swallow +{ + Evas_Object *swallowed_object; // 4 // FIXME: move with swallow_params data struct { Edje_Size min, max; // 16 Edje_Aspect aspect; // 12 } swallow_params; // 28 // FIXME: only if type SWALLOW +}; +struct _Edje_Real_Part +{ + Edje *edje; // 4 + Edje_Part *part; // 4 + int x, y, w, h; // 16 + Edje_Rectangle req; // 16 + Evas_Object *object; // 4 + Evas_Object *nested_smart; // 4 Edje_Real_Part_Drag *drag; // 4 Edje_Real_Part *events_to; // 4 - - struct { - Edje_Real_Part *source; // 4 - Edje_Real_Part *text_source; // 4 - const char *text; // 4 - Edje_Position offset; // 8 text only - const char *font; // 4 text only - const char *style; // 4 text only - int size; // 4 text only - struct { - double in_w, in_h; // 16 text only - int in_size; // 4 text only - const char *in_str; // 4 text only - const char *out_str; // 4 text only - int out_size; // 4 text only - FLOAT_T align_x, align_y; // 16 text only - double elipsis; // 8 text only - int fit_x, fit_y; // 8 text only - } cache; // 64 - } text; // 86 // FIXME make text a potiner to struct and alloc at end - // if part type is TEXT move common members textblock + - // text to front and have smaller struct for textblock - FLOAT_T description_pos; // 8 Edje_Part_Description_Common *chosen_description; // 4 - Edje_Real_Part_State param1; // 20 + Edje_Real_Part_State param1; // 32 // WITH EDJE_CALC_CACHE: 140 Edje_Real_Part_State *param2, *custom; // 8 Edje_Calc_Params *current; // 4 - -#ifdef EDJE_CALC_CACHE - int state; // 4 -#endif - Edje_Real_Part *clip_to; // 4 - Edje_Running_Program *program; // 4 - + union { + Edje_Real_Part_Text *text; + Edje_Real_Part_Container *container; + Edje_Real_Part_Swallow *swallow; + } typedata; // 4 int clicked_button; // 4 - +#ifdef EDJE_CALC_CACHE + int state; // 4 +#endif + unsigned char type; // 1 unsigned char calculated; // 1 unsigned char calculating; // 1 - unsigned char still_in : 1; // 1 #ifdef EDJE_CALC_CACHE unsigned char invalidate : 1; // 0 #endif -}; // 268 +}; // 287 -> 126 // WITH EDJE_CALC_CACHE: 404 struct _Edje_Running_Program diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c index ba03720..5ad5140 100644 --- a/src/lib/edje_program.c +++ b/src/lib/edje_program.c @@ -205,8 +205,11 @@ edje_object_play_set(Evas_Object *obj, Eina_Bool play) { Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_play_set(rp->swallowed_object, play); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_play_set(rp->typedata.swallow->swallowed_object, play); } } @@ -272,8 +275,11 @@ edje_object_animation_set(Evas_Object *obj, Eina_Bool on) { Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_animation_set(rp->swallowed_object, on); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_animation_set(rp->typedata.swallow->swallowed_object, on); } _edje_thaw(ed); @@ -771,7 +777,10 @@ _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, for (i = 0; i < ed->table_parts_size; ++i) { rp = ed->table_parts[i]; - if (rp && rp->swallowed_object == focused) + if ((rp) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object == focused)) { evas_object_focus_set(focused, EINA_FALSE); break; @@ -786,8 +795,11 @@ _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, if (pt->id >= 0) { rp = ed->table_parts[pt->id % ed->table_parts_size]; - if (rp && rp->swallowed_object) - evas_object_focus_set(rp->swallowed_object, EINA_TRUE); + if (rp && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + evas_object_focus_set(rp->typedata.swallow->swallowed_object, EINA_TRUE); } } } @@ -956,8 +968,11 @@ _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*f switch (rp->part->type) { case EDJE_PART_TYPE_GROUP: - if (!rp->swallowed_object) goto end; - ed2 = _edje_fetch(rp->swallowed_object); + if (((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) || + (!rp->typedata.swallow->swallowed_object)) + goto end; + ed2 = _edje_fetch(rp->typedata.swallow->swallowed_object); if (!ed2) goto end; _edje_emit(ed2, newsig, src); @@ -965,11 +980,14 @@ _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*f break; case EDJE_PART_TYPE_EXTERNAL: - if (!rp->swallowed_object) break ; + if (((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) || + (!rp->typedata.swallow->swallowed_object)) + break; if (!idx) { - _edje_external_signal_emit(rp->swallowed_object, newsig, src); + _edje_external_signal_emit(rp->typedata.swallow->swallowed_object, newsig, src); } else { @@ -1370,8 +1388,12 @@ _edje_external_param_info_get(const Evas_Object *obj, const char *name) static Edje_External_Param * _edje_param_external_get(Edje_Real_Part *rp, const char *name, Edje_External_Param *param) { - Evas_Object *swallowed_object = rp->swallowed_object; + Evas_Object *swallowed_object; const Edje_External_Param_Info *info; + + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + swallowed_object = rp->typedata.swallow->swallowed_object; info = _edje_external_param_info_get(swallowed_object, name); if (!info) return NULL; @@ -1399,8 +1421,10 @@ _edje_param_native_get(Edje_Real_Part *rp, const char *name, Edje_External_Param _edje_recalc_do(rp->edje); if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) param->s = _edje_entry_text_get(rp); - else if (rp->part->type == EDJE_PART_TYPE_TEXT) - param->s = rp->text.text; + else if ((rp->part->type == EDJE_PART_TYPE_TEXT) && + ((rp->type == EDJE_RP_TYPE_TEXT) && + (rp->typedata.text))) + param->s = rp->typedata.text->text; else param->s = evas_object_textblock_text_markup_get(rp->object); return param; @@ -1420,8 +1444,10 @@ _edje_param_native_get(Edje_Real_Part *rp, const char *name, Edje_External_Param *free_ptr = unescaped; param->s = unescaped; } - else if (rp->part->type == EDJE_PART_TYPE_TEXT) - param->s = rp->text.text; + else if ((rp->part->type == EDJE_PART_TYPE_TEXT) && + ((rp->type == EDJE_RP_TYPE_TEXT) && + (rp->typedata.text))) + param->s = rp->typedata.text->text; else { const char *tmp; @@ -1436,9 +1462,11 @@ _edje_param_native_get(Edje_Real_Part *rp, const char *name, Edje_External_Param return param; } - if ((rp->entry_data) && - (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) && - (!strcmp(name, "select_allow"))) + if (((rp->type == EDJE_RP_TYPE_TEXT) && + (rp->typedata.text)) && + ((rp->typedata.text->entry_data) && + (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) && + (!strcmp(name, "select_allow")))) { param->name = name; param->type = EDJE_EXTERNAL_PARAM_TYPE_BOOL; @@ -1572,9 +1600,11 @@ _edje_param_native_set(Edje_Real_Part *rp, const char *name, const Edje_External return EINA_TRUE; } - if ((rp->entry_data) && - (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) && - (!strcmp(name, "select_allow"))) + if (((rp->type == EDJE_RP_TYPE_TEXT) && + (rp->typedata.text)) && + ((rp->typedata.text->entry_data) && + (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) && + (!strcmp(name, "select_allow")))) { if (param->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL) return EINA_FALSE; @@ -1967,9 +1997,11 @@ _edje_param_copy(Edje_Real_Part *src_part, const char *src_param, Edje_Real_Part if ((!src_part) || (!src_param) || (!dst_part) || (!dst_param)) return; - if (dst_part->part->type == EDJE_PART_TYPE_EXTERNAL) + if ((dst_part->part->type == EDJE_PART_TYPE_EXTERNAL) && + (dst_part->type == EDJE_RP_TYPE_SWALLOW) && + (dst_part->typedata.swallow)) dst_info = _edje_external_param_info_get - (dst_part->swallowed_object, dst_param); + (dst_part->typedata.swallow->swallowed_object, dst_param); else dst_info = _edje_native_param_info_get(dst_part, dst_param); @@ -2050,8 +2082,10 @@ _edje_param_set(Edje_Real_Part *part, const char *param, const char *value) if ((!part) || (!param) || (!value)) return; - if (part->part->type == EDJE_PART_TYPE_EXTERNAL) - info = _edje_external_param_info_get(part->swallowed_object, param); + if ((part->part->type == EDJE_PART_TYPE_EXTERNAL) && + (part->type == EDJE_RP_TYPE_SWALLOW) && + (part->typedata.swallow)) + info = _edje_external_param_info_get(part->typedata.swallow->swallowed_object, param); else info = _edje_native_param_info_get(part, param); diff --git a/src/lib/edje_smart.c b/src/lib/edje_smart.c index 9eb2af2..c3b0b31 100644 --- a/src/lib/edje_smart.c +++ b/src/lib/edje_smart.c @@ -202,17 +202,27 @@ _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y) for (i = 0; i < ed->table_parts_size; i++) { Edje_Real_Part *ep; - Evas_Coord ox, oy; ep = ed->table_parts[i]; - evas_object_geometry_get(ep->object, &ox, &oy, NULL, NULL); - evas_object_move(ep->object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y); + if ((ep->type == EDJE_RP_TYPE_TEXT) && + (ep->typedata.text)) + evas_object_move(ep->object, + ed->x + ep->x + ep->typedata.text->offset.x, + ed->y + ep->y + ep->typedata.text->offset.y); + else + evas_object_move(ep->object, + ed->x + ep->x, + ed->y + ep->y); if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) _edje_entry_real_part_configure(ep); - if (ep->swallowed_object) + if ((ep->type == EDJE_RP_TYPE_SWALLOW) && + (ep->typedata.swallow)) { - evas_object_geometry_get(ep->swallowed_object, &ox, &oy, NULL, NULL); - evas_object_move(ep->swallowed_object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y); + if (ep->typedata.swallow->swallowed_object) + evas_object_move + (ep->typedata.swallow->swallowed_object, + ed->x + ep->x, + ed->y + ep->y); } } } diff --git a/src/lib/edje_text.c b/src/lib/edje_text.c index 8d81159..700154c 100644 --- a/src/lib/edje_text.c +++ b/src/lib/edje_text.c @@ -346,27 +346,29 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, int inlined_font = 0, free_text = 0; Eina_Bool same_text = EINA_FALSE; FLOAT_T sc; - + + if ((ep->type != EDJE_RP_TYPE_TEXT) || + (!ep->typedata.text)) return; sc = ed->scale; if (sc == 0.0) sc = _edje_scale; text = edje_string_get(&chosen_desc->text.text); font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); - 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; + if (ep->typedata.text->text) text = ep->typedata.text->text; + if (ep->typedata.text->font) font = ep->typedata.text->font; + if (ep->typedata.text->size > 0) size = ep->typedata.text->size; - if (ep->text.text_source) + if (ep->typedata.text->text_source) { - text = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text)); - if (ep->text.text_source->text.text) text = ep->text.text_source->text.text; + text = edje_string_get(&(((Edje_Part_Description_Text *)ep->typedata.text->text_source->chosen_description)->text.text)); + if (ep->typedata.text->text_source->typedata.text->text) text = ep->typedata.text->text_source->typedata.text->text; } - if (ep->text.source) + if (ep->typedata.text->source) { - font = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.font)); - size = ((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.size; - if (ep->text.source->text.font) font = ep->text.source->text.font; - if (ep->text.source->text.size > 0) size = ep->text.source->text.size; + font = edje_string_get(&(((Edje_Part_Description_Text *)ep->typedata.text->source->chosen_description)->text.font)); + size = ((Edje_Part_Description_Text *)ep->typedata.text->source->chosen_description)->text.size; + if (ep->typedata.text->source->typedata.text->font) font = ep->typedata.text->source->typedata.text->font; + if (ep->typedata.text->source->typedata.text->size > 0) size = ep->typedata.text->source->typedata.text->size; } if (!text) text = ""; @@ -410,35 +412,35 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, size = params->type.text.size; if (!text) text = ""; - if ((text == ep->text.cache.in_str) - || (text && ep->text.cache.in_str && !strcmp(ep->text.cache.in_str, text))) + if ((text == ep->typedata.text->cache.in_str) + || (text && ep->typedata.text->cache.in_str && !strcmp(ep->typedata.text->cache.in_str, text))) { - text = ep->text.cache.in_str; + text = ep->typedata.text->cache.in_str; same_text = EINA_TRUE; } - if ((ep->text.cache.in_size == size) && - (ep->text.cache.in_w == sw) && - (ep->text.cache.in_h == sh) && - (ep->text.cache.in_str) && + if ((ep->typedata.text->cache.in_size == size) && + (ep->typedata.text->cache.in_w == sw) && + (ep->typedata.text->cache.in_h == sh) && + (ep->typedata.text->cache.in_str) && same_text && - (ep->text.cache.align_x == params->type.text.align.x) && - (ep->text.cache.align_y == params->type.text.align.y) && - (ep->text.cache.elipsis == params->type.text.elipsis) && - (ep->text.cache.fit_x == chosen_desc->text.fit_x) && - (ep->text.cache.fit_y == chosen_desc->text.fit_y)) + (ep->typedata.text->cache.align_x == params->type.text.align.x) && + (ep->typedata.text->cache.align_y == params->type.text.align.y) && + (ep->typedata.text->cache.elipsis == params->type.text.elipsis) && + (ep->typedata.text->cache.fit_x == chosen_desc->text.fit_x) && + (ep->typedata.text->cache.fit_y == chosen_desc->text.fit_y)) { - text = ep->text.cache.out_str; - size = ep->text.cache.out_size; + text = ep->typedata.text->cache.out_str; + size = ep->typedata.text->cache.out_size; goto arrange_text; } if (!same_text) { - eina_stringshare_replace(&ep->text.cache.in_str, text); + eina_stringshare_replace(&ep->typedata.text->cache.in_str, text); } - ep->text.cache.in_size = size; - if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) + ep->typedata.text->cache.in_size = size; + if (chosen_desc->text.fit_x && (ep->typedata.text->cache.in_str && eina_stringshare_strlen(ep->typedata.text->cache.in_str) > 0)) { if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); else evas_object_text_font_source_set(ep->object, NULL); @@ -464,7 +466,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, * but it's still way better than what was here before. */ if (tw > sw) size--; } - if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) + if (chosen_desc->text.fit_y && (ep->typedata.text->cache.in_str && eina_stringshare_strlen(ep->typedata.text->cache.in_str) > 0)) { /* if we fit in the x axis, too, size already has a somewhat * meaningful value, so don't overwrite it with the starting @@ -567,15 +569,15 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, text = _edje_text_fit_x(ed, ep, params, text, font, size, sw, &free_text); } - eina_stringshare_replace(&ep->text.cache.out_str, text); - ep->text.cache.in_w = sw; - ep->text.cache.in_h = sh; - ep->text.cache.out_size = size; - ep->text.cache.align_x = params->type.text.align.x; - ep->text.cache.align_y = params->type.text.align.y; - ep->text.cache.elipsis = params->type.text.elipsis; - ep->text.cache.fit_x = chosen_desc->text.fit_x; - ep->text.cache.fit_y = chosen_desc->text.fit_y; + eina_stringshare_replace(&ep->typedata.text->cache.out_str, text); + ep->typedata.text->cache.in_w = sw; + ep->typedata.text->cache.in_h = sh; + ep->typedata.text->cache.out_size = size; + ep->typedata.text->cache.align_x = params->type.text.align.x; + ep->typedata.text->cache.align_y = params->type.text.align.y; + ep->typedata.text->cache.elipsis = params->type.text.elipsis; + ep->typedata.text->cache.fit_x = chosen_desc->text.fit_x; + ep->typedata.text->cache.fit_y = chosen_desc->text.fit_y; arrange_text: if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); @@ -604,13 +606,13 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, { align_x = params->type.text.align.x; } - ep->text.offset.x = TO_INT(SCALE(align_x, (sw - tw))); - ep->text.offset.y = TO_INT(SCALE(params->type.text.align.y, (sh - th))); + ep->typedata.text->offset.x = TO_INT(SCALE(align_x, (sw - tw))); + ep->typedata.text->offset.y = TO_INT(SCALE(params->type.text.align.y, (sh - th))); } evas_object_move(ep->object, - ed->x + params->x + ep->text.offset.x, - ed->y + params->y + ep->text.offset.y); + ed->x + params->x + ep->typedata.text->offset.x, + ed->y + params->y + ep->typedata.text->offset.y); if (params->visible) evas_object_show(ep->object); else evas_object_hide(ep->object); diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index 295df7d..442d88e 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -94,11 +94,15 @@ _edje_user_definition_free(Edje_User_Defined *eud) if (rp) { _edje_real_part_swallow_clear(rp); - rp->swallowed_object = NULL; - rp->swallow_params.min.w = 0; - rp->swallow_params.min.h = 0; - rp->swallow_params.max.w = 0; - rp->swallow_params.max.h = 0; + if ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) + { + rp->typedata.swallow->swallowed_object = NULL; + rp->typedata.swallow->swallow_params.min.w = 0; + rp->typedata.swallow->swallow_params.min.h = 0; + rp->typedata.swallow->swallow_params.max.w = 0; + rp->typedata.swallow->swallow_params.max.h = 0; + } rp->edje->dirty = EINA_TRUE; rp->edje->recalc_call = EINA_TRUE; #ifdef EDJE_CALC_CACHE @@ -253,11 +257,14 @@ _edje_thaw_edje(Edje *ed) Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) { Edje *ed2; - ed2 = _edje_fetch(rp->swallowed_object); + ed2 = _edje_fetch(rp->typedata.swallow->swallowed_object); if (ed2) _edje_thaw_edje(ed2); } } @@ -438,8 +445,11 @@ edje_object_freeze(Evas_Object *obj) { Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_freeze(rp->swallowed_object); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_freeze(rp->typedata.swallow->swallowed_object); } return _edje_freeze(ed); } @@ -457,8 +467,11 @@ edje_object_thaw(Evas_Object *obj) Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_thaw(rp->swallowed_object); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_thaw(rp->typedata.swallow->swallowed_object); } return _edje_thaw(ed); } @@ -704,8 +717,12 @@ edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, in Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_color_class_set(rp->swallowed_object, color_class, + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_color_class_set(rp->typedata.swallow->swallowed_object, + color_class, r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3); } @@ -763,8 +780,11 @@ edje_object_color_class_del(Evas_Object *obj, const char *color_class) Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_color_class_del(rp->swallowed_object, color_class); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_color_class_del(rp->typedata.swallow->swallowed_object, color_class); } ed->dirty = EINA_TRUE; @@ -939,9 +959,12 @@ edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char Edje_Real_Part *rp; rp = ed->table_parts[i]; - if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) - edje_object_text_class_set(rp->swallowed_object, text_class, - font, size); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_text_class_set(rp->typedata.swallow->swallowed_object, + text_class, font, size); } ed->dirty = EINA_TRUE; @@ -1047,28 +1070,33 @@ edje_object_text_change_cb_set(Evas_Object *obj, Edje_Text_Change_Cb func, void Edje_Real_Part *rp; rp = ed->table_parts[i]; - if ((rp->part->type == EDJE_PART_TYPE_GROUP) && (rp->swallowed_object)) - edje_object_text_change_cb_set(rp->swallowed_object, func, data); + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + edje_object_text_change_cb_set(rp->typedata.swallow->swallowed_object, func, data); } } Eina_Bool _edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) { - if ((!rp->text.text) && (!text)) + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_TRUE; + if ((!rp->typedata.text->text) && (!text)) return EINA_TRUE; /* nothing to do, no error */ - if ((rp->text.text) && (text) && - (!strcmp(rp->text.text, text))) + if ((rp->typedata.text->text) && (text) && + (!strcmp(rp->typedata.text->text, text))) return EINA_TRUE; /* nothing to do, no error */ - if (rp->text.text) + if (rp->typedata.text->text) { - eina_stringshare_del(rp->text.text); - rp->text.text = NULL; + eina_stringshare_del(rp->typedata.text->text); + rp->typedata.text->text = NULL; } if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) _edje_entry_text_markup_set(rp, text); else - if (text) rp->text.text = eina_stringshare_add(text); + if (text) rp->typedata.text->text = eina_stringshare_add(text); rp->edje->dirty = EINA_TRUE; rp->edje->recalc_call = EINA_TRUE; rp->edje->recalc_hints = EINA_TRUE; @@ -1084,25 +1112,27 @@ _edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char Eina_Bool _edje_object_part_text_raw_append(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) { + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_TRUE; if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) _edje_entry_text_markup_append(rp, text); else if (text) { - if (rp->text.text) + if (rp->typedata.text->text) { char *new = NULL; int len_added = strlen(text); - int len_old = strlen(rp->text.text); + int len_old = strlen(rp->typedata.text->text); new = malloc(len_old + len_added + 1); - memcpy(new, rp->text.text, len_old); + memcpy(new, rp->typedata.text->text, len_old); memcpy(new + len_old, text, len_added); new[len_old + len_added] = '\0'; - eina_stringshare_replace(&rp->text.text, new); + eina_stringshare_replace(&rp->typedata.text->text, new); free(new); } else { - eina_stringshare_replace(&rp->text.text, text); + eina_stringshare_replace(&rp->typedata.text->text, text); } } rp->edje->dirty = EINA_TRUE; @@ -1184,7 +1214,7 @@ edje_object_part_text_style_user_peek(const Evas_Object *obj, const char *part) static void _edje_user_define_string(Edje *ed, const char *part, const char *raw_text) { - /* NOTE: This one is tricky, text is referenced in rp->text.text for the life of the + /* NOTE: This one is tricky, text is referenced in rp->typedata.text->text for the life of the rp. So on edje_object_file_set, we should first ref it, before destroying the old layout. */ Edje_User_Defined *eud; @@ -1220,8 +1250,10 @@ edje_object_part_text_set(Evas_Object *obj, const char *part, const char *text) if (!rp) return EINA_FALSE; if ((rp->part->type != EDJE_PART_TYPE_TEXT) && (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return EINA_FALSE; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_TRUE; r = _edje_object_part_text_raw_set(obj, rp, part, text); - _edje_user_define_string(ed, part, rp->text.text); + _edje_user_define_string(ed, part, rp->typedata.text->text); return r; } @@ -1239,11 +1271,14 @@ edje_object_part_text_get(const Evas_Object *obj, const char *part) rp = _edje_real_part_recursive_get(ed, part); if (!rp) return NULL; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) return _edje_entry_text_get(rp); else { - if (rp->part->type == EDJE_PART_TYPE_TEXT) return rp->text.text; + if (rp->part->type == EDJE_PART_TYPE_TEXT) + return rp->typedata.text->text; if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) return evas_object_textblock_text_markup_get(rp->object); } @@ -1261,6 +1296,8 @@ edje_object_part_text_escaped_set(Evas_Object *obj, const char *part, const char if ((!ed) || (!part)) return EINA_FALSE; rp = _edje_real_part_recursive_get(ed, part); if (!rp) return EINA_FALSE; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; if ((rp->part->type == EDJE_PART_TYPE_TEXT) && (text)) { Eina_Strbuf *sbuf; @@ -1313,13 +1350,13 @@ edje_object_part_text_escaped_set(Evas_Object *obj, const char *part, const char } ret = _edje_object_part_text_raw_set (obj, rp, part, eina_strbuf_string_get(sbuf)); - _edje_user_define_string(ed, part, rp->text.text); + _edje_user_define_string(ed, part, rp->typedata.text->text); eina_strbuf_free(sbuf); return ret; } if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return EINA_FALSE; ret = _edje_object_part_text_raw_set(obj, rp, part, text); - _edje_user_define_string(ed, part, rp->text.text); + _edje_user_define_string(ed, part, rp->typedata.text->text); return ret; } @@ -1443,6 +1480,8 @@ edje_object_part_text_unescaped_set(Evas_Object *obj, const char *part, const ch if ((!ed) || (!part)) return ret; rp = _edje_real_part_recursive_get(ed, part); if (!rp) return ret; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; if (rp->part->type == EDJE_PART_TYPE_TEXT) ret = _edje_object_part_text_raw_set(obj, rp, part, text_to_escape); else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) @@ -1452,7 +1491,7 @@ edje_object_part_text_unescaped_set(Evas_Object *obj, const char *part, const ch ret = _edje_object_part_text_raw_set(obj, rp, part, text); free(text); } - _edje_user_define_string(ed, part, rp->text.text); + _edje_user_define_string(ed, part, rp->typedata.text->text); return ret; } @@ -1470,6 +1509,8 @@ edje_object_part_text_unescaped_get(const Evas_Object *obj, const char *part) rp = _edje_real_part_recursive_get(ed, part); if (!rp) return NULL; + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return NULL; if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) { const char *t = _edje_entry_text_get(rp); @@ -1477,7 +1518,7 @@ edje_object_part_text_unescaped_get(const Evas_Object *obj, const char *part) } else { - if (rp->part->type == EDJE_PART_TYPE_TEXT) return strdup(rp->text.text); + if (rp->part->type == EDJE_PART_TYPE_TEXT) return strdup(rp->typedata.text->text); if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) { const char *t = evas_object_textblock_text_markup_get(rp->object); @@ -2472,9 +2513,11 @@ edje_object_part_swallow(Evas_Object *obj, const char *part, Evas_Object *obj_sw ERR("cannot swallow part %s: not swallow type!", rp->part->name); return EINA_FALSE; } + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return EINA_FALSE; _edje_real_part_swallow(rp, obj_swallow, EINA_TRUE); - if (rp->swallowed_object) + if (rp->typedata.swallow->swallowed_object) { if (!eud) { @@ -2515,8 +2558,10 @@ edje_extern_object_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord mi rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); if (rp) { - rp->swallow_params.min.w = minw; - rp->swallow_params.min.h = minh; + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; + rp->typedata.swallow->swallow_params.min.w = minw; + rp->typedata.swallow->swallow_params.min.h = minh; _recalc_extern_parent(obj); } @@ -2531,8 +2576,10 @@ edje_extern_object_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord ma rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); if (rp) { - rp->swallow_params.max.w = maxw; - rp->swallow_params.max.h = maxh; + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; + rp->typedata.swallow->swallow_params.max.w = maxw; + rp->typedata.swallow->swallow_params.max.h = maxh; _recalc_extern_parent(obj); } @@ -2560,9 +2607,11 @@ edje_extern_object_aspect_set(Evas_Object *obj, Edje_Aspect_Control aspect, Evas rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); if (rp) { - rp->swallow_params.aspect.mode = aspect; - rp->swallow_params.aspect.w = aw; - rp->swallow_params.aspect.h = ah; + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; + rp->typedata.swallow->swallow_params.aspect.mode = aspect; + rp->typedata.swallow->swallow_params.aspect.w = aw; + rp->typedata.swallow->swallow_params.aspect.h = ah; _recalc_extern_parent(obj); } } @@ -2770,8 +2819,11 @@ edje_object_part_unswallow(Evas_Object *obj, Evas_Object *obj_swallow) ERR("cannot unswallow part %s: not swallow type!", rp->part->name); return; } + + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; - if (rp->swallowed_object == obj_swallow) + if (rp->typedata.swallow->swallowed_object == obj_swallow) { Edje_User_Defined *eud; Eina_List *l; @@ -2798,11 +2850,11 @@ edje_object_part_unswallow(Evas_Object *obj, Evas_Object *obj_swallow) } _edje_real_part_swallow_clear(rp); - rp->swallowed_object = NULL; - rp->swallow_params.min.w = 0; - rp->swallow_params.min.h = 0; - rp->swallow_params.max.w = 0; - rp->swallow_params.max.h = 0; + rp->typedata.swallow->swallowed_object = NULL; + rp->typedata.swallow->swallow_params.min.w = 0; + rp->typedata.swallow->swallow_params.min.h = 0; + rp->typedata.swallow->swallow_params.max.w = 0; + rp->typedata.swallow->swallow_params.max.h = 0; rp->edje->dirty = EINA_TRUE; rp->edje->recalc_call = EINA_TRUE; #ifdef EDJE_CALC_CACHE @@ -2827,7 +2879,9 @@ edje_object_part_swallow_get(const Evas_Object *obj, const char *part) rp = _edje_real_part_recursive_get(ed, part); if (!rp) return NULL; - return rp->swallowed_object; + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + return rp->typedata.swallow->swallowed_object; } EAPI void @@ -4378,8 +4432,11 @@ edje_object_preload(Evas_Object *obj, Eina_Bool cancel) rp = ed->table_parts[i]; ep = rp->part; - if (ep->type == EDJE_PART_TYPE_IMAGE || - (ep->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)) + if ((ep->type == EDJE_PART_TYPE_IMAGE) || + ((ep->type == EDJE_PART_TYPE_GROUP) && + ((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object))) count++; } @@ -4416,23 +4473,25 @@ edje_object_preload(Evas_Object *obj, Eina_Bool cancel) } else if (ep->type == EDJE_PART_TYPE_GROUP) { - if (rp->swallowed_object) { - char *tmp; - - if (rp->part->name) - { - tmp = alloca(strlen(rp->part->name) + 2); - sprintf(tmp, "%s:", rp->part->name); - - edje_object_signal_callback_del(obj, EDJE_PRELOAD_EMISSION, tmp, _edje_object_signal_preload_cb); - edje_object_signal_callback_add(obj, EDJE_PRELOAD_EMISSION, tmp, _edje_object_signal_preload_cb, ed); - edje_object_preload(rp->swallowed_object, cancel); - } - else - { - ed->preload_count--; - } - + if (((rp->type == EDJE_RP_TYPE_SWALLOW) && + (rp->typedata.swallow)) && + (rp->typedata.swallow->swallowed_object)) + { + char *tmp; + + if (rp->part->name) + { + tmp = alloca(strlen(rp->part->name) + 2); + sprintf(tmp, "%s:", rp->part->name); + + edje_object_signal_callback_del(obj, EDJE_PRELOAD_EMISSION, tmp, _edje_object_signal_preload_cb); + edje_object_signal_callback_add(obj, EDJE_PRELOAD_EMISSION, tmp, _edje_object_signal_preload_cb, ed); + edje_object_preload(rp->typedata.swallow->swallowed_object, cancel); + } + else + { + ed->preload_count--; + } count--; } } @@ -4546,7 +4605,10 @@ _edje_children_get(Edje_Real_Part *rp, const char *partid) switch (rp->part->type) { case EDJE_PART_TYPE_EXTERNAL: - return _edje_external_content_get(rp->swallowed_object, partid); + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + return _edje_external_content_get + (rp->typedata.swallow->swallowed_object, partid); case EDJE_PART_TYPE_BOX: l = evas_object_box_children_get(rp->object); break; @@ -4655,8 +4717,10 @@ _edje_real_part_recursive_get_helper(const Edje *ed, char **path) switch (rp->part->type) { case EDJE_PART_TYPE_GROUP: - if (!rp->swallowed_object) return NULL; - ed = _edje_fetch(rp->swallowed_object); + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + if (!rp->typedata.swallow->swallowed_object) return NULL; + ed = _edje_fetch(rp->typedata.swallow->swallowed_object); if (!ed) return NULL; path++; return _edje_real_part_recursive_get_helper(ed, path); @@ -4935,72 +4999,74 @@ _edje_real_part_swallow_hints_update(Edje_Real_Part *rp) { const char *type; - type = evas_object_type_get(rp->swallowed_object); + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; + type = evas_object_type_get(rp->typedata.swallow->swallowed_object); - rp->swallow_params.min.w = 0; - rp->swallow_params.min.h = 0; - rp->swallow_params.max.w = -1; - rp->swallow_params.max.h = -1; + rp->typedata.swallow->swallow_params.min.w = 0; + rp->typedata.swallow->swallow_params.min.h = 0; + rp->typedata.swallow->swallow_params.max.w = -1; + rp->typedata.swallow->swallow_params.max.h = -1; if ((type) && (!strcmp(type, "edje"))) { Evas_Coord w, h; #if 0 - edje_object_size_min_get(rp->swallowed_object, &w, &h); - rp->swallow_params.min.w = w; - rp->swallow_params.min.h = h; + edje_object_size_min_get(rp->typedata.swallow->swallowed_object, &w, &h); + rp->typedata.swallow->swallow_params.min.w = w; + rp->typedata.swallow->swallow_params.min.h = h; #endif - edje_object_size_max_get(rp->swallowed_object, &w, &h); - rp->swallow_params.max.w = w; - rp->swallow_params.max.h = h; + edje_object_size_max_get(rp->typedata.swallow->swallowed_object, &w, &h); + rp->typedata.swallow->swallow_params.max.w = w; + rp->typedata.swallow->swallow_params.max.h = h; } else if ((type) && ((!strcmp(type, "text")) || (!strcmp(type, "polygon")) || (!strcmp(type, "line")))) { Evas_Coord w, h; - evas_object_geometry_get(rp->swallowed_object, NULL, NULL, &w, &h); + evas_object_geometry_get(rp->typedata.swallow->swallowed_object, NULL, NULL, &w, &h); #if 0 - rp->swallow_params.min.w = w; - rp->swallow_params.min.h = h; + rp->typedata.swallow->swallow_params.min.w = w; + rp->typedata.swallow->swallow_params.min.h = h; #endif - rp->swallow_params.max.w = w; - rp->swallow_params.max.h = h; + rp->typedata.swallow->swallow_params.max.w = w; + rp->typedata.swallow->swallow_params.max.h = h; } { Evas_Coord w1, h1, w2, h2, aw, ah; Evas_Aspect_Control am; - evas_object_size_hint_min_get(rp->swallowed_object, &w1, &h1); - evas_object_size_hint_max_get(rp->swallowed_object, &w2, &h2); - evas_object_size_hint_aspect_get(rp->swallowed_object, &am, &aw, &ah); - rp->swallow_params.min.w = w1; - rp->swallow_params.min.h = h1; - if (w2 > 0) rp->swallow_params.max.w = w2; - if (h2 > 0) rp->swallow_params.max.h = h2; + evas_object_size_hint_min_get(rp->typedata.swallow->swallowed_object, &w1, &h1); + evas_object_size_hint_max_get(rp->typedata.swallow->swallowed_object, &w2, &h2); + evas_object_size_hint_aspect_get(rp->typedata.swallow->swallowed_object, &am, &aw, &ah); + rp->typedata.swallow->swallow_params.min.w = w1; + rp->typedata.swallow->swallow_params.min.h = h1; + if (w2 > 0) rp->typedata.swallow->swallow_params.max.w = w2; + if (h2 > 0) rp->typedata.swallow->swallow_params.max.h = h2; switch (am) { case EVAS_ASPECT_CONTROL_NONE: - rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NONE; + rp->typedata.swallow->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NONE; break; case EVAS_ASPECT_CONTROL_NEITHER: - rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NEITHER; + rp->typedata.swallow->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NEITHER; break; case EVAS_ASPECT_CONTROL_HORIZONTAL: - rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_HORIZONTAL; + rp->typedata.swallow->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_HORIZONTAL; break; case EVAS_ASPECT_CONTROL_VERTICAL: - rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_VERTICAL; + rp->typedata.swallow->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_VERTICAL; break; case EVAS_ASPECT_CONTROL_BOTH: - rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_BOTH; + rp->typedata.swallow->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_BOTH; break; default: break; } - rp->swallow_params.aspect.w = aw; - rp->swallow_params.aspect.h = ah; - evas_object_data_set(rp->swallowed_object, "\377 edje.swallowing_part", rp); + rp->typedata.swallow->swallow_params.aspect.w = aw; + rp->typedata.swallow->swallow_params.aspect.h = ah; + evas_object_data_set(rp->typedata.swallow->swallowed_object, "\377 edje.swallowing_part", rp); } #ifdef EDJE_CALC_CACHE @@ -5026,19 +5092,22 @@ _edje_object_part_swallow_image_resize_cb(void *data, Evas *e __UNUSED__, Evas_O { Edje_Real_Part *rp = data; Evas_Coord w, h; + Evas_Map *map; if (!rp->chosen_description->map.on) return; - Evas_Map *map = (Evas_Map *) evas_object_map_get(rp->swallowed_object); + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; + map = (Evas_Map *)evas_object_map_get(rp->typedata.swallow->swallowed_object); if (!map) return; - evas_object_image_size_get(rp->swallowed_object, &w, &h); + evas_object_image_size_get(rp->typedata.swallow->swallowed_object, &w, &h); evas_map_point_image_uv_set(map, 0, 0, 0); evas_map_point_image_uv_set(map, 1, w, 0); evas_map_point_image_uv_set(map, 2, w, h); evas_map_point_image_uv_set(map, 3, 0, h); - evas_object_map_set(rp->swallowed_object, map); + evas_object_map_set(rp->typedata.swallow->swallowed_object, map); } void @@ -5046,11 +5115,13 @@ _edje_real_part_swallow(Edje_Real_Part *rp, Evas_Object *obj_swallow, Eina_Bool hints_update) { - if (rp->swallowed_object) + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return; + if (rp->typedata.swallow->swallowed_object) { - if (rp->swallowed_object != obj_swallow) + if (rp->typedata.swallow->swallowed_object != obj_swallow) { - edje_object_part_unswallow(rp->edje->obj, rp->swallowed_object); + edje_object_part_unswallow(rp->edje->obj, rp->typedata.swallow->swallowed_object); } else { @@ -5067,23 +5138,23 @@ _edje_real_part_swallow(Edje_Real_Part *rp, rp->invalidate = 1; #endif if (!obj_swallow) return; - rp->swallowed_object = obj_swallow; - evas_object_smart_member_add(rp->swallowed_object, rp->edje->obj); + rp->typedata.swallow->swallowed_object = obj_swallow; + evas_object_smart_member_add(rp->typedata.swallow->swallowed_object, rp->edje->obj); if (rp->clip_to) - evas_object_clip_set(rp->swallowed_object, rp->clip_to->object); - else evas_object_clip_set(rp->swallowed_object, rp->edje->base.clipper); - evas_object_stack_above(rp->swallowed_object, rp->object); - evas_object_event_callback_add(rp->swallowed_object, + evas_object_clip_set(rp->typedata.swallow->swallowed_object, rp->clip_to->object); + else evas_object_clip_set(rp->typedata.swallow->swallowed_object, rp->edje->base.clipper); + evas_object_stack_above(rp->typedata.swallow->swallowed_object, rp->object); + evas_object_event_callback_add(rp->typedata.swallow->swallowed_object, EVAS_CALLBACK_DEL, _edje_object_part_swallow_free_cb, rp); - evas_object_event_callback_add(rp->swallowed_object, + evas_object_event_callback_add(rp->typedata.swallow->swallowed_object, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _edje_object_part_swallow_changed_hints_cb, rp); //If the map is enabled, uv should be updated when image size is changed. - if (!strcmp(evas_object_type_get(rp->swallowed_object), "image")) + if (!strcmp(evas_object_type_get(rp->typedata.swallow->swallowed_object), "image")) evas_object_event_callback_add(obj_swallow, EVAS_CALLBACK_IMAGE_RESIZE, _edje_object_part_swallow_image_resize_cb, rp); @@ -5102,7 +5173,7 @@ _edje_real_part_swallow(Edje_Real_Part *rp, } else evas_object_pass_events_set(obj_swallow, 1); - _edje_callbacks_focus_add(rp->swallowed_object, rp->edje, rp); + _edje_callbacks_focus_add(rp->typedata.swallow->swallowed_object, rp->edje, rp); if (rp->part->precise_is_inside) evas_object_precise_is_inside_set(obj_swallow, 1); @@ -5116,27 +5187,29 @@ _edje_real_part_swallow(Edje_Real_Part *rp, void _edje_real_part_swallow_clear(Edje_Real_Part *rp) { - if (!rp->swallowed_object) return ; - evas_object_smart_member_del(rp->swallowed_object); - evas_object_event_callback_del_full(rp->swallowed_object, + if ((rp->type != EDJE_RP_TYPE_SWALLOW) || + (!rp->typedata.swallow)) return NULL; + if (!rp->typedata.swallow->swallowed_object) return; + evas_object_smart_member_del(rp->typedata.swallow->swallowed_object); + evas_object_event_callback_del_full(rp->typedata.swallow->swallowed_object, EVAS_CALLBACK_DEL, _edje_object_part_swallow_free_cb, rp); - evas_object_event_callback_del_full(rp->swallowed_object, + evas_object_event_callback_del_full(rp->typedata.swallow->swallowed_object, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _edje_object_part_swallow_changed_hints_cb, rp); - if (!strcmp(evas_object_type_get(rp->swallowed_object), "image")) - evas_object_event_callback_del_full(rp->swallowed_object, + if (!strcmp(evas_object_type_get(rp->typedata.swallow->swallowed_object), "image")) + evas_object_event_callback_del_full(rp->typedata.swallow->swallowed_object, EVAS_CALLBACK_IMAGE_RESIZE, _edje_object_part_swallow_image_resize_cb, rp); - evas_object_clip_unset(rp->swallowed_object); - evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); + evas_object_clip_unset(rp->typedata.swallow->swallowed_object); + evas_object_data_del(rp->typedata.swallow->swallowed_object, "\377 edje.swallowing_part"); if (rp->part->mouse_events) - _edje_callbacks_del(rp->swallowed_object, rp->edje); - _edje_callbacks_focus_del(rp->swallowed_object, rp->edje); - rp->swallowed_object = NULL; + _edje_callbacks_del(rp->typedata.swallow->swallowed_object, rp->edje); + _edje_callbacks_focus_del(rp->typedata.swallow->swallowed_object, rp->edje); + rp->typedata.swallow->swallowed_object = NULL; } static void -- 2.7.4