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)
downloadelementary-60396b1158df8a6ea4ca958c6ead92965ca61822.tar.gz
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 @@
style { name: "calendar_date_today_style";\
base: "font="FN" font_size=10 color=#3399ff style=glow glow_color=#3399ff18 align=center";\
}\
+ style { name: "calendar_date_disabled_style";\
+ base: "font="FN" font_size=10 color=#151515 style=shadow_bottom shadow_color=#ffffffc0 align=center";\
+ }\
#define CAL_SPIN(_sufix, _signal_sufix, _text, _relative)\
part { name: "left_bt"#_sufix; type: RECT;\
@@ -291,6 +294,10 @@
inherit: "default" 0.0; \
text.style: "calendar_date_today_style"; \
} \
+ description { state: "disabled" 0.0; \
+ inherit: "default" 0.0; \
+ text.style: "calendar_date_disabled_style"; \
+ } \
} \
part { name: "cit_"#_pos".check"; mouse_events: 0; \
scale: 1; \
@@ -355,6 +362,25 @@
target: "cit_"#_pos".text"; \
} \
program { \
+ name: "cit_"#_pos".enable"; \
+ signal: "cit_"#_pos",enable"; \
+ source: "elm"; \
+ script { \
+ new st[31]; \
+ new Float:vl; \
+ get_state(PART:"cit_"#_pos".text", st, 30, vl); \
+ if (!strcmp(st, "disabled")) \
+ set_state(PART:"cit_"#_pos".text", "default", 0.0); \
+ } \
+ } \
+ program { \
+ name: "cit_"#_pos".disable"; \
+ signal: "cit_"#_pos",disable"; \
+ source: "elm"; \
+ action: STATE_SET "disabled" 0.0; \
+ target: "cit_"#_pos".text"; \
+ } \
+ program { \
source: "cit_"#_pos".clicked"; \
signal: "mouse,down,1"; \
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
}
static inline int
-_maxdays_get(struct tm *selected_time)
+_maxdays_get(struct tm *selected_time, int month_offset)
{
int month, year;
- month = selected_time->tm_mon;
+ month = (selected_time->tm_mon + month_offset) % 12;
year = selected_time->tm_year + 1900;
+ if (month < 0) month += 12;
+
return _days_in_month
[((!(year % 4)) && ((!(year % 400)) || (year % 100)))][month];
}
@@ -145,6 +147,28 @@ _today(Elm_Calendar_Data *sd,
sd->today_it = it;
}
+static inline void
+_enable(Elm_Calendar_Data *sd,
+ int it)
+{
+ char emission[32];
+
+ snprintf(emission, sizeof(emission), "cit_%i,enable", it);
+ elm_layout_signal_emit(sd->obj, emission, "elm");
+ sd->today_it = it;
+}
+
+static inline void
+_disable(Elm_Calendar_Data *sd,
+ int it)
+{
+ char emission[32];
+
+ snprintf(emission, sizeof(emission), "cit_%i,disable", it);
+ elm_layout_signal_emit(sd->obj, emission, "elm");
+ sd->today_it = it;
+}
+
static char *
_format_month_year(struct tm *selected_time)
{
@@ -272,7 +296,7 @@ _access_calendar_item_register(Evas_Object *obj)
ELM_CALENDAR_DATA_GET(obj, sd);
day = 0;
- maxdays = _maxdays_get(&sd->shown_time);
+ maxdays = _maxdays_get(&sd->shown_time, 0);
for (i = 0; i < 42; i++)
{
if ((!day) && (i == sd->first_day_it)) day = 1;
@@ -355,7 +379,7 @@ _access_calendar_register(Evas_Object *obj)
static void
_populate(Evas_Object *obj)
{
- int maxdays, day, mon, yr, i;
+ int maxdays, prev_month_maxdays, day, mon, yr, i;
Elm_Calendar_Mark *mark;
char part[12], day_s[3];
struct tm first_day;
@@ -369,7 +393,8 @@ _populate(Evas_Object *obj)
sd->filling = EINA_FALSE;
if (sd->today_it > 0) _not_today(sd);
- maxdays = _maxdays_get(&sd->shown_time);
+ maxdays = _maxdays_get(&sd->shown_time, 0);
+ prev_month_maxdays = _maxdays_get(&sd->shown_time, -1);
mon = sd->shown_time.tm_mon;
yr = sd->shown_time.tm_year;
@@ -459,9 +484,19 @@ _populate(Evas_Object *obj)
}
if ((day) && (day <= maxdays))
- snprintf(day_s, sizeof(day_s), "%i", day++);
+ {
+ _enable(sd, i);
+ snprintf(day_s, sizeof(day_s), "%i", day++);
+ }
else
- day_s[0] = 0;
+ {
+ _disable(sd, i);
+
+ if (day <= maxdays)
+ snprintf(day_s, sizeof(day_s), "%i", prev_month_maxdays - sd->first_day_it + i + 1);
+ else
+ snprintf(day_s, sizeof(day_s), "%i", i - sd->first_day_it - maxdays + 1);
+ }
snprintf(part, sizeof(part), "cit_%i.text", i);
elm_layout_text_set(obj, part, day_s);
@@ -641,7 +676,7 @@ _update_data(Evas_Object *obj, Eina_Bool month,
if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
&& (sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE))
{
- maxdays = _maxdays_get(&sd->shown_time);
+ maxdays = _maxdays_get(&sd->shown_time, 0);
if (sd->selected_time.tm_mday > maxdays)
sd->selected_time.tm_mday = maxdays;
@@ -778,7 +813,7 @@ _get_item_day(Evas_Object *obj,
ELM_CALENDAR_DATA_GET(obj, sd);
day = selected_it - sd->first_day_it + 1;
- if ((day < 0) || (day > _maxdays_get(&sd->shown_time)))
+ if ((day < 0) || (day > _maxdays_get(&sd->shown_time, 0)))
return 0;
return day;
@@ -1100,7 +1135,7 @@ _elm_calendar_elm_widget_focus_next(Eo *obj, Elm_Calendar_Data *sd, Elm_Focus_Di
items = eina_list_append(items, sd->inc_btn_year_access);
day = 0;
- maxdays = _maxdays_get(&sd->shown_time);
+ maxdays = _maxdays_get(&sd->shown_time, 0);
for (i = 0; i < 42; i++)
{
if ((!day) && (i == sd->first_day_it)) day = 1;
@@ -1132,7 +1167,7 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access)
else
{
day = 0;
- maxdays = _maxdays_get(&sd->shown_time);
+ maxdays = _maxdays_get(&sd->shown_time, 0);
for (i = 0; i < 42; i++)
{
if ((!day) && (i == sd->first_day_it)) day = 1;