From 811c97eabb72f001d0cdb971c5cd9df54700b39c Mon Sep 17 00:00:00 2001 From: Vyacheslav Reutskiy Date: Thu, 19 Dec 2013 15:33:53 +0900 Subject: [PATCH] edje: edje_edit - adding getter and setter for text source This commit will add API for working with text source. There are two functions will be added: 1. edje_edit_state_text_source_get 2. edje_edit_state_text_source_set Reviewers: cedric, seoz, raster CC: cedric Differential Revision: https://phab.enlightenment.org/D389 Signed-off-by: Cedric BAIL --- src/lib/edje/Edje_Edit.h | 27 +++++++++++++++++++++++++++ src/lib/edje/edje_edit.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 5d38a6c255..a264260a35 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -2706,6 +2706,33 @@ edje_edit_state_text_style_get(Evas_Object *obj, const char *part, const char *s EAPI Eina_Bool edje_edit_state_text_style_set(Evas_Object *obj, const char *part, const char *state, double value, const char *style); +/** Get part name, which used as text source. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the the maximum vertical size of + * the container to be equal (not including the state value). + * + * @return The name of part or NULL, if text_source param not a setted. + */ +EAPI const char * +edje_edit_state_text_source_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the source text part for a given part. + * Causes the part to display the text content of another part and update them + * as they change. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the the maximum vertical size of + * the container to be equal (not including the state value). + * @param source The text source part name. + * + * @return EINA_TRUE if successful, EINA_FALSE - otherwise. + */ +EAPI Eina_Bool +edje_edit_state_text_source_set(Evas_Object *obj, const char *part, const char *state, double value, const char *source); + /** Get the list of all the fonts in the given edje. * * Use edje_edit_string_list_free() when you don't need the list anymore. diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 6c8f19a50f..edf558f138 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -4652,6 +4652,46 @@ edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect e return EINA_TRUE; } +EAPI const char * +edje_edit_state_text_source_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Real_Part *rel; + + GET_PD_OR_RETURN(NULL); + + if ((rp->part->type == EDJE_PART_TYPE_TEXT) || + (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + Edje_Part_Description_Text *txt; + txt = (Edje_Part_Description_Text *) pd; + if (txt->text.id_text_source == -1) return NULL; + rel = ed->table_parts[txt->text.id_text_source % ed->table_parts_size]; + if (rel->part->name) return eina_stringshare_add(rel->part->name); + } + + return NULL; +} + +EAPI Eina_Bool +edje_edit_state_text_source_set(Evas_Object *obj, const char *part, const char *state, double value, const char *source) +{ + Edje_Part_Description_Text *txt; + int id_text_source; + GET_PD_OR_RETURN(EINA_FALSE); + if (!source) return EINA_FALSE; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) || + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return EINA_FALSE; + + txt = (Edje_Part_Description_Text *) pd; + id_text_source = _edje_part_id_find(ed, source); + txt->text.id_text_source = id_text_source; + + /* need to recalc, because the source part can has a text */ + edje_object_calc_force(obj); + return EINA_TRUE; +} /****************/ /* IMAGES API */ /****************/