summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2015-12-22 18:48:16 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2015-12-22 18:48:16 +0900
commit55352b09346ca541c98bdfe16832430ab5ec25c6 (patch)
tree0f7c446da4e6a203580218674d48893cb2784620
parentb034b4884f4690e16fbdd33f5a443d5a2d614bf4 (diff)
calendar: Apply elm_button widgets instead of manually implemented spinner buttons.
Summary: The spinner buttons in elm_calendar widget can be replaced by elm_buttons. Then, using elm_button widgets makes it much easier to maintain. And the buttons has to be focusable with "tab" key just like elm_spinner widget. The lagacy callbacks for signals from edje is not removed for backward compatibility. @feature Test Plan: elementary_test -> calendar, calendar2, calendar3 Reviewers: seoz, Hermet, kimcinoo, cedric, woohyun Reviewed By: woohyun Subscribers: CHAN Differential Revision: https://phab.enlightenment.org/D3198
-rw-r--r--data/themes/edc/elm/button.edc4
-rw-r--r--data/themes/edc/elm/calendar.edc134
-rw-r--r--src/lib/elm_calendar.c426
-rw-r--r--src/lib/elm_widget_calendar.h10
4 files changed, 429 insertions, 145 deletions
diff --git a/data/themes/edc/elm/button.edc b/data/themes/edc/elm/button.edc
index 92b026b04..0088b6d1f 100644
--- a/data/themes/edc/elm/button.edc
+++ b/data/themes/edc/elm/button.edc
@@ -1337,6 +1337,8 @@ group { name: "elm/button/base/hoversel_horizontal_entry/default";
1337/******************* SPINNER BUTTONS STYLES **********************/ 1337/******************* SPINNER BUTTONS STYLES **********************/
1338 group { name: "elm/button/base/spinner/increase/default"; 1338 group { name: "elm/button/base/spinner/increase/default";
1339 alias: "elm/button/base/spinner/increase/colorselector/default"; 1339 alias: "elm/button/base/spinner/increase/colorselector/default";
1340 alias: "elm/button/base/calendar/increase/default";
1341 alias: "elm/button/base/calendar/increase/double_spinners";
1340 images.image: "sym_right_light_normal.png" COMP; 1342 images.image: "sym_right_light_normal.png" COMP;
1341 images.image: "sym_right_glow_normal.png" COMP; 1343 images.image: "sym_right_glow_normal.png" COMP;
1342 images.image: "sym_right_dark_normal.png" COMP; 1344 images.image: "sym_right_dark_normal.png" COMP;
@@ -1489,6 +1491,8 @@ group { name: "elm/button/base/hoversel_horizontal_entry/default";
1489 group { name: "elm/button/base/spinner/decrease/default"; 1491 group { name: "elm/button/base/spinner/decrease/default";
1490 alias: "elm/button/base/spinner/decrease/colorselector/default"; 1492 alias: "elm/button/base/spinner/decrease/colorselector/default";
1491 inherit: "elm/button/base/spinner/increase/default"; 1493 inherit: "elm/button/base/spinner/increase/default";
1494 alias: "elm/button/base/calendar/decrease/default";
1495 alias: "elm/button/base/calendar/decrease/double_spinners";
1492 images.image: "sym_left_light_normal.png" COMP; 1496 images.image: "sym_left_light_normal.png" COMP;
1493 images.image: "sym_left_glow_normal.png" COMP; 1497 images.image: "sym_left_glow_normal.png" COMP;
1494 images.image: "sym_left_dark_normal.png" COMP; 1498 images.image: "sym_left_dark_normal.png" COMP;
diff --git a/data/themes/edc/elm/calendar.edc b/data/themes/edc/elm/calendar.edc
index 35a0367fc..b706a82e3 100644
--- a/data/themes/edc/elm/calendar.edc
+++ b/data/themes/edc/elm/calendar.edc
@@ -12,8 +12,8 @@
12 base: "font="FN" font_size=10 color=#151515 style=shadow_bottom shadow_color=#ffffffc0 align=center";\ 12 base: "font="FN" font_size=10 color=#151515 style=shadow_bottom shadow_color=#ffffffc0 align=center";\
13 }\ 13 }\
14 14
15#define CAL_SPIN(_sufix, _signal_sufix, _text, _relative)\ 15#define CAL_SPIN(_sufix, _text, _relative)\
16 part { name: "left_bt"#_sufix; type: RECT;\ 16 part { name: "left_bt"#_sufix; type: SPACER;\
17 scale: 1;\ 17 scale: 1;\
18 description { state: "default" 0.0;\ 18 description { state: "default" 0.0;\
19 fixed: 1 1;\ 19 fixed: 1 1;\
@@ -26,30 +26,6 @@
26 align: 0.0 0.5;\ 26 align: 0.0 0.5;\
27 min: 15 15;\ 27 min: 15 15;\
28 max: 15 15;\ 28 max: 15 15;\
29 color: 0 0 0 0;\
30 }\
31 }\
32 part { name: "left_bt"#_sufix"_over"; repeat_events: 1;\
33 scale: 1;\
34 description { state: "default" 0.0;\
35 min: 15 15;\
36 max: 15 15;\
37 align: 0.5 0.5;\
38 rel1.to: "left_bt"#_sufix;\
39 rel2.to: "left_bt"#_sufix;\
40 image.normal: "sym_left_light_normal.png";\
41 }\
42 description { state: "rtl" 0.0;\
43 inherit: "default" 0.0;\
44 image.normal: "sym_right_light_normal.png";\
45 }\
46 description { state: "clicked" 0.0;\
47 inherit: "default" 0.0;\
48 image.normal: "sym_left_glow_normal.png";\
49 }\
50 description { state: "clicked_rtl" 0.0;\
51 inherit: "default" 0.0;\
52 image.normal: "sym_right_glow_normal.png";\
53 }\ 29 }\
54 }\ 30 }\
55 part { name: "right_bt"#_sufix; type: RECT;\ 31 part { name: "right_bt"#_sufix; type: RECT;\
@@ -68,26 +44,32 @@
68 color: 0 0 0 0;\ 44 color: 0 0 0 0;\
69 }\ 45 }\
70 }\ 46 }\
71 part { name: "right_bt"#_sufix"_over"; repeat_events: 1;\ 47 part { name: "elm,calendar,button"#_sufix",left";\
48 type: SWALLOW;\
72 scale: 1;\ 49 scale: 1;\
73 description { state: "default" 0.0;\ 50 description { state: "default" 0.0;\
74 min: 15 15;\ 51 fixed: 1 1;\
75 max: 15 15;\ 52 rel1.to: "left_bt"#_sufix;\
76 rel1.to: "right_bt"#_sufix;\ 53 rel2.to: "left_bt"#_sufix;\
77 rel2.to: "right_bt"#_sufix;\
78 image.normal: "sym_right_light_normal.png";\
79 }\ 54 }\
80 description { state: "rtl" 0.0;\ 55 description { state: "rtl" 0.0;\
81 inherit: "default" 0.0;\ 56 inherit: "default" 0.0;\
82 image.normal: "sym_left_light_normal.png";\ 57 rel1.to: "right_bt"#_sufix;\
58 rel2.to: "right_bt"#_sufix;\
83 }\ 59 }\
84 description { state: "clicked" 0.0;\ 60 }\
85 inherit: "default" 0.0;\ 61 part { name: "elm,calendar,button"#_sufix",right";\
86 image.normal: "sym_right_glow_normal.png";\ 62 type: SWALLOW;\
63 scale: 1;\
64 description { state: "default" 0.0;\
65 fixed: 1 1;\
66 rel1.to: "right_bt"#_sufix;\
67 rel2.to: "right_bt"#_sufix;\
87 }\ 68 }\
88 description { state: "clicked_rtl" 0.0;\ 69 description { state: "rtl" 0.0;\
89 inherit: "default" 0.0;\ 70 inherit: "default" 0.0;\
90 image.normal: "sym_left_glow_normal.png";\ 71 rel1.to: "left_bt"#_sufix;\
72 rel2.to: "left_bt"#_sufix;\
91 }\ 73 }\
92 }\ 74 }\
93 part { name: #_text; type: TEXT; mouse_events: 0;\ 75 part { name: #_text; type: TEXT; mouse_events: 0;\
@@ -106,76 +88,6 @@
106 min: 0 1;\ 88 min: 0 1;\
107 }\ 89 }\
108 }\ 90 }\
109 }\
110 programs {\
111 program {\
112 signal: "mouse,down,1"; source: "left_bt"#_sufix;\
113 action: SIGNAL_EMIT "elm,action,decrement,start"#_signal_sufix "elm";\
114 }\
115 program {\
116 signal: "mouse,up,1"; source: "left_bt"#_sufix;\
117 action: SIGNAL_EMIT "elm,action,stop"#_signal_sufix "elm"; \
118 }\
119 program { name: "left_bt"#_sufix"_click";\
120 signal: "mouse,down,1"; source: "left_bt"#_sufix;\
121 script {\
122 if (get_int(rtl) == 1)\
123 set_state(PART:"left_bt"#_sufix"_over", "clicked_rtl", 0.0);\
124 else\
125 set_state(PART:"left_bt"#_sufix"_over", "clicked", 0.0);\
126 }\
127 }\
128 program { name: "left_bt"#_sufix"_unclick";\
129 signal: "mouse,up,1"; source: "left_bt"#_sufix;\
130 script {\
131 if (get_int(rtl) == 1)\
132 set_state(PART:"left_bt"#_sufix"_over", "rtl", 0.0);\
133 else\
134 set_state(PART:"left_bt"#_sufix"_over", "default", 0.0);\
135 }\
136 }\
137 program {\
138 signal: "mouse,down,1"; source: "right_bt"#_sufix;\
139 action: SIGNAL_EMIT "elm,action,increment,start"#_signal_sufix "elm";\
140 }\
141 program {\
142 signal: "mouse,up,1"; source: "right_bt"#_sufix;\
143 action: SIGNAL_EMIT "elm,action,stop"#_signal_sufix "elm"; \
144 }\
145 program { name: "right_bt"#_sufix"_click";\
146 signal: "mouse,down,1"; source: "right_bt"#_sufix;\
147 script {\
148 if (get_int(rtl) == 1)\
149 set_state(PART:"right_bt"#_sufix"_over", "clicked_rtl", 0.0);\
150 else\
151 set_state(PART:"right_bt"#_sufix"_over", "clicked", 0.0);\
152 }\
153 }\
154 program { name: "right_bt"#_sufix"_unclick";\
155 signal: "mouse,up,1"; source: "right_bt"#_sufix;\
156 script {\
157 if (get_int(rtl) == 1)\
158 set_state(PART:"right_bt"#_sufix"_over", "rtl", 0.0);\
159 else\
160 set_state(PART:"right_bt"#_sufix"_over", "default", 0.0);\
161 }\
162 }\
163 program { name: "rtl"#_sufix;\
164 signal: "edje,state,rtl"; source: "edje";\
165 script {\
166 set_int(rtl, 1);\
167 set_state(PART:"left_bt"#_sufix"_over", "rtl", 0.0);\
168 set_state(PART:"right_bt"#_sufix"_over", "rtl", 0.0);\
169 }\
170 }\
171 program { name: "ltr"#_sufix;\
172 signal: "edje,state,ltr"; source: "edje";\
173 script {\
174 set_int(rtl, 0);\
175 set_state(PART:"left_bt"#_sufix"_over", "default", 0.0);\
176 set_state(PART:"right_bt"#_sufix"_over", "default", 0.0);\
177 }\
178 }\
179 } 91 }
180 92
181#define CH(_pos) \ 93#define CH(_pos) \
@@ -512,7 +424,7 @@ group { name: "elm/calendar/base/default";
512 } 424 }
513 } 425 }
514 426
515 CAL_SPIN(,,month_text, spinner-base1) 427 CAL_SPIN(,month_text, spinner-base1)
516 CH(0) CH(1) CH(2) CH(3) CH(4) CH(5) CH(6) 428 CH(0) CH(1) CH(2) CH(3) CH(4) CH(5) CH(6)
517 CIT(0) CIT(1) CIT(2) CIT(3) CIT(4) CIT(5) CIT(6) 429 CIT(0) CIT(1) CIT(2) CIT(3) CIT(4) CIT(5) CIT(6)
518 CIT(7) CIT(8) CIT(9) CIT(10) CIT(11) CIT(12) CIT(13) 430 CIT(7) CIT(8) CIT(9) CIT(10) CIT(11) CIT(12) CIT(13)
@@ -551,8 +463,8 @@ group { name: "elm/calendar/base/double_spinners";
551 align: 0.0 0.0; 463 align: 0.0 0.0;
552 } 464 }
553 } 465 }
554 CAL_SPIN(,,month_text, spinner-base1) 466 CAL_SPIN(,month_text, spinner-base1)
555 CAL_SPIN(_year, year, year_text, spinner-base2) 467 CAL_SPIN(_year, year_text, spinner-base2)
556 } 468 }
557} 469}
558 470
diff --git a/src/lib/elm_calendar.c b/src/lib/elm_calendar.c
index c1aa2d67c..65e13e7e6 100644
--- a/src/lib/elm_calendar.c
+++ b/src/lib/elm_calendar.c
@@ -14,6 +14,11 @@
14#define MY_CLASS_NAME "Elm_Calendar" 14#define MY_CLASS_NAME "Elm_Calendar"
15#define MY_CLASS_NAME_LEGACY "elm_calendar" 15#define MY_CLASS_NAME_LEGACY "elm_calendar"
16 16
17#define ELM_CALENDAR_BUTTON_LEFT "elm,calendar,button,left"
18#define ELM_CALENDAR_BUTTON_RIGHT "elm,calendar,button,right"
19#define ELM_CALENDAR_BUTTON_YEAR_LEFT "elm,calendar,button_year,left"
20#define ELM_CALENDAR_BUTTON_YEAR_RIGHT "elm,calendar,button_year,right"
21
17static const char SIG_CHANGED[] = "changed"; 22static const char SIG_CHANGED[] = "changed";
18static const char SIG_DISPLAY_CHANGED[] = "display,changed"; 23static const char SIG_DISPLAY_CHANGED[] = "display,changed";
19 24
@@ -27,6 +32,96 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
27 {NULL, NULL} 32 {NULL, NULL}
28}; 33};
29 34
35/* Originally, the button functionalities of month, year spinners were
36 * implemented by its own edc. There was a bunch of callback functions
37 * for handle the signals. The following functions are the old callback
38 * functions for handle the signals.
39 * _button_month_dec_start
40 * _button_year_inc_start
41 * _button_year_dec_start
42 * _button_month_stop
43 * _button_year_stop
44 *
45 * But, it is replaced by elm_button widget objects. The following
46 * callback functions are also newly added for button objects.
47 * We still keep the old signal callback functions for backward compatibility. */
48static void
49_button_widget_month_inc_start_click(void *data,
50 Evas_Object *obj EINA_UNUSED,
51 void *event_info EINA_UNUSED);
52static void
53_button_widget_month_inc_start(void *data,
54 Evas_Object *obj EINA_UNUSED,
55 void *event_info EINA_UNUSED);
56static void
57_button_widget_month_dec_start_click(void *data,
58 Evas_Object *obj EINA_UNUSED,
59 void *event_info EINA_UNUSED);
60static void
61_button_widget_month_dec_start(void *data,
62 Evas_Object *obj EINA_UNUSED,
63 void *event_info EINA_UNUSED);
64static void
65_button_widget_year_inc_start_click(void *data,
66 Evas_Object *obj EINA_UNUSED,
67 void *event_info EINA_UNUSED);
68static void
69_button_widget_year_inc_start(void *data,
70 Evas_Object *obj EINA_UNUSED,
71 void *event_info EINA_UNUSED);
72static void
73_button_widget_year_dec_start_click(void *data,
74 Evas_Object *obj EINA_UNUSED,
75 void *event_info EINA_UNUSED);
76static void
77_button_widget_year_dec_start(void *data,
78 Evas_Object *obj EINA_UNUSED,
79 void *event_info EINA_UNUSED);
80
81/* This two functions should be moved in Eina for next release. */
82static Eina_Tmpstr *
83_eina_tmpstr_strftime(const char *format, const struct tm *tm)
84{
85 const size_t flen = strlen(format);
86 size_t buflen = 16; // An arbitrary starting size
87 char *buf = NULL;
88
89 do {
90 char *tmp;
91 size_t len;
92
93 tmp = realloc(buf, buflen * sizeof(char));
94 if (!tmp) goto on_error;
95 buf = tmp;
96
97 len = strftime(buf, buflen, format, tm);
98 // Check if we have the expected result and return it.
99 if ((len > 0 && len < buflen) || (len == 0 && flen == 0))
100 {
101 Eina_Tmpstr *r;
102
103 r = eina_tmpstr_add_length(buf, len + 1);
104 free(buf);
105 return r;
106 }
107
108 /* Possibly buf overflowed - try again with a bigger buffer */
109 buflen <<= 1; // multiply buffer size by 2
110 } while (buflen < 128 * flen);
111
112 on_error:
113 free(buf);
114 return NULL;
115}
116
117static char *
118_eina_tmpstr_steal(Eina_Tmpstr *s)
119{
120 char *r = s ? strdup(s) : NULL;
121 eina_tmpstr_del(s);
122 return r;
123}
124
30static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); 125static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
31 126
32static const Elm_Action key_actions[] = { 127static const Elm_Action key_actions[] = {
@@ -321,24 +416,28 @@ _access_calendar_spinner_register(Evas_Object *obj)
321 Elm_Access_Info *ai; 416 Elm_Access_Info *ai;
322 ELM_CALENDAR_DATA_GET(obj, sd); 417 ELM_CALENDAR_DATA_GET(obj, sd);
323 418
324 sd->dec_btn_month_access = _elm_access_edje_object_part_object_register 419 if (!sd->dec_btn_month)
325 (obj, elm_layout_edje_get(obj), "left_bt"); 420 sd->dec_btn_month = _elm_access_edje_object_part_object_register
326 ai = _elm_access_info_get(sd->dec_btn_month_access); 421 (obj, elm_layout_edje_get(obj), "left_bt");
422 ai = _elm_access_info_get(sd->dec_btn_month);
327 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement month button")); 423 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement month button"));
328 424
329 sd->dec_btn_year_access = _elm_access_edje_object_part_object_register 425 if (!sd->dec_btn_year)
330 (obj, elm_layout_edje_get(obj), "left_bt_year"); 426 sd->dec_btn_year = _elm_access_edje_object_part_object_register
331 ai = _elm_access_info_get(sd->dec_btn_year_access); 427 (obj, elm_layout_edje_get(obj), "left_bt_year");
428 ai = _elm_access_info_get(sd->dec_btn_year);
332 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement year button")); 429 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement year button"));
333 430
334 sd->inc_btn_month_access = _elm_access_edje_object_part_object_register 431 if (!sd->inc_btn_month)
335 (obj, elm_layout_edje_get(obj), "right_bt"); 432 sd->inc_btn_month = _elm_access_edje_object_part_object_register
336 ai = _elm_access_info_get(sd->inc_btn_month_access); 433 (obj, elm_layout_edje_get(obj), "right_bt");
434 ai = _elm_access_info_get(sd->inc_btn_month);
337 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment month button")); 435 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment month button"));
338 436
339 sd->inc_btn_year_access = _elm_access_edje_object_part_object_register 437 if (!sd->inc_btn_year)
340 (obj, elm_layout_edje_get(obj), "right_bt_year"); 438 sd->inc_btn_year = _elm_access_edje_object_part_object_register
341 ai = _elm_access_info_get(sd->inc_btn_year_access); 439 (obj, elm_layout_edje_get(obj), "right_bt_year");
440 ai = _elm_access_info_get(sd->inc_btn_year);
342 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment year button")); 441 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment year button"));
343 442
344 sd->month_access = _elm_access_edje_object_part_object_register 443 sd->month_access = _elm_access_edje_object_part_object_register
@@ -627,14 +726,140 @@ _set_headers(Evas_Object *obj)
627 elm_layout_thaw(obj); 726 elm_layout_thaw(obj);
628} 727}
629 728
729static void
730_spinner_buttons_add(Evas_Object *obj, Elm_Calendar_Data *sd)
731{
732 char left_buf[255] = { 0 };
733 char right_buf[255] = { 0 };
734
735 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
736
737 snprintf(left_buf, sizeof(left_buf), "calendar/decrease/%s", elm_object_style_get(obj));
738 snprintf(right_buf, sizeof(right_buf), "calendar/increase/%s", elm_object_style_get(obj));
739
740 if (edje_object_part_exists(wd->resize_obj, ELM_CALENDAR_BUTTON_LEFT))
741 {
742 if (sd->dec_btn_month && eo_isa(sd->dec_btn_month, ELM_ACCESS_CLASS))
743 {
744 _elm_access_edje_object_part_object_unregister
745 (obj, elm_layout_edje_get(obj), "left_bt");
746 sd->dec_btn_month = NULL;
747 }
748
749 if (!sd->dec_btn_month)
750 {
751 sd->dec_btn_month = elm_button_add(obj);
752 elm_button_autorepeat_set(sd->dec_btn_month, EINA_TRUE);
753 elm_button_autorepeat_initial_timeout_set(sd->dec_btn_month, 0.5);
754 elm_button_autorepeat_gap_timeout_set(sd->dec_btn_month, 0.2);
755 evas_object_smart_callback_add(sd->dec_btn_month, "clicked", _button_widget_month_dec_start_click, obj);
756 evas_object_smart_callback_add(sd->dec_btn_month, "repeated", _button_widget_month_dec_start, obj);
757 }
758
759 elm_object_style_set(sd->dec_btn_month, left_buf);
760 elm_layout_content_set(obj, ELM_CALENDAR_BUTTON_LEFT, sd->dec_btn_month);
761 }
762 else if (sd->dec_btn_month && !eo_isa(sd->dec_btn_month, ELM_ACCESS_CLASS))
763 {
764 evas_object_del(sd->dec_btn_month);
765 sd->dec_btn_month = NULL;
766 }
767
768 if (edje_object_part_exists(wd->resize_obj, ELM_CALENDAR_BUTTON_RIGHT))
769 {
770 if (sd->inc_btn_month && eo_isa(sd->inc_btn_month, ELM_ACCESS_CLASS))
771 {
772 _elm_access_edje_object_part_object_unregister
773 (obj, elm_layout_edje_get(obj), "right_bt");
774 sd->inc_btn_month = NULL;
775 }
776
777 if (!sd->inc_btn_month)
778 {
779 sd->inc_btn_month = elm_button_add(obj);
780 elm_button_autorepeat_set(sd->inc_btn_month, EINA_TRUE);
781 elm_button_autorepeat_initial_timeout_set(sd->inc_btn_month, 0.5);
782 elm_button_autorepeat_gap_timeout_set(sd->inc_btn_month, 0.2);
783 evas_object_smart_callback_add(sd->inc_btn_month, "clicked", _button_widget_month_inc_start_click, obj);
784 evas_object_smart_callback_add(sd->inc_btn_month, "repeated", _button_widget_month_inc_start, obj);
785 }
786
787 elm_object_style_set(sd->inc_btn_month, right_buf);
788 elm_layout_content_set(obj, ELM_CALENDAR_BUTTON_RIGHT, sd->inc_btn_month);
789 }
790 else if (sd->inc_btn_month && !eo_isa(sd->inc_btn_month, ELM_ACCESS_CLASS))
791 {
792 evas_object_del(sd->inc_btn_month);
793 sd->inc_btn_month = NULL;
794 }
795
796 if (edje_object_part_exists(wd->resize_obj, ELM_CALENDAR_BUTTON_YEAR_LEFT))
797 {
798 if (sd->dec_btn_year && eo_isa(sd->dec_btn_year, ELM_ACCESS_CLASS))
799 {
800 _elm_access_edje_object_part_object_unregister
801 (obj, elm_layout_edje_get(obj), "left_bt_year");
802 sd->dec_btn_year = NULL;
803 }
804
805 if (!sd->dec_btn_year)
806 {
807 sd->dec_btn_year = elm_button_add(obj);
808 elm_button_autorepeat_set(sd->dec_btn_year, EINA_TRUE);
809 elm_button_autorepeat_initial_timeout_set(sd->dec_btn_year, 0.5);
810 elm_button_autorepeat_gap_timeout_set(sd->dec_btn_year, 0.2);
811 evas_object_smart_callback_add(sd->dec_btn_year, "clicked", _button_widget_year_dec_start_click, obj);
812 evas_object_smart_callback_add(sd->dec_btn_year, "repeated", _button_widget_year_dec_start, obj);
813 }
814
815 elm_object_style_set(sd->dec_btn_year, left_buf);
816 elm_layout_content_set(obj, ELM_CALENDAR_BUTTON_YEAR_LEFT, sd->dec_btn_year);
817 }
818 else if (sd->dec_btn_year && !eo_isa(sd->dec_btn_year, ELM_ACCESS_CLASS))
819 {
820 evas_object_del(sd->dec_btn_year);
821 sd->dec_btn_year = NULL;
822 }
823
824 if (edje_object_part_exists(wd->resize_obj, ELM_CALENDAR_BUTTON_YEAR_RIGHT))
825 {
826 if (sd->inc_btn_year && eo_isa(sd->inc_btn_year, ELM_ACCESS_CLASS))
827 {
828 _elm_access_edje_object_part_object_unregister
829 (obj, elm_layout_edje_get(obj), "right_bt_year");
830 sd->inc_btn_year = NULL;
831 }
832
833 if (!sd->inc_btn_year)
834 {
835 sd->inc_btn_year = elm_button_add(obj);
836 elm_button_autorepeat_set(sd->inc_btn_year, EINA_TRUE);
837 elm_button_autorepeat_initial_timeout_set(sd->inc_btn_year, 0.5);
838 elm_button_autorepeat_gap_timeout_set(sd->inc_btn_year, 0.2);
839 evas_object_smart_callback_add(sd->inc_btn_year, "clicked", _button_widget_year_inc_start_click, obj);
840 evas_object_smart_callback_add(sd->inc_btn_year, "repeated", _button_widget_year_inc_start, obj);
841 }
842
843 elm_object_style_set(sd->inc_btn_year, right_buf);
844 elm_layout_content_set(obj, ELM_CALENDAR_BUTTON_YEAR_RIGHT, sd->inc_btn_year);
845 }
846 else if (sd->inc_btn_year && !eo_isa(sd->inc_btn_year, ELM_ACCESS_CLASS))
847 {
848 evas_object_del(sd->inc_btn_year);
849 sd->inc_btn_year = NULL;
850 }
851}
852
630EOLIAN static Eina_Bool 853EOLIAN static Eina_Bool
631_elm_calendar_elm_widget_theme_apply(Eo *obj, Elm_Calendar_Data *_pd EINA_UNUSED) 854_elm_calendar_elm_widget_theme_apply(Eo *obj, Elm_Calendar_Data *sd)
632{ 855{
633 Eina_Bool int_ret = EINA_FALSE; 856 Eina_Bool int_ret = EINA_FALSE;
634 857
635 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply()); 858 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
636 if (!int_ret) return EINA_FALSE; 859 if (!int_ret) return EINA_FALSE;
637 860
861 _spinner_buttons_add(obj, sd);
862
638 evas_object_smart_changed(obj); 863 evas_object_smart_changed(obj);
639 return EINA_TRUE; 864 return EINA_TRUE;
640} 865}
@@ -745,6 +970,7 @@ _spin_year_value(void *data)
745 return ECORE_CALLBACK_RENEW; 970 return ECORE_CALLBACK_RENEW;
746} 971}
747 972
973/* Legacy callbacks for signals from edje */
748static void 974static void
749_button_month_inc_start(void *data, 975_button_month_inc_start(void *data,
750 Evas_Object *obj EINA_UNUSED, 976 Evas_Object *obj EINA_UNUSED,
@@ -761,6 +987,7 @@ _button_month_inc_start(void *data,
761 _spin_month_value(data); 987 _spin_month_value(data);
762} 988}
763 989
990/* Legacy callbacks for signals from edje */
764static void 991static void
765_button_month_dec_start(void *data, 992_button_month_dec_start(void *data,
766 Evas_Object *obj EINA_UNUSED, 993 Evas_Object *obj EINA_UNUSED,
@@ -777,6 +1004,7 @@ _button_month_dec_start(void *data,
777 _spin_month_value(data); 1004 _spin_month_value(data);
778} 1005}
779 1006
1007/* Legacy callbacks for signals from edje */
780static void 1008static void
781_button_month_stop(void *data, 1009_button_month_stop(void *data,
782 Evas_Object *obj EINA_UNUSED, 1010 Evas_Object *obj EINA_UNUSED,
@@ -789,6 +1017,7 @@ _button_month_stop(void *data,
789 ELM_SAFE_FREE(sd->spin_month, ecore_timer_del); 1017 ELM_SAFE_FREE(sd->spin_month, ecore_timer_del);
790} 1018}
791 1019
1020/* Legacy callbacks for signals from edje */
792static void 1021static void
793_button_year_inc_start(void *data, 1022_button_year_inc_start(void *data,
794 Evas_Object *obj EINA_UNUSED, 1023 Evas_Object *obj EINA_UNUSED,
@@ -805,6 +1034,7 @@ _button_year_inc_start(void *data,
805 _spin_year_value(data); 1034 _spin_year_value(data);
806} 1035}
807 1036
1037/* Legacy callbacks for signals from edje */
808static void 1038static void
809_button_year_dec_start(void *data, 1039_button_year_dec_start(void *data,
810 Evas_Object *obj EINA_UNUSED, 1040 Evas_Object *obj EINA_UNUSED,
@@ -821,6 +1051,7 @@ _button_year_dec_start(void *data,
821 _spin_year_value(data); 1051 _spin_year_value(data);
822} 1052}
823 1053
1054/* Legacy callbacks for signals from edje */
824static void 1055static void
825_button_year_stop(void *data, 1056_button_year_stop(void *data,
826 Evas_Object *obj EINA_UNUSED, 1057 Evas_Object *obj EINA_UNUSED,
@@ -833,6 +1064,126 @@ _button_year_stop(void *data,
833 ELM_SAFE_FREE(sd->spin_year, ecore_timer_del); 1064 ELM_SAFE_FREE(sd->spin_year, ecore_timer_del);
834} 1065}
835 1066
1067static void
1068_button_widget_month_inc_start_click(void *data,
1069 Evas_Object *obj EINA_UNUSED,
1070 void *event_info EINA_UNUSED)
1071{
1072 ELM_CALENDAR_DATA_GET(data, sd);
1073 if (sd->month_repeated)
1074 {
1075 sd->month_repeated = EINA_FALSE;
1076 return;
1077 }
1078
1079 sd->interval = sd->first_interval;
1080 sd->spin_speed = 1;
1081 _spin_month_value(data);
1082}
1083
1084static void
1085_button_widget_month_inc_start(void *data,
1086 Evas_Object *obj EINA_UNUSED,
1087 void *event_info EINA_UNUSED)
1088{
1089 ELM_CALENDAR_DATA_GET(data, sd);
1090
1091 sd->interval = sd->first_interval;
1092 sd->spin_speed = 1;
1093 _spin_month_value(data);
1094 sd->month_repeated = EINA_TRUE;
1095}
1096
1097static void
1098_button_widget_month_dec_start_click(void *data,
1099 Evas_Object *obj EINA_UNUSED,
1100 void *event_info EINA_UNUSED)
1101{
1102 ELM_CALENDAR_DATA_GET(data, sd);
1103 if (sd->month_repeated)
1104 {
1105 sd->month_repeated = EINA_FALSE;
1106 return;
1107 }
1108
1109 sd->interval = sd->first_interval;
1110 sd->spin_speed = -1;
1111 _spin_month_value(data);
1112}
1113
1114static void
1115_button_widget_month_dec_start(void *data,
1116 Evas_Object *obj EINA_UNUSED,
1117 void *event_info EINA_UNUSED)
1118{
1119 ELM_CALENDAR_DATA_GET(data, sd);
1120
1121 sd->interval = sd->first_interval;
1122 sd->spin_speed = -1;
1123 _spin_month_value(data);
1124 sd->month_repeated = EINA_TRUE;
1125}
1126
1127static void
1128_button_widget_year_inc_start_click(void *data,
1129 Evas_Object *obj EINA_UNUSED,
1130 void *event_info EINA_UNUSED)
1131{
1132 ELM_CALENDAR_DATA_GET(data, sd);
1133 if (sd->year_repeated)
1134 {
1135 sd->year_repeated = EINA_FALSE;
1136 return;
1137 }
1138
1139 sd->interval = sd->first_interval;
1140 sd->spin_speed = 1;
1141 _spin_year_value(data);
1142}
1143
1144static void
1145_button_widget_year_inc_start(void *data,
1146 Evas_Object *obj EINA_UNUSED,
1147 void *event_info EINA_UNUSED)
1148{
1149 ELM_CALENDAR_DATA_GET(data, sd);
1150
1151 sd->interval = sd->first_interval;
1152 sd->spin_speed = 1;
1153 _spin_year_value(data);
1154 sd->year_repeated = EINA_TRUE;
1155}
1156
1157static void
1158_button_widget_year_dec_start_click(void *data,
1159 Evas_Object *obj EINA_UNUSED,
1160 void *event_info EINA_UNUSED)
1161{
1162 ELM_CALENDAR_DATA_GET(data, sd);
1163 if (sd->year_repeated)
1164 {
1165 sd->year_repeated = EINA_FALSE;
1166 return;
1167 }
1168
1169 sd->interval = sd->first_interval;
1170 sd->spin_speed = -1;
1171 _spin_year_value(data);
1172}
1173
1174static void
1175_button_widget_year_dec_start(void *data,
1176 Evas_Object *obj EINA_UNUSED,
1177 void *event_info EINA_UNUSED)
1178{
1179 ELM_CALENDAR_DATA_GET(data, sd);
1180
1181 sd->interval = sd->first_interval;
1182 sd->spin_speed = -1;
1183 _spin_year_value(data);
1184 sd->year_repeated = EINA_TRUE;
1185}
1186
836static int 1187static int
837_get_item_day(Evas_Object *obj, 1188_get_item_day(Evas_Object *obj,
838 int selected_it) 1189 int selected_it)
@@ -1076,6 +1427,8 @@ _elm_calendar_evas_object_smart_add(Eo *obj, Elm_Calendar_Data *priv)
1076 elm_object_style_get(obj))) 1427 elm_object_style_get(obj)))
1077 CRI("Failed to set layout!"); 1428 CRI("Failed to set layout!");
1078 1429
1430 _spinner_buttons_add(obj, priv);
1431
1079 evas_object_smart_changed(obj); 1432 evas_object_smart_changed(obj);
1080 1433
1081 // ACCESS 1434 // ACCESS
@@ -1112,7 +1465,7 @@ static Eina_Bool _elm_calendar_smart_focus_next_enable = EINA_FALSE;
1112EOLIAN static Eina_Bool 1465EOLIAN static Eina_Bool
1113_elm_calendar_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Calendar_Data *_pd EINA_UNUSED) 1466_elm_calendar_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Calendar_Data *_pd EINA_UNUSED)
1114{ 1467{
1115 return _elm_calendar_smart_focus_next_enable; 1468 return EINA_TRUE;
1116} 1469}
1117 1470
1118EOLIAN static Eina_Bool 1471EOLIAN static Eina_Bool
@@ -1130,12 +1483,12 @@ _elm_calendar_elm_widget_focus_next(Eo *obj, Elm_Calendar_Data *sd, Elm_Focus_Di
1130 Evas_Object *po; 1483 Evas_Object *po;
1131 1484
1132 items = eina_list_append(items, sd->month_access); 1485 items = eina_list_append(items, sd->month_access);
1133 items = eina_list_append(items, sd->dec_btn_month_access); 1486 items = eina_list_append(items, sd->dec_btn_month);
1134 items = eina_list_append(items, sd->inc_btn_month_access); 1487 items = eina_list_append(items, sd->inc_btn_month);
1135 1488
1136 items = eina_list_append(items, sd->year_access); 1489 items = eina_list_append(items, sd->year_access);
1137 items = eina_list_append(items, sd->dec_btn_year_access); 1490 items = eina_list_append(items, sd->dec_btn_year);
1138 items = eina_list_append(items, sd->inc_btn_year_access); 1491 items = eina_list_append(items, sd->inc_btn_year);
1139 1492
1140 day = 0; 1493 day = 0;
1141 maxdays = _maxdays_get(&sd->shown_time, 0); 1494 maxdays = _maxdays_get(&sd->shown_time, 0);
@@ -1164,6 +1517,7 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1164 int maxdays, day, i; 1517 int maxdays, day, i;
1165 1518
1166 ELM_CALENDAR_DATA_GET(obj, sd); 1519 ELM_CALENDAR_DATA_GET(obj, sd);
1520 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1167 1521
1168 if (is_access) 1522 if (is_access)
1169 _access_calendar_register(obj); 1523 _access_calendar_register(obj);
@@ -1184,22 +1538,34 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1184 } 1538 }
1185 } 1539 }
1186 1540
1187 if (sd->dec_btn_month_access) 1541 if (sd->dec_btn_month && eo_isa(sd->dec_btn_month, ELM_ACCESS_CLASS))
1188 _elm_access_edje_object_part_object_unregister 1542 {
1189 (obj, elm_layout_edje_get(obj), "left_bt"); 1543 _elm_access_edje_object_part_object_unregister
1190 if (sd->inc_btn_month_access) 1544 (obj, elm_layout_edje_get(obj), "left_bt");
1191 _elm_access_edje_object_part_object_unregister 1545 sd->dec_btn_month = NULL;
1192 (obj, elm_layout_edje_get(obj), "right_bt"); 1546 }
1547 if (sd->inc_btn_month && eo_isa(sd->inc_btn_month, ELM_ACCESS_CLASS))
1548 {
1549 _elm_access_edje_object_part_object_unregister
1550 (obj, elm_layout_edje_get(obj), "right_bt");
1551 sd->inc_btn_month = NULL;
1552 }
1193 if (sd->month_access) 1553 if (sd->month_access)
1194 _elm_access_edje_object_part_object_unregister 1554 _elm_access_edje_object_part_object_unregister
1195 (obj, elm_layout_edje_get(obj), "month_text"); 1555 (obj, elm_layout_edje_get(obj), "month_text");
1196 1556
1197 if (sd->dec_btn_year_access) 1557 if (sd->dec_btn_year && eo_isa(sd->dec_btn_year, ELM_ACCESS_CLASS))
1198 _elm_access_edje_object_part_object_unregister 1558 {
1199 (obj, elm_layout_edje_get(obj), "left_bt_year"); 1559 _elm_access_edje_object_part_object_unregister
1200 if (sd->inc_btn_year_access) 1560 (obj, elm_layout_edje_get(obj), "left_bt_year");
1201 _elm_access_edje_object_part_object_unregister 1561 sd->dec_btn_year = NULL;
1202 (obj, elm_layout_edje_get(obj), "right_bt_year"); 1562 }
1563 if (sd->inc_btn_year && eo_isa(sd->inc_btn_year, ELM_ACCESS_CLASS))
1564 {
1565 _elm_access_edje_object_part_object_unregister
1566 (obj, elm_layout_edje_get(obj), "right_bt_year");
1567 sd->inc_btn_year = NULL;
1568 }
1203 if (sd->year_access) 1569 if (sd->year_access)
1204 _elm_access_edje_object_part_object_unregister 1570 _elm_access_edje_object_part_object_unregister
1205 (obj, elm_layout_edje_get(obj), "year_text"); 1571 (obj, elm_layout_edje_get(obj), "year_text");
diff --git a/src/lib/elm_widget_calendar.h b/src/lib/elm_widget_calendar.h
index e7d4d47e3..f5b54a72d 100644
--- a/src/lib/elm_widget_calendar.h
+++ b/src/lib/elm_widget_calendar.h
@@ -44,11 +44,11 @@ struct _Elm_Calendar_Data
44 const char *weekdays[ELM_DAY_LAST]; 44 const char *weekdays[ELM_DAY_LAST];
45 struct tm current_time, selected_time, shown_time; 45 struct tm current_time, selected_time, shown_time;
46 Day_Color day_color[42]; // EINA_DEPRECATED 46 Day_Color day_color[42]; // EINA_DEPRECATED
47 Evas_Object *inc_btn_month_access; 47 Evas_Object *inc_btn_month;
48 Evas_Object *dec_btn_month_access; 48 Evas_Object *dec_btn_month;
49 Evas_Object *month_access; 49 Evas_Object *month_access;
50 Evas_Object *inc_btn_year_access; 50 Evas_Object *inc_btn_year;
51 Evas_Object *dec_btn_year_access; 51 Evas_Object *dec_btn_year;
52 Evas_Object *year_access; 52 Evas_Object *year_access;
53 53
54 Elm_Calendar_Weekday first_week_day; 54 Elm_Calendar_Weekday first_week_day;
@@ -59,6 +59,8 @@ struct _Elm_Calendar_Data
59 Eina_Bool double_spinners : 1; 59 Eina_Bool double_spinners : 1;
60 Eina_Bool filling : 1; 60 Eina_Bool filling : 1;
61 Eina_Bool weekdays_set : 1; 61 Eina_Bool weekdays_set : 1;
62 Eina_Bool month_repeated : 1;
63 Eina_Bool year_repeated : 1;
62}; 64};
63 65
64struct _Elm_Calendar_Mark 66struct _Elm_Calendar_Mark