summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_spin_button.c
diff options
context:
space:
mode:
authorSungtaek Hong <sth253.hong@samsung.com>2017-12-08 14:52:08 +0900
committerSungtaek Hong <sth253.hong@samsung.com>2017-12-08 16:02:24 +0900
commit1503fb53599602cda091d9bb7843de7056e95e1b (patch)
treeb3e1ebec7a933f4c4229e013d48acf4f8d175eb5 /src/lib/elementary/efl_ui_spin_button.c
parente29b9e5371923f74b2be0a30d5441ca6948151e3 (diff)
efl_ui_spin: apply new theme set policy
Summary: Applied new theme group name. Moved logic in finalize to constructor. Test Plan: Run elementary_test->Efl.Ui.Spin, Efl.Ui.Spin.Button, Part_Background Reviewers: jpeg, woohyun, CHAN Reviewed By: CHAN Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D5592
Diffstat (limited to 'src/lib/elementary/efl_ui_spin_button.c')
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c63
1 files changed, 24 insertions, 39 deletions
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index eaf4743..abc49ed 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -20,6 +20,10 @@
20 20
21#define EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME 0.2 21#define EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME 0.2
22 22
23static const char PART_NAME_DEC_BUTTON[] = "dec_button";
24static const char PART_NAME_TEXT_BUTTON[] = "text_button";
25static const char PART_NAME_INC_BUTTON[] = "inc_button";
26
23static void 27static void
24_inc_dec_button_clicked_cb(void *data, const Efl_Event *event); 28_inc_dec_button_clicked_cb(void *data, const Efl_Event *event);
25static void 29static void
@@ -101,13 +105,15 @@ _label_write(Evas_Object *obj)
101 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS); 105 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS);
102 106
103 if (pd->templates) 107 if (pd->templates)
104 elm_layout_text_set(sd->text_button, "elm.text", pd->templates); 108 {
109 efl_text_set(sd->text_button, pd->templates);
110 }
105 else 111 else
106 { 112 {
107 char buf[1024]; 113 char buf[1024];
108 114
109 snprintf(buf, sizeof(buf), "%.0f", pd->val); 115 snprintf(buf, sizeof(buf), "%.0f", pd->val);
110 elm_layout_text_set(sd->text_button, "elm.text", buf); 116 efl_text_set(sd->text_button, buf);
111 } 117 }
112} 118}
113 119
@@ -151,9 +157,7 @@ _entry_hide(Evas_Object *obj)
151 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS); 157 Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(obj, MY_CLASS);
152 158
153 elm_layout_signal_emit(obj, "elm,state,button,active", "elm"); 159 elm_layout_signal_emit(obj, "elm,state,button,active", "elm");
154 evas_object_show(sd->text_button);
155 elm_layout_signal_emit(obj, "elm,state,entry,inactive", "elm"); 160 elm_layout_signal_emit(obj, "elm,state,entry,inactive", "elm");
156 evas_object_hide(sd->ent);
157 161
158 if (sd->entry_visible && !evas_focus_state_get(evas_object_evas_get(obj))) 162 if (sd->entry_visible && !evas_focus_state_get(evas_object_evas_get(obj)))
159 sd->entry_reactivate = EINA_TRUE; 163 sd->entry_reactivate = EINA_TRUE;
@@ -337,7 +341,6 @@ _entry_show_cb(void *data,
337 elm_entry_select_all(obj); 341 elm_entry_select_all(obj);
338 sd->entry_visible = EINA_TRUE; 342 sd->entry_visible = EINA_TRUE;
339 elm_layout_signal_emit(data, "elm,state,button,inactive", "elm"); 343 elm_layout_signal_emit(data, "elm,state,button,inactive", "elm");
340 evas_object_hide(sd->text_button);
341} 344}
342 345
343static void 346static void
@@ -376,7 +379,6 @@ _toggle_entry(Evas_Object *obj)
376 _entry_focus_changed_cb, obj); 379 _entry_focus_changed_cb, obj);
377 sd->entry_visible = EINA_TRUE; 380 sd->entry_visible = EINA_TRUE;
378 elm_layout_signal_emit(obj, "elm,state,entry,active", "elm"); 381 elm_layout_signal_emit(obj, "elm,state,entry,active", "elm");
379 evas_object_show(sd->ent);
380 { 382 {
381 Eina_List *items = NULL; 383 Eina_List *items = NULL;
382 384
@@ -617,7 +619,7 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
617 if (sd->entry_visible) 619 if (sd->entry_visible)
618 txt = elm_object_text_get(sd->ent); 620 txt = elm_object_text_get(sd->ent);
619 else 621 else
620 txt = elm_object_text_get(sd->text_button); 622 txt = efl_text_get(sd->text_button);
621 623
622 if (txt) return strdup(txt); 624 if (txt) return strdup(txt);
623 625
@@ -717,13 +719,14 @@ _access_spinner_register(Evas_Object *obj, Eina_Bool is_access)
717EOLIAN static Efl_Ui_Theme_Apply 719EOLIAN static Efl_Ui_Theme_Apply
718_efl_ui_spin_button_elm_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED) 720_efl_ui_spin_button_elm_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED)
719{ 721{
720 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_FAILED); 722 Efl_Ui_Theme_Apply int_ret = EFL_UI_THEME_APPLY_FAILED;
721 723
722 if (!elm_layout_theme_set(obj, "spin_button", "base", elm_widget_style_get(obj))) 724 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
723 CRI("Failed to set layout!"); 725 if (!int_ret) return EFL_UI_THEME_APPLY_FAILED;
724 726
725 if (sd->ent) 727 if (sd->ent)
726 { 728 {
729 //elm_widget_element_update(obj, sd->ent, PART_NAME_TEXT);
727 Eina_Strbuf *buf = eina_strbuf_new(); 730 Eina_Strbuf *buf = eina_strbuf_new();
728 eina_strbuf_append_printf(buf, "spin_button/%s", elm_widget_style_get(obj)); 731 eina_strbuf_append_printf(buf, "spin_button/%s", elm_widget_style_get(obj));
729 elm_widget_style_set(sd->ent, eina_strbuf_string_get(buf)); 732 elm_widget_style_set(sd->ent, eina_strbuf_string_get(buf));
@@ -731,56 +734,40 @@ _efl_ui_spin_button_elm_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd
731 } 734 }
732 735
733 if (sd->inc_button) 736 if (sd->inc_button)
734 { 737 elm_widget_element_update(obj, sd->inc_button, PART_NAME_INC_BUTTON);
735 Eina_Strbuf *buf = eina_strbuf_new();
736 eina_strbuf_append_printf(buf, "spin_button/increase/%s", elm_widget_style_get(obj));
737 elm_widget_style_set(sd->inc_button, eina_strbuf_string_get(buf));
738 eina_strbuf_free(buf);
739 }
740 738
741 if (sd->text_button) 739 if (sd->text_button)
742 { 740 elm_widget_element_update(obj, sd->text_button, PART_NAME_TEXT_BUTTON);
743 Eina_Strbuf *buf = eina_strbuf_new();
744 eina_strbuf_append_printf(buf, "spin_button/%s", elm_widget_style_get(obj));
745 elm_widget_style_set(sd->text_button, eina_strbuf_string_get(buf));
746 eina_strbuf_free(buf);
747 }
748 741
749 if (sd->dec_button) 742 if (sd->dec_button)
750 { 743 elm_widget_element_update(obj, sd->dec_button, PART_NAME_DEC_BUTTON);
751 Eina_Strbuf *buf = eina_strbuf_new();
752 eina_strbuf_append_printf(buf, "spin_button/decrease/%s", elm_widget_style_get(obj));
753 elm_widget_style_set(sd->dec_button, eina_strbuf_string_get(buf));
754 eina_strbuf_free(buf);
755 }
756 744
757 if (_elm_config->access_mode) 745 if (_elm_config->access_mode)
758 _access_spinner_register(obj, EINA_TRUE); 746 _access_spinner_register(obj, EINA_TRUE);
759 747
748 _label_write(obj);
760 elm_layout_sizing_eval(obj); 749 elm_layout_sizing_eval(obj);
761 return EFL_UI_THEME_APPLY_SUCCESS; 750 return EFL_UI_THEME_APPLY_SUCCESS;
762} 751}
763 752
764EOLIAN static Eo * 753EOLIAN static Eo *
765_efl_ui_spin_button_efl_object_finalize(Eo *obj, Efl_Ui_Spin_Button_Data *sd) 754_efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
766{ 755{
767 obj = efl_finalize(efl_super(obj, MY_CLASS)); 756 if (!elm_widget_theme_klass_get(obj))
757 elm_widget_theme_klass_set(obj, "spin_button");
758 obj = efl_constructor(efl_super(obj, MY_CLASS));
768 759
769 elm_widget_sub_object_parent_add(obj); 760 elm_widget_sub_object_parent_add(obj);
770 761
771 sd->first_interval = 0.85; 762 sd->first_interval = 0.85;
772 763
773 if (!elm_layout_theme_set(obj, "spin_button", "base",
774 elm_widget_style_get(obj)))
775 CRI("Failed to set layout!");
776
777 sd->inc_button = efl_add(EFL_UI_BUTTON_CLASS, obj, 764 sd->inc_button = efl_add(EFL_UI_BUTTON_CLASS, obj,
778 efl_ui_widget_style_set(efl_added, "spinner/increase/default"), 765 elm_widget_element_update(obj, efl_added, PART_NAME_INC_BUTTON),
779 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj), 766 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj),
780 efl_content_set(efl_part(obj, "elm.swallow.inc_button"), efl_added)); 767 efl_content_set(efl_part(obj, "elm.swallow.inc_button"), efl_added));
781 768
782 sd->text_button = efl_add(EFL_UI_BUTTON_CLASS, obj, 769 sd->text_button = efl_add(EFL_UI_BUTTON_CLASS, obj,
783 efl_ui_widget_style_set(efl_added, "spinner/default"), 770 elm_widget_element_update(obj, efl_added, PART_NAME_TEXT_BUTTON),
784 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, 771 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
785 _text_button_clicked_cb, obj), 772 _text_button_clicked_cb, obj),
786 efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED, 773 efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
@@ -788,7 +775,7 @@ _efl_ui_spin_button_efl_object_finalize(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
788 efl_content_set(efl_part(obj, "elm.swallow.text_button"), efl_added)); 775 efl_content_set(efl_part(obj, "elm.swallow.text_button"), efl_added));
789 776
790 sd->dec_button = efl_add(EFL_UI_BUTTON_CLASS, obj, 777 sd->dec_button = efl_add(EFL_UI_BUTTON_CLASS, obj,
791 efl_ui_widget_style_set(efl_added, "spinner/decrease/default"), 778 elm_widget_element_update(obj, efl_added, PART_NAME_DEC_BUTTON),
792 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj), 779 efl_event_callback_array_add(efl_added, _inc_dec_button_cb(), obj),
793 efl_content_set(efl_part(obj, "elm.swallow.dec_button"), efl_added)); 780 efl_content_set(efl_part(obj, "elm.swallow.dec_button"), efl_added));
794 781
@@ -805,10 +792,8 @@ _efl_ui_spin_button_efl_object_finalize(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
805 elm_layout_signal_callback_add 792 elm_layout_signal_callback_add
806 (obj, "elm,action,entry,toggle", "*", _entry_toggle_cb, NULL); 793 (obj, "elm,action,entry,toggle", "*", _entry_toggle_cb, NULL);
807 794
808 _label_write(obj);
809 elm_widget_can_focus_set(obj, EINA_TRUE); 795 elm_widget_can_focus_set(obj, EINA_TRUE);
810 796
811 elm_layout_sizing_eval(obj);
812 efl_access_role_set(obj, EFL_ACCESS_ROLE_SPIN_BUTTON); 797 efl_access_role_set(obj, EFL_ACCESS_ROLE_SPIN_BUTTON);
813 798
814 return obj; 799 return obj;