rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=452f527bc727f358339bb5dab88f81b0a7500658
commit 452f527bc727f358339bb5dab88f81b0a7500658 Author: Vitalii Vorobiov <[email protected]> Date: Fri Jan 13 14:30:08 2017 +0200 popup: special control (for property) that shows only vectors when clicked on --- src/bin/ui/main_window.h | 3 +- src/bin/ui/popup.c | 101 +++++++++++++++++++++++++++- src/bin/ui/property/property_common.c | 5 ++ src/bin/ui/property/property_common_image.c | 41 +++++++++++ src/bin/ui/property/property_common_tween.c | 3 +- src/bin/ui/property/property_group.c | 3 +- src/bin/ui/property/property_private.h | 5 ++ 7 files changed, 155 insertions(+), 6 deletions(-) diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h index 7894b6a..ec78197 100644 --- a/src/bin/ui/main_window.h +++ b/src/bin/ui/main_window.h @@ -113,6 +113,7 @@ typedef enum typedef enum { + VECTOR_IMAGE, SINGLE_IMAGE, IMAGE_SET, IMAGE_SET_ITEM @@ -422,7 +423,7 @@ popup_log_message_helper(const char *msg); void popup_gengrid_image_helper(const char *title, Evas_Object *follow_up, Helper_Done_Cb func, void *data, - Eina_Bool multi); + Eina_Bool multi, Eina_Bool vector); void popup_gengrid_helper_item_select(const char *item_title); diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c index ac724ef..e506aa7 100644 --- a/src/bin/ui/popup.c +++ b/src/bin/ui/popup.c @@ -55,6 +55,7 @@ struct _Item typedef struct _Item Item; static Elm_Gengrid_Item_Class *gic = NULL; static Elm_Gengrid_Item_Class *gic_set = NULL; +static Elm_Gengrid_Item_Class *gic_vec = NULL; static void _delete_object_job(void *data) @@ -710,11 +711,51 @@ _grid_del(void *data, assert(it != NULL); eina_stringshare_del(it->image_name); - eina_stringshare_del(it->source); + TODO("Remove 'IF' when exporting from edj to svg would be done properly") + if (it->source) + eina_stringshare_del(it->source); free(it); } static Eina_Bool +_vector_gengrid_init(Helper_Data *helper_data) +{ + Eina_List *l = NULL; + Item *it = NULL; + Eina_List *vectors = NULL; + int counter = 0; + Vector2 *res; + + vectors = ap.project->RM.vectors; + + if (vectors) + { + EINA_LIST_FOREACH(vectors, l, res) + { + counter++; + if (!res->common.name) + { + ERR("name not found for image #%d",counter); + continue; + } + it = (Item *)mem_malloc(sizeof(Item)); + it->image_name = eina_stringshare_add(res->common.name); + TODO("Export SVG images then allow to load it properly, through source"); + it->source = NULL; /* eina_stringshare_add(res->source); */ + it->type = VECTOR_IMAGE; + elm_gengrid_item_append(helper_data->gengrid, gic_vec, it, NULL, NULL); + } + elm_gengrid_item_bring_in(elm_gengrid_first_item_get(helper_data->gengrid), + ELM_GENGRID_ITEM_SCROLLTO_TOP); + } + elm_scroller_policy_set(helper_data->gengrid, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_AUTO); + evas_object_smart_calculate(helper_data->gengrid); + + return true; +} + +static Eina_Bool _image_gengrid_init(Helper_Data *helper_data) { Eina_List *l = NULL; @@ -918,6 +959,49 @@ empty_content: return NULL; } +/* icon fetching callback */ +static Evas_Object * +_grid_vector_content_get(void *data, + Evas_Object *obj, + const char *part) +{ + Item *it = data; + Evas_Object *image_obj = NULL; + Evas_Object *grid = (Evas_Object *)obj; + Resource2 *res; + + assert(it != NULL); + assert(grid != NULL); + + if (!strcmp(part, "elm.swallow.icon")) + { +#ifndef _WIN32 + image_obj = elm_thumb_add(grid); + TODO("Learn how to load picture from eet file to show OR wait when export svg implemenetation will be") +// elm_thumb_file_set(image_obj, it->source, it->image_name); +#else + TODO("Remove this urgly hack when we fix thumbs on Windows") + image_obj = elm_image_add(grid); +// elm_image_file_set(image_obj, it->source, it->image_name); +#endif /* _WIN32 */ + elm_object_style_set(image_obj, "noframe"); + evas_object_show(image_obj); + } + else if (!strcmp(part, "elm.swallow.end")) + { + res = resource_manager_find(ap.project->RM.vectors, it->image_name); + if (eina_list_count(res->common.used_in) == 0) + { + image_obj = elm_icon_add(grid); + elm_image_file_set(image_obj, ap.path.theme_edj, "elm/image/icon/attention"); + evas_object_show(image_obj); + } + } + + return image_obj; +} +#undef MAX_ICON_SIZE + ITEM_SEARCH_FUNC(gengrid, ELM_GENGRID_ITEM_SCROLLTO_MIDDLE, NULL) static void @@ -971,7 +1055,7 @@ _btn_image_manager_cb(void *data __UNUSED__, void popup_gengrid_image_helper(const char *title, Evas_Object *follow_up, Helper_Done_Cb func, void *data, - Eina_Bool multi) + Eina_Bool multi, Eina_Bool vector) { Evas_Object *entry, *icon, *button; Helper_Data *helper_data = (Helper_Data *)mem_calloc(1, sizeof(Helper_Data)); @@ -1035,8 +1119,19 @@ popup_gengrid_image_helper(const char *title, Evas_Object *follow_up, gic_set->func.del = _grid_del; } + if (!gic_vec) + { + gic_vec = elm_gengrid_item_class_new(); + gic_vec->item_style = "default"; + gic_vec->func.text_get = _grid_label_get; + gic_vec->func.content_get = _grid_vector_content_get; + gic_vec->func.del = _grid_del; + } - _image_gengrid_init(helper_data); + if (vector) + _vector_gengrid_init(helper_data); + else + _image_gengrid_init(helper_data); ENTRY_ADD(fs, entry, true); elm_object_part_text_set(entry, "guide", _("Search")); diff --git a/src/bin/ui/property/property_common.c b/src/bin/ui/property/property_common.c index 74f828c..88946d8 100644 --- a/src/bin/ui/property/property_common.c +++ b/src/bin/ui/property/property_common.c @@ -436,6 +436,10 @@ _control_create(Property_Attribute *pa, Property_Action *action, Evas_Object *pa content = property_image_normal_control_add(parent); evas_object_smart_callback_add(content, signals.eflete.property.image_normal_control.changed, _start_change_stop_cb, pa); break; + case PROPERTY_CONTROL_VECTOR_NORMAL: + content = property_vector_normal_control_add(parent); + evas_object_smart_callback_add(content, signals.eflete.property.image_normal_control.changed, _start_change_stop_cb, pa); + break; case PROPERTY_CONTROL_IMAGE_TWEEN: content = property_image_tween_control_add(parent); evas_object_smart_callback_add(content, signals.eflete.property.image_tween_control.changed, _start_change_stop_cb, pa); @@ -754,6 +758,7 @@ property_common_itc_init(Property_Data *pd) pd->item_classes[PROPERTY_CONTROL_COMBOBOX_CC] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow; pd->item_classes[PROPERTY_CONTROL_COLORSEL] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow_wide; pd->item_classes[PROPERTY_CONTROL_LABEL] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow; + pd->item_classes[PROPERTY_CONTROL_VECTOR_NORMAL] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow; pd->item_classes[PROPERTY_CONTROL_IMAGE_NORMAL] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow; pd->item_classes[PROPERTY_CONTROL_IMAGE_TWEEN] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow; pd->item_classes[PROPERTY_CONTROL_IMAGE_SELECTOR] [PROPERTY_CONTROL_NONE] = pd->itc_1swallow; diff --git a/src/bin/ui/property/property_common_image.c b/src/bin/ui/property/property_common_image.c index 96d644e..d486c6c 100644 --- a/src/bin/ui/property/property_common_image.c +++ b/src/bin/ui/property/property_common_image.c @@ -56,6 +56,7 @@ _on_state_image_choose(void *data, data, _on_image_editor_done, data, + false, false); TODO("apply after helper popup would be fixed") // elm_object_scroll_freeze_push(data); @@ -85,3 +86,43 @@ property_image_normal_control_add(Evas_Object *parent) return content; } + +static void +_on_state_vector_choose(void *data, + Evas_Object *obj __UNUSED__, + void *ei __UNUSED__) +{ + popup_gengrid_image_helper(NULL, + data, + _on_image_editor_done, + data, + false, + true); +TODO("apply after helper popup would be fixed") +// elm_object_scroll_freeze_push(data); +} + +Evas_Object * +property_vector_normal_control_add(Evas_Object *parent) +{ + Evas_Object *content, *btn; + + assert(parent != NULL); + + ENTRY_ADD(parent, content, true); + btn = elm_button_add(content); + elm_object_style_set(btn, "elipsis"); + evas_object_smart_callback_add(btn, signals.elm.button.clicked, _on_state_vector_choose, content); + evas_object_smart_callback_add(content, signals.elm.entry.clicked, _on_state_vector_choose, content); + elm_object_part_content_set(content, "elm.swallow.elipsis", btn); + elm_entry_editable_set(content, false); + evas_object_show(btn); + evas_object_show(content); + + evas_object_event_callback_add(content, + EVAS_CALLBACK_FREE, + popup_active_helper_close, + (void*)(uintptr_t)POPUP_GENGRID_IMAGE_HELPER); + + return content; +} diff --git a/src/bin/ui/property/property_common_tween.c b/src/bin/ui/property/property_common_tween.c index 92f6483..99c3317 100644 --- a/src/bin/ui/property/property_common_tween.c +++ b/src/bin/ui/property/property_common_tween.c @@ -128,7 +128,8 @@ _add_tween_image(void *data, obj, _on_image_editor_tween_done, control, - true); + true, + false); TODO("apply when popup will be fixed"); // elm_object_scroll_freeze_push(data); } diff --git a/src/bin/ui/property/property_group.c b/src/bin/ui/property/property_group.c index 77e4e96..3853e18 100644 --- a/src/bin/ui/property/property_group.c +++ b/src/bin/ui/property/property_group.c @@ -3461,6 +3461,7 @@ _change_cb(Property_Attribute *pa, Property_Action *action) break; case PROPERTY_CONTROL_ENTRY: case PROPERTY_CONTROL_IMAGE_NORMAL: + case PROPERTY_CONTROL_VECTOR_NORMAL: str_val1 = property_entry_get(action->control); break; case PROPERTY_CONTROL_CHECK: @@ -5410,7 +5411,7 @@ _init_items() break; case PROPERTY_GROUP_ITEM_STATE_VECTOR_NORMAL: IT.name = "Vector"; - _action1(&IT, NULL, NULL, PROPERTY_CONTROL_IMAGE_NORMAL, ATTRIBUTE_STATE_VECTOR, + _action1(&IT, NULL, NULL, PROPERTY_CONTROL_VECTOR_NORMAL, ATTRIBUTE_STATE_VECTOR, _("Name of vector to be used.")); break; diff --git a/src/bin/ui/property/property_private.h b/src/bin/ui/property/property_private.h index dc4ea7e..d78af84 100644 --- a/src/bin/ui/property/property_private.h +++ b/src/bin/ui/property/property_private.h @@ -54,6 +54,7 @@ enum _Property_Control { PROPERTY_CONTROL_COLOR, PROPERTY_CONTROL_COLORSEL, PROPERTY_CONTROL_LABEL, + PROPERTY_CONTROL_VECTOR_NORMAL, PROPERTY_CONTROL_IMAGE_NORMAL, PROPERTY_CONTROL_IMAGE_TWEEN, PROPERTY_CONTROL_IMAGE_SELECTOR, @@ -559,6 +560,10 @@ property_color_control_color_get(Evas_Object *control, int *r, int *g, int *b, i Evas_Object * property_image_normal_control_add(Evas_Object *parent); +/* group vectornormal control */ +Evas_Object * +property_vector_normal_control_add(Evas_Object *parent); + /* tween images control */ Evas_Object * property_image_tween_control_add(Evas_Object *parent); --
