summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_spin_button.c
diff options
context:
space:
mode:
authorWoochanlee <wc0917.lee@samsung.com>2018-08-21 13:52:28 +0900
committerHermet Park <hermetpark@gmail.com>2018-08-21 13:52:29 +0900
commit739da4f736cec242042ba3a39d8a7c2417d924ab (patch)
tree4b97b79eece027abb0059b066fc005982f122058 /src/lib/elementary/efl_ui_spin_button.c
parent28ee520428872f4503be036492db9f7455fc2e8c (diff)
efl_ui_spin_button: Addded direction feature.
Summary: The Spin_Button class supports two types(horizontal, vertical). User can use 'efl_ui_direction()' for spin_button. @feature Test Plan: elementary_test-> spin_button sample. Reviewers: Hermet, Jaehyun_Cho Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6680
Diffstat (limited to 'src/lib/elementary/efl_ui_spin_button.c')
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c92
1 files changed, 89 insertions, 3 deletions
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index 6b2bfbe..fa21913 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -735,10 +735,71 @@ _access_spinner_register(Evas_Object *obj, Eina_Bool is_access)
735 } 735 }
736} 736}
737 737
738static const char *
739_theme_group_modify_pos_get(const char *cur_group, const char *search, size_t len)
740{
741 const char *pos = NULL;
742 const char *temp_str = NULL;
743
744 temp_str = cur_group + len - strlen(search);
745 if (temp_str >= cur_group)
746 {
747 if (!strcmp(temp_str, search))
748 pos = temp_str;
749 }
750
751 return pos;
752}
753
754static char *
755_efl_ui_spin_button_theme_group_get(Evas_Object *obj, Efl_Ui_Spin_Button_Data *sd)
756{
757 const char *pos = NULL;
758 const char *cur_group = elm_widget_theme_element_get(obj);
759 Eina_Strbuf *new_group = eina_strbuf_new();
760 size_t len = 0;
761
762 if (cur_group)
763 {
764 len = strlen(cur_group);
765 pos = _theme_group_modify_pos_get(cur_group, "horizontal", len);
766 if (!pos)
767 pos = _theme_group_modify_pos_get(cur_group, "vertical", len);
768
769 // TODO: change separator when it is decided.
770 // can skip when prev_group == cur_group
771 if (!pos)
772 {
773 eina_strbuf_append(new_group, cur_group);
774 eina_strbuf_append(new_group, "/");
775 }
776 else
777 {
778 eina_strbuf_append_length(new_group, cur_group, pos - cur_group);
779 }
780 }
781
782 if (efl_ui_dir_is_horizontal(sd->dir, EINA_TRUE))
783 eina_strbuf_append(new_group, "horizontal");
784 else
785 eina_strbuf_append(new_group, "vertical");
786
787 return eina_strbuf_release(new_group);
788}
789
790
738EOLIAN static Efl_Ui_Theme_Apply 791EOLIAN static Efl_Ui_Theme_Apply
739_efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED) 792_efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED)
740{ 793{
741 Efl_Ui_Theme_Apply int_ret = EFL_UI_THEME_APPLY_FAILED; 794 Efl_Ui_Theme_Apply int_ret = EFL_UI_THEME_APPLY_FAILED;
795 char *group;
796
797 group = _efl_ui_spin_button_theme_group_get(obj, sd);
798 if (group)
799 {
800 elm_widget_theme_element_set(obj, group);
801 free(group);
802 }
742 803
743 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 804 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
744 if (!int_ret) return EFL_UI_THEME_APPLY_FAILED; 805 if (!int_ret) return EFL_UI_THEME_APPLY_FAILED;
@@ -766,11 +827,22 @@ _efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *
766EOLIAN static Eo * 827EOLIAN static Eo *
767_efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd) 828_efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
768{ 829{
769 if (!elm_widget_theme_klass_get(obj)) 830 char *group;
770 elm_widget_theme_klass_set(obj, "spin_button");
771 obj = efl_constructor(efl_super(obj, MY_CLASS));
772 831
832 obj = efl_constructor(efl_super(obj, MY_CLASS));
773 elm_widget_sub_object_parent_add(obj); 833 elm_widget_sub_object_parent_add(obj);
834 elm_widget_theme_klass_set(obj, "spin_button");
835
836 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
837
838 group = _efl_ui_spin_button_theme_group_get(obj, sd);
839 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
840 elm_widget_theme_klass_get(obj),
841 group,
842 elm_widget_theme_style_get(obj)))
843 CRI("Failed to set layout!");
844
845 free(group);
774 846
775 sd->first_interval = 0.85; 847 sd->first_interval = 0.85;
776 848
@@ -813,6 +885,20 @@ _efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
813} 885}
814 886
815EOLIAN static void 887EOLIAN static void
888_efl_ui_spin_button_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Spin_Button_Data *sd, Efl_Ui_Dir dir)
889{
890 sd->dir = dir;
891
892 efl_ui_widget_theme_apply(obj);
893}
894
895EOLIAN static Efl_Ui_Dir
896_efl_ui_spin_button_efl_ui_direction_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spin_Button_Data *sd)
897{
898 return sd->dir;
899}
900
901EOLIAN static void
816_efl_ui_spin_button_efl_ui_range_range_value_set(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED, double val) 902_efl_ui_spin_button_efl_ui_range_range_value_set(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED, double val)
817{ 903{
818 efl_ui_range_value_set(efl_super(obj, MY_CLASS), val); 904 efl_ui_range_value_set(efl_super(obj, MY_CLASS), val);