From: Enlightenment S. <no-...@en...> - 2010-11-24 15:27:02
|
Log: Use mempools to create parts Author: sachiel Date: 2010-11-24 07:26:54 -0800 (Wed, 24 Nov 2010) New Revision: 54933 Modified: trunk/edje/src/lib/edje_edit.c Modified: trunk/edje/src/lib/edje_edit.c =================================================================== --- trunk/edje/src/lib/edje_edit.c 2010-11-24 14:59:24 UTC (rev 54932) +++ trunk/edje/src/lib/edje_edit.c 2010-11-24 15:26:54 UTC (rev 54933) @@ -1964,17 +1964,21 @@ if (_edje_real_part_get(ed, name)) return EINA_FALSE; + ce = eina_hash_find(ed->file->collection, ed->group); + /* Alloc Edje_Part or return */ - ep = _alloc(sizeof(Edje_Part)); + ep = eina_mempool_malloc(ce->mp.part, sizeof(Edje_Part)); if (!ep) return EINA_FALSE; + memset(ep, 0, sizeof(Edje_Part)); /* Alloc Edje_Real_Part or return */ - rp = _alloc(sizeof(Edje_Real_Part)); + rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part)); if (!rp) { - free(ep); + eina_mempool_free(ce->mp.part, ep); return EINA_FALSE; } + memset(rp, 0, sizeof(Edje_Real_Part)); /* Init Edje_Part */ pc = ed->collection; @@ -1982,8 +1986,8 @@ tmp = realloc(pc->parts, (pc->parts_count + 1) * sizeof (Edje_Part *)); if (!tmp) { - free(ep); - free(rp); + eina_mempool_free(ce->mp.part, ep); + eina_mempool_free(_edje_real_part_mp, rp); return EINA_FALSE; } @@ -2088,14 +2092,12 @@ _edje_if_string_free(ed, ep->name); if (source) _edje_if_string_free(ed, ep->source); - free(ep); - free(rp); - free(ed); + eina_mempool_free(ce->mp.part, ep); + eina_mempool_free(_edje_real_part_mp, rp); return EINA_FALSE; } edje_edit_part_selected_state_set(obj, name, "default", 0.0); - ce = eina_hash_find(ed->file->collection, ed->group); ce->count.part++; return EINA_TRUE; |
From: Enlightenment S. <no-...@en...> - 2010-12-02 18:20:42
|
Log: Edje_Edit has been taught the basics of Embryo scripting. It is possible now to call a recompile of the script, which if it doesn't fail, will also update the running Embryo VM. Saving the object, when opened from a file compiled with a sufficiently new edje_cc (early this week, I think), will generate the source including the scripts in their right place. It's still missing a proper report of errors during the script build, but that will come later. Author: sachiel Date: 2010-12-02 10:20:34 -0800 (Thu, 02 Dec 2010) New Revision: 55160 Trac: http://trac.enlightenment.org/e/changeset/55160 Modified: trunk/edje/src/lib/Edje_Edit.h trunk/edje/src/lib/edje_edit.c Modified: trunk/edje/src/lib/Edje_Edit.h =================================================================== --- trunk/edje/src/lib/Edje_Edit.h 2010-12-02 17:57:40 UTC (rev 55159) +++ trunk/edje/src/lib/Edje_Edit.h 2010-12-02 18:20:34 UTC (rev 55160) @@ -3381,15 +3381,76 @@ */ //@{ /** - * Get the script for the given object, + * Get the Embryo script for the group of the given object. * + * Get the shared script for the group under edition. Shared script means + * the script {} block for the group, not counting what's in each program. + * It returns a malloc'd duplicate of the code, so users are free to modify + * the contents directly and they should remember to free() it when done. + * NULL will be returned if there's no script or an error occurred. + * * @param obj Object being edited. * - * @return The script name. + * @return The shared script code for this group. */ -EAPI const char * edje_edit_script_get(Evas_Object *obj); +EAPI char *edje_edit_script_get(Evas_Object *obj); +/** + * Set the code for the group script. + * + * Set the Embryo source code for the shared script of the edited group. + * Note that changing the code itself will not update the running VM, you + * need to call edje_edit_script_compile for it to get updated. + * + * @param obj The object being edited + * @param code The Embryo source + */ +EAPI void edje_edit_script_set(Evas_Object *obj, const char *code); +/** + * Get the Embryo script for the given program. + * + * Get the script code for the given program. Like the group script, this + * function returns a duplicate of the code that the user can modify at will + * and must free when done using it. + * NULL will be returned if the program doesn't exist, doesn't have any + * script or is not of type script. + * + * @param obj Object being edited + * @param prog Program name + * + * @return The program script code + */ +EAPI char *edje_edit_script_program_get(Evas_Object *obj, const char *prog); + +/** + * Set the Embryo script for the given program. + * + * Set the Embryo source code for the program @p prog. It must be an + * existing program of type EDJE_ACTION_TYPE_SCRIPT, or the function + * will fail and do nothing. + * Note that changing the code itself will not update the running VM, you + * need to call edje_edit_script_compile for it to get updated. + * + * @param obj The object being edited + * @param prog The program name. + * @param code The Embryo source + */ +EAPI void edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *code); + +/** + * Compile the Embryo script for the given object + * + * If required, this function will process all script code for the group and + * build the bytecode, updating the running Embryo VM Program if the build + * is succesful. + * + * @param obj The object being edited + * + */ +EAPI Eina_Bool edje_edit_script_compile(Evas_Object *obj); + + //@} /******************************************************************************/ /************************** ERROR API ***********************************/ Modified: trunk/edje/src/lib/edje_edit.c =================================================================== --- trunk/edje/src/lib/edje_edit.c 2010-12-02 17:57:40 UTC (rev 55159) +++ trunk/edje/src/lib/edje_edit.c 2010-12-02 18:20:34 UTC (rev 55160) @@ -90,8 +90,30 @@ struct _Edje_Edit { Edje base; + + void *bytecode; + int bytecode_size; + + char *embryo_source; + char *embryo_processed; + Eina_Hash *program_scripts; + + Eina_Bool bytecode_dirty:1; + Eina_Bool embryo_source_dirty:1; + Eina_Bool all_dirty:1; + Eina_Bool script_need_recompile:1; }; +typedef struct _Program_Script Program_Script; +struct _Program_Script +{ + int id; + char *code; + char *processed; + Eina_Bool dirty:1; + Eina_Bool delete_me:1; +}; + static void _edje_edit_smart_add(Evas_Object *obj); static void _edje_edit_smart_del(Evas_Object *obj); @@ -134,22 +156,60 @@ } static void +_edje_edit_data_clean(Edje_Edit *eed) +{ + free(eed->bytecode); + free(eed->embryo_source); + free(eed->embryo_processed); + + if (eed->program_scripts) + eina_hash_free(eed->program_scripts); + + eed->bytecode = NULL; + eed->embryo_source = NULL; + eed->embryo_processed = NULL; + eed->program_scripts = NULL; + eed->bytecode_size = 0; + eed->bytecode_dirty = EINA_FALSE; + eed->embryo_source_dirty = EINA_FALSE; + eed->all_dirty = EINA_FALSE; + eed->script_need_recompile = EINA_FALSE; +} + +static void _edje_edit_smart_del(Evas_Object *obj) { -// Edje_Edit *eed; + Edje_Edit *eed; -// eed = evas_object_smart_data_get(obj); + eed = evas_object_smart_data_get(obj); + + _edje_edit_data_clean(eed); + _edje_edit_parent_sc->base.del(obj); } +static void +_edje_edit_program_script_free(Program_Script *ps) +{ + free(ps->code); + free(ps->processed); + free(ps); +} + static Eina_Bool _edje_edit_smart_file_set(Evas_Object *obj, const char *file, const char *group) { -// Edje_Edit *eed; + Edje_Edit *eed; + Eet_File *ef; + char **keys, buf[64]; + int count, i; + int len = strlen("edje/scripts/embryo/source/"); -// eed = evas_object_smart_data_get(obj); - /* Nothing custom here yet, so we just call the parent function. - * TODO and maybes: + eed = evas_object_smart_data_get(obj); + + _edje_edit_data_clean(eed); + + /* TODO and maybes: * * The whole point of this thing is keep track of stuff such as * strings to free and who knows what, so we need to take care * of those if the file/group changes. @@ -162,7 +222,33 @@ * (GROUP parts or BOX/TABLE items pointing to non-existent/renamed * groups). */ - return _edje_edit_parent_sc->file_set(obj, file, group); + if (!_edje_edit_parent_sc->file_set(obj, file, group)) + return EINA_FALSE; + + eed->program_scripts = eina_hash_int32_new((Eina_Free_Cb)_edje_edit_program_script_free); + + ef = eet_open(file, EET_FILE_MODE_READ); + + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i", + eed->base.collection->id); + eed->embryo_source = eet_read(ef, buf, &count); + + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/*", + eed->base.collection->id); + keys = eet_list(ef, buf, &count); + for (i = 0; i < count; i++) + { + Program_Script *ps; + int size; + + ps = calloc(1, sizeof(Program_Script)); + + sscanf(keys[i] + len, "%*i/%i", &ps->id); + ps->code = eet_read(ef, keys[i], &size); + eina_hash_add(eed->program_scripts, &ps->id, ps); + } + + return EINA_TRUE; } static void @@ -205,39 +291,36 @@ } static int -_edje_image_id_find(Evas_Object *obj, const char *image_name) +_edje_image_id_find(Edje_Edit *eed, const char *image_name) { unsigned int i; - GET_ED_OR_RETURN(-1); + if (!eed->base.file) return -1; + if (!eed->base.file->image_dir) return -1; - if (!ed->file) return -1; - if (!ed->file->image_dir) return -1; - //printf("SEARCH IMAGE %s\n", image_name); - for (i = 0; i < ed->file->image_dir->entries_count; ++i) - if (ed->file->image_dir->entries[i].entry - && !strcmp(image_name, ed->file->image_dir->entries[i].entry)) + for (i = 0; i < eed->base.file->image_dir->entries_count; ++i) + if (eed->base.file->image_dir->entries[i].entry + && !strcmp(image_name, eed->base.file->image_dir->entries[i].entry)) return i; return -1; } static const char * -_edje_image_name_find(Evas_Object *obj, int image_id) +_edje_image_name_find(Edje_Edit *eed, int image_id) { - GET_ED_OR_RETURN(NULL); + if (!eed->base.file) return NULL; + if (!eed->base.file->image_dir) return NULL; - if (!ed->file) return NULL; - if (!ed->file->image_dir) return NULL; - /* Special case for external image */ if (image_id < 0) image_id = -image_id - 1; //printf("SEARCH IMAGE ID %d\n", image_id); - if ((unsigned int) image_id >= ed->file->image_dir->entries_count) return NULL; - return ed->file->image_dir->entries[image_id].entry; + if ((unsigned int) image_id >= eed->base.file->image_dir->entries_count) + return NULL; + return eed->base.file->image_dir->entries[image_id].entry; } static void @@ -819,6 +902,14 @@ evas_object_del(part_obj); } +static void +_edje_edit_flag_script_dirty(Edje_Edit *eed, Eina_Bool all) +{ + eed->script_need_recompile = EINA_TRUE; + if (all) + eed->all_dirty = EINA_TRUE; +} + /*****************/ /* GENERAL API */ /*****************/ @@ -990,7 +1081,8 @@ Edje_Part_Collection *g; Eina_List *l; Eet_File *eetf; - char buf[32]; + char buf[64], **keys; + int count; eina_error_set(0); @@ -1043,8 +1135,19 @@ "for writing output", ed->file->path); return EINA_FALSE; } - snprintf(buf, sizeof(buf), "collections/%d", e->id); + snprintf(buf, sizeof(buf), "edje/collections/%d", e->id); eet_delete(eetf, buf); + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%d", e->id); + eet_delete(eetf, buf); + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%d", e->id); + eet_delete(eetf, buf); + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%d/*", e->id); + keys = eet_list(eetf, buf, &count); + if (keys) + do { + count--; + eet_delete(eetf, keys[count]); + } while(count); eet_close(eetf); /* Free Group */ @@ -1922,6 +2025,8 @@ _edje_if_string_free(ed, rp->part->name); rp->part->name = (char *)eina_stringshare_add(new_name); + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; } @@ -2224,6 +2329,8 @@ ce->count.part--; + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; } @@ -2297,6 +2404,8 @@ if (rp->swallowed_object) evas_object_stack_above(rp->swallowed_object, rp->object); + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; } @@ -2331,6 +2440,8 @@ if (rp->swallowed_object) evas_object_stack_above(rp->swallowed_object, rp->object); + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; } @@ -4574,6 +4685,8 @@ _edje_if_string_free(ed, de->entry); de->entry = NULL; + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; invalid_image: @@ -4618,7 +4731,9 @@ { eina_error_set(0); - return _edje_image_id_find(obj, image_name); + GET_ED_OR_RETURN(-1); + + return _edje_image_id_find(eed, image_name); } EAPI Edje_Edit_Image_Comp @@ -4693,7 +4808,7 @@ edje_edit_state_image_get(Evas_Object *obj, const char *part, const char *state, double value) { Edje_Part_Description_Image *img; - char *image; + const char *image; eina_error_set(0); @@ -4704,7 +4819,7 @@ img = (Edje_Part_Description_Image *) pd; - image = (char *)_edje_image_name_find(obj, img->image.id); + image = _edje_image_name_find(eed, img->image.id); if (!image) return NULL; //printf("GET IMAGE for %s [%s]\n", state, image); @@ -4726,7 +4841,7 @@ if (rp->part->type != EDJE_PART_TYPE_IMAGE) return; - id = _edje_image_id_find(obj, image); + id = _edje_image_id_find(eed, image); //printf("SET IMAGE for %s [%s]\n", state, image); img = (Edje_Part_Description_Image *) pd; @@ -4755,7 +4870,7 @@ for (i = 0; i < img->image.tweens_count; ++i) { - name = _edje_image_name_find(obj, img->image.tweens[i]->id); + name = _edje_image_name_find(eed, img->image.tweens[i]->id); //printf(" t: %s\n", name); tweens = eina_list_append(tweens, eina_stringshare_add(name)); } @@ -4778,7 +4893,7 @@ if (rp->part->type != EDJE_PART_TYPE_IMAGE) return EINA_FALSE; - id = _edje_image_id_find(obj, tween); + id = _edje_image_id_find(eed, tween); if (id < EINA_FALSE) return 0; /* alloc Edje_Part_Image_Id */ @@ -4821,7 +4936,7 @@ if (!img->image.tweens_count) return EINA_FALSE; - search = _edje_image_id_find(obj, tween); + search = _edje_image_id_find(eed, tween); if (search < 0) return EINA_FALSE; for (i = 0; i < img->image.tweens_count; ++i) @@ -4935,6 +5050,21 @@ /******************/ /* PROGRAMS API */ /******************/ +static int +_edje_program_id_find(Edje_Edit *eed, const char *program) +{ + Edje_Program *epr; + int i; + + for (i = 0; i < eed->base.table_programs_size; i++) + { + epr = eed->base.table_programs[i]; + if (epr->name && !strcmp(epr->name, program)) + return epr->id; + } + return -1; +} + static Edje_Program * _edje_program_get_byname(Evas_Object *obj, const char *prog_name) { @@ -5049,6 +5179,7 @@ Edje_Program_After *pa; Edje_Part_Collection *pc; Edje_Program *p; + Program_Script *ps, *old_ps; int id, i; int old_id = -1; @@ -5073,6 +5204,37 @@ ed->table_programs[epr->id]->id = epr->id; } + ps = eina_hash_find(eed->program_scripts, &id); + old_ps = eina_hash_find(eed->program_scripts, &old_id); + if (old_ps) + { + if (!ps) + { + ps = _alloc(sizeof(Program_Script)); + ps->id = id; + eina_hash_add(eed->program_scripts, &id, ps); + } + else + { + free(ps->code); + free(ps->processed); + ps->processed = NULL; + ps->delete_me = EINA_FALSE; + } + ps->code = old_ps->code; + old_ps->code = NULL; + free(old_ps->processed); + old_ps->processed = NULL; + ps->dirty = EINA_TRUE; + old_ps->dirty = EINA_FALSE; + old_ps->delete_me = EINA_TRUE; + } + else if (ps) + { + ps->dirty = EINA_FALSE; + ps->delete_me = EINA_TRUE; + } + //Free Edje_Program _edje_if_string_free(ed, epr->name); _edje_if_string_free(ed, epr->signal); @@ -5105,7 +5267,10 @@ if (pa->id == old_id) pa->id = id; else if (pa->id == id) - p->after = eina_list_remove_list(p->after, l); + { + p->after = eina_list_remove_list(p->after, l); + free(pa); + } } /* check in targets */ if (p->action == EDJE_ACTION_TYPE_ACTION_STOP) @@ -5117,11 +5282,16 @@ if (pt->id == old_id) pt->id = id; else if (pt->id == id) - p->targets = eina_list_remove_list(p->targets, l); + { + p->targets = eina_list_remove_list(p->targets, l); + free(pt); + } } } } + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; } @@ -5164,6 +5334,8 @@ _edje_if_string_free(ed, epr->name); epr->name = eina_stringshare_add(new_name); + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + return EINA_TRUE; } @@ -5503,13 +5675,49 @@ EAPI Eina_Bool edje_edit_program_action_set(Evas_Object *obj, const char *prog, Edje_Action_Type action) { + Program_Script *ps; + eina_error_set(0); + GET_ED_OR_RETURN(EINA_FALSE); GET_EPR_OR_RETURN(EINA_FALSE); //printf("SET ACTION for program: %s [%d]\n", prog, action); if (action >= EDJE_ACTION_TYPE_LAST) return EINA_FALSE; + if ((Edje_Action_Type)epr->action == action) + return EINA_TRUE; + + if (action == EDJE_ACTION_TYPE_SCRIPT) + { + ps = eina_hash_find(eed->program_scripts, &epr->id); + if (!ps) + { + ps = _alloc(sizeof(Program_Script)); + if (!ps) + return EINA_FALSE; + } + ps->id = epr->id; + ps->code = strdup(""); + ps->dirty = EINA_TRUE; + ps->delete_me = EINA_FALSE; + eina_hash_set(eed->program_scripts, &ps->id, ps); + _edje_edit_flag_script_dirty(eed, EINA_FALSE); + } + if (epr->action == EDJE_ACTION_TYPE_SCRIPT) + { + ps = eina_hash_find(eed->program_scripts, &epr->id); + if (ps) + { + free(ps->code); + free(ps->processed); + ps->code = ps->processed = NULL; + ps->dirty = EINA_FALSE; + ps->delete_me = EINA_TRUE; + _edje_edit_flag_script_dirty(eed, EINA_FALSE); + } + } + epr->action = action; return EINA_TRUE; } @@ -5797,26 +6005,472 @@ /*************************/ /* EMBRYO SCRIPTS API */ /*************************/ -EAPI const char * +EAPI char * edje_edit_script_get(Evas_Object *obj) { - Embryo_Program *script = NULL; - eina_error_set(0); GET_ED_OR_RETURN(NULL); if (!ed->collection) return NULL; - if (!ed->collection->script) return NULL; + if (!eed->embryo_source) return NULL; - script = ed->collection->script; + return strdup(eed->embryo_source); +} - printf("Get Script [%p] %d\n", script, embryo_program_recursion_get(script)); +EAPI void +edje_edit_script_set(Evas_Object *obj, const char *code) +{ + eina_error_set(0); - return "Not yet complete..."; + GET_ED_OR_RETURN(); + + free(eed->embryo_source); + free(eed->embryo_processed); + + if (code) + eed->embryo_source = strdup(code); + else + eed->embryo_source = NULL; + eed->embryo_processed = NULL; + + eed->embryo_source_dirty = EINA_TRUE; + + _edje_edit_flag_script_dirty(eed, EINA_FALSE); } +EAPI char * +edje_edit_script_program_get(Evas_Object *obj, const char *prog) +{ + Program_Script *ps; + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + GET_EPR_OR_RETURN(NULL); + + if (epr->action != EDJE_ACTION_TYPE_SCRIPT) + return NULL; + + ps = eina_hash_find(eed->program_scripts, prog); + if (!ps) /* mmm? it should be there, even if empty */ + return NULL; + + return ps->code ? strdup(ps->code) : NULL; +} + +EAPI void +edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *code) +{ + Program_Script *ps; + + eina_error_set(0); + + GET_ED_OR_RETURN(); + GET_EPR_OR_RETURN(); + + if (epr->action != EDJE_ACTION_TYPE_SCRIPT) + return; + + ps = eina_hash_find(eed->program_scripts, prog); + if (!ps) /* ???? how so? */ + return; + + free(ps->code); + free(ps->processed); + + if (code) + ps->code = strdup(code); + else + ps->code = NULL; + ps->processed = NULL; + ps->dirty = EINA_TRUE; + + _edje_edit_flag_script_dirty(eed, EINA_FALSE); +} + +static int +__part_replace(Edje_Edit *eed, char *pcode, char *name) +{ + int id; + + id = _edje_part_id_find((Edje *)eed, name); + if (id < 0) + return 0; + return eina_convert_itoa(id, pcode); +} + +static int +__program_replace(Edje_Edit *eed, char *pcode, char *name) +{ + int id; + + id = _edje_program_id_find(eed, name); + if (id < 0) + return 0; + return eina_convert_itoa(id, pcode); +} + +static int +__group_replace(Edje_Edit *eed __UNUSED__, char *pcode, char *name) +{ + strcpy(pcode, name); + return strlen(name) + 1; +} + +static int +__image_replace(Edje_Edit *eed, char *pcode, char *name) +{ + int id; + + id = _edje_image_id_find(eed, name); + if (id < 0) + return 0; + return eina_convert_itoa(id, pcode); +} + +static char * +_edje_edit_script_process(Edje_Edit *eed, char *code) +{ + char *pcode, *psrc, *pdst; + int codesize, pcodesize; + int quoted = 0, escaped = 0; + Eina_Bool success = EINA_TRUE; + + codesize = strlen(code); + pcode = malloc(codesize + 1); + if (!pcode) + return NULL; + + pcodesize = 0; + psrc = code; + pdst = pcode; + while (*psrc) + { + if (!quoted) + { + char *ptr = NULL; + int (*func)(Edje_Edit *, char *, char *); + + if (*psrc == 'P') + { + if (!strncmp(psrc, "PART:\"", 6)) + { + psrc += 6; + ptr = psrc; + func = __part_replace; + } + else if (!strncmp(psrc, "PROGRAM:\"", 9)) + { + psrc += 9; + ptr = psrc; + func = __program_replace; + } + } + else if (*psrc == 'G') + { + if (!strncmp(psrc, "GROUP:\"", 7)) + { + psrc += 7; + ptr = psrc; + func = __group_replace; + } + } + else if (*psrc == 'I') + { + if (!strncmp(psrc, "IMAGE:\"", 7)) + { + psrc += 7; + ptr = psrc; + func = __image_replace; + } + } + else if (*psrc == '#') + { + while (*psrc) + if (*psrc == '\n') + break; + continue; + } + else if (*psrc == '\"') + quoted = 1; + + if (ptr) + { + int i = 0, inesc = 0; + char *name; + while (*psrc) + { + if (!inesc) + { + if (*psrc == '\\') + inesc = 1; + else if (*psrc == '\"') + { + /* string concatenation as in "foo""bar" */ + if (*(psrc + 1) != '\"') + { + psrc++; + break; + } + else + psrc++; + } + } + else + inesc = 0; + psrc++; + } + name = alloca(psrc - ptr); + inesc = 0; + while (*ptr) + { + if (!inesc) + { + if (*ptr == '\\') + inesc = 1; + else if (*ptr == '\"') + { + if (*(ptr + 1) == '\"') + ptr++; + else + { + name[i] = 0; + break; + } + } + else + { + name[i] = *ptr; + name[i + 1] = 0; + i++; + } + } + else + inesc = 0; + ptr++; + } + i = func(eed, pdst, name); + if (!i) + { + /* something was not found, report it, keep track of + * it to inform of non-existant referenced things + * and continue processing to find all of those errors + */ + success = EINA_FALSE; + } + else + { + pcodesize += i; + pdst += i; + } + /* replaced reference for the right value, now go + * to the next iteration */ + continue; + } + } + else + { + if (!escaped) + { + if (*psrc == '\"') + quoted = 0; + else if (*psrc == '\\') + escaped = 1; + } + else if (escaped) + escaped = 0; + } + *pdst = *psrc; + pdst++; + psrc++; + pcodesize++; + } + + if (!success) + { + free(pcode); + return NULL; + } + + if (pcodesize < codesize) + pcode = realloc(pcode, pcodesize + 1); + pcode[pcodesize] = 0; + + return pcode; +} + +static Eina_Bool +_edje_edit_embryo_rebuild(Edje_Edit *eed) +{ + FILE *f; + int fd, size, ret; + const char *tmp_dir; + char tmp_in[PATH_MAX]; + char tmp_out[PATH_MAX]; + char buf[4096]; + Eina_Iterator *it; + Program_Script *ps; + Edje_Part_Collection *edc; + Eina_Bool success = EINA_TRUE; /* we are optimists! */ + +#ifdef HAVE_EVIL + tmp_dir = evil_tmpdir_get(); +#else + tmp_dir = "/tmp"; +#endif + + snprintf(tmp_in, sizeof(tmp_in), "%s/edje_edit.sma-tmp-XXXXXX", tmp_dir); + snprintf(tmp_out, sizeof(tmp_out), "%s/edje_edit.amx-tmp-XXXXXX", tmp_dir); + + fd = mkstemp(tmp_in); + if (fd < 0) + return EINA_FALSE; /* FIXME: report something */ + + f = fdopen(fd, "w"); + if (!f) + { + close(fd); + unlink(tmp_in); + return EINA_FALSE; + } + + fprintf(f, "#include <edje>\n"); + if (eed->embryo_source) + { + if (eed->all_dirty) + { + free(eed->embryo_processed); + eed->embryo_processed = NULL; + } + if (!eed->embryo_processed) + eed->embryo_processed = _edje_edit_script_process(eed, + eed->embryo_source); + if (!eed->embryo_processed) + { + /* oops.. an error finding references parts or something. + * we could flag it and do some lighter processing of the + * rest of the scripts, in order to find all the errors of + * this kind and report them at once, but knowing already + * that the script will not compile we can avoid some work + */ + success = EINA_FALSE; + } + else + fprintf(f, eed->embryo_processed); + } + + it = eina_hash_iterator_data_new(eed->program_scripts); + EINA_ITERATOR_FOREACH(it, ps) + { + if (ps->delete_me) + continue; + if (eed->all_dirty) + { + free(ps->processed); + ps->processed = NULL; + } + if (!ps->processed) + ps->processed = _edje_edit_script_process(eed, ps->code); + if (!ps->processed) + { + /* oops.. an error finding references parts or something. + * we could flag it and do some lighter processing of the + * rest of the scripts, in order to find all the errors of + * this kind and report them at once, but knowing already + * that the script will not compile we can avoid some work + */ + success = EINA_FALSE; + continue; + } + fprintf(f, "public _p%i(sig[], src[]) {\n", ps->id); + fprintf(f, ps->processed); + fprintf(f, "}\n"); + } + eina_iterator_free(it); + + fclose(f); + + fd = mkstemp(tmp_out); + if (fd < 0) + { + success = EINA_FALSE; + goto almost_out; + } + + snprintf(buf, sizeof(buf), "embryo_cc -i %s/include -o %s %s", + PACKAGE_DATA_DIR, tmp_out, tmp_in); + ret = system(buf); + + if ((ret < 0) || (ret > 1)) + { + success = EINA_FALSE; + close(fd); + goto the_way_out; + } + + f = fdopen(fd, "rb"); + if (!f) + { + success = EINA_FALSE; + close(fd); + goto the_way_out; + } + + fseek(f, 0, SEEK_END); + size = ftell(f); + rewind(f); + + free(eed->bytecode); + if (size > 0) + { + eed->bytecode = malloc(size); + if (!eed->bytecode) + { + success = EINA_FALSE; + goto the_way_out; + } + if (fread(eed->bytecode, size, 1, f) != 1) + { + success = EINA_FALSE; + goto the_way_out; + } + } + else + eed->bytecode = NULL; /* correctness mostly, I don't see why we + would get a 0 sized program */ + + eed->bytecode_size = size; + eed->bytecode_dirty = EINA_TRUE; + eed->script_need_recompile = EINA_FALSE; + eed->all_dirty = EINA_FALSE; + + edc = eed->base.collection; + embryo_program_free(edc->script); + edc->script = embryo_program_new(eed->bytecode, eed->bytecode_size); + _edje_embryo_script_init(edc); + _edje_var_init((Edje *)eed); + +the_way_out: + fclose(f); + unlink(tmp_out); +almost_out: + unlink(tmp_in); + + return success; +} + +EAPI Eina_Bool +edje_edit_script_compile(Evas_Object *obj) +{ + GET_ED_OR_RETURN(EINA_FALSE); + + if (!eed->script_need_recompile) + return EINA_TRUE; + + return _edje_edit_embryo_rebuild(eed); +} + /***************************/ /* EDC SOURCE GENERATION */ /***************************/ @@ -5893,9 +6547,12 @@ char *data; Eina_Bool ret = EINA_TRUE; const char *api_name, *api_description; + Edje_Program *epr; GET_ED_OR_RETURN(EINA_FALSE); + epr = _edje_program_get_byname(obj, program); + BUF_APPENDF(I3"program { name: \"%s\";\n", program); /* Signal */ @@ -5936,6 +6593,19 @@ edje_edit_string_free(s2); } break; + case EDJE_ACTION_TYPE_SCRIPT: + { + Program_Script *ps; + + ps = eina_hash_find(eed->program_scripts, &epr->id); + if (ps && !ps->delete_me) + { + BUF_APPEND(I4"script {\n"); + BUF_APPEND(ps->code); + BUF_APPEND(I4"}\n"); + } + } + break; //TODO Support Drag //~ case EDJE_ACTION_TYPE_DRAG_VAL_SET: //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_SET TODO;\n"); @@ -6134,7 +6804,7 @@ BUF_APPEND(I5"image {\n"); - image_name = _edje_image_name_find(obj, img->image.id); + image_name = _edje_image_name_find(eed, img->image.id); if (image_name) BUF_APPENDF(I6"normal: \"%s\";\n", image_name); @@ -6375,17 +7045,30 @@ static Eina_Bool _edje_generate_source_of_group(Edje *ed, Edje_Part_Collection_Directory_Entry *pce, Eina_Strbuf *buf) { + Edje_Edit *eed; + Eet_File *ef; Evas_Object *obj; Eina_List *l, *ll; unsigned int i; int w, h; char *data; const char *group = pce->entry; + Edje_Part_Collection *pc; Eina_Bool ret = EINA_TRUE; obj = edje_edit_object_add(ed->evas); if (!edje_object_file_set(obj, ed->file->path, group)) return EINA_FALSE; + ef = eet_open(ed->file->path, EET_FILE_MODE_READ); + if (!ef) + { + evas_object_del(obj); + return EINA_FALSE; + } + + eed = evas_object_smart_data_get(obj); + pc = eed->base.collection; + BUF_APPENDF(I1"group { name: \"%s\";\n", group); //TODO Support alias: w = edje_edit_group_min_w_get(obj); @@ -6398,13 +7081,13 @@ BUF_APPENDF(I2"max: %d %d;\n", w, h); /* Data */ - if (pce->ref->data) + if (pc->data) { Eina_Iterator *it; Eina_Hash_Tuple *tuple; BUF_APPEND(I2"data {\n"); - it = eina_hash_iterator_tuple_new(pce->ref->data); + it = eina_hash_iterator_tuple_new(pc->data); if (!it) { @@ -6420,14 +7103,19 @@ BUF_APPEND(I2"}\n"); } - //TODO Support script + if (eed->embryo_source) + { + BUF_APPEND(I2"script {\n"); + BUF_APPEND(eed->embryo_source); + BUF_APPEND(I2"}\n"); + } /* Parts */ BUF_APPEND(I2"parts {\n"); - for (i = 0; i < pce->ref->parts_count; i++) + for (i = 0; i < pc->parts_count; i++) { Edje_Part *ep; - ep = pce->ref->parts[i]; + ep = pc->parts[i]; ret &= _edje_generate_source_of_part(obj, ep, buf); } BUF_APPEND(I2"}\n");//parts @@ -6447,7 +7135,7 @@ BUF_APPEND(I2 "}\n"); edje_edit_string_list_free(ll); } - BUF_APPEND(" }\n");//group + BUF_APPEND(I1"}\n");//group if (!ret) { @@ -6456,6 +7144,7 @@ return EINA_FALSE; } + eet_close(ef); evas_object_del(obj); return ret; } @@ -6867,6 +7556,57 @@ } } + if (eed->bytecode_dirty || eed->script_need_recompile) + { + char buf[64]; + Eina_Iterator *it; + Program_Script *ps; + Eina_List *deathnote = NULL; + + if (eed->bytecode_dirty) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", + ed->collection->id); + eet_write(eetf, buf, eed->bytecode, eed->bytecode_size, 1); + free(eed->bytecode); + eed->bytecode = NULL; + eed->bytecode_size = 0; + eed->bytecode_dirty = EINA_FALSE; + } + + if (eed->embryo_source_dirty) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i", + ed->collection->id); + eet_write(eetf, buf, eed->embryo_source, + strlen(eed->embryo_source) +1, 1); + eed->embryo_source_dirty = EINA_FALSE; + } + + it = eina_hash_iterator_data_new(eed->program_scripts); + EINA_ITERATOR_FOREACH(it, ps) + { + if (ps->dirty) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/%i", + ed->collection->id, ps->id); + eet_write(eetf, buf, ps->code, strlen(ps->code) + 1, 1); + ps->dirty = EINA_FALSE; + } + else if (ps->delete_me) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/%i", + ed->collection->id, ps->id); + eet_delete(eetf, buf); + deathnote = eina_list_append(deathnote, ps); + } + } + eina_iterator_free(it); + + EINA_LIST_FREE(deathnote, ps) + eina_hash_del(eed->program_scripts, &ps->id, ps); + } + if (!_edje_edit_source_save(eetf, obj)) { eet_close(eetf); |
From: Enlightenment S. <no-...@en...> - 2010-12-03 14:00:11
|
Log: twinkle twinkle little fix... Author: sachiel Date: 2010-12-03 06:00:04 -0800 (Fri, 03 Dec 2010) New Revision: 55185 Trac: http://trac.enlightenment.org/e/changeset/55185 Modified: trunk/edje/src/lib/edje_edit.c Modified: trunk/edje/src/lib/edje_edit.c =================================================================== --- trunk/edje/src/lib/edje_edit.c 2010-12-03 11:18:36 UTC (rev 55184) +++ trunk/edje/src/lib/edje_edit.c 2010-12-03 14:00:04 UTC (rev 55185) @@ -6391,6 +6391,9 @@ fclose(f); + if (!success) + goto almost_out; + fd = mkstemp(tmp_out); if (fd < 0) { @@ -6406,7 +6409,7 @@ { success = EINA_FALSE; close(fd); - goto the_way_out; + goto the_doorway; } f = fdopen(fd, "rb"); @@ -6414,7 +6417,7 @@ { success = EINA_FALSE; close(fd); - goto the_way_out; + goto the_doorway; } fseek(f, 0, SEEK_END); @@ -6453,6 +6456,7 @@ the_way_out: fclose(f); +the_doorway: unlink(tmp_out); almost_out: unlink(tmp_in); |
From: Enlightenment S. <no-...@en...> - 2010-12-06 13:50:57
|
Log: NULL out focused part when clearing the remnants of a gone Edje Author: sachiel Date: 2010-12-06 05:50:51 -0800 (Mon, 06 Dec 2010) New Revision: 55330 Trac: http://trac.enlightenment.org/e/changeset/55330 Modified: trunk/edje/src/lib/edje_load.c Modified: trunk/edje/src/lib/edje_load.c =================================================================== --- trunk/edje/src/lib/edje_load.c 2010-12-06 12:46:16 UTC (rev 55329) +++ trunk/edje/src/lib/edje_load.c 2010-12-06 13:50:51 UTC (rev 55330) @@ -1082,6 +1082,7 @@ if (ed->table_programs) free(ed->table_programs); ed->table_programs = NULL; ed->table_programs_size = 0; + ed->focused_part = NULL; } void |
From: Enlightenment S. <no-...@en...> - 2010-12-07 19:07:01
|
Log: List and allow to fetch pre-processing errors when compiling Embryo scripts. Author: sachiel Date: 2010-12-07 11:06:53 -0800 (Tue, 07 Dec 2010) New Revision: 55359 Trac: http://trac.enlightenment.org/e/changeset/55359 Modified: trunk/edje/src/lib/Edje_Edit.h trunk/edje/src/lib/edje_edit.c Modified: trunk/edje/src/lib/Edje_Edit.h =================================================================== --- trunk/edje/src/lib/Edje_Edit.h 2010-12-07 15:55:25 UTC (rev 55358) +++ trunk/edje/src/lib/Edje_Edit.h 2010-12-07 19:06:53 UTC (rev 55359) @@ -42,6 +42,14 @@ EDJE_EDIT_IMAGE_COMP_LOSSY } Edje_Edit_Image_Comp; +struct _Edje_Edit_Script_Error +{ + const char *program_name; /* null == group shared script */ + int line; + const char *error_str; +}; +typedef struct _Edje_Edit_Script_Error Edje_Edit_Script_Error; + /** * @file * @brief Functions to deal with edje internal object. Don't use in standard @@ -3450,6 +3458,21 @@ */ EAPI Eina_Bool edje_edit_script_compile(Evas_Object *obj); +/** + * Get the list of errors resulting from the last script build + * + * Get the list of errors that resulted from the last attempt to rebuild + * the Embryo script for the edited group. This will be a standard Eina_List + * with Edje_Edit_Script_Error pointers as its data. + * The user should not do anything else but read the contents of this list. + * These errors can be the output of the embryo compiler, or internal errors + * generated by Edje_Edit if the preprocessing of the scripts failed. + * + * @param obj The object being edited + * + * @return A constant list of Edje_Edit_Script_Error, or NULL if there are none + */ +EAPI const Eina_List *edje_edit_script_error_list_get(Evas_Object *obj); //@} /******************************************************************************/ Modified: trunk/edje/src/lib/edje_edit.c =================================================================== --- trunk/edje/src/lib/edje_edit.c 2010-12-07 15:55:25 UTC (rev 55358) +++ trunk/edje/src/lib/edje_edit.c 2010-12-07 19:06:53 UTC (rev 55359) @@ -98,6 +98,8 @@ char *embryo_processed; Eina_Hash *program_scripts; + Eina_List *errors; + Eina_Bool bytecode_dirty:1; Eina_Bool embryo_source_dirty:1; Eina_Bool all_dirty:1; @@ -158,6 +160,8 @@ static void _edje_edit_data_clean(Edje_Edit *eed) { + Edje_Edit_Script_Error *se; + free(eed->bytecode); free(eed->embryo_source); free(eed->embryo_processed); @@ -165,6 +169,13 @@ if (eed->program_scripts) eina_hash_free(eed->program_scripts); + EINA_LIST_FREE(eed->errors, se) + { + eina_stringshare_del(se->program_name); + eina_stringshare_del(se->error_str); + free(se); + } + eed->bytecode = NULL; eed->embryo_source = NULL; eed->embryo_processed = NULL; @@ -6130,11 +6141,12 @@ } static char * -_edje_edit_script_process(Edje_Edit *eed, char *code) +_edje_edit_script_process(Edje_Edit *eed, const char *progname, char *code) { char *pcode, *psrc, *pdst; int codesize, pcodesize; int quoted = 0, escaped = 0; + int line = 1; Eina_Bool success = EINA_TRUE; codesize = strlen(code); @@ -6150,6 +6162,7 @@ if (!quoted) { char *ptr = NULL; + const char *what = NULL; int (*func)(Edje_Edit *, char *, char *); if (*psrc == 'P') @@ -6159,12 +6172,14 @@ psrc += 6; ptr = psrc; func = __part_replace; + what = "part"; } else if (!strncmp(psrc, "PROGRAM:\"", 9)) { psrc += 9; ptr = psrc; func = __program_replace; + what = "program"; } } else if (*psrc == 'G') @@ -6174,6 +6189,7 @@ psrc += 7; ptr = psrc; func = __group_replace; + what = "group"; } } else if (*psrc == 'I') @@ -6183,6 +6199,7 @@ psrc += 7; ptr = psrc; func = __image_replace; + what = "image"; } } else if (*psrc == '#') @@ -6190,10 +6207,13 @@ while (*psrc) if (*psrc == '\n') break; + line++; continue; } else if (*psrc == '\"') quoted = 1; + else if (*psrc == '\n') + line++; if (ptr) { @@ -6253,10 +6273,15 @@ i = func(eed, pdst, name); if (!i) { - /* something was not found, report it, keep track of - * it to inform of non-existant referenced things - * and continue processing to find all of those errors - */ + Edje_Edit_Script_Error *se; + se = malloc(sizeof(Edje_Edit_Script_Error)); + se->program_name = progname ? + eina_stringshare_add(progname) : NULL; + se->line = line; + se->error_str = eina_stringshare_printf( + "Referenced %s '%s' could not be found in object.", + what, name); + eed->errors = eina_list_append(eed->errors, se); success = EINA_FALSE; } else @@ -6313,7 +6338,15 @@ Program_Script *ps; Edje_Part_Collection *edc; Eina_Bool success = EINA_TRUE; /* we are optimists! */ + Edje_Edit_Script_Error *se; + EINA_LIST_FREE(eed->errors, se) + { + eina_stringshare_del(se->program_name); + eina_stringshare_del(se->error_str); + free(se); + } + #ifdef HAVE_EVIL tmp_dir = evil_tmpdir_get(); #else @@ -6344,7 +6377,7 @@ eed->embryo_processed = NULL; } if (!eed->embryo_processed) - eed->embryo_processed = _edje_edit_script_process(eed, + eed->embryo_processed = _edje_edit_script_process(eed, NULL, eed->embryo_source); if (!eed->embryo_processed) { @@ -6363,6 +6396,8 @@ it = eina_hash_iterator_data_new(eed->program_scripts); EINA_ITERATOR_FOREACH(it, ps) { + Edje_Program *epr; + if (ps->delete_me) continue; if (eed->all_dirty) @@ -6370,8 +6405,9 @@ free(ps->processed); ps->processed = NULL; } + epr = eed->base.table_programs[ps->id]; if (!ps->processed) - ps->processed = _edje_edit_script_process(eed, ps->code); + ps->processed = _edje_edit_script_process(eed, epr->name, ps->code); if (!ps->processed) { /* oops.. an error finding references parts or something. @@ -6475,6 +6511,13 @@ return _edje_edit_embryo_rebuild(eed); } +EAPI const Eina_List * +edje_edit_script_error_list_get(Evas_Object *obj) +{ + GET_ED_OR_RETURN(NULL); + return eed->errors; +} + /***************************/ /* EDC SOURCE GENERATION */ /***************************/ |
From: Enlightenment S. <no-...@en...> - 2011-08-03 18:46:47
|
Log: Some more docs for the edje_external c api Author: sachiel Date: 2011-08-03 11:46:40 -0700 (Wed, 03 Aug 2011) New Revision: 62064 Trac: http://trac.enlightenment.org/e/changeset/62064 Modified: trunk/edje/src/lib/Edje.h Modified: trunk/edje/src/lib/Edje.h =================================================================== --- trunk/edje/src/lib/Edje.h 2011-08-03 18:08:32 UTC (rev 62063) +++ trunk/edje/src/lib/Edje.h 2011-08-03 18:46:40 UTC (rev 62064) @@ -824,47 +824,34 @@ EDJE_TEXT_FILTER_MARKUP = 2 } Edje_Text_Filter_Type; +/** + * The possible types the parameters of an EXTERNAL part can be. + */ typedef enum _Edje_External_Param_Type { - EDJE_EXTERNAL_PARAM_TYPE_INT, - EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, - EDJE_EXTERNAL_PARAM_TYPE_STRING, - EDJE_EXTERNAL_PARAM_TYPE_BOOL, - EDJE_EXTERNAL_PARAM_TYPE_CHOICE, - EDJE_EXTERNAL_PARAM_TYPE_MAX + EDJE_EXTERNAL_PARAM_TYPE_INT, /**< Parameter value is an integer. */ + EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, /**< Parameter value is a double. */ + EDJE_EXTERNAL_PARAM_TYPE_STRING, /**< Paramater value is a string. */ + EDJE_EXTERNAL_PARAM_TYPE_BOOL, /**< Parameter value is boolean. */ + EDJE_EXTERNAL_PARAM_TYPE_CHOICE, /**< Parameter value is one of a set of + predefined string choices. */ + EDJE_EXTERNAL_PARAM_TYPE_MAX /**< Sentinel. Don't use. */ } Edje_External_Param_Type; /** - * @typedef Edje_External_Param_Flags flags that determines the - * behavior of a parameter. - * - * @var EDJE_EXTERNAL_PARAM_FLAGS_NONE property is incapable of - * operations, this is used to catch bogus flags. - * @var EDJE_EXTERNAL_PARAM_FLAGS_GET property can be read/get - * @var EDJE_EXTERNAL_PARAM_FLAGS_SET property can be written/set. - * This only enables edje_object_part_external_param_set() and - * Embryo scripts. To enable parameter being set from state - * description whenever it changes state, use - * #EDJE_EXTERNAL_PARAM_FLAGS_STATE. - * @var EDJE_EXTERNAL_PARAM_FLAGS_STATE property can be set from state - * description. - * @var EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR this property is only - * set once when object is constructed using its value from - * "default" 0.0 state description. Setting this overrides - * #EDJE_EXTERNAL_PARAM_FLAGS_STATE. - * @var EDJE_EXTERNAL_PARAM_FLAGS_REGULAR convenience flag that sets - * property as GET, SET and STATE. + * Flags that determine how a parameter may be accessed in different + * circumstances. */ typedef enum _Edje_External_Param_Flags { - EDJE_EXTERNAL_PARAM_FLAGS_NONE = 0, - EDJE_EXTERNAL_PARAM_FLAGS_GET = (1 << 0), - EDJE_EXTERNAL_PARAM_FLAGS_SET = (1 << 1), - EDJE_EXTERNAL_PARAM_FLAGS_STATE = (1 << 2), - EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR = (1 << 3), + EDJE_EXTERNAL_PARAM_FLAGS_NONE = 0, /**< Propery is incapable of operations, this is used to catch bogus flags. */ + EDJE_EXTERNAL_PARAM_FLAGS_GET = (1 << 0), /**< Property can be read/get. */ + EDJE_EXTERNAL_PARAM_FLAGS_SET = (1 << 1), /**< Property can be written/set. This only enables edje_object_part_external_param_set() and Embryo scripts. To enable the parameter being set from state description whenever it changes state, use #EDJE_EXTERNAL_PARAM_FLAGS_STATE. */ + EDJE_EXTERNAL_PARAM_FLAGS_STATE = (1 << 2), /**< Property can be set from state dsecription. */ + EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR = (1 << 3), /**< This property is only set once when the object is constructed using its value from "default" 0.0 state description. Setting this overrides #EDJE_EXTERNAL_PARAM_FLAGS_STATE. */ EDJE_EXTERNAL_PARAM_FLAGS_REGULAR = (EDJE_EXTERNAL_PARAM_FLAGS_GET | EDJE_EXTERNAL_PARAM_FLAGS_SET | - EDJE_EXTERNAL_PARAM_FLAGS_STATE) + EDJE_EXTERNAL_PARAM_FLAGS_STATE) /**< Convenience flag that sets property as GET, SET and STATE. */ } Edje_External_Param_Flags; @@ -878,49 +865,97 @@ */ EAPI const char *edje_external_param_type_str(Edje_External_Param_Type type) EINA_PURE; +/** + * Struct that holds parameters for parts of type EXTERNAL. + */ struct _Edje_External_Param { - const char *name; - Edje_External_Param_Type type; + const char *name; /**< The name of the parameter. */ + Edje_External_Param_Type type; /**< The type of the parameter. This defines + which of the next three variables holds + the value for it. */ // XXX these could be in a union, but eet doesn't support them (or does it?) - int i; /**< used by both integer and boolean */ - double d; - const char *s; /**< used by both string and choice */ + int i; /**< Used by both integer and boolean */ + double d; /**< Used by double */ + const char *s; /**< Used by both string and choice */ }; +/** + * Struct that holds parameters for parts of type EXTERNAL. + */ typedef struct _Edje_External_Param Edje_External_Param; +/** + * Helper macro to indicate an EXTERNAL's integer parameter is undefined. + */ #define EDJE_EXTERNAL_INT_UNSET INT_MAX +/** + * Helper macro to indicate an EXTERNAL's double parameter is undefined. + */ #define EDJE_EXTERNAL_DOUBLE_UNSET DBL_MAX +/** + * Struct holding information about an EXTERNAL part's parameters. + * + * When creating types to use with EXTERNAL parts, an array of this type is + * used to describe the different parameters the object uses. + * + * This struct holds the name, type and flags that define how and when the + * parameter is used, as well as information specific to each type, like the + * maximum or minimum value, that can be used by editors to restrict the + * range of values to set for each parameter. + */ typedef struct _Edje_External_Param_Info Edje_External_Param_Info; +/** + * Struct holding information about an EXTERNAL part's parameters. + * + * When creating types to use with EXTERNAL parts, an array of this type is + * used to describe the different parameters the object uses. + * + * This struct holds the name, type and flags that define how and when the + * parameter is used, as well as information specific to each type, like the + * maximum or minimum value, that can be used by editors to restrict the + * range of values to set for each parameter. + */ struct _Edje_External_Param_Info { - const char *name; - Edje_External_Param_Type type; - Edje_External_Param_Flags flags; + const char *name; /**< Name of the parameter. */ + Edje_External_Param_Type type; /**< Type of the parameter. */ + Edje_External_Param_Flags flags; /**< Flags indicating how this parameter is + used. */ union { struct { - int def, min, max, step; - } i; + int def, /**< Default value for the paramter. */ + min, /**< Minimum value it can have. */ + max, /**< Maximum value it can have. */ + step; /**< Values will be a multiple of this. */ + } i; /**< Info about integer type parametrs. Use #EDJE_EXTERNAL_INT_UNSET + on any of them to indicate they are not defined.*/ struct { - double def, min, max, step; - } d; + double def, /**< Default value for the paramter. */ + min, /**< Minimum value it can have. */ + max, /**< Maximum value it can have. */ + step; /**< Values will be a multiple of this. */ + } d; /**< Info about double type parametrs. Use +#EDJE_EXTERNAL_DOUBLE_UNSET on any of them to indicate they are not defined.*/ struct { - const char *def; - const char *accept_fmt; - const char *deny_fmt; - } s; + const char *def; /**< Default value. */ + const char *accept_fmt; /**< Not implemented. */ + const char *deny_fmt; /**< Not implemented */ + } s; /**< Info about string type parameters. NULL indicates undefined. */ struct { - int def; - const char *false_str; - const char *true_str; - } b; + int def; /**< Default value. */ + const char *false_str; /**< String shown by editors to indicate the false state. */ + const char *true_str; /**< String shown by editors to indicate the true state. */ + } b; /**< Info about boolean type parameters.*/ struct { - const char *def; - const char **choices; /* NULL terminated array */ - char *(*def_get)(void *data, const Edje_External_Param_Info *info); /* return malloc() memory with the default choice, should be used if def is NULL. First parameter is Edje_External_Type::data */ - char **(*query)(void *data, const Edje_External_Param_Info *info); /* NULL terminated array of strings, memory is dynamically allocated and should be freed with free() for array and each element. First parameter is Edje_External_Type::data */ - } c; + const char *def; /**< Default value. */ + const char **choices; /* Array of strings, each represents a + valid value for this parameter. The + last element of the array must be + NULL. */ + char *(*def_get)(void *data, const Edje_External_Param_Info *info); /** return malloc() memory with the default choice, should be used if def is NULL. First parameter is Edje_External_Type::data */ + char **(*query)(void *data, const Edje_External_Param_Info *info); /** NULL terminated array of strings, memory is dynamically allocated and should be freed with free() for array and each element. First parameter is Edje_External_Type::data */ + } c; /**< Info about choice type parameters. */ } info; }; @@ -1013,34 +1048,43 @@ * - #EDJE_EXTERNAL_TYPE_ABI_VERSION to declare. * - edje_external_type_abi_version_get() to check. */ - const char *module; - const char *module_name; - Evas_Object *(*add) (void *data, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name); /**< creates the object to be used by Edje as the part */ - void (*state_set) (void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos); /**< called upon state changes, including the initial "default" 0.0 state. Parameters are the value returned by params_parse() */ + const char *module; /**< Name of the module that holds these definitions, + as used in the externals {} block of a theme + definition. */ + const char *module_name; /**< Canonical name of the module, for displaying + in edition programs, for example. */ + Evas_Object *(*add) (void *data, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name); /**< Creates the object to be used by Edje as the part. @p part_name is the name of the part that holds the object and can be used to forward callbacks from the object as signals from Edje. @p params is the list of #Edje_External_Param, not parsed, from the default state of the part. Parameters of type #EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR should be set on + the object here. */ + void (*state_set) (void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos); /**< Called upon state changes, including the initial "default" 0.0 state. Parameters are the value returned by params_parse(). The @p pos parameter is a value between 0.0 and 1.0 indicating the position in time within the state transition. */ void (*signal_emit) (void *data, Evas_Object *obj, const char *emission, const char *source); /**< Feed a signal emitted with emission originally set as part_name:signal to this object (without the "part_name:" prefix) */ - Eina_Bool (*param_set) (void *data, Evas_Object *obj, const Edje_External_Param *param); /**< dynamically change a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success */ - Eina_Bool (*param_get) (void *data, const Evas_Object *obj, Edje_External_Param *param); /**< dynamically fetch a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success. (Must check parameter name and type!) */ - Evas_Object *(*content_get) (void *data, const Evas_Object *obj, const char *content); /**< dynamically fetch a sub object of this external, called by scripts and user code. Returns @c Evas_Object * on success. (Must check parameter name and type!) */ - void *(*params_parse) (void *data, Evas_Object *obj, const Eina_List *params); /**< parses the list of parameters, converting into a friendly representation. Used with state_set() */ - void (*params_free) (void *params); /**< free parameters parsed with params_parse() */ + Eina_Bool (*param_set) (void *data, Evas_Object *obj, const Edje_External_Param *param); /**< Dynamically change a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success */ + Eina_Bool (*param_get) (void *data, const Evas_Object *obj, Edje_External_Param *param); /**< Dynamically fetch a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success. (Must check parameter name and type!) */ + Evas_Object *(*content_get) (void *data, const Evas_Object *obj, const char *content); /**< Dynamically fetch a sub object of this external, called by scripts and user code. Returns @c Evas_Object * on success. (Must check parameter name and type!) */ + void *(*params_parse) (void *data, Evas_Object *obj, const Eina_List *params); /**< Parses the list of parameters, converting into a friendly representation. Used with state_set() */ + void (*params_free) (void *params); /**< Free parameters parsed with params_parse() */ /* The following callbacks aren't used by Edje itself, but by UI design tools instead */ - const char *(*label_get) (void *data); - const char *(*description_get) (void *data); - Evas_Object *(*icon_add) (void *data, Evas *e); - Evas_Object *(*preview_add) (void *data, Evas *e); - const char *(*translate) (void *data, const char *orig); /**< called to translate parameters_info name properties for use in user interfaces that support internationalization (i18n) */ + const char *(*label_get) (void *data); /**< Get a label to use to identify this EXTERNAL. (For editors) */ + const char *(*description_get) (void *data); /**< Get a user friendly description of this EXTERNAL. (For editors) */ + Evas_Object *(*icon_add) (void *data, Evas *e); /**< Get an icon to use to identify this EXTERNAL. (For editors) */ + Evas_Object *(*preview_add) (void *data, Evas *e); /**< Get a preview of the EXTERNAL object in use. (For editors) */ + const char *(*translate) (void *data, const char *orig); /**< called to translate parameters_info name properties for use in user interfaces that support internationalization (i18n) (For editors) */ - Edje_External_Param_Info *parameters_info; - void *data; + Edje_External_Param_Info *parameters_info; /**< An array of #Edje_External_Param_Info describing the different parameters this EXTERNAL may have. The last element in the array must be #EDJE_EXTERNAL_PARAM_INFO_SENTINEL. */ + void *data; /**< Private user data that will be passed to all of the class functions. */ }; typedef struct _Edje_External_Type Edje_External_Type; +/** + * Convenience struct used to mass-register types of EXTERNAL objects. + * + * Used with edje_external_type_array_register(). + */ struct _Edje_External_Type_Info { - const char *name; - const Edje_External_Type *info; + const char *name; /**< The name of the type to register. */ + const Edje_External_Type *info; /**< The type definition. */ }; typedef struct _Edje_External_Type_Info Edje_External_Type_Info; @@ -3070,6 +3114,16 @@ */ EAPI Eina_Bool edje_object_part_external_param_get (const Evas_Object *obj, const char *part, Edje_External_Param *param); +/** + * @brief Get an object contained in an part of type EXTERNAL + * + * The @p content string must not be NULL. Its actual value depends on the + * code providing the EXTERNAL. + * + * @param obj The Edje object + * @param part The name of the part holding the EXTERNAL + * @param content A string identifying which content from the EXTERNAL to get + */ EAPI Evas_Object *edje_object_part_external_content_get (const Evas_Object *obj, const char *part, const char *content); /** @@ -3354,8 +3408,13 @@ EAPI void edje_message_signal_process (void); /** - * Register given type name to return the given information. + * Register a type to be used by EXTERNAL parts. * + * Edje supports parts of type EXTERNAL, which will call user defined functions + * to create and manipulate the object that's allocated in that part. This is + * done by expecifying in the @c source property of the part the name of the + * external to use, which must be one registered with this function. + * * @param type_name name to register and be known by edje's "source:" * parameter of "type: EXTERNAL" parts. * @param type_info meta-information describing how to interact with it. @@ -3368,9 +3427,9 @@ EAPI Eina_Bool edje_external_type_register (const char *type_name, const Edje_External_Type *type_info); /** - * Unregister given type name previously registered. + * Unregister a previously registered EXTERNAL type. * - * @param type_name name to unregister. It should be registered with + * @param type_name name to unregister. It should have been registered with * edje_external_type_register() before. * * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like @@ -3383,18 +3442,19 @@ /** * Register a batch of types and their information. * - * This is the recommended function to add information as it's faster - * than the single version edje_external_type_register(). + * When several types will be registered it is recommended to use this + * function instead of several calls to edje_external_type_register(), as it + * is faster. * - * @note the given array is not modified, but the type name strings - * are @b not duplicated! That is, all type names must be @b - * live until they are unregistered! This was chosen to save - * some memory and most people will just define the array as a - * global static const type anyway. + * @note The contents of the array will be referenced directly for as long as + * the type remains registered, so both the @c name and @c info in the + * @p array must be kept alive during all this period (usually, the entire + * program lifetime). The most common case would be to keep the array as a + * @c static @c const type anyway. * * @param array @c NULL terminated array with type name and - * information. Note that type name or information are not - * modified by are @b referenced, so they must keep alive after + * information. Note that type name or information are + * referenced directly, so they must be kept alive after * this function returns! * * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like @@ -3430,14 +3490,17 @@ * - use edje_external_type_abi_version_get() to check. * - use #EDJE_EXTERNAL_TYPE_ABI_VERSION to define/declare. * - * @return version this edje library was compiled. + * @return The external ABI version the Edje library was compiled with. That + * is, the value #EDJE_EXTERNAL_TYPE_ABI_VERSION had at that moment. */ EAPI unsigned int edje_external_type_abi_version_get (void) EINA_CONST; /** - * Returns an iterator that emits Eina_Hash_Tuple pointers with key - * being the name and data being the Edje_External_Type pointer. + * Returns an interator of all the registered EXTERNAL types. * + * Each item in the iterator is an @c Eina_Hash_Tuple which has the type + * of the external in the @c key and #Edje_External_Type as @c data. + * * @code * const Eina_Hash_Tuple *tuple; * Eina_Iterator *itr; @@ -3476,17 +3539,109 @@ */ EAPI Eina_Iterator *edje_external_iterator_get (void); +/** + * Conevenience function to find a specific parameter in a list of them. + * + * @param params The list of parameters for the external + * @param key The parameter to look for + * + * @return The matching #Edje_External_Param or NULL if it's not found. + */ EAPI Edje_External_Param *edje_external_param_find (const Eina_List *params, const char *key); +/** + * Get the value of the given parameter of integer type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_INT, its value will be stored in the int pointed + * by @p ret, returning EINA_TRUE. In any other case, the function returns + * EINA_FALSE. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret Int pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of integer type, + * EINA_FALSE otherwise. + */ EAPI Eina_Bool edje_external_param_int_get (const Eina_List *params, const char *key, int *ret); +/** + * Get the value of the given parameter of double type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, its value will be stored in the double + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret Double pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of double type, + * EINA_FALSE otherwise. + */ EAPI Eina_Bool edje_external_param_double_get (const Eina_List *params, const char *key, double *ret); +/** + * Get the value of the given parameter of string type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_STRING, its value will be stored in the pointer + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * The string stored in @p ret must not be freed or modified. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret String pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of string type, + * EINA_FALSE otherwise. + */ EAPI Eina_Bool edje_external_param_string_get (const Eina_List *params, const char *key, const char **ret); +/** + * Get the value of the given parameter of boolean type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_BOOL, its value will be stored in the Eina_Bool + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret Eina_Bool pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of boolean type, + * EINA_FALSE otherwise. + */ EAPI Eina_Bool edje_external_param_bool_get (const Eina_List *params, const char *key, Eina_Bool *ret); +/** + * Get the value of the given parameter of choice type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_CHOICE, its value will be stored in the string + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * The string stored in @p ret must not be freed or modified. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret String pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of integer type, + * EINA_FALSE otherwise. + */ EAPI Eina_Bool edje_external_param_choice_get (const Eina_List *params, const char *key, const char **ret); /** * Get the array of parameters information about a type given its name. * - * @note the type names and other strings are static, that means they + * @note the type names and other strings are static, that means they are * @b NOT translated. One must use * Edje_External_Type::translate() to translate those. * @@ -3497,6 +3652,10 @@ */ EAPI const Edje_External_Param_Info *edje_external_param_info_get (const char *type_name); +/** + * Get the #Edje_External_Type that defines an EXTERNAL type registered with + * the name @p type_name. + */ EAPI const Edje_External_Type *edje_external_type_get (const char *type_name); EAPI Eina_Bool edje_module_load (const char *module); |
From: Enlightenment S. <no-...@en...> - 2011-08-13 00:30:20
|
Log: Forward messages to Edje defined children of box and table Author: sachiel Date: 2011-08-12 17:30:12 -0700 (Fri, 12 Aug 2011) New Revision: 62418 Trac: http://trac.enlightenment.org/e/changeset/62418 Modified: trunk/edje/src/lib/edje_message_queue.c Modified: trunk/edje/src/lib/edje_message_queue.c =================================================================== --- trunk/edje/src/lib/edje_message_queue.c 2011-08-12 23:15:11 UTC (rev 62417) +++ trunk/edje/src/lib/edje_message_queue.c 2011-08-13 00:30:12 UTC (rev 62418) @@ -28,6 +28,14 @@ Edje_Real_Part *rp = ed->table_parts[i]; if ((rp->part->type == EDJE_PART_TYPE_GROUP) && (rp->swallowed_object)) edje_object_message_send(rp->swallowed_object, type, id, msg); + else if (((rp->part->type == EDJE_PART_TYPE_BOX) || + (rp->part->type == EDJE_PART_TYPE_TABLE)) && (rp->items)) + { + Eina_List *itr; + Evas_Object *o; + EINA_LIST_FOREACH(rp->items, itr, o) + edje_object_message_send(o, type, id, msg); + } } } @@ -221,6 +229,19 @@ if (!edj2) continue; _edje_message_cb_set(edj2, func, data); } + else if (((rp->part->type == EDJE_PART_TYPE_BOX) || + (rp->part->type == EDJE_PART_TYPE_TABLE)) && rp->items) + { + Eina_List *itr; + Evas_Object *obj; + EINA_LIST_FOREACH(rp->items, itr, obj) + { + Edje *edj2; + edj2 = _edje_fetch(obj); + if (!edj2) continue; + _edje_message_cb_set(edj2, func, data); + } + } } } |
From: Enlightenment S. <no-...@en...> - 2011-11-04 16:26:48
|
Log: Clarify the need (or not) to free data values returned. Author: sachiel Date: 2011-11-04 09:26:41 -0700 (Fri, 04 Nov 2011) New Revision: 64739 Trac: http://trac.enlightenment.org/e/changeset/64739 Modified: trunk/edje/src/lib/Edje.h Modified: trunk/edje/src/lib/Edje.h =================================================================== --- trunk/edje/src/lib/Edje.h 2011-11-04 15:49:06 UTC (rev 64738) +++ trunk/edje/src/lib/Edje.h 2011-11-04 16:26:41 UTC (rev 64739) @@ -1333,7 +1333,8 @@ * Get data from the file level data block of an edje file * @param file The path to the .edj file * @param key The data key - * @return The string value of the data + * @return The string value of the data. Must be freed by the user when no + * longer needed. * * If an edje file is built from the following edc: * @@ -1678,7 +1679,7 @@ * * @param obj A handle to an Edje object * @param key The data field's key string - * @return The data's value string + * @return The data's value string. Must not be freed. * * This function fetches an EDC data field's value, which is declared * on the objects building EDC file, <b>under its group</b>. EDC data |
From: Enlightenment S. <no-...@en...> - 2011-11-17 14:07:49
|
Log: Fix building without Ecore_IMF Author: sachiel Date: 2011-11-17 06:07:39 -0800 (Thu, 17 Nov 2011) New Revision: 65342 Trac: http://trac.enlightenment.org/e/changeset/65342 Modified: trunk/edje/src/lib/edje_entry.c Modified: trunk/edje/src/lib/edje_entry.c =================================================================== --- trunk/edje/src/lib/edje_entry.c 2011-11-17 11:27:26 UTC (rev 65341) +++ trunk/edje/src/lib/edje_entry.c 2011-11-17 14:07:39 UTC (rev 65342) @@ -2830,7 +2830,7 @@ _edje_entry_input_panel_layout_get(Edje_Real_Part *rp) { Entry *en = rp->entry_data; - if ((!en) || (!en->imf_context)) return EDJE_INPUT_PANEL_LAYOUT_INVALID; + if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID; #ifdef HAVE_ECORE_IMF if (en->imf_context) return ecore_imf_context_input_panel_layout_get(en->imf_context); @@ -2851,12 +2851,12 @@ static void _edje_entry_imf_cursor_info_set(Entry *en) { +#ifdef HAVE_ECORE_IMF Evas_Coord cx, cy, cw, ch; if (!en || !en->rp || !en->imf_context) return; _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch); -#ifdef HAVE_ECORE_IMF ecore_imf_context_cursor_position_set(en->imf_context, evas_textblock_cursor_pos_get(en->cursor)); ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch); |
From: Enlightenment S. <no-...@en...> - 2012-01-26 21:26:14
|
Log: Tell the descriptors about our new properties Author: sachiel Date: 2012-01-26 13:26:08 -0800 (Thu, 26 Jan 2012) New Revision: 67559 Trac: http://trac.enlightenment.org/e/changeset/67559 Modified: trunk/edje/src/lib/edje_data.c Modified: trunk/edje/src/lib/edje_data.c =================================================================== --- trunk/edje/src/lib/edje_data.c 2012-01-26 21:20:55 UTC (rev 67558) +++ trunk/edje/src/lib/edje_data.c 2012-01-26 21:26:08 UTC (rev 67559) @@ -586,6 +586,8 @@ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.id", image.id, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.set", image.set, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.min.limit", image.min.limit, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.max.limit", image.max.limit, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.l", image.border.l, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.r", image.border.r, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.t", image.border.t, EET_T_INT); |
From: Enlightenment S. <no-...@en...> - 2012-01-27 14:32:52
|
Log: Do set the max to the image size if asked for it Author: sachiel Date: 2012-01-27 06:32:45 -0800 (Fri, 27 Jan 2012) New Revision: 67567 Trac: http://trac.enlightenment.org/e/changeset/67567 Modified: trunk/edje/src/lib/edje_calc.c Modified: trunk/edje/src/lib/edje_calc.c =================================================================== --- trunk/edje/src/lib/edje_calc.c 2012-01-27 11:59:22 UTC (rev 67566) +++ trunk/edje/src/lib/edje_calc.c 2012-01-27 14:32:45 UTC (rev 67567) @@ -1978,8 +1978,8 @@ } if (((Edje_Part_Description_Image *)chosen_desc)->image.max.limit) { - if (w < maxw) maxw = w; - if (h < maxh) maxh = h; + if ((maxw <= 0) || (w < maxw)) maxw = w; + if ((maxh <= 0) || (h < maxh)) maxh = h; } } |