Enlightenment CVS committal Author : davemds Project : e17 Module : proto/edje_editor
Dir : e17/proto/edje_editor/src/bin Modified Files: callbacks.c callbacks.h interface.c interface.h main.c main.h Log Message: * Add ability to do internal autoswallow (part of type GROUP) wow, this is a great feature, really usefull in the editor. :) You can for example make a group that is a 'custom button' and then use it in other groups (maybe your main interface). =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/src/bin/callbacks.c,v retrieving revision 1.62 retrieving revision 1.63 diff -u -3 -r1.62 -r1.63 --- callbacks.c 24 Feb 2008 14:17:09 -0000 1.62 +++ callbacks.c 26 Feb 2008 01:33:35 -0000 1.63 @@ -37,8 +37,9 @@ evas_object_move(embed_object, 0, 55); evas_object_resize(embed_object, TREE_WIDTH, win_h - 55); + //Resize Consolle evas_object_move(Consolle, TREE_WIDTH + 5, win_h - 80); - evas_object_resize(Consolle, 400, 75); + evas_object_resize(Consolle, win_w - TREE_WIDTH - 10, 75); } /* Catch all the signal from the editing edje object */ void @@ -128,6 +129,9 @@ else row = AddPartToTree(Cur.part->string, (void*)1); etk_tree_row_select(row); + //Reload the edje if needed + if (edje_edit_part_type_get(edje_o, Cur.part->string) == EDJE_PART_TYPE_GROUP) + ReloadEdje(); break; case TOOLBAR_MOVE_DOWN: //Raise @@ -147,6 +151,9 @@ etk_tree_row_delete(row); row = AddPartToTree(Cur.part->string, next); etk_tree_row_select(row); + //Reload the edje if needed + if (edje_edit_part_type_get(edje_o, Cur.part->string) == EDJE_PART_TYPE_GROUP) + ReloadEdje(); break; case TOOLBAR_IMAGE_FILE_ADD: @@ -443,6 +450,7 @@ on_PartNameEntryImage_mouse_clicked(Etk_Object *object, void *data) { const char *name; + char *image_name; Etk_Tree_Row *row; Etk_Tree_Row *child; @@ -470,30 +478,11 @@ //Update PartTree row = etk_tree_selected_row_get(ETK_TREE(UI_PartsTree)); + image_name = GetPartTypeImage(edje_edit_part_type_get(edje_o, Cur.part->string)); + etk_tree_row_fields_set(row,TRUE, + COL_NAME, EdjeFile, image_name, name, NULL); + free(image_name); - switch (edje_edit_part_type_get(edje_o, Cur.part->string)) - { - case EDJE_PART_TYPE_IMAGE: - etk_tree_row_fields_set(row,TRUE, - COL_NAME, EdjeFile, "IMAGE.PNG", name, NULL); - break; - case EDJE_PART_TYPE_RECTANGLE: - etk_tree_row_fields_set(row,TRUE, - COL_NAME, EdjeFile, "RECT.PNG", name, NULL); - break; - case EDJE_PART_TYPE_TEXT: - etk_tree_row_fields_set(row,TRUE, - COL_NAME, EdjeFile, "TEXT.PNG", name, NULL); - break; - case EDJE_PART_TYPE_SWALLOW: - etk_tree_row_fields_set(row,TRUE, - COL_NAME, EdjeFile, "SWAL.PNG", name, NULL); - break; - default: - etk_tree_row_fields_set(row,TRUE, - COL_NAME, EdjeFile, "NONE.PNG", name, NULL); - break; - } /* Update hidden colon on every child */ child = etk_tree_row_first_child_get(row); @@ -533,6 +522,30 @@ } Etk_Bool +on_PartSourceComboBox_item_activated(Etk_Combobox *combobox, Etk_Combobox_Item *item, void *data) +{ + char *gr; + printf("Item Activated Signal on PartSourceCombobox EMITTED\n"); + + gr = etk_combobox_item_field_get(item,0); + + if (!strcmp(gr, Cur.group->string)) + { + ShowAlert("A group can't contain itself"); + return ETK_TRUE; + } + + if (strcmp(gr, "None")) + edje_edit_part_source_set(edje_o, Cur.part->string, gr); + else + edje_edit_part_source_set(edje_o, Cur.part->string, NULL); + + ReloadEdje(); + + return ETK_TRUE; +} + +Etk_Bool on_PartEventsCheck_toggled(Etk_Object *object, void *data) { printf("Toggled Signal on EventsCheck EMITTED\n"); @@ -1502,7 +1515,30 @@ PopulateRelComboBoxes(); PopulateSourceComboEntry(); break; - + case NEW_GROUPSWAL: + if (!etk_string_length_get(Cur.group)) + { + ShowAlert("You must first select a group."); + break; + } + //generate a unique new name + snprintf(name, sizeof(name), "New group swallow"); + i = 2; + while (edje_edit_part_exist(edje_o, name)) + snprintf(name, sizeof(name), "New group swallow %d", i++); + + if (!edje_edit_part_add(edje_o, name, EDJE_PART_TYPE_GROUP)) + { + ShowAlert("Can't create part."); + break; + } + row = AddPartToTree(name, NULL); + etk_tree_row_select(row); + etk_tree_row_unfold(row); + PopulateRelComboBoxes(); + PopulateSourceComboEntry(); + + break; case NEW_DESC: if (!etk_string_length_get(Cur.part)) { =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/src/bin/callbacks.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- callbacks.h 22 Feb 2008 02:36:40 -0000 1.24 +++ callbacks.h 26 Feb 2008 01:33:35 -0000 1.25 @@ -15,6 +15,7 @@ Etk_Bool on_PartNameEntryImage_mouse_clicked(Etk_Object *object, void *data); Etk_Bool on_PartNameEntry_key_down (Etk_Object *object, Etk_Event_Key_Down *event, void *data); Etk_Bool on_CliptoComboBox_item_activated (Etk_Combobox *combobox, Etk_Combobox_Item *item, void *data); +Etk_Bool on_PartSourceComboBox_item_activated(Etk_Combobox *combobox, Etk_Combobox_Item *item, void *data); Etk_Bool on_PartEventsCheck_toggled (Etk_Object *object, void *data); Etk_Bool on_PartEventsRepeatCheck_toggled (Etk_Object *object, void *data); Etk_Bool on_StateEntry_key_down (Etk_Object *object, Etk_Event_Key_Down *event, void *data); =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/src/bin/interface.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -3 -r1.66 -r1.67 --- interface.c 24 Feb 2008 14:17:09 -0000 1.66 +++ interface.c 26 Feb 2008 01:33:35 -0000 1.67 @@ -114,6 +114,31 @@ * functions to update interface * ***********************************/ + +char* +GetPartTypeImage(int part_type) +{ + /* Get the name ot the group in edje_editor.edj that + * correspond to the given EDJE_PART_TYPE. + * Remember to free the returned string. + */ + + static char buf[20]; + char *ret; + + switch (part_type) + { + case EDJE_PART_TYPE_IMAGE: strcpy(buf,"IMAGE.PNG"); break; + case EDJE_PART_TYPE_TEXT: strcpy(buf,"TEXT.PNG"); break; + case EDJE_PART_TYPE_RECTANGLE: strcpy(buf,"RECT.PNG"); break; + case EDJE_PART_TYPE_SWALLOW: strcpy(buf,"SWAL.PNG"); break; + case EDJE_PART_TYPE_GROUP: strcpy(buf,"GROUP.PNG"); break; + default: strcpy(buf,"NONE.PNG"); break; + } + ret = strdup(buf); + printf("IMAGE: %s\n",ret); + return ret; +} Etk_Tree_Row * AddPartToTree(const char *part_name, Etk_Tree_Row *after) { @@ -124,18 +149,9 @@ I hope no one get a real row pointer == 1 :P */ Etk_Tree_Row *row = NULL; - char buf[20]; + char *buf; //printf("Add Part to tree: %s\n",par->name); - - switch (edje_edit_part_type_get(edje_o, part_name)) - { - case EDJE_PART_TYPE_IMAGE: strcpy(buf,"IMAGE.PNG"); break; - case EDJE_PART_TYPE_TEXT: strcpy(buf,"TEXT.PNG"); break; - case EDJE_PART_TYPE_RECTANGLE: strcpy(buf,"RECT.PNG"); break; - case EDJE_PART_TYPE_SWALLOW: strcpy(buf,"SWAL.PNG"); break; - default: strcpy(buf,"NONE.PNG"); break; - } /* Search for the last row that isn't a program */ if (after == 0) @@ -152,6 +168,8 @@ } } + /* Add the row in the right position */ + buf = GetPartTypeImage(edje_edit_part_type_get(edje_o, part_name)); if ((int)after > 1) row = etk_tree_row_insert(ETK_TREE(UI_PartsTree), NULL, @@ -183,6 +201,7 @@ sp = sp->next; } edje_edit_string_list_free(states); + free(buf); return row; } @@ -254,16 +273,31 @@ Evas_List *groups, *l; //Stop signal propagation - etk_signal_block("item-activated",ETK_OBJECT(UI_GroupsComboBox), on_GroupsComboBox_activated, NULL); + etk_signal_block("item-activated",ETK_OBJECT(UI_GroupsComboBox), + on_GroupsComboBox_activated, NULL); + etk_signal_block("item-activated",ETK_OBJECT(UI_PartSourceComboBox), + on_PartSourceComboBox_item_activated, NULL); + + //Clear the combos etk_combobox_clear(ETK_COMBOBOX(UI_GroupsComboBox)); + etk_combobox_clear(ETK_COMBOBOX(UI_PartSourceComboBox)); + etk_combobox_item_append(ETK_COMBOBOX(UI_PartSourceComboBox), "None"); + //Populate UI_GroupsComboBox & UI_PartSourceComboBox groups = edje_file_collection_list(Cur.edj_temp_name->string); for(l = groups; l; l = l->next) + { etk_combobox_item_append(ETK_COMBOBOX(UI_GroupsComboBox), (char*)l->data); + etk_combobox_item_append(ETK_COMBOBOX(UI_PartSourceComboBox), (char*)l->data); + } edje_file_collection_list_free(groups); //Renable signal propagation - etk_signal_unblock("item-activated",ETK_OBJECT(UI_GroupsComboBox), on_GroupsComboBox_activated, NULL); + etk_signal_unblock("item-activated",ETK_OBJECT(UI_GroupsComboBox), + on_GroupsComboBox_activated, NULL); + etk_signal_unblock("item-activated",ETK_OBJECT(UI_PartSourceComboBox), + on_PartSourceComboBox_item_activated, NULL); + etk_combobox_active_item_set(ETK_COMBOBOX(UI_GroupsComboBox), etk_combobox_first_item_get(ETK_COMBOBOX(UI_GroupsComboBox))); @@ -331,8 +365,8 @@ PopulateRelComboBoxes(void) { Evas_List *l; - - char buf[20]; + char *image_name; + printf("Populate 4 Rel Comboboxs\n"); //Stop signal propagation etk_signal_block("active-item-changed", ETK_OBJECT(UI_Rel1ToXComboBox), ETK_CALLBACK(on_RelToComboBox_changed), (void *)REL1X_SPINNER); @@ -376,33 +410,24 @@ { //printf("-- %s\n", (char *)l->data); type = edje_edit_part_type_get(edje_o,(char *)l->data); - - if (type == EDJE_PART_TYPE_RECTANGLE) - snprintf(buf, 19,"RECT.PNG"); - else if (type == EDJE_PART_TYPE_TEXT) - snprintf(buf, 19,"TEXT.PNG"); - else if (type == EDJE_PART_TYPE_IMAGE) - snprintf(buf, 19,"IMAGE.PNG"); - else if (type == EDJE_PART_TYPE_SWALLOW) - snprintf(buf, 19,"SWAL.PNG"); - else snprintf(buf, 19,"NONE.PNG"); + image_name = GetPartTypeImage(type); etk_combobox_item_append(ETK_COMBOBOX(UI_Rel1ToXComboBox), - etk_image_new_from_edje(EdjeFile,buf), + etk_image_new_from_edje(EdjeFile, image_name), (char *)l->data); etk_combobox_item_append(ETK_COMBOBOX(UI_Rel1ToYComboBox), - etk_image_new_from_edje(EdjeFile,buf), + etk_image_new_from_edje(EdjeFile, image_name), (char *)l->data); etk_combobox_item_append(ETK_COMBOBOX(UI_Rel2ToXComboBox), - etk_image_new_from_edje(EdjeFile,buf), + etk_image_new_from_edje(EdjeFile, image_name), (char *)l->data); etk_combobox_item_append(ETK_COMBOBOX(UI_Rel2ToYComboBox), - etk_image_new_from_edje(EdjeFile,buf), + etk_image_new_from_edje(EdjeFile, image_name), (char *)l->data); etk_combobox_item_append(ETK_COMBOBOX(UI_CliptoComboBox), - etk_image_new_from_edje(EdjeFile,buf), + etk_image_new_from_edje(EdjeFile, image_name), (char *)l->data); - + free(image_name); l = l->next; } edje_edit_string_list_free(parts); @@ -446,7 +471,7 @@ PopulateSourceComboEntry(void) { Evas_List *l; - char buf[20]; + char *image_name; printf("Populate Program Source ComboEntry\n"); //Stop signal propagation @@ -458,18 +483,11 @@ l = edje_edit_parts_list_get(edje_o); while (l) { - switch (edje_edit_part_type_get(edje_o, (char*)l->data)) - { - case EDJE_PART_TYPE_IMAGE: strcpy(buf,"IMAGE.PNG"); break; - case EDJE_PART_TYPE_TEXT: strcpy(buf,"TEXT.PNG"); break; - case EDJE_PART_TYPE_RECTANGLE: strcpy(buf,"RECT.PNG"); break; - case EDJE_PART_TYPE_SWALLOW: strcpy(buf,"SWAL.PNG"); break; - default: strcpy(buf,"NONE.PNG"); break; - } - + image_name = GetPartTypeImage(edje_edit_part_type_get(edje_o, (char*)l->data)); etk_combobox_entry_item_append(ETK_COMBOBOX_ENTRY(UI_SourceEntry), - etk_image_new_from_edje(EdjeFile, buf), + etk_image_new_from_edje(EdjeFile, image_name), (char *)l->data); + free(image_name); l = l->next; } @@ -588,6 +606,8 @@ on_PartEventsRepeatCheck_toggled, NULL); etk_signal_block("item-activated", ETK_OBJECT(UI_CliptoComboBox), ETK_CALLBACK(on_CliptoComboBox_item_activated), NULL); + etk_signal_block("item-activated", ETK_OBJECT(UI_PartSourceComboBox), + ETK_CALLBACK(on_PartSourceComboBox_item_activated), NULL); if (etk_string_length_get(Cur.part)) { @@ -623,10 +643,43 @@ else etk_combobox_active_item_set(ETK_COMBOBOX(UI_CliptoComboBox), etk_combobox_first_item_get(ETK_COMBOBOX(UI_CliptoComboBox))); - edje_edit_string_free(clipto); + + + /* Update PartSource combobox */ + const char *source; + source = edje_edit_part_source_get(edje_o, Cur.part->string); + + if (source) + { + //Loop for all the item in the Combobox + i=1; + while ((item = etk_combobox_nth_item_get(ETK_COMBOBOX(UI_PartSourceComboBox),i))) + { + p = etk_combobox_item_field_get(item, 0); + if (!strcmp(p, source)) + etk_combobox_active_item_set(ETK_COMBOBOX(UI_PartSourceComboBox),item); + i++; + } + } + else + etk_combobox_active_item_set(ETK_COMBOBOX(UI_PartSourceComboBox), + etk_combobox_first_item_get(ETK_COMBOBOX(UI_PartSourceComboBox))); + + edje_edit_string_free(source); } + //Show/hide Sourcecombo for part EDJE_PART_TYPE_GROUP + if (edje_edit_part_type_get(edje_o, Cur.part->string) == EDJE_PART_TYPE_GROUP) + { + etk_widget_show(UI_PartSourceComboBox); + etk_widget_show(UI_PartSourceLabel); + } + else + { + etk_widget_hide(UI_PartSourceComboBox); + etk_widget_hide(UI_PartSourceLabel); + } //ReEnable Signal Propagation etk_signal_unblock("text-changed",ETK_OBJECT(UI_PartNameEntry), @@ -637,6 +690,8 @@ on_PartEventsRepeatCheck_toggled, NULL); etk_signal_unblock("item-activated", ETK_OBJECT(UI_CliptoComboBox), ETK_CALLBACK(on_CliptoComboBox_item_activated), NULL); + etk_signal_unblock("item-activated", ETK_OBJECT(UI_PartSourceComboBox), + ETK_CALLBACK(on_PartSourceComboBox_item_activated), NULL); } @@ -1438,6 +1493,14 @@ ETK_CALLBACK(on_AddMenu_item_activated), (void*)NEW_SWAL); etk_menu_shell_append(ETK_MENU_SHELL(UI_AddMenu), ETK_MENU_ITEM(menu_item)); + //New GroupSwallow + menu_item = etk_menu_item_image_new_with_label("Group swallow"); + image = etk_image_new_from_edje(EdjeFile,"GROUP.PNG"); + etk_menu_item_image_set(ETK_MENU_ITEM_IMAGE(menu_item), ETK_IMAGE(image)); + etk_signal_connect("activated", ETK_OBJECT(menu_item), + ETK_CALLBACK(on_AddMenu_item_activated), (void*)NEW_GROUPSWAL); + etk_menu_shell_append(ETK_MENU_SHELL(UI_AddMenu), ETK_MENU_ITEM(menu_item)); + //New Program menu_item = etk_menu_item_image_new_with_label("Program"); image = etk_image_new_from_edje(EdjeFile,"PROG.PNG"); @@ -2418,7 +2481,7 @@ Etk_Widget *hbox; //table - table = etk_table_new(2, 3, ETK_TABLE_NOT_HOMOGENEOUS); + table = etk_table_new(2, 4, ETK_TABLE_NOT_HOMOGENEOUS); //PartNameEntry label = etk_label_new("<b>Name</b>"); @@ -2431,14 +2494,14 @@ etk_table_attach_default(ETK_TABLE(table),UI_PartNameEntry, 1, 1, 0, 0); //UI_CliptoComboBox - label = etk_label_new("<b>Clip_to</b>"); + label = etk_label_new("<b>Clip to</b>"); etk_table_attach(ETK_TABLE(table), label, 0, 0, 1, 1,ETK_TABLE_NONE,0,0); UI_CliptoComboBox = etk_combobox_new(); etk_combobox_column_add(ETK_COMBOBOX(UI_CliptoComboBox), - ETK_COMBOBOX_IMAGE, 24, ETK_COMBOBOX_NONE, 0.0); + ETK_COMBOBOX_IMAGE, 24, ETK_COMBOBOX_NONE, 0.0); etk_combobox_column_add(ETK_COMBOBOX(UI_CliptoComboBox), - ETK_COMBOBOX_LABEL, 75, ETK_COMBOBOX_NONE, 0.0); + ETK_COMBOBOX_LABEL, 75, ETK_COMBOBOX_NONE, 0.0); etk_combobox_build(ETK_COMBOBOX(UI_CliptoComboBox)); etk_table_attach_default(ETK_TABLE(table), UI_CliptoComboBox, 1, 1, 1, 1); @@ -2461,19 +2524,33 @@ etk_box_append(ETK_BOX(hbox), UI_PartEventsRepeatCheck, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); + //UI_PartSourceComboBox + UI_PartSourceLabel = etk_label_new("<b>Source</b>"); + etk_table_attach(ETK_TABLE(table), UI_PartSourceLabel, + 0, 0, 3, 3, ETK_TABLE_NONE, 0, 0); + + UI_PartSourceComboBox = etk_combobox_new(); + etk_combobox_column_add(ETK_COMBOBOX(UI_PartSourceComboBox), + ETK_COMBOBOX_LABEL, 75, ETK_COMBOBOX_NONE, 0.0); + etk_combobox_build(ETK_COMBOBOX(UI_PartSourceComboBox)); + etk_table_attach_default(ETK_TABLE(table), UI_PartSourceComboBox, 1, 1, 3, 3); + + + etk_signal_connect("text-changed", ETK_OBJECT(UI_PartNameEntry), ETK_CALLBACK(on_NamesEntry_text_changed), NULL); etk_signal_connect("key-down", ETK_OBJECT(UI_PartNameEntry), ETK_CALLBACK(on_PartNameEntry_key_down), NULL); etk_signal_connect("mouse-click", ETK_OBJECT(UI_PartNameEntryImage), ETK_CALLBACK(on_PartNameEntryImage_mouse_clicked), NULL); - etk_signal_connect("toggled", ETK_OBJECT(UI_PartEventsCheck), ETK_CALLBACK(on_PartEventsCheck_toggled), NULL); etk_signal_connect("toggled", ETK_OBJECT(UI_PartEventsRepeatCheck), ETK_CALLBACK(on_PartEventsRepeatCheck_toggled), NULL); etk_signal_connect("item-activated", ETK_OBJECT(UI_CliptoComboBox), ETK_CALLBACK(on_CliptoComboBox_item_activated), NULL); + etk_signal_connect("item-activated", ETK_OBJECT(UI_PartSourceComboBox), + ETK_CALLBACK(on_PartSourceComboBox_item_activated), NULL); return table; } =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/src/bin/interface.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- interface.h 24 Feb 2008 14:17:09 -0000 1.34 +++ interface.h 26 Feb 2008 01:33:36 -0000 1.35 @@ -50,6 +50,8 @@ Etk_Widget *UI_PartEventsCheck; Etk_Widget *UI_PartEventsRepeatCheck; Etk_Widget *UI_CliptoComboBox; +Etk_Widget *UI_PartSourceComboBox; +Etk_Widget *UI_PartSourceLabel; /* state frame objects */ Etk_Widget *UI_StateEntry; Etk_Widget *UI_StateEntryImage; @@ -177,5 +179,6 @@ void ConsolleLog(char *text); void ConsolleClear(void); void TogglePlayButton(int set); +char* GetPartTypeImage(int part_type); #endif =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/src/bin/main.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- main.c 23 Feb 2008 03:54:46 -0000 1.35 +++ main.c 26 Feb 2008 01:33:36 -0000 1.36 @@ -165,6 +165,19 @@ } +void ReloadEdje(void) +{ + if (!etk_string_length_get(Cur.group)) return; + if (!etk_string_length_get(Cur.edj_temp_name)) return; + + //Set a fake object to make sure edje is reloading + //maybe we can fix this removing the check from _edje_object_file_set_internal + edje_edit_save(edje_o); + edje_object_file_set(edje_o, EdjeFile, "IMAGE.PNG"); + edje_object_file_set(edje_o, Cur.edj_temp_name->string, Cur.group->string); + +} + int LoadEDJ(char *file) { =================================================================== RCS file: /cvs/e/e17/proto/edje_editor/src/bin/main.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- main.h 24 Feb 2008 14:17:09 -0000 1.31 +++ main.h 26 Feb 2008 01:33:36 -0000 1.32 @@ -69,6 +69,7 @@ NEW_RECT, NEW_TEXT, NEW_SWAL, + NEW_GROUPSWAL, NEW_PROG, NEW_DESC, NEW_GROUP, @@ -151,6 +152,7 @@ void DebugInfo(int full); int LoadEDJ(char *file); void ChangeGroup(char *group); +void ReloadEdje(void); //This define is copied from edje_private.h (find a way to export it) ------------------------------------------------------------------------- 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