From a8719f824d7f0f4a6be0e3076cc9b898067d5dae Mon Sep 17 00:00:00 2001 From: Flavio Vinicius Alvares Ceolin Date: Thu, 3 Jan 2013 20:50:10 +0000 Subject: [PATCH] [elm] calendar: spinners for month and year now Adding a separated spinner for year. SVN revision: 82108 --- .../data/themes/widgets/calendar.edc | 624 ++++++++++-------- legacy/elementary/src/lib/elm_calendar.c | 274 ++++++-- legacy/elementary/src/lib/elm_calendar.h | 2 +- .../elementary/src/lib/elm_widget_calendar.h | 9 +- 4 files changed, 541 insertions(+), 368 deletions(-) diff --git a/legacy/elementary/data/themes/widgets/calendar.edc b/legacy/elementary/data/themes/widgets/calendar.edc index a4d3b6709b..000d4697df 100644 --- a/legacy/elementary/data/themes/widgets/calendar.edc +++ b/legacy/elementary/data/themes/widgets/calendar.edc @@ -1,3 +1,293 @@ +#define CAL_SPIN(_sufix, _relative)\ + part { name: "left_bt_"#_sufix;\ + mouse_events: 1;\ + description { state: "default" 0.0;\ + rel1 { to: #_relative;\ + offset: 2 2;\ + }\ + rel2 { to: #_relative;\ + offset: -3 -3;\ + }\ + align: 0.0 0.5;\ + min: 24 24;\ + max: 24 24;\ + fixed: 1 1;\ + image {\ + normal: "bt_base1.png";\ + border: 6 6 6 6;\ + }\ + fill.smooth : 0;\ + }\ + description { state: "clicked" 0.0;\ + inherit: "default" 0.0;\ + image.normal: "bt_base1.png";\ + image.middle: SOLID;\ + }\ + }\ + part { name: "left_bt_"#_sufix"_over1";\ + mouse_events: 0;\ + description { state: "default" 0.0;\ + rel1.to: "left_bt_"#_sufix;\ + rel2 { to: "left_bt_"#_sufix;\ + relative: 1.0 0.5;\ + }\ + image {\ + normal: "bt_hilight.png";\ + border: 7 7 7 0;\ + }\ + }\ + }\ + part { name: "left_bt_"#_sufix"_over2";\ + mouse_events: 1;\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + rel1.to: "left_bt_"#_sufix;\ + rel2.to: "left_bt_"#_sufix;\ + image {\ + normal: "bt_shine.png";\ + border: 7 7 7 7;\ + }\ + }\ + }\ + part { name: "left_bt_"#_sufix"_over3";\ + mouse_events: 1;\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + color: 255 255 255 0;\ + rel1.to: "left_bt_"#_sufix;\ + rel2.to: "left_bt_"#_sufix;\ + image {\ + normal: "bt_glow.png";\ + border: 12 12 12 12;\ + }\ + fill.smooth : 0;\ + }\ + description { state: "clicked" 0.0;\ + inherit: "default" 0.0;\ + visible: 1;\ + color: 255 255 255 255;\ + }\ + } \ + part { name: "left_bt_"#_sufix"_icon";\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + rel1.to: "left_bt_"#_sufix;\ + rel2.to: "left_bt_"#_sufix;\ + align: 0.5 0.5;\ + min: 16 16;\ + max: 16 16;\ + image.normal: "sp_bt_l.png";\ + }\ + description { state: "rtl" 0.0;\ + inherit: "default" 0.0;\ + image.normal: "sp_bt_r.png";\ + }\ + }\ + part { name: "right_bt_"#_sufix;\ + mouse_events: 1;\ + description { state: "default" 0.0;\ + rel1 { to: #_relative;\ + offset: -27 2;\ + }\ + rel2 { to: #_relative;\ + offset: -3 -3;\ + }\ + align: 1.0 0.5;\ + min: 24 24;\ + max: 24 24;\ + fixed: 1 1;\ + image {\ + normal: "bt_base1.png";\ + border: 5 5 4 12;\ + }\ + fill.smooth : 0;\ + }\ + description { state: "clicked" 0.0;\ + inherit: "default" 0.0;\ + image.normal: "bt_base1.png";\ + image.middle: SOLID;\ + }\ + }\ + part { name: "right_bt_"#_sufix"_over1";\ + mouse_events: 0;\ + description { state: "default" 0.0;\ + rel1.to: "right_bt_"#_sufix;\ + rel2 { to: "right_bt_"#_sufix;\ + relative: 1.0 0.5;\ + }\ + image {\ + normal: "bt_hilight.png";\ + border: 7 7 7 0;\ + }\ + }\ + }\ + part { name: "right_bt_"#_sufix"_over2";\ + mouse_events: 1;\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + rel1.to: "right_bt_"#_sufix;\ + rel2.to: "right_bt_"#_sufix;\ + image {\ + normal: "bt_shine.png";\ + border: 7 7 7 7;\ + }\ + }\ + }\ + part { name: "right_bt_"#_sufix"_over3";\ + mouse_events: 1;\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + color: 255 255 255 0;\ + rel1.to: "right_bt_"#_sufix;\ + rel2.to: "right_bt_"#_sufix;\ + image {\ + normal: "bt_glow.png";\ + border: 12 12 12 12;\ + }\ + fill.smooth : 0;\ + }\ + description { state: "clicked" 0.0;\ + inherit: "default" 0.0;\ + visible: 1;\ + color: 255 255 255 255;\ + }\ + }\ + part { name: "right_bt_"#_sufix"_icon";\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + rel1.to: "right_bt_"#_sufix;\ + rel2.to: "right_bt_"#_sufix;\ + align: 0.5 0.5;\ + min: 16 16;\ + max: 16 16;\ + image.normal: "sp_bt_r.png";\ + }\ + description { state: "rtl" 0.0;\ + inherit: "default" 0.0;\ + image.normal: "sp_bt_l.png";\ + }\ + }\ + part { name: "text_"#_sufix;\ + type: TEXT;\ + mouse_events: 0;\ + scale: 1;\ + description { state: "default" 0.0;\ + align: 0 0.5;\ + fixed: 1 1;\ + rel1 { relative: 1.0 0.0;\ + offset: 3 2;\ + to: "left_bt_"#_sufix;\ + to_y: #_relative;\ + }\ + rel2 { relative: 0.0 1.0;\ + offset: -3 -2;\ + to_x: "right_bt_"#_sufix;\ + to_y: #_relative;\ + }\ + color: 0 0 0 255;\ + text {\ + font: "Sans,Edje-Vera";\ + size: 12;\ + min: 1 1;\ + align: 0.5 0.5;\ + }\ + }\ + }\ + programs {\ + program { name: "dec_"#_sufix"_start";\ + signal: "mouse,down,1";\ + source: "left_bt_"#_sufix;\ + action: SIGNAL_EMIT "elm,action,decrement,"#_sufix",start" "";\ + }\ + program { name: "dec_"#_sufix"_stop";\ + signal: "mouse,up,1";\ + source: "left_bt_"#_sufix;\ + action: SIGNAL_EMIT "elm,action,"#_sufix",stop" ""; \ + }\ + program {\ + name: "left_bt_"#_sufix"_click";\ + signal: "mouse,down,1";\ + source: "left_bt_"#_sufix"_over2";\ + action: STATE_SET "clicked" 0.0;\ + target: "left_bt_"#_sufix;\ + }\ + program {\ + name: "left_bt_"#_sufix"_unclick";\ + signal: "mouse,up,1";\ + source: "left_bt_"#_sufix"over2";\ + action: STATE_SET "default" 0.0;\ + target: "left_bt_"#_sufix;\ + }\ + program {\ + name: "left_bt_"#_sufix"_click2";\ + signal: "mouse,down,1";\ + source: "left_bt_"#_sufix"_over3";\ + action: STATE_SET "clicked" 0.0;\ + target: "left_bt_"#_sufix"_over3";\ + }\ + program {\ + name: "left_bt_"#_sufix"_unclick2";\ + signal: "mouse,up,1";\ + source: "left_bt_"#_sufix"_over3";\ + action: STATE_SET "default" 0.0;\ + transition: DECELERATE 0.5;\ + target: "left_bt_"#_sufix"_over3";\ + }\ + program { name: "inc_"#_sufix"_start";\ + signal: "mouse,down,1";\ + source: "right_bt_"#_sufix;\ + action: SIGNAL_EMIT "elm,action,increment,"#_sufix",start" "";\ + }\ + program { name: "inc_"#_sufix"_stop";\ + signal: "mouse,up,1";\ + source: "right_bt_"#_sufix;\ + action: SIGNAL_EMIT "elm,action,"#_sufix",stop" "";\ + }\ + program {\ + name: "right_bt_"#_sufix"_click";\ + signal: "mouse,down,1";\ + source: "right_bt_"#_sufix"_over2";\ + action: STATE_SET "clicked" 0.0;\ + target: "right_bt_"#_sufix;\ + }\ + program {\ + name: "right_bt_"#_sufix"_unclick";\ + signal: "mouse,up,1";\ + source: "right_bt_"#_sufix"_over2";\ + action: STATE_SET "default" 0.0;\ + target: "right_bt_"#_sufix;\ + }\ + program {\ + name: "right_bt_"#_sufix"_click2";\ + signal: "mouse,down,1";\ + source: "right_bt_"#_sufix"_over3";\ + action: STATE_SET "clicked" 0.0;\ + target: "right_bt_"#_sufix"_over3";\ + }\ + program {\ + name: "right_bt_"#_sufix"_unclick2";\ + signal: "mouse,up,1";\ + source: "right_bt_"#_sufix"_over3";\ + action: STATE_SET "default" 0.0;\ + transition: DECELERATE 0.5;\ + target: "right_bt_"#_sufix"_over3";\ + }\ + program { name: "to_rtl_"#_sufix;\ + signal: "edje,state,rtl";\ + source: "edje";\ + action: STATE_SET "rtl" 0.0;\ + target: "left_bt_"#_sufix"_icon";\ + target: "right_bt_"#_sufix"_icon";\ + }\ + program { name: "to_ltr_"#_sufix;\ + signal: "edje,state,ltr";\ + source: "edje";\ + action: STATE_SET "default" 0.0;\ + target: "left_bt_"#_sufix"_icon";\ + target: "right_bt_"#_sufix"_icon";\ + }\ + } + #define CH(_pos) \ part { name: "ch_"#_pos".base"; \ type: RECT; \ @@ -363,7 +653,7 @@ group { name: "elm/calendar/base/default"; align: 0.0 0.5; } } - part { name: "spinner-base"; + part { name: "spinner-base1"; type: RECT; mouse_events: 0; description { state: "default" 0.0; @@ -372,17 +662,49 @@ group { name: "elm/calendar/base/default"; rel1.to: "bg"; rel1.offset: 6 6; rel2.to: "bg"; + rel2.relative: 0.5 1.0; rel2.offset: -7 -7; color: 255 255 255 0; align: 0.0 0.0; } } - part { name: "conf_over_spinner"; + part { name: "conf_over_spinner1"; mouse_events: 0; description { state: "default" 0.0; - rel1.to: "spinner-base"; + rel1.to: "spinner-base1"; rel1.offset: -3 -3; - rel2.to: "spinner-base"; + rel2.to: "spinner-base1"; + rel2.offset: 2 2; + image { + normal: "shelf_inset.png"; + border: 7 7 7 7; + middle: 0; + } + fill.smooth : 0; + } + } + part { name: "spinner-base2"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + min: 24 24; + max: 999999 24; + rel1.to_x: "spinner-base1"; + rel1.to_y: "bg"; + rel1.relative: 1.0 0; + rel1.offset: 6 6; + rel2.to: "bg"; + rel2.offset: -7 -7; + color: 255 255 255 0; + align: 0.0 0.0; + } + } + part { name: "conf_over_spinner2"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "spinner-base2"; + rel1.offset: -2 -2; + rel2.to: "spinner-base2"; rel2.offset: 2 2; image { normal: "shelf_inset.png"; @@ -398,7 +720,7 @@ group { name: "elm/calendar/base/default"; description { state: "default" 0.0; min: 256 220; rel1.to_x: "bg"; - rel1.to_y: "spinner-base"; + rel1.to_y: "spinner-base1"; rel1.offset: 6 6; rel1.relative: 0 1; rel2.to: "bg"; @@ -445,200 +767,10 @@ group { name: "elm/calendar/base/default"; color: 255 255 255 0; } } - part { name: "left_bt"; - mouse_events: 1; - description { state: "default" 0.0; - rel1 { to: "spinner-base"; - offset: 2 2; - } - rel2 { to: "spinner-base"; - offset: -3 -3; - } - align: 0.0 0.5; - min: 24 24; - max: 24 24; - fixed: 1 1; - image { - normal: "bt_base1.png"; - border: 6 6 6 6; - } - fill.smooth : 0; - } - description { state: "clicked" 0.0; - inherit: "default" 0.0; - image.normal: "bt_base1.png"; - image.middle: SOLID; - } - } - part { name: "left_over1"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "left_bt"; - rel2 { to: "left_bt"; - relative: 1.0 0.5; - } - image { - normal: "bt_hilight.png"; - border: 7 7 7 0; - } - } - } - part { name: "left_over2"; - mouse_events: 1; - repeat_events: 1; - description { state: "default" 0.0; - rel1.to: "left_bt"; - rel2.to: "left_bt"; - image { - normal: "bt_shine.png"; - border: 7 7 7 7; - } - } - } - part { name: "left_over3"; - mouse_events: 1; - repeat_events: 1; - description { state: "default" 0.0; - color: 255 255 255 0; - rel1.to: "left_bt"; - rel2.to: "left_bt"; - image { - normal: "bt_glow.png"; - border: 12 12 12 12; - } - fill.smooth : 0; - } - description { state: "clicked" 0.0; - inherit: "default" 0.0; - visible: 1; - color: 255 255 255 255; - } - } - part { name: "right_bt"; - mouse_events: 1; - description { state: "default" 0.0; - rel1 { to: "spinner-base"; - offset: -27 3; - } - rel2 { to: "spinner-base"; - offset: -3 -3; - } - align: 1.0 0.5; - min: 24 24; - max: 24 24; - fixed: 1 1; - image { - normal: "bt_base1.png"; - border: 5 5 4 12; - } - fill.smooth : 0; - } - description { state: "clicked" 0.0; - inherit: "default" 0.0; - image.normal: "bt_base1.png"; - image.middle: SOLID; - } - } - part { name: "right_over1"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "right_bt"; - rel2 { to: "right_bt"; - relative: 1.0 0.5; - } - image { - normal: "bt_hilight.png"; - border: 7 7 7 0; - } - } - } - part { name: "right_over2"; - mouse_events: 1; - repeat_events: 1; - description { state: "default" 0.0; - rel1.to: "right_bt"; - rel2.to: "right_bt"; - image { - normal: "bt_shine.png"; - border: 7 7 7 7; - } - } - } - part { name: "right_over3"; - mouse_events: 1; - repeat_events: 1; - description { state: "default" 0.0; - color: 255 255 255 0; - rel1.to: "right_bt"; - rel2.to: "right_bt"; - image { - normal: "bt_glow.png"; - border: 12 12 12 12; - } - fill.smooth : 0; - } - description { state: "clicked" 0.0; - inherit: "default" 0.0; - visible: 1; - color: 255 255 255 255; - } - } - part { name: "left_bt_icon"; - repeat_events: 1; - description { state: "default" 0.0; - rel1.to: "left_bt"; - rel2.to: "left_bt"; - align: 0.5 0.5; - min: 16 16; - max: 16 16; - image.normal: "sp_bt_l.png"; - } - description { state: "rtl" 0.0; - inherit: "default" 0.0; - image.normal: "sp_bt_r.png"; - } - } - part { name: "right_bt_icon"; - repeat_events: 1; - description { state: "default" 0.0; - rel1.to: "right_bt"; - rel2.to: "right_bt"; - align: 0.5 0.5; - min: 16 16; - max: 16 16; - image.normal: "sp_bt_r.png"; - } - description { state: "rtl" 0.0; - inherit: "default" 0.0; - image.normal: "sp_bt_l.png"; - } - } - part { name: "month_text"; - type: TEXT; - mouse_events: 0; - scale: 1; - description { state: "default" 0.0; - align: 0 0.5; - fixed: 1 1; - rel1 { relative: 1.0 0.0; - offset: 3 2; - to: "left_bt"; - to_y: "spinner-base"; - } - rel2 { relative: 0.0 1.0; - offset: -3 -2; - to_x: "right_bt"; - to_y: "spinner-base"; - } - color: 0 0 0 255; - text { - font: "Sans,Edje-Vera"; - size: 12; - min: 1 1; - align: 0.5 0.5; - } - } - } + + CAL_SPIN(month, spinner-base1) + CAL_SPIN(year, spinner-base2) + CH(0) CH(1) CH(2) CH(3) CH(4) CH(5) CH(6) CIT(0) CIT(1) CIT(2) CIT(3) CIT(4) CIT(5) CIT(6) CIT(7) CIT(8) CIT(9) CIT(10) CIT(11) CIT(12) CIT(13) @@ -647,100 +779,6 @@ group { name: "elm/calendar/base/default"; CIT(28) CIT(29) CIT(30) CIT(31) CIT(32) CIT(33) CIT(34) CIT(35) CIT(36) CIT(37) CIT(38) CIT(39) CIT(40) CIT(41) } - programs { - program { name: "dec_start"; - signal: "mouse,down,1"; - source: "left_bt"; - action: SIGNAL_EMIT "elm,action,decrement,start" ""; - } - program { name: "dec_stop"; - signal: "mouse,up,1"; - source: "left_bt"; - action: SIGNAL_EMIT "elm,action,stop" ""; - } - program { name: "inc_start"; - signal: "mouse,down,1"; - source: "right_bt"; - action: SIGNAL_EMIT "elm,action,increment,start" ""; - } - program { name: "inc_stop"; - signal: "mouse,up,1"; - source: "right_bt"; - action: SIGNAL_EMIT "elm,action,stop" ""; - } - program { - name: "left_bt_click"; - signal: "mouse,down,1"; - source: "left_over2"; - action: STATE_SET "clicked" 0.0; - target: "left_bt"; - } - program { - name: "left_bt_unclick"; - signal: "mouse,up,1"; - source: "left_over2"; - action: STATE_SET "default" 0.0; - target: "left_bt"; - } - program { - name: "left_bt_click2"; - signal: "mouse,down,1"; - source: "left_over3"; - action: STATE_SET "clicked" 0.0; - target: "left_over3"; - } - program { - name: "left_bt_unclick2"; - signal: "mouse,up,1"; - source: "left_over3"; - action: STATE_SET "default" 0.0; - transition: DECELERATE 0.5; - target: "left_over3"; - } - program { - name: "right_bt_click"; - signal: "mouse,down,1"; - source: "right_over2"; - action: STATE_SET "clicked" 0.0; - target: "right_bt"; - } - program { - name: "right_bt_unclick"; - signal: "mouse,up,1"; - source: "right_over2"; - action: STATE_SET "default" 0.0; - target: "right_bt"; - } - program { - name: "right_bt_click2"; - signal: "mouse,down,1"; - source: "right_over3"; - action: STATE_SET "clicked" 0.0; - target: "right_over3"; - } - program { - name: "right_bt_unclick2"; - signal: "mouse,up,1"; - source: "right_over3"; - action: STATE_SET "default" 0.0; - transition: DECELERATE 0.5; - target: "right_over3"; - } - program { name: "to_rtl"; - signal: "edje,state,rtl"; - source: "edje"; - action: STATE_SET "rtl" 0.0; - target: "right_bt_icon"; - target: "left_bt_icon"; - } - program { name: "to_ltr"; - signal: "edje,state,ltr"; - source: "edje"; - action: STATE_SET "default" 0.0; - target: "right_bt_icon"; - target: "left_bt_icon"; - } - } } #undef CIT diff --git a/legacy/elementary/src/lib/elm_calendar.c b/legacy/elementary/src/lib/elm_calendar.c index 44a8ac048a..22ab24a8a2 100644 --- a/legacy/elementary/src/lib/elm_calendar.c +++ b/legacy/elementary/src/lib/elm_calendar.c @@ -136,6 +136,24 @@ _format_month_year(struct tm *selected_time) return strdup(buf); } +static char * +_format_month(struct tm *selected_time) +{ + char buf[32]; + + if (!strftime(buf, sizeof(buf), E_("%B"), selected_time)) return NULL; + return strdup(buf); +} + +static char * +_format_year(struct tm *selected_time) +{ + char buf[32]; + + if (!strftime(buf, sizeof(buf), E_("%Y"), selected_time)) return NULL; + return strdup(buf); +} + static inline void _cit_mark(Evas_Object *cal, int cit, @@ -187,14 +205,21 @@ _set_month_year(Elm_Calendar_Smart_Data *sd) { char *buf; - /* Set selected month */ - buf = sd->format_func(&sd->shown_time); + buf = _format_month(&sd->shown_time); if (buf) { - elm_layout_text_set(sd->obj, "month_text", buf); + elm_layout_text_set(sd->obj, "text_month", buf); free(buf); } - else elm_layout_text_set(sd->obj, "month_text", ""); + else elm_layout_text_set(sd->obj, "text_month", ""); + + buf = _format_year(&sd->shown_time); + if (buf) + { + elm_layout_text_set(sd->obj, "text_year", buf); + free(buf); + } + else elm_layout_text_set(sd->obj, "text_year", ""); } static char * @@ -255,28 +280,43 @@ _access_calendar_spinner_register(Evas_Object *obj) Elm_Access_Info *ai; ELM_CALENDAR_DATA_GET(obj, sd); - // decrement button - sd->dec_btn_access = _elm_access_edje_object_part_object_register - (obj, elm_layout_edje_get(obj), "left_bt"); - ai = _elm_access_object_get(sd->dec_btn_access); - _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement button")); + sd->dec_btn_month_access = _elm_access_edje_object_part_object_register + (obj, elm_layout_edje_get(obj), "left_bt_month"); + ai = _elm_access_object_get(sd->dec_btn_month_access); + _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement month button")); - // increment button - sd->inc_btn_access = _elm_access_edje_object_part_object_register - (obj, elm_layout_edje_get(obj), "right_bt"); - ai = _elm_access_object_get(sd->inc_btn_access); - _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment button")); + sd->dec_btn_year_access = _elm_access_edje_object_part_object_register + (obj, elm_layout_edje_get(obj), "left_bt_year"); + ai = _elm_access_object_get(sd->dec_btn_year_access); + _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement year button")); + + sd->inc_btn_month_access = _elm_access_edje_object_part_object_register + (obj, elm_layout_edje_get(obj), "right_bt_month"); + ai = _elm_access_object_get(sd->inc_btn_month_access); + _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment month button")); + + sd->inc_btn_year_access = _elm_access_edje_object_part_object_register + (obj, elm_layout_edje_get(obj), "right_bt_year"); + ai = _elm_access_object_get(sd->inc_btn_year_access); + _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment year button")); - // month text sd->month_access = _elm_access_edje_object_part_object_register - (obj, elm_layout_edje_get(obj), "month_text"); + (obj, elm_layout_edje_get(obj), "text_month"); ai = _elm_access_object_get(sd->month_access); _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar month")); + sd->year_access = _elm_access_edje_object_part_object_register + (obj, elm_layout_edje_get(obj), "text_year"); + ai = _elm_access_object_get(sd->year_access); + _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar year")); + po = (Evas_Object *)edje_object_part_object_get - (elm_layout_edje_get(obj), "month_text"); + (elm_layout_edje_get(obj), "text_month"); evas_object_pass_events_set(po, EINA_FALSE); + po = (Evas_Object *)edje_object_part_object_get + (elm_layout_edje_get(obj), "text_year"); + evas_object_pass_events_set(po, EINA_FALSE); } static void @@ -517,7 +557,7 @@ _fix_selected_time(Elm_Calendar_Smart_Data *sd) } static Eina_Bool -_update_month(Evas_Object *obj, +_update_data(Evas_Object *obj, Eina_Bool month, int delta) { struct tm time_check; @@ -527,30 +567,40 @@ _update_month(Evas_Object *obj, /* check if it's a valid time. for 32 bits, year greater than 2037 is not */ time_check = sd->shown_time; - time_check.tm_mon += delta; + if (month) + time_check.tm_mon += delta; + else + time_check.tm_year += delta; if (mktime(&time_check) == -1) return EINA_FALSE; - sd->shown_time.tm_mon += delta; - if (sd->shown_time.tm_mon < 0) + if (month) { - if (sd->shown_time.tm_year == sd->year_min) - { - sd->shown_time.tm_mon++; - return EINA_FALSE; - } - sd->shown_time.tm_mon = 11; - sd->shown_time.tm_year--; + sd->shown_time.tm_mon += delta; + if (sd->shown_time.tm_mon < 0) + { + if (sd->shown_time.tm_year == sd->year_min) + { + sd->shown_time.tm_mon++; + return EINA_FALSE; + } + sd->shown_time.tm_mon = 11; + sd->shown_time.tm_year--; + } + else if (sd->shown_time.tm_mon > 11) + { + if (sd->shown_time.tm_year == sd->year_max) + { + sd->shown_time.tm_mon--; + return EINA_FALSE; + } + sd->shown_time.tm_mon = 0; + sd->shown_time.tm_year++; + } } - else if (sd->shown_time.tm_mon > 11) + else { - if (sd->shown_time.tm_year == sd->year_max) - { - sd->shown_time.tm_mon--; - return EINA_FALSE; - } - sd->shown_time.tm_mon = 0; - sd->shown_time.tm_year++; + sd->shown_time.tm_year += delta; } if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND) @@ -569,21 +619,35 @@ _update_month(Evas_Object *obj, } static Eina_Bool -_spin_value(void *data) +_spin_month_value(void *data) { ELM_CALENDAR_DATA_GET(data, sd); - if (_update_month(data, sd->spin_speed)) + if (_update_data(data, EINA_TRUE, sd->spin_speed)) evas_object_smart_changed(data); sd->interval = sd->interval / 1.05; - ecore_timer_interval_set(sd->spin, sd->interval); + ecore_timer_interval_set(sd->spin_month, sd->interval); + + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool +_spin_year_value(void *data) +{ + ELM_CALENDAR_DATA_GET(data, sd); + + if (_update_data(data, EINA_FALSE, sd->spin_speed)) + evas_object_smart_changed(data); + + sd->interval = sd->interval / 1.05; + ecore_timer_interval_set(sd->spin_year, sd->interval); return ECORE_CALLBACK_RENEW; } static void -_button_inc_start(void *data, +_button_month_inc_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) @@ -592,14 +656,14 @@ _button_inc_start(void *data, sd->interval = sd->first_interval; sd->spin_speed = 1; - if (sd->spin) ecore_timer_del(sd->spin); - sd->spin = ecore_timer_add(sd->interval, _spin_value, data); + if (sd->spin_month) ecore_timer_del(sd->spin_month); + sd->spin_month = ecore_timer_add(sd->interval, _spin_month_value, data); - _spin_value(data); + _spin_month_value(data); } static void -_button_dec_start(void *data, +_button_month_dec_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) @@ -608,23 +672,68 @@ _button_dec_start(void *data, sd->interval = sd->first_interval; sd->spin_speed = -1; - if (sd->spin) ecore_timer_del(sd->spin); - sd->spin = ecore_timer_add(sd->interval, _spin_value, data); + if (sd->spin_month) ecore_timer_del(sd->spin_month); + sd->spin_month = ecore_timer_add(sd->interval, _spin_month_value, data); - _spin_value(data); + _spin_month_value(data); } static void -_button_stop(void *data, - Evas_Object *obj __UNUSED__, - const char *emission __UNUSED__, - const char *source __UNUSED__) +_button_month_stop(void *data, + Evas_Object *obj __UNUSED__, + const char *emission __UNUSED__, + const char *source __UNUSED__) { ELM_CALENDAR_DATA_GET(data, sd); sd->interval = sd->first_interval; - if (sd->spin) ecore_timer_del(sd->spin); - sd->spin = NULL; + if (sd->spin_month) ecore_timer_del(sd->spin_month); + sd->spin_month = NULL; +} + +static void +_button_year_inc_start(void *data, + Evas_Object *obj __UNUSED__, + const char *emission __UNUSED__, + const char *source __UNUSED__) +{ + ELM_CALENDAR_DATA_GET(data, sd); + + sd->interval = sd->first_interval; + sd->spin_speed = 1; + if (sd->spin_year) ecore_timer_del(sd->spin_year); + sd->spin_year = ecore_timer_add(sd->interval, _spin_year_value, data); + + _spin_year_value(data); +} + +static void +_button_year_dec_start(void *data, + Evas_Object *obj __UNUSED__, + const char *emission __UNUSED__, + const char *source __UNUSED__) +{ + ELM_CALENDAR_DATA_GET(data, sd); + + sd->interval = sd->first_interval; + sd->spin_speed = -1; + if (sd->spin_year) ecore_timer_del(sd->spin_year); + sd->spin_year = ecore_timer_add(sd->interval, _spin_year_value, data); + + _spin_year_value(data); +} + +static void +_button_year_stop(void *data, + Evas_Object *obj __UNUSED__, + const char *emission __UNUSED__, + const char *source __UNUSED__) +{ + ELM_CALENDAR_DATA_GET(data, sd); + + sd->interval = sd->first_interval; + if (sd->spin_year) ecore_timer_del(sd->spin_year); + sd->spin_year = NULL; } static int @@ -735,12 +844,12 @@ _elm_calendar_smart_event(Eo *obj, void *_pd, va_list *list) if ((!strcmp(ev->keyname, "Prior")) || ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string))) { - if (_update_month(obj, -1)) _populate(obj); + if (_update_data(obj, EINA_TRUE, -1)) _populate(obj); } else if ((!strcmp(ev->keyname, "Next")) || ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string))) { - if (_update_month(obj, 1)) _populate(obj); + if (_update_data(obj, EINA_TRUE, 1)) _populate(obj); } else if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE) && ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND) @@ -819,14 +928,23 @@ _elm_calendar_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED) priv->selectable = (~(ELM_CALENDAR_SELECTABLE_NONE)); edje_object_signal_callback_add - (wd->resize_obj, "elm,action,increment,start", "*", - _button_inc_start, obj); + (wd->resize_obj, "elm,action,increment,month,start", "*", + _button_month_inc_start, obj); edje_object_signal_callback_add - (wd->resize_obj, "elm,action,decrement,start", "*", - _button_dec_start, obj); + (wd->resize_obj, "elm,action,decrement,month,start", "*", + _button_month_dec_start, obj); edje_object_signal_callback_add - (wd->resize_obj, "elm,action,stop", "*", - _button_stop, obj); + (wd->resize_obj, "elm,action,increment,year,start", "*", + _button_year_inc_start, obj); + edje_object_signal_callback_add + (wd->resize_obj, "elm,action,decrement,year,start", "*", + _button_year_dec_start, obj); + edje_object_signal_callback_add + (wd->resize_obj, "elm,action,month,stop", "*", + _button_month_stop, obj); + edje_object_signal_callback_add + (wd->resize_obj, "elm,action,year,stop", "*", + _button_year_stop, obj); edje_object_signal_callback_add (wd->resize_obj, "elm,action,selected", "*", _day_selected, obj); @@ -875,7 +993,8 @@ _elm_calendar_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED) Elm_Calendar_Mark *mark; Elm_Calendar_Smart_Data *sd = _pd; - if (sd->spin) ecore_timer_del(sd->spin); + if (sd->spin_month) ecore_timer_del(sd->spin_month); + if (sd->spin_year) ecore_timer_del(sd->spin_year); if (sd->update_timer) ecore_timer_del(sd->update_timer); if (sd->marks) @@ -925,8 +1044,12 @@ _elm_calendar_smart_focus_next(Eo *obj, void *_pd, va_list *list) Elm_Calendar_Smart_Data *sd = _pd; items = eina_list_append(items, sd->month_access); - items = eina_list_append(items, sd->dec_btn_access); - items = eina_list_append(items, sd->inc_btn_access); + items = eina_list_append(items, sd->dec_btn_month_access); + items = eina_list_append(items, sd->inc_btn_month_access); + + items = eina_list_append(items, sd->year_access); + items = eina_list_append(items, sd->dec_btn_year_access); + items = eina_list_append(items, sd->inc_btn_year_access); day = 0; maxdays = _maxdays_get(&sd->shown_time); @@ -976,15 +1099,25 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access) } } - if (sd->dec_btn_access) + if (sd->dec_btn_month_access) _elm_access_edje_object_part_object_unregister - (obj, elm_layout_edje_get(obj), "left_bt"); - if (sd->inc_btn_access) + (obj, elm_layout_edje_get(obj), "left_bt_month"); + if (sd->inc_btn_month_access) _elm_access_edje_object_part_object_unregister - (obj, elm_layout_edje_get(obj), "right_bt"); + (obj, elm_layout_edje_get(obj), "right_bt_month"); if (sd->month_access) _elm_access_edje_object_part_object_unregister - (obj, elm_layout_edje_get(obj), "month_text"); + (obj, elm_layout_edje_get(obj), "text_month"); + + if (sd->dec_btn_year_access) + _elm_access_edje_object_part_object_unregister + (obj, elm_layout_edje_get(obj), "left_bt_year"); + if (sd->inc_btn_year_access) + _elm_access_edje_object_part_object_unregister + (obj, elm_layout_edje_get(obj), "right_bt_year"); + if (sd->year_access) + _elm_access_edje_object_part_object_unregister + (obj, elm_layout_edje_get(obj), "text_year"); } } @@ -1238,7 +1371,7 @@ _selected_time_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list) *ret = EINA_TRUE; } -EAPI void +EINA_DEPRECATED EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_function) { @@ -1253,7 +1386,6 @@ _format_function_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list) Elm_Calendar_Smart_Data *sd = _pd; sd->format_func = format_function; - _set_month_year(sd); } EAPI Elm_Calendar_Mark * diff --git a/legacy/elementary/src/lib/elm_calendar.h b/legacy/elementary/src/lib/elm_calendar.h index b92200ba4c..e2ff30bbbd 100644 --- a/legacy/elementary/src/lib/elm_calendar.h +++ b/legacy/elementary/src/lib/elm_calendar.h @@ -640,7 +640,7 @@ EAPI Eina_Bool elm_calendar_selected_time_get(const Evas_Object *obj, * * @ingroup Calendar */ -EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_func); +EINA_DEPRECATED EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_func); /** * Add a new mark to the calendar diff --git a/legacy/elementary/src/lib/elm_widget_calendar.h b/legacy/elementary/src/lib/elm_widget_calendar.h index dd79f8e68e..2d3c722af0 100644 --- a/legacy/elementary/src/lib/elm_widget_calendar.h +++ b/legacy/elementary/src/lib/elm_widget_calendar.h @@ -34,15 +34,18 @@ struct _Elm_Calendar_Smart_Data int year_min, year_max, spin_speed; int today_it, selected_it, first_day_it; Elm_Calendar_Weekday first_week_day; - Ecore_Timer *spin, *update_timer; + Ecore_Timer *spin_month, *spin_year, *update_timer; Elm_Calendar_Format_Cb format_func; const char *weekdays[ELM_DAY_LAST]; struct tm current_time, selected_time, shown_time; Day_Color day_color[42]; // EINA_DEPRECATED Elm_Calendar_Select_Mode select_mode; - Evas_Object *inc_btn_access; - Evas_Object *dec_btn_access; + Evas_Object *inc_btn_month_access; + Evas_Object *dec_btn_month_access; Evas_Object *month_access; + Evas_Object *inc_btn_year_access; + Evas_Object *dec_btn_year_access; + Evas_Object *year_access; Eina_Bool selected : 1; Elm_Calendar_Selectable selectable; };