rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=d2a00b33a7aa9de2117265d9539ec3a77287ea3f
commit d2a00b33a7aa9de2117265d9539ec3a77287ea3f Author: Vyacheslav Reutskiy <[email protected]> Date: Thu Jul 9 15:49:52 2015 +0300 Property: make the common macro for entry manipulated attribute Change-Id: I4002977a108df252ef5428b05cf9c4481fd6993c --- src/bin/ui/blocks/property_macros.h | 175 ++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 75 deletions(-) diff --git a/src/bin/ui/blocks/property_macros.h b/src/bin/ui/blocks/property_macros.h index 37588e8..46b9a13 100644 --- a/src/bin/ui/blocks/property_macros.h +++ b/src/bin/ui/blocks/property_macros.h @@ -525,6 +525,101 @@ _on_##MEMBER##_##VALUE##_change(void *data, \ workspace_edit_object_recalc(pd->workspace); \ } +/** + * Macro defines functions that create an item with label and 1 entry. + * + * @param TEXT The label text + * @param SUB The prefix of main parameter of part attribute + * @param VALUE The value of part attribute + * @param MEMBER The entry member from Prop_Data structure + * @param REGEX The regex for validation input string + * @param TOOLTIP The tooltip for combobox + * + * @ingroup Property_Macro + */ +#define COMMON_ENTRY_ADD(TEXT, SUB, VALUE, MEMBER, REGEX, TOOLTIP) \ +static Evas_Object * \ +prop_##SUB##_##VALUE##_add(Evas_Object *parent, \ + Prop_Data *pd, \ + void *btn_func_cb) \ +{ \ + Evas_Object *btn; \ + PROPERTY_ITEM_ADD(parent, TEXT, "1swallow") \ + EWE_ENTRY_ADD(item, pd->MEMBER.VALUE, true) \ + if (btn_func_cb) \ + { \ + btn = elm_button_add(parent); \ + elm_object_style_set(btn, "elipsis"); \ + evas_object_smart_callback_add(btn, "clicked", btn_func_cb, pd); \ + evas_object_smart_callback_add(pd->MEMBER.VALUE, "clicked", btn_func_cb, pd); \ + elm_object_part_content_set(pd->MEMBER.VALUE, "elm.swallow.end", btn); \ + elm_entry_editable_set(pd->MEMBER.VALUE, false); \ + evas_object_show(btn); \ + } \ + else \ + evas_object_smart_callback_add(pd->MEMBER.VALUE, "changed,user", _on_##SUB##_##VALUE##_change, pd); \ + ewe_entry_regex_set(pd->MEMBER.VALUE, REGEX, EWE_REG_EXTENDED); \ + ewe_entry_regex_autocheck_set(pd->MEMBER.VALUE, true); \ + ewe_entry_regex_glow_set(pd->MEMBER.VALUE, true); \ + if (TOOLTIP) elm_object_tooltip_text_set(pd->MEMBER.VALUE, TOOLTIP); \ + elm_layout_content_set(item, NULL, pd->MEMBER.VALUE); \ + prop_##SUB##_##VALUE##_update(pd); \ + return item; \ +} + +/** + * Macro defines a function that updates control by COMMON_ENTRY_ADD macro. + * + * @param SUB The prefix of main parameter of part attribute + * @param VALUE The value of part attribute + * @param MEMBER The entry member from Prop_Data structure + * @param ARGS The edje edit function arguments + * + * @ingroup Property_Macro + */ +#define COMMON_ENTRY_UPDATE(SUB, VALUE, MEMBER, ARGS) \ +static void \ +prop_##SUB##_##VALUE##_update(Prop_Data *pd) \ +{ \ + const char *value; \ + value = edje_edit_##SUB##_##VALUE##_get(pd->wm_style->obj ARGS); \ + char *text = elm_entry_utf8_to_markup(value); \ + ewe_entry_entry_set(pd->MEMBER.VALUE, text); \ + edje_edit_string_free(value); \ + free(text); \ +} + +/** + * Macro defines a callback for COMMON_ENTRY_ADD. + * + * @param SUB The prefix of main parameter of part attribute + * @param VALUE The value of part attribute + * @param ARGS The edje edit function arguments + * + * @ingroup Property_Macro + */ +#define COMMON_ENTRY_CALLBACK(SUB, VALUE, ARGS) \ +static void \ +_on_##SUB##_##VALUE##_change(void *data, \ + Evas_Object *obj, \ + void *ei __UNUSED__) \ +{ \ + Prop_Data *pd = (Prop_Data *)data; \ + if (ewe_entry_regex_error_get(obj)) return; \ + const char *text = elm_entry_entry_get(obj); \ + char *value = elm_entry_markup_to_utf8(text); \ + const char *old_value = edje_edit_##SUB##_##VALUE##_get(pd->wm_style->obj ARGS); \ + edje_edit_##SUB##_##VALUE##_set(pd->wm_style->obj ARGS, value); \ + history_diff_add(pd->wm_style->obj, PROPERTY, MODIFY, VAL_STRING, old_value, \ + value, pd->wm_style->full_group_name,\ + (void*)edje_edit_##SUB##_##VALUE##_set, #SUB"_"#VALUE ARGS); \ + elm_object_focus_set(obj, true); \ + project_changed(false); \ + workspace_edit_object_recalc(pd->workspace); \ + eina_stringshare_del(old_value); \ + free(value); \ +} + /*****************************************************************************/ /* GROUP 2 CHECK CONTROL */ /*****************************************************************************/ @@ -1829,67 +1924,22 @@ prop_##MEMBER##_##VALUE##_update(Prop_Data *pd) \ * Macro defines functions that create an item with label and 1 entry for state * attribute. * - * @param TEXT The label text - * @param SUB The prefix of main parameter of part attribute - * @param VALUE The value of part attribute - * @param MEMBER The entry member from Prop_Data structure - * @param REGEX The regex for validation input string - * @param TOOLTIP The tooltip for combobox + * @see COMMON_ENTRY_ADD * * @ingroup Property_Macro */ #define STATE_ATTR_1ENTRY_ADD(TEXT, SUB, VALUE, MEMBER, REGEX, TOOLTIP) \ -static Evas_Object * \ -prop_##SUB##_##VALUE##_add(Evas_Object *parent, \ - Prop_Data *pd, \ - void *btn_func_cb) \ -{ \ - Evas_Object *btn; \ - PROPERTY_ITEM_ADD(parent, TEXT, "1swallow") \ - EWE_ENTRY_ADD(item, pd->MEMBER.VALUE, true) \ - if (btn_func_cb) \ - { \ - btn = elm_button_add(parent); \ - elm_object_style_set(btn, "elipsis"); \ - evas_object_smart_callback_add(btn, "clicked", btn_func_cb, pd); \ - evas_object_smart_callback_add(pd->MEMBER.VALUE, "clicked", btn_func_cb, pd); \ - elm_object_part_content_set(pd->MEMBER.VALUE, "elm.swallow.end", btn); \ - elm_entry_editable_set(pd->MEMBER.VALUE, false); \ - evas_object_show(btn); \ - } \ - else \ - evas_object_smart_callback_add(pd->MEMBER.VALUE, "changed,user", _on_##SUB##_##VALUE##_change, pd); \ - ewe_entry_regex_set(pd->MEMBER.VALUE, REGEX, EWE_REG_EXTENDED); \ - ewe_entry_regex_autocheck_set(pd->MEMBER.VALUE, true); \ - ewe_entry_regex_glow_set(pd->MEMBER.VALUE, true); \ - if (TOOLTIP) elm_object_tooltip_text_set(pd->MEMBER.VALUE, TOOLTIP); \ - elm_layout_content_set(item, NULL, pd->MEMBER.VALUE); \ - prop_##SUB##_##VALUE##_update(pd); \ - return item; \ -} + COMMON_ENTRY_ADD(TEXT, SUB, VALUE, MEMBER, REGEX, TOOLTIP) /** * Macro defines a function that updates control by STATE_ATTR_1ENTRY_ADD macro. * - * @param SUB The prefix of main parameter of part attribute - * @param VALUE The value of part attribute - * @paramram MEMBER The entry member from Prop_Data structure + * @see COMMON_ENTRY_UPDATE * * @ingroup Property_Macro */ #define STATE_ATTR_1ENTRY_UPDATE(SUB, VALUE, MEMBER) \ -static void \ -prop_##SUB##_##VALUE##_update(Prop_Data *pd) \ -{ \ - const char *value; \ - value = edje_edit_##SUB##_##VALUE##_get(pd->wm_style->obj, pd->wm_part->name, \ - pd->wm_part->curr_state, \ - pd->wm_part->curr_state_value); \ - char *text = elm_entry_utf8_to_markup(value); \ - ewe_entry_entry_set(pd->MEMBER.VALUE, text); \ - edje_edit_string_free(value); \ - free(text); \ -} + COMMON_ENTRY_UPDATE(SUB, VALUE, MEMBER, STATE_ARGS) \ /** * Macro defines a callback for STATE_ATTR_1ENTRY_ADD. @@ -1900,32 +1950,7 @@ prop_##SUB##_##VALUE##_update(Prop_Data *pd) \ * @ingroup Property_Macro */ #define STATE_ATTR_1ENTRY_CALLBACK(SUB, VALUE) \ -static void \ -_on_##SUB##_##VALUE##_change(void *data, \ - Evas_Object *obj, \ - void *ei __UNUSED__) \ -{ \ - Prop_Data *pd = (Prop_Data *)data; \ - if (ewe_entry_regex_error_get(obj)) return; \ - const char *text = elm_entry_entry_get(obj); \ - char *value = elm_entry_markup_to_utf8(text); \ - const char *old_value = edje_edit_##SUB##_##VALUE##_get(pd->wm_style->obj, \ - pd->wm_part->name, pd->wm_part->curr_state, \ - pd->wm_part->curr_state_value); \ - edje_edit_##SUB##_##VALUE##_set(pd->wm_style->obj, pd->wm_part->name, \ - pd->wm_part->curr_state, \ - pd->wm_part->curr_state_value, value); \ - history_diff_add(pd->wm_style->obj, PROPERTY, MODIFY, VAL_STRING, old_value, \ - value, pd->wm_style->full_group_name,\ - (void*)edje_edit_##SUB##_##VALUE##_set, #SUB"_"#VALUE, \ - pd->wm_part->name, pd->wm_part->curr_state, \ - pd->wm_part->curr_state_value); \ - elm_object_focus_set(obj, true); \ - project_changed(false); \ - workspace_edit_object_recalc(pd->workspace); \ - eina_stringshare_del(old_value); \ - free(value); \ -} + COMMON_ENTRY_CALLBACK(SUB, VALUE, STATE_ARGS) \ /*****************************************************************************/ /* STATE CONTAINER 2 SPINNERS DOUBLEVAL CONTROL */ --
