diff options
author | JunsuChoi <jsuya.choi@samsung.com> | 2020-01-20 17:01:38 +0900 |
---|---|---|
committer | Hermet Park <hermetpark@gmail.com> | 2020-01-20 17:01:39 +0900 |
commit | 3f1c7492f9b03e09b396474510e16ae88b78fb8a (patch) | |
tree | 776e33b3828c700fbef266a5170fc301bd7b794f | |
parent | c85bb1b46dccf641c0207c593752970d03649cca (diff) | |
download | efl-3f1c7492f9b03e09b396474510e16ae88b78fb8a.tar.gz |
vg_common_json: Supports transform properties
Summary:
Supports scale, position, and rotation properties
related to transform among properties supported by value provider.
Test Plan:
Remove 'json' in evas-loaders-disabler
build
elementary_test -to "value provider"
(path : layer.box1)
Reviewers: Hermet, smohanty, kimcinoo
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D11129
-rw-r--r-- | src/bin/elementary/test_efl_gfx_vg_value_provider.c | 77 | ||||
-rw-r--r-- | src/static_libs/vg_common/vg_common_json.c | 15 |
2 files changed, 87 insertions, 5 deletions
diff --git a/src/bin/elementary/test_efl_gfx_vg_value_provider.c b/src/bin/elementary/test_efl_gfx_vg_value_provider.c index 5127bb0eb2..68ca42462c 100644 --- a/src/bin/elementary/test_efl_gfx_vg_value_provider.c +++ b/src/bin/elementary/test_efl_gfx_vg_value_provider.c @@ -55,8 +55,6 @@ add_value_provider(char* new_path, char* new_type, char* new_values) efl_gfx_vg_value_provider_stroke_color_set(vp, color[0], color[1], color[2], color[3]); sprintf(new_type, "StrokeColor"); } - - efl_ui_vg_animation_value_provider_override(anim_view, vp); } if (!strcmp(type, "StrokeWidth")) @@ -68,11 +66,50 @@ add_value_provider(char* new_path, char* new_type, char* new_values) if (v) width = strtod(v, NULL); efl_gfx_vg_value_provider_stroke_width_set(vp, width); efl_ui_vg_animation_value_provider_override(anim_view, vp); - evas_object_show(anim_view); sprintf(new_path, "%s", path); sprintf(new_type, "StrokeWidth"); sprintf(new_values, "%f", width); } + if (strstr(type, "Tr")) + { + double value[2], value_cnt; + Eina_Matrix3 m; + Eo *vp = efl_add(EFL_GFX_VG_VALUE_PROVIDER_CLASS, anim_view); + + efl_gfx_vg_value_provider_keypath_set(vp, (char*)path); + + value_cnt = strstr(type, "Rotation") ? 1 : 2; + for( int i = 0; i < value_cnt; i++) + { + char* v = (char*)efl_text_get(values[i]); + if (v) value[i] = atof(v); + } + + eina_matrix3_identity(&m); + if (!strcmp(type, "TrPosition")) + { + eina_matrix3_translate(&m, value[0], value[1]); + sprintf(new_type, "TrPosition"); + sprintf(new_values, "%f %f",value[0], value[1]); + + } + else if (!strcmp(type, "TrScale")) + { + eina_matrix3_scale(&m, value[0], value[1]); + sprintf(new_type, "TrScale"); + sprintf(new_values, "%f %f",value[0], value[1]); + } + else if (!strcmp(type, "TrRotation")) + { + eina_matrix3_rotate(&m, value[0]); + sprintf(new_values, "%f",value[0]); + sprintf(new_type, "TrRotation"); + } + + sprintf(new_path, "%s", path); + efl_gfx_vg_value_provider_transform_set(vp, &m); + efl_ui_vg_animation_value_provider_override(anim_view, vp); + } return EINA_TRUE; } @@ -235,6 +272,37 @@ void values_input(Eo* box, const char* type) efl_gfx_hint_size_min_set(values[0], EINA_SIZE2D(50, 10)); efl_text_set(efl_part(values[0], "efl.text_guide"), "Width(double type)"); } + else if (strstr(type, "Tr")) + { + char text[2][2]; + if (!strcmp(type, "TrPosition")) + { + sprintf(text[0], "X"); + sprintf(text[1], "Y"); + } + else if (!strcmp(type, "TrScale")) + { + sprintf(text[0], "W"); + sprintf(text[1], "H"); + } + else if (!strcmp(type, "TrRotation")) + { + sprintf(text[0], "R"); + } + + int value_cnt = strstr(type, "Rotation") ? 1 : 2; + for( int i = 0; i < value_cnt; i++) + { + values[i] = efl_add(EFL_UI_TEXTBOX_CLASS, box, + efl_gfx_hint_weight_set(efl_added, EFL_GFX_HINT_EXPAND, 0), + efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE), + efl_gfx_hint_align_set(efl_added, EVAS_HINT_FILL, EVAS_HINT_FILL), + efl_text_interactive_editable_set(efl_added, EINA_TRUE), + efl_pack(box, efl_added)); + efl_gfx_hint_size_min_set(values[i], EINA_SIZE2D(50, 10)); + efl_text_set(efl_part(values[i], "efl.text_guide"), text[i]); + } + } } static void @@ -434,6 +502,9 @@ test_efl_gfx_vg_value_provider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU elm_hoversel_item_add(type_hoversel, "FillColor", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub); elm_hoversel_item_add(type_hoversel, "StrokeColor", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub); elm_hoversel_item_add(type_hoversel, "StrokeWidth", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub); + elm_hoversel_item_add(type_hoversel, "TrPosition", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub); + elm_hoversel_item_add(type_hoversel, "TrScale", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub); + elm_hoversel_item_add(type_hoversel, "TrRotation", NULL, ELM_ICON_NONE, _hover_item_selected_cb, box_sub); evas_object_show(type_hoversel); elm_object_focus_set(type_hoversel, EINA_TRUE); efl_pack(box_sub, type_hoversel); diff --git a/src/static_libs/vg_common/vg_common_json.c b/src/static_libs/vg_common/vg_common_json.c index bb357d1c01..e70fe443ac 100644 --- a/src/static_libs/vg_common/vg_common_json.c +++ b/src/static_libs/vg_common/vg_common_json.c @@ -530,8 +530,19 @@ _value_provider_override(Vg_File_Data *vfd) } if (flag & EFL_GFX_VG_VALUE_PROVIDER_CHANGE_FLAG_TRANSFORM_MATRIX) { - //TODO: When the lottie animation's transform property is implemented, - // the transform property override function have to added. + Eina_Matrix3 *m; + double m11, m13, m21, m22, m23; + + m = efl_gfx_vg_value_provider_transform_get(vp); + if (!m) continue; + + keypath = efl_gfx_vg_value_provider_keypath_get(vp); + eina_matrix3_values_get(m, &m11, NULL, &m13, + &m21, &m22, &m23, + NULL, NULL, NULL); + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_TR_SCALE, (char*)keypath, 100.0 * m11, 100.0 * m22); + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_TR_ROTATION, (char*)keypath, atan2(m21, m11) * (180.0 / M_PI)); // radian to degree + lottie_animation_property_override(lot_anim, LOTTIE_ANIMATION_PROPERTY_TR_POSITION, (char*)keypath, m13, m23); } } } |