Enlightenment CVS committal Author : davemds Project : e17 Module : proto/edje_editor
Dir : e17/proto/edje_editor Modified Files: edje_edit.patch Log Message: * More robust remove/restack of parts =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/edje_edit.patch,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- edje_edit.patch 18 Feb 2008 20:38:40 -0000 1.7 +++ edje_edit.patch 19 Feb 2008 06:16:25 -0000 1.8 @@ -4,7 +4,7 @@ retrieving revision 1.4 diff -u -r1.4 Doxyfile --- Doxyfile 6 Dec 2007 23:40:48 -0000 1.4 -+++ Doxyfile 18 Feb 2008 20:33:01 -0000 ++++ Doxyfile 19 Feb 2008 06:13:15 -0000 @@ -1,7 +1,7 @@ PROJECT_NAME = Edje PROJECT_NUMBER = @@ -29,7 +29,7 @@ retrieving revision 1.93 diff -u -r1.93 configure.in --- configure.in 25 Jan 2008 03:35:46 -0000 1.93 -+++ configure.in 18 Feb 2008 20:33:01 -0000 ++++ configure.in 19 Feb 2008 06:13:15 -0000 @@ -66,6 +66,7 @@ evas >= 0.9.9 ecore-evas >= 0.9.9 @@ -44,7 +44,7 @@ retrieving revision 1.6 diff -u -r1.6 gendoc --- gendoc 6 Dec 2007 23:42:38 -0000 1.6 -+++ gendoc 18 Feb 2008 20:33:01 -0000 ++++ gendoc 19 Feb 2008 06:13:15 -0000 @@ -1,7 +1,7 @@ #!/bin/sh cp ./edje.c.in ./edje.c @@ -68,8 +68,8 @@ RCS file: src/lib/Edje_Edit.h diff -N src/lib/Edje_Edit.h --- /dev/null 1 Jan 1970 00:00:00 -0000 -+++ src/lib/Edje_Edit.h 18 Feb 2008 20:33:01 -0000 -@@ -0,0 +1,1274 @@ ++++ src/lib/Edje_Edit.h 19 Feb 2008 06:13:15 -0000 +@@ -0,0 +1,1277 @@ +#ifndef _EDJE_EDIT_H +#define _EDJE_EDIT_H + @@ -286,14 +286,17 @@ + const char *part ///< The name of the part to remove +); + -+/**Restack the give part to be after the 'after' part. -+ * Set after to NULL to move the object in the first (more deeper) position. -+ */ ++/**Move the given part below the previous one.*/ ++EAPI unsigned char ///@return 1 on success, 0 on failure ++edje_edit_part_restack_below( ++ Evas_Object *obj, ///< The edje object ++ const char *part ///< The name of the part to restack ++); ++/**Move the given part above the next one.*/ +EAPI unsigned char ///@return 1 on success, 0 on failure -+edje_edit_part_restack( ++edje_edit_part_restack_above( + Evas_Object *obj, ///< The edje object -+ const char *part, ///< The name of the part to move -+ const char *after ///< The name of the part to place part after ++ const char *part ///< The name of the part to restack +); + +/**Set a new name for part. @@ -1350,7 +1353,7 @@ retrieving revision 1.39 diff -u -r1.39 Makefile.am --- src/lib/Makefile.am 18 Jan 2008 06:38:46 -0000 1.39 -+++ src/lib/Makefile.am 18 Feb 2008 20:33:01 -0000 ++++ src/lib/Makefile.am 19 Feb 2008 06:13:15 -0000 @@ -14,7 +14,8 @@ libedje.la @@ -1376,8 +1379,8 @@ RCS file: src/lib/edje_edit.c diff -N src/lib/edje_edit.c --- /dev/null 1 Jan 1970 00:00:00 -0000 -+++ src/lib/edje_edit.c 18 Feb 2008 20:33:01 -0000 -@@ -0,0 +1,2953 @@ ++++ src/lib/edje_edit.c 19 Feb 2008 06:13:15 -0000 +@@ -0,0 +1,3133 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ @@ -2084,8 +2087,7 @@ + if (ep->precise_is_inside) + evas_object_precise_is_inside_set(rp->object, 1); + } -+ if (rp->part->clip_to_id < 0) -+ evas_object_clip_set(rp->object, ed->clipper); ++ evas_object_clip_set(rp->object, ed->clipper); + } + rp->drag.step.x = ep->dragable.step_x; + rp->drag.step.y = ep->dragable.step_y; @@ -2106,9 +2108,193 @@ + rp->param1.description = ep->default_desc; + rp->chosen_description = rp->param1.description; + ++ edje_object_calc_force(obj); ++ + return TRUE; +} + ++static void ++_edje_part_id_set(Edje *ed, Edje_Real_Part *rp, int new_id) ++{ ++ /* This function change the id of a given real_part. ++ * All the depedency will be updated too. ++ * Also the table_parts is updated, and the current *rp in the table ++ * is lost. ++ */ ++ int old_id; ++ Edje_Part *part; ++ Evas_List *l; ++ ++ part = rp->part; ++ ++ if (!part) return; ++ printf("CHANGE ID OF PART %s TO %d\n", part->name, new_id); ++ ++ if (!ed || !part || new_id < 0) return; ++ ++ if (part->id == new_id) return; ++ ++ old_id = part->id; ++ part->id = new_id; ++ ++ // Fix all the dependecies in all parts... ++ for (l = ed->collection->parts; l; l = l->next) ++ { ++ Edje_Part *p; ++ p = l->data; ++ printf(" search id: %d in %s\n", old_id, p->name); ++ if (p->clip_to_id == old_id) p->clip_to_id = new_id; ++ if (p->dragable.confine_id == old_id) p->dragable.confine_id = new_id; ++ ++ // ...in default description ++ Evas_List *ll; ++ Edje_Part_Description *d; ++ d = p->default_desc; ++ printf(" search in %s (%s)\n", p->name, d->state.name); ++ if (d->rel1.id_x == old_id) d->rel1.id_x = new_id; ++ if (d->rel1.id_y == old_id) d->rel1.id_y = new_id; ++ if (d->rel2.id_x == old_id) d->rel2.id_x = new_id; ++ if (d->rel2.id_y == old_id) d->rel2.id_y = new_id; ++ if (d->text.id_source == old_id) d->text.id_source = new_id; ++ if (d->text.id_text_source == old_id) d->text.id_text_source = new_id; ++ // ...and in all other descriptions ++ for (ll = p->other_desc; ll; ll = ll->next) ++ { ++ d = ll->data; ++ printf(" search in %s (%s)\n", p->name, d->state.name); ++ if (d->rel1.id_x == old_id) d->rel1.id_x = new_id; ++ if (d->rel1.id_y == old_id) d->rel1.id_y = new_id; ++ if (d->rel2.id_x == old_id) d->rel2.id_x = new_id; ++ if (d->rel2.id_y == old_id) d->rel2.id_y = new_id; ++ if (d->text.id_source == old_id) d->text.id_source = new_id; ++ if (d->text.id_text_source == old_id) d->text.id_text_source = new_id; ++ } ++ } ++ ++ //TODO search also in programs ++ ++ ++ // adjust table_parts ++ ed->table_parts[new_id] = rp; ++} ++static void ++_edje_part_id_switch(Edje *ed, Edje_Real_Part *rp1, Edje_Real_Part *rp2) ++{ ++ /* This function switch the id of two parts. ++ * All the depedency will be updated too. ++ * Also the table_parts is updated, ++ * The parts list isn't touched ++ */ ++ int id1; ++ int id2; ++ Evas_List *l; ++ ++ printf("SWITCH ID OF PART %d AND %d\n", rp1->part->id, rp2->part->id); ++ ++ if (!ed || !rp1 || !rp2) return; ++ if (rp1 == rp2) return; ++ ++ id1 = rp1->part->id; ++ id2 = rp2->part->id; ++ ++ //Switch ids ++ rp1->part->id = id2; ++ rp2->part->id = id1; ++ ++ // adjust table_parts ++ ed->table_parts[id1] = rp2; ++ ed->table_parts[id2] = rp1; ++ ++ // Fix all the dependecies in all parts... ++ for (l = ed->collection->parts; l; l = l->next) ++ { ++ Edje_Part *p; ++ p = l->data; ++ //printf(" search id: %d in %s\n", old_id, p->name); ++ if (p->clip_to_id == id1) p->clip_to_id = id2; ++ else if (p->clip_to_id == id2) p->clip_to_id = id1; ++ if (p->dragable.confine_id == id1) p->dragable.confine_id = id2; ++ else if (p->dragable.confine_id == id2) p->dragable.confine_id = id1; ++ ++ // ...in default description ++ Evas_List *ll; ++ Edje_Part_Description *d; ++ d = p->default_desc; ++ // printf(" search in %s (%s)\n", p->name, d->state.name); ++ if (d->rel1.id_x == id1) d->rel1.id_x = id2; ++ else if (d->rel1.id_x == id2) d->rel1.id_x = id1; ++ if (d->rel1.id_y == id1) d->rel1.id_y = id2; ++ else if (d->rel1.id_y == id2) d->rel1.id_y = id1; ++ if (d->rel2.id_x == id1) d->rel2.id_x = id2; ++ else if (d->rel2.id_x == id2) d->rel2.id_x = id1; ++ if (d->rel2.id_y == id1) d->rel2.id_y = id2; ++ else if (d->rel2.id_y == id2) d->rel2.id_y = id1; ++ if (d->text.id_source == id1) d->text.id_source = id2; ++ else if (d->text.id_source == id2) d->text.id_source = id1; ++ if (d->text.id_text_source == id1) d->text.id_text_source = id2; ++ else if (d->text.id_text_source == id2) d->text.id_text_source = id2; ++ // ...and in all other descriptions ++ for (ll = p->other_desc; ll; ll = ll->next) ++ { ++ d = ll->data; ++ printf(" search in %s (%s)\n", p->name, d->state.name); ++ if (d->rel1.id_x == id1) d->rel1.id_x = id2; ++ else if (d->rel1.id_x == id2) d->rel1.id_x = id1; ++ if (d->rel1.id_y == id1) d->rel1.id_y = id2; ++ else if (d->rel1.id_y == id2) d->rel1.id_y = id1; ++ if (d->rel2.id_x == id1) d->rel2.id_x = id2; ++ else if (d->rel2.id_x == id2) d->rel2.id_x = id1; ++ if (d->rel2.id_y == id1) d->rel2.id_y = id2; ++ else if (d->rel2.id_y == id2) d->rel2.id_y = id1; ++ if (d->text.id_source == id1) d->text.id_source = id2; ++ else if (d->text.id_source == id2) d->text.id_source = id1; ++ if (d->text.id_text_source == id1) d->text.id_text_source = id2; ++ else if (d->text.id_text_source == id2) d->text.id_text_source = id2; ++ } ++ } ++ ++ //TODO search also in programs ++ //TODO Real part dependencies are ok? ++} ++static void ++_edje_fix_parts_id(Edje *ed) ++{ ++ /* We use this to clear the id hole leaved when a part is removed. ++ * After the execution of this function all parts will have a right ++ * (uniqe & ordered) id. The table_parts is also updated. ++ */ ++ Evas_List *l; ++ int correct_id; ++ int count; ++ printf("FIXING PARTS ID \n"); ++ ++ //TODO order the list first to be more robust ++ ++ //Give a correct id to all the parts ++ correct_id = 0; ++ for (l = ed->collection->parts; l; l = l->next) ++ { ++ Edje_Part *p; ++ ++ p = l->data; ++ printf(" [%d]Checking part: %s id: %d\n", correct_id, p->name, p->id); ++ if (p->id != correct_id) ++ _edje_part_id_set(ed, ed->table_parts[p->id], correct_id); ++ ++ correct_id++; ++ } ++ ++ //If we have removed some parts realloc table_parts ++ count = evas_list_count(ed->collection->parts); ++ if (count != ed->table_parts_size) ++ { ++ ed->table_parts = realloc(ed->table_parts, SZ(Edje_Real_Part *) * count); ++ ed->table_parts_size = count; ++ } ++ ++ printf("\n"); ++} ++ +EAPI unsigned char +edje_edit_part_del(Evas_Object *obj, const char* part) +{ @@ -2123,6 +2309,7 @@ + if (ed->table_parts_size <= 1) return FALSE; //don't remove the last part + + //Remove part from parts list ++ //...at the end of the function we fix the list/table association + Edje_Part_Collection *pc; + pc = ed->collection; + pc->parts = evas_list_remove(pc->parts, ep); @@ -2167,73 +2354,46 @@ + if (real->custom.rel1_to_y == rp) real->custom.rel1_to_y = NULL; + if (real->custom.rel2_to_x == rp) real->custom.rel2_to_x = NULL; + if (real->custom.rel2_to_y == rp) real->custom.rel2_to_y = NULL; ++ //TODO clip_to ?? confine ?? + } + -+ -+ //Free real_part -+ _edje_real_part_free(rp); -+ -+ -+ //Update parts table (and all references?) -+ //We move the last part in place of the deleted one -+ //and realloc the table without the last element. -+ ed->table_parts[id % ed->table_parts_size] = ed->table_parts[ed->table_parts_size-1]; -+ ed->table_parts_size--; -+ ed->table_parts = realloc(ed->table_parts, -+ sizeof(Edje_Real_Part *) * ed->table_parts_size); -+ -+ //Update the id of the moved part -+ int old_id; -+ if (id < ed->table_parts_size) -+ { -+ rp = ed->table_parts[id % ed->table_parts_size]; -+ printf("UPDATE: %s(id:%d) with new id: %d\n", -+ rp->part->name, rp->part->id, id); -+ old_id = rp->part->id; -+ rp->part->id = id; -+ }else -+ old_id = -1; -+ -+ //We also update all the parts and descriptions that refer to id or old_id ++ // Clear all the parts and descriptions that refer to id + for (l = ed->collection->parts; l; l = l->next) + { + Edje_Part *p; + p = l->data; -+ if (p->clip_to_id == id) p->clip_to_id = 0; //TODO is 0 right?? don't tink so (maybe we need to unclip in some way) -+ if (p->clip_to_id == old_id && old_id != -1) p->clip_to_id = id; -+ if (p->dragable.confine_id == id) p->dragable.confine_id = 0; //TODO is 0 right?? don't tink so (maybe we need to unclip in some way) -+ if (p->dragable.confine_id == old_id && old_id != -1) -+ p->dragable.confine_id = id; ++ if (p->clip_to_id == id) p->clip_to_id = -1; //TODO is 0 right?? don't tink so (maybe we need to unclip in some way) ++ if (p->dragable.confine_id == id) p->dragable.confine_id = 0; //TODO is 0 right?? don't tink so + + Evas_List *ll; + Edje_Part_Description *d; + d = p->default_desc; + if (d->rel1.id_x == id) d->rel1.id_x = -1; -+ if (d->rel1.id_x == old_id && old_id != -1) d->rel1.id_x = id; + if (d->rel1.id_y == id) d->rel1.id_y = -1; -+ if (d->rel1.id_y == old_id && old_id != -1) d->rel1.id_y = id; + if (d->rel2.id_x == id) d->rel2.id_x = -1; -+ if (d->rel2.id_x == old_id && old_id != -1) d->rel2.id_x = id; + if (d->rel2.id_y == id) d->rel2.id_y = -1; -+ if (d->rel2.id_y == old_id && old_id != -1) d->rel2.id_y = id; -+ //TODO d->text.id_source ?? -+ //TODO d->text.id_text_source ?? ++ if (d->text.id_source == id) d->text.id_source = -1; ++ if (d->text.id_text_source == id) d->text.id_text_source = -1; ++ + for (ll = p->other_desc; ll; ll = ll->next) + { + d = ll->data; + if (d->rel1.id_x == id) d->rel1.id_x = -1; -+ if (d->rel1.id_x == old_id && old_id != -1) d->rel1.id_x = id; + if (d->rel1.id_y == id) d->rel1.id_y = -1; -+ if (d->rel1.id_y == old_id && old_id != -1) d->rel1.id_y = id; + if (d->rel2.id_x == id) d->rel2.id_x = -1; -+ if (d->rel2.id_x == old_id && old_id != -1) d->rel2.id_x = id; + if (d->rel2.id_y == id) d->rel2.id_y = -1; -+ if (d->rel2.id_y == old_id && old_id != -1) d->rel2.id_y = id; -+ //TODO d->text.id_source ?? -+ //TODO d->text.id_text_source ?? ++ if (d->text.id_source == id) d->text.id_source = -1; ++ if (d->text.id_text_source == id) d->text.id_text_source = -1; + } + } + ++ ++ //Free real_part ++ _edje_real_part_free(rp); ++ ++ //We have now a hole in the id sequence...fixing it ++ _edje_fix_parts_id(ed); ++ + edje_object_calc_force(obj); + + return TRUE; @@ -2241,33 +2401,49 @@ + + +EAPI unsigned char -+edje_edit_part_restack(Evas_Object *obj, const char* part, const char *after) ++edje_edit_part_restack_below(Evas_Object *obj, const char* part) +{ -+ printf("RESTACK PART: %s [after: %s]\n", part, after); ++ printf("RESTACK PART: %s BELOW\n", part); + GET_RP_OR_RETURN(0) + ++ if (rp->part->id < 1) return 0; + Edje_Part_Collection *group; + group = ed->collection; + -+ if (after) -+ { -+ Edje_Real_Part *af; -+ af = _edje_real_part_get(ed, after); -+ if(!af) return 0; -+ -+ group->parts = evas_list_remove(group->parts, rp->part); -+ group->parts = evas_list_append_relative(group->parts, rp->part, af->part); ++ /* update parts list */ ++ Edje_Real_Part *prev; ++ prev = ed->table_parts[(rp->part->id - 1) % ed->table_parts_size]; ++ group->parts = evas_list_remove(group->parts, rp->part); ++ group->parts = evas_list_prepend_relative(group->parts, rp->part, prev->part); + -+ evas_object_stack_above(rp->object, af->object); -+ } -+ else -+ { -+ group->parts = evas_list_remove(group->parts, rp->part); -+ group->parts = evas_list_prepend(group->parts, rp->part); -+ evas_object_lower(rp->object); -+ } ++ _edje_part_id_switch(ed, rp, prev); + -+ edje_object_calc_force(obj); ++ evas_object_stack_below(rp->object, prev->object); ++ ++ return 1; ++} ++ ++EAPI unsigned char ++edje_edit_part_restack_above(Evas_Object *obj, const char* part) ++{ ++ printf("RESTACK PART: %s ABOVE\n", part); ++ GET_RP_OR_RETURN(0) ++ ++ if (rp->part->id >= ed->table_parts_size - 1) return 0; ++ ++ Edje_Part_Collection *group; ++ group = ed->collection; ++ ++ /* update parts list */ ++ Edje_Real_Part *next; ++ next = ed->table_parts[(rp->part->id + 1) % ed->table_parts_size]; ++ group->parts = evas_list_remove(group->parts, rp->part); ++ group->parts = evas_list_append_relative(group->parts, rp->part, next->part); ++ ++ /* update ids */ ++ _edje_part_id_switch(ed, rp, next); ++ ++ evas_object_stack_above(rp->object, next->object); + + return 1; +} @@ -4306,6 +4482,7 @@ +edje_edit_print_internal_status(Evas_Object *obj) +{ + int i; ++ Evas_List *l; + GET_ED_OR_RETURN() + printf("\n****** CHECKIN' INTERNAL STRUCTS STATUS *********\n"); + @@ -4323,11 +4500,17 @@ + rp = ed->table_parts[i % ed->table_parts_size]; + printf(" [%d]%s (id:%d)\n", i , rp->part->name, rp->part->id); + } ++ printf("---------\n"); ++ for (l = ed->collection->parts; l; l = l->next) ++ { ++ Edje_Part *p; ++ ++ p = l->data; ++ printf(" []%s (id:%d)\n", p->name, p->id); ++ } + + printf("\n"); + -+ printf("\n"); -+ printf("\n"); + + printf("****************** END ************************\n\n"); +} @@ -4337,7 +4520,7 @@ retrieving revision 1.111 diff -u -r1.111 edje_load.c --- src/lib/edje_load.c 18 Jan 2008 06:34:04 -0000 1.111 -+++ src/lib/edje_load.c 18 Feb 2008 20:33:02 -0000 ++++ src/lib/edje_load.c 19 Feb 2008 06:13:15 -0000 @@ -5,7 +5,7 @@ #include "Edje.h" #include "edje_private.h" ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs