rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=54337b0e9b38fd0c2e364c82613c0d9a3037c803
commit 54337b0e9b38fd0c2e364c82613c0d9a3037c803 Author: Andrii Kroitor <an.kroi...@samsung.com> Date: Mon Oct 12 14:17:09 2015 +0300 property: use editor api for text, font and image --- src/bin/editor/editor.h | 10 ++++++++++ src/bin/ui/property.c | 27 ++++++++++++++++----------- src/bin/ui/property_macros.h | 43 +++++++++++++++++++++++++++++++++---------- 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h index 24875d4..e336496 100644 --- a/src/bin/editor/editor.h +++ b/src/bin/editor/editor.h @@ -390,6 +390,16 @@ Eina_Bool editor_state_color3_set(Evas_Object *obj, Change *change, Eina_Bool merge, const char *part_name, const char *state_name, double state_val, int r, int g, int b, int a); +Eina_Bool +editor_state_text_set(Evas_Object *obj, Change *change, Eina_Bool merge, const char *part_name, const char *state_name, double state_val, + const char * new_val); +Eina_Bool +editor_state_font_set(Evas_Object *obj, Change *change, Eina_Bool merge, const char *part_name, const char *state_name, double state_val, + const char * new_val); +Eina_Bool +editor_state_image_set(Evas_Object *obj, Change *change, Eina_Bool merge, const char *part_name, const char *state_name, double state_val, + const char * new_val); + /* Part */ diff --git a/src/bin/ui/property.c b/src/bin/ui/property.c index 240a249..8ce746f 100644 --- a/src/bin/ui/property.c +++ b/src/bin/ui/property.c @@ -1005,6 +1005,14 @@ TODO("Implement rename. Note: groups list must remain sorted") //project_changed(false); free(entry); } +static void +_on_group_name_activated(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *ei __UNUSED__) +{ +return; +TODO("Implement rename. Note: groups list must remain sorted") +} #define GROUP_ATTR_2SPINNER(TEXT, SUB1, SUB2, VALUE1, VALUE2, DESCRIPTION1, DESCRIPTION2) \ GROUP_ATTR_2SPINNER_CALLBACK(SUB1, SUB2, VALUE1, DESCRIPTION1) \ @@ -2309,8 +2317,8 @@ ui_property_state_obj_area_unset(Evas_Object *property) } #undef pd_obj_area -#define STATE_ATTR_1ENTRY(TEXT, SUB, VALUE, MEMBER, VALIDATOR, TOOLTIP) \ - STATE_ATTR_1ENTRY_CALLBACK(SUB, VALUE, VALIDATOR) \ +#define STATE_ATTR_1ENTRY(TEXT, SUB, VALUE, MEMBER, VALIDATOR, TOOLTIP, DESCRIPTION) \ + STATE_ATTR_1ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, DESCRIPTION) \ STATE_ATTR_1ENTRY_UPDATE(SUB, VALUE, MEMBER) \ STATE_ATTR_1ENTRY_ADD(TEXT, SUB, VALUE, MEMBER, VALIDATOR, TOOLTIP) @@ -2321,9 +2329,11 @@ ui_property_state_obj_area_unset(Evas_Object *property) STATE_ATTR_1SPINNER_ADD(TEXT, SUB, VALUE, MEMBER, MIN, MAX, STEP, FMT, \ L_START, L_END, TOOLTIP, MULTIPLIER) -STATE_ATTR_1ENTRY(_("text"), state, text, state_text, NULL, _("The dispalyed text")) +STATE_ATTR_1ENTRY(_("text"), state, text, state_text, NULL, _("The dispalyed text"), + _("text changed to %s")) STATE_ATTR_1ENTRY(_("font"), state, font, state_text, pd->attributes.state_text.validator, - _("The text font, posible set a font style. Ex: Sans:style=italic")) + _("The text font, posible set a font style. Ex: Sans:style=italic"), + _("font changed to %s")) STATE_ATTR_1SPINNER(_("size"), state_text, size, state_text, 1, 128, 1, "%.0f", "", "pt", _("The font size"), 1, int, _("font size changed from %d to %d")) @@ -2921,14 +2931,8 @@ _on_image_editor_done(void *data, if (strcmp(value, selected) == 0) return; elm_entry_entry_set(pd->attributes.state_image.image, selected); - edje_edit_state_image_set(pd->group->edit_object, pd->part->name, - pd->part->current_state->parsed_name, - pd->part->current_state->parsed_val, selected); -TODO("uncomment after changing save API") -// pm_save_to_dev(ap.project, pd->wm_style, false); evas_object_smart_callback_call(pd->attributes.state_image.image, "changed,user", NULL); evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, NULL); - //project_changed(false); } static void @@ -3306,7 +3310,8 @@ prop_##SUB##_##VALUE##_add(Evas_Object *box, Prop_Data *pd) \ ATTR_4SPINNERS(_("border"), state_image, border, state_image, NULL, STATE_ARGS, _("border changed to [%d %d %d %d]")) -STATE_ATTR_1ENTRY(_("image"), state, image, state_image, NULL, NULL) +STATE_ATTR_1ENTRY(_("image"), state, image, state_image, NULL, NULL, + _("image changed to %s")) STATE_ATTR_1COMBOBOX_LIST(_("border fill"), state_image, border_fill, state_image,\ edje_middle_type, NULL, unsigned char, _("border fill changed to %s")) diff --git a/src/bin/ui/property_macros.h b/src/bin/ui/property_macros.h index 162eed0..0611660 100644 --- a/src/bin/ui/property_macros.h +++ b/src/bin/ui/property_macros.h @@ -480,7 +480,11 @@ prop_##SUB##_##VALUE##_add(Evas_Object *parent, \ evas_object_show(btn); \ } \ else \ - evas_object_smart_callback_add(pd->attributes.MEMBER.VALUE, "changed,user", _on_##SUB##_##VALUE##_change, pd); \ + { \ + evas_object_smart_callback_add(pd->attributes.MEMBER.VALUE, "changed,user", _on_##SUB##_##VALUE##_change, pd); \ + evas_object_smart_callback_add(pd->attributes.MEMBER.VALUE, "activated", _on_##SUB##_##VALUE##_activated, pd); \ + evas_object_smart_callback_add(pd->attributes.MEMBER.VALUE, "unfocused", _on_##SUB##_##VALUE##_activated, pd); \ + } \ if (VALIDATOR) \ eo_do(pd->attributes.MEMBER.VALUE, eo_event_callback_add(ELM_ENTRY_EVENT_VALIDATE, elm_validator_regexp_helper, VALIDATOR)); \ if (TOOLTIP) elm_object_tooltip_text_set(pd->attributes.MEMBER.VALUE, TOOLTIP); \ @@ -506,7 +510,8 @@ prop_##SUB##_##VALUE##_update(Prop_Data *pd) \ const char *value; \ value = edje_edit_##SUB##_##VALUE##_get(pd->group->edit_object ARGS); \ char *text = elm_entry_utf8_to_markup(value); \ - elm_entry_entry_set(pd->attributes.MEMBER.VALUE, text); \ + if (strcmp(text, elm_entry_entry_get(pd->attributes.MEMBER.VALUE))) \ + elm_entry_entry_set(pd->attributes.MEMBER.VALUE, text); \ edje_edit_string_free(value); \ free(text); \ } @@ -521,7 +526,7 @@ prop_##SUB##_##VALUE##_update(Prop_Data *pd) \ * * @ingroup Property_Macro */ -#define COMMON_ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, ARGS) \ +#define COMMON_ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, ARGS, DESCRIPTION) \ static void \ _on_##SUB##_##VALUE##_change(void *data, \ Evas_Object *obj, \ @@ -530,13 +535,31 @@ _on_##SUB##_##VALUE##_change(void *data, \ Prop_Data *pd = (Prop_Data *)data; \ if (VALIDATOR && (elm_validator_regexp_status_get(VALIDATOR)) != ELM_REG_NOERROR) \ return; \ + if (!pd->change) pd->change = change_add(NULL); \ const char *text = elm_entry_entry_get(obj); \ char *value = elm_entry_markup_to_utf8(text); \ - edje_edit_##SUB##_##VALUE##_set(pd->group->edit_object ARGS, value); \ - elm_object_focus_set(obj, true); \ + editor_##SUB##_##VALUE##_set(pd->group->edit_object, pd->change, true ARGS, value); \ evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, NULL); \ - /*project_changed(false);*/ \ free(value); \ +} \ +static void \ +_on_##SUB##_##VALUE##_activated(void *data, \ + Evas_Object *obj __UNUSED__, \ + void *ei __UNUSED__) \ +{ \ + Prop_Data *pd = (Prop_Data *)data; \ + if (VALIDATOR && (elm_validator_regexp_status_get(VALIDATOR)) != ELM_REG_NOERROR) \ + return; \ + if (!pd->change) \ + return; \ + Eina_Stringshare * val = edje_edit_##SUB##_##VALUE##_get(pd->group->edit_object ARGS); \ + Eina_Stringshare *msg = eina_stringshare_printf(DESCRIPTION, val); \ + change_description_set(pd->change, msg); \ + history_change_add(pd->group->history, pd->change); \ + pd->change = NULL; \ + prop_##SUB##_##VALUE##_update(pd); \ + eina_stringshare_del(msg); \ + eina_stringshare_del(val); \ } /*****************************************************************************/ @@ -724,8 +747,8 @@ _on_group_##SUB1##_##VALUE##_change(void *data, \ * * @ingroup Property_Macro */ -#define GROUP_ATTR_1ENTRY_CALLBACK(SUB, VALUE, VALIDATOR) \ - COMMON_ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, GROUP_ARGS) \ +#define GROUP_ATTR_1ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, DESCRIPTION) \ + COMMON_ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, GROUP_ARGS, DESCRIPTION) \ @@ -1781,7 +1804,7 @@ prop_##MEMBER##_##VALUE##_update(Prop_Data *pd) \ * * @ingroup Property_Macro */ -#define STATE_ATTR_1ENTRY_CALLBACK(SUB, VALUE, VALIDATOR) \ - COMMON_ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, STATE_ARGS) \ +#define STATE_ATTR_1ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, DESCRIPTION) \ + COMMON_ENTRY_CALLBACK(SUB, VALUE, VALIDATOR, STATE_ARGS, DESCRIPTION) \ /** @} privatesection */ --