summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2015-06-25 16:13:56 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-25 17:24:08 +0200
commit60396b1158df8a6ea4ca958c6ead92965ca61822 (patch)
tree6e6f6da96b9bb9bf477c5e3d251fea00dd285822
parent4fe4ee851673817043773d66d2b1552b9c0141d1 (diff)
calendar: show days of prev/next month.
Summary: Show days of previous and next month on the blank area of calendar. @feature Test Plan: See calendar widget on elementary_test. Reviewers: raster, seoz, woohyun, cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D2728 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--data/themes/edc/elm/calendar.edc26
-rw-r--r--src/lib/elm_calendar.c57
2 files changed, 72 insertions, 11 deletions
diff --git a/data/themes/edc/elm/calendar.edc b/data/themes/edc/elm/calendar.edc
index b1b15c854..35a0367fc 100644
--- a/data/themes/edc/elm/calendar.edc
+++ b/data/themes/edc/elm/calendar.edc
@@ -8,6 +8,9 @@
8 style { name: "calendar_date_today_style";\ 8 style { name: "calendar_date_today_style";\
9 base: "font="FN" font_size=10 color=#3399ff style=glow glow_color=#3399ff18 align=center";\ 9 base: "font="FN" font_size=10 color=#3399ff style=glow glow_color=#3399ff18 align=center";\
10 }\ 10 }\
11 style { name: "calendar_date_disabled_style";\
12 base: "font="FN" font_size=10 color=#151515 style=shadow_bottom shadow_color=#ffffffc0 align=center";\
13 }\
11 14
12#define CAL_SPIN(_sufix, _signal_sufix, _text, _relative)\ 15#define CAL_SPIN(_sufix, _signal_sufix, _text, _relative)\
13 part { name: "left_bt"#_sufix; type: RECT;\ 16 part { name: "left_bt"#_sufix; type: RECT;\
@@ -291,6 +294,10 @@
291 inherit: "default" 0.0; \ 294 inherit: "default" 0.0; \
292 text.style: "calendar_date_today_style"; \ 295 text.style: "calendar_date_today_style"; \
293 } \ 296 } \
297 description { state: "disabled" 0.0; \
298 inherit: "default" 0.0; \
299 text.style: "calendar_date_disabled_style"; \
300 } \
294 } \ 301 } \
295 part { name: "cit_"#_pos".check"; mouse_events: 0; \ 302 part { name: "cit_"#_pos".check"; mouse_events: 0; \
296 scale: 1; \ 303 scale: 1; \
@@ -355,6 +362,25 @@
355 target: "cit_"#_pos".text"; \ 362 target: "cit_"#_pos".text"; \
356 } \ 363 } \
357 program { \ 364 program { \
365 name: "cit_"#_pos".enable"; \
366 signal: "cit_"#_pos",enable"; \
367 source: "elm"; \
368 script { \
369 new st[31]; \
370 new Float:vl; \
371 get_state(PART:"cit_"#_pos".text", st, 30, vl); \
372 if (!strcmp(st, "disabled")) \
373 set_state(PART:"cit_"#_pos".text", "default", 0.0); \
374 } \
375 } \
376 program { \
377 name: "cit_"#_pos".disable"; \
378 signal: "cit_"#_pos",disable"; \
379 source: "elm"; \
380 action: STATE_SET "disabled" 0.0; \
381 target: "cit_"#_pos".text"; \
382 } \
383 program { \
358 source: "cit_"#_pos".clicked"; \ 384 source: "cit_"#_pos".clicked"; \
359 signal: "mouse,down,1"; \ 385 signal: "mouse,down,1"; \
360 source: "cit_"#_pos".event"; \ 386 source: "cit_"#_pos".event"; \
diff --git a/src/lib/elm_calendar.c b/src/lib/elm_calendar.c
index 58d4d6cf1..18574a1b3 100644
--- a/src/lib/elm_calendar.c
+++ b/src/lib/elm_calendar.c
@@ -90,13 +90,15 @@ _elm_calendar_elm_layout_sizing_eval(Eo *obj, Elm_Calendar_Data *_pd EINA_UNUSED
90} 90}
91 91
92static inline int 92static inline int
93_maxdays_get(struct tm *selected_time) 93_maxdays_get(struct tm *selected_time, int month_offset)
94{ 94{
95 int month, year; 95 int month, year;
96 96
97 month = selected_time->tm_mon; 97 month = (selected_time->tm_mon + month_offset) % 12;
98 year = selected_time->tm_year + 1900; 98 year = selected_time->tm_year + 1900;
99 99
100 if (month < 0) month += 12;
101
100 return _days_in_month 102 return _days_in_month
101 [((!(year % 4)) && ((!(year % 400)) || (year % 100)))][month]; 103 [((!(year % 4)) && ((!(year % 400)) || (year % 100)))][month];
102} 104}
@@ -145,6 +147,28 @@ _today(Elm_Calendar_Data *sd,
145 sd->today_it = it; 147 sd->today_it = it;
146} 148}
147 149
150static inline void
151_enable(Elm_Calendar_Data *sd,
152 int it)
153{
154 char emission[32];
155
156 snprintf(emission, sizeof(emission), "cit_%i,enable", it);
157 elm_layout_signal_emit(sd->obj, emission, "elm");
158 sd->today_it = it;
159}
160
161static inline void
162_disable(Elm_Calendar_Data *sd,
163 int it)
164{
165 char emission[32];
166
167 snprintf(emission, sizeof(emission), "cit_%i,disable", it);
168 elm_layout_signal_emit(sd->obj, emission, "elm");
169 sd->today_it = it;
170}
171
148static char * 172static char *
149_format_month_year(struct tm *selected_time) 173_format_month_year(struct tm *selected_time)
150{ 174{
@@ -272,7 +296,7 @@ _access_calendar_item_register(Evas_Object *obj)
272 ELM_CALENDAR_DATA_GET(obj, sd); 296 ELM_CALENDAR_DATA_GET(obj, sd);
273 297
274 day = 0; 298 day = 0;
275 maxdays = _maxdays_get(&sd->shown_time); 299 maxdays = _maxdays_get(&sd->shown_time, 0);
276 for (i = 0; i < 42; i++) 300 for (i = 0; i < 42; i++)
277 { 301 {
278 if ((!day) && (i == sd->first_day_it)) day = 1; 302 if ((!day) && (i == sd->first_day_it)) day = 1;
@@ -355,7 +379,7 @@ _access_calendar_register(Evas_Object *obj)
355static void 379static void
356_populate(Evas_Object *obj) 380_populate(Evas_Object *obj)
357{ 381{
358 int maxdays, day, mon, yr, i; 382 int maxdays, prev_month_maxdays, day, mon, yr, i;
359 Elm_Calendar_Mark *mark; 383 Elm_Calendar_Mark *mark;
360 char part[12], day_s[3]; 384 char part[12], day_s[3];
361 struct tm first_day; 385 struct tm first_day;
@@ -369,7 +393,8 @@ _populate(Evas_Object *obj)
369 sd->filling = EINA_FALSE; 393 sd->filling = EINA_FALSE;
370 if (sd->today_it > 0) _not_today(sd); 394 if (sd->today_it > 0) _not_today(sd);
371 395
372 maxdays = _maxdays_get(&sd->shown_time); 396 maxdays = _maxdays_get(&sd->shown_time, 0);
397 prev_month_maxdays = _maxdays_get(&sd->shown_time, -1);
373 mon = sd->shown_time.tm_mon; 398 mon = sd->shown_time.tm_mon;
374 yr = sd->shown_time.tm_year; 399 yr = sd->shown_time.tm_year;
375 400
@@ -459,9 +484,19 @@ _populate(Evas_Object *obj)
459 } 484 }
460 485
461 if ((day) && (day <= maxdays)) 486 if ((day) && (day <= maxdays))
462 snprintf(day_s, sizeof(day_s), "%i", day++); 487 {
488 _enable(sd, i);
489 snprintf(day_s, sizeof(day_s), "%i", day++);
490 }
463 else 491 else
464 day_s[0] = 0; 492 {
493 _disable(sd, i);
494
495 if (day <= maxdays)
496 snprintf(day_s, sizeof(day_s), "%i", prev_month_maxdays - sd->first_day_it + i + 1);
497 else
498 snprintf(day_s, sizeof(day_s), "%i", i - sd->first_day_it - maxdays + 1);
499 }
465 500
466 snprintf(part, sizeof(part), "cit_%i.text", i); 501 snprintf(part, sizeof(part), "cit_%i.text", i);
467 elm_layout_text_set(obj, part, day_s); 502 elm_layout_text_set(obj, part, day_s);
@@ -641,7 +676,7 @@ _update_data(Evas_Object *obj, Eina_Bool month,
641 if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND) 676 if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
642 && (sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE)) 677 && (sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE))
643 { 678 {
644 maxdays = _maxdays_get(&sd->shown_time); 679 maxdays = _maxdays_get(&sd->shown_time, 0);
645 if (sd->selected_time.tm_mday > maxdays) 680 if (sd->selected_time.tm_mday > maxdays)
646 sd->selected_time.tm_mday = maxdays; 681 sd->selected_time.tm_mday = maxdays;
647 682
@@ -778,7 +813,7 @@ _get_item_day(Evas_Object *obj,
778 ELM_CALENDAR_DATA_GET(obj, sd); 813 ELM_CALENDAR_DATA_GET(obj, sd);
779 814
780 day = selected_it - sd->first_day_it + 1; 815 day = selected_it - sd->first_day_it + 1;
781 if ((day < 0) || (day > _maxdays_get(&sd->shown_time))) 816 if ((day < 0) || (day > _maxdays_get(&sd->shown_time, 0)))
782 return 0; 817 return 0;
783 818
784 return day; 819 return day;
@@ -1100,7 +1135,7 @@ _elm_calendar_elm_widget_focus_next(Eo *obj, Elm_Calendar_Data *sd, Elm_Focus_Di
1100 items = eina_list_append(items, sd->inc_btn_year_access); 1135 items = eina_list_append(items, sd->inc_btn_year_access);
1101 1136
1102 day = 0; 1137 day = 0;
1103 maxdays = _maxdays_get(&sd->shown_time); 1138 maxdays = _maxdays_get(&sd->shown_time, 0);
1104 for (i = 0; i < 42; i++) 1139 for (i = 0; i < 42; i++)
1105 { 1140 {
1106 if ((!day) && (i == sd->first_day_it)) day = 1; 1141 if ((!day) && (i == sd->first_day_it)) day = 1;
@@ -1132,7 +1167,7 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
1132 else 1167 else
1133 { 1168 {
1134 day = 0; 1169 day = 0;
1135 maxdays = _maxdays_get(&sd->shown_time); 1170 maxdays = _maxdays_get(&sd->shown_time, 0);
1136 for (i = 0; i < 42; i++) 1171 for (i = 0; i < 42; i++)
1137 { 1172 {
1138 if ((!day) && (i == sd->first_day_it)) day = 1; 1173 if ((!day) && (i == sd->first_day_it)) day = 1;