From 9d86178f538b15ed487c0914ea38a79b5511390f Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Wed, 7 Mar 2012 08:45:49 +0000 Subject: [PATCH] elementary/dayselector - trivial changes SVN revision: 68903 --- data/themes/widgets/dayselector.edc | 112 ++++++++++++++++-------------------- src/lib/elc_dayselector.c | 69 ++++++++++++++-------- src/lib/elc_dayselector.h | 7 +-- 3 files changed, 98 insertions(+), 90 deletions(-) diff --git a/data/themes/widgets/dayselector.edc b/data/themes/widgets/dayselector.edc index bbce21d..343cd98 100644 --- a/data/themes/widgets/dayselector.edc +++ b/data/themes/widgets/dayselector.edc @@ -59,9 +59,9 @@ group { name: "bg"; type: RECT; mouse_events: 0; - scale: 1; clip_to: "clipper"; - description { state: "default" 0.0; + description { + state: "default" 0.0; rel1 { relative: 0.5 0.0; to: "day0"; @@ -78,16 +78,16 @@ group { type: SWALLOW; scale: 1; clip_to: "clipper"; - description { state: "default" 0.0; + description { + state: "default" 0.0; visible: 0; min: 0 0; align: 0.0 0.5; fixed: 1 0; - rel2 { - relative: 0.0 1.0; - } + rel2.relative: 0.0 1.0; } - description { state: "visible" 0.0; + description { + state: "visible" 0.0; inherit: "default" 0.0; visible: 1; min: 40 25; @@ -102,18 +102,14 @@ group { part { name: "clipper"; type: RECT; - description { state: "default" 0.0; - rel1 { - relative: 0.0 0.0; - to: "day0"; - } - rel2 { - relative: 1.0 1.0; - to: "day6"; - } + description { + state: "default" 0.0; + rel1.to: "day0"; + rel2.to: "day6"; color: 255 255 255 255; } - description { state: "visible" 0.0; + description { + state: "visible" 0.0; inherit: "default" 0.0; color: 200 200 200 255; } @@ -121,11 +117,13 @@ group { part { name: "disabler"; type: RECT; - description { state: "default" 0.0; + description { + state: "default" 0.0; color: 0 0 0 0; visible: 0; } - description { state: "visible" 0.0; + description { + state: "visible" 0.0; inherit: "default" 0.0; visible: 1; } @@ -185,46 +183,42 @@ group { public check_state = DAYSELECOR_DAY_STATE_DEFAULT; // Default, Pressed, Selected. public check_bg_show() { - if(get_int(check_pos) == DAYSELECOR_DAY_POS_LEFT) - { - if(get_int(check_state) == DAYSELECOR_DAY_STATE_DEFAULT) - set_state(PART:"bg", "default_left", 0.0); - else if(get_int(check_state) == DAYSELECOR_DAY_STATE_PRESSED) - set_state(PART:"bg", "pressed_left", 0.0); - else if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) - set_state(PART:"bg", "selected_left", 0.0); - } - else if(get_int(check_pos) == DAYSELECOR_DAY_POS_RIGHT) - { - if(get_int(check_state) == DAYSELECOR_DAY_STATE_DEFAULT) - set_state(PART:"bg", "default_right", 0.0); - else if(get_int(check_state) == DAYSELECOR_DAY_STATE_PRESSED) - set_state(PART:"bg", "pressed_right", 0.0); - else if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) - set_state(PART:"bg", "selected_right", 0.0); - } - else if(get_int(check_pos) == DAYSELECOR_DAY_POS_MIDDLE) - { - if(get_int(check_state) == DAYSELECOR_DAY_STATE_DEFAULT) - set_state(PART:"bg", "default_middle", 0.0); - else if(get_int(check_state) == DAYSELECOR_DAY_STATE_PRESSED) - set_state(PART:"bg", "pressed_middle", 0.0); - else if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) - set_state(PART:"bg", "selected_middle", 0.0); + if(get_int(check_pos) == DAYSELECOR_DAY_POS_LEFT) { + if(get_int(check_state) == DAYSELECOR_DAY_STATE_DEFAULT) + set_state(PART:"bg", "default_left", 0.0); + else if(get_int(check_state) == DAYSELECOR_DAY_STATE_PRESSED) + set_state(PART:"bg", "pressed_left", 0.0); + else if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) + set_state(PART:"bg", "selected_left", 0.0); + } + else if(get_int(check_pos) == DAYSELECOR_DAY_POS_RIGHT) { + if(get_int(check_state) == DAYSELECOR_DAY_STATE_DEFAULT) + set_state(PART:"bg", "default_right", 0.0); + else if(get_int(check_state) == DAYSELECOR_DAY_STATE_PRESSED) + set_state(PART:"bg", "pressed_right", 0.0); + else if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) + set_state(PART:"bg", "selected_right", 0.0); + } + else if(get_int(check_pos) == DAYSELECOR_DAY_POS_MIDDLE) { + if(get_int(check_state) == DAYSELECOR_DAY_STATE_DEFAULT) + set_state(PART:"bg", "default_middle", 0.0); + else if(get_int(check_state) == DAYSELECOR_DAY_STATE_PRESSED) + set_state(PART:"bg", "pressed_middle", 0.0); + else if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) + set_state(PART:"bg", "selected_middle", 0.0); } } public check_text_show() { - if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) - set_state(PART:"elm.text", "selected", 0.0); - else - { - if(get_int(check_type) == DAYSELECOR_DAY_TYPE_WEEKDAY) + if(get_int(check_state) == DAYSELECOR_DAY_STATE_SELECTED) + set_state(PART:"elm.text", "selected", 0.0); + else { + if(get_int(check_type) == DAYSELECOR_DAY_TYPE_WEEKDAY) set_state(PART:"elm.text", "default", 0.0); - else if (get_int(check_type) == DAYSELECOR_DAY_TYPE_WEEKEND_DEFAULT) + else if (get_int(check_type) == DAYSELECOR_DAY_TYPE_WEEKEND_DEFAULT) set_state(PART:"elm.text", "weekend_default", 0.0); - else if (get_int(check_type) == DAYSELECOR_DAY_TYPE_WEEKEND_STYLE1) + else if (get_int(check_type) == DAYSELECOR_DAY_TYPE_WEEKEND_STYLE1) set_state(PART:"elm.text", "weekend_style1", 0.0); - } + } } } parts { @@ -360,12 +354,12 @@ group { description { state: "weekend_default" 0.0; inherit: "default" 0.0; - color: 8 96 170 255; + color: 225 49 8 255; } description { state: "weekend_style1" 0.0; inherit: "default" 0.0; - color: 225 49 8 255; + color: 8 96 170 255; } description { state: "selected" 0.0; @@ -379,12 +373,8 @@ group { ignore_flags: ON_HOLD; description { state: "default" 0.0; - rel1 { - to: "bg"; - } - rel2 { - to: "bg"; - } + rel1.to: "bg"; + rel2.to: "bg"; color: 0 0 0 0; } } diff --git a/src/lib/elc_dayselector.c b/src/lib/elc_dayselector.c index ec166ec..2878c3a 100644 --- a/src/lib/elc_dayselector.c +++ b/src/lib/elc_dayselector.c @@ -36,19 +36,25 @@ static void _dayselector_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__); static void _disable_hook(Evas_Object *obj); static Eina_Bool _focus_next_hook(const Evas_Object *obj, - Elm_Focus_Direction dir __UNUSED__, Evas_Object **next __UNUSED__); + Elm_Focus_Direction dir __UNUSED__, + Evas_Object **next __UNUSED__); static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl); static void _translate_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); -static void _item_text_set_hook(Evas_Object *obj, const char *item, const char *label); -static const char *_item_text_get_hook(const Evas_Object *obj, const char *item); -static void _content_set_hook(Evas_Object *obj, const char *item, Evas_Object *content); +static void _item_text_set_hook(Evas_Object *obj, const char *item, + const char *label); +static const char *_item_text_get_hook(const Evas_Object *obj, + const char *item); +static void _content_set_hook(Evas_Object *obj, const char *item, + Evas_Object *content); static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *item); static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *item); static void _signal_emit_cb(void *data, Evas_Object *obj, const char *emission, - const char *source __UNUSED__); -static void _item_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__); -static Elm_Dayselector_Item * _item_find(const Evas_Object *obj, Elm_Dayselector_Day day); + const char *source __UNUSED__); +static void _item_clicked_cb(void *data, Evas_Object *obj, + void *event_info __UNUSED__); +static Elm_Dayselector_Item * _item_find(const Evas_Object *obj, + Elm_Dayselector_Day day); static void _items_style_set(Evas_Object *obj); static void _update_items(Evas_Object *obj); static void _create_items(Evas_Object *obj); @@ -74,7 +80,6 @@ _del_hook(Evas_Object *obj) eina_stringshare_del(it->day_style); elm_widget_item_free(it); } - free(wd); } @@ -164,7 +169,8 @@ _theme_hook(Evas_Object *obj) _elm_widget_mirrored_reload(obj); _mirrored_set(obj, elm_widget_mirrored_get(obj)); - _elm_theme_object_set(obj, wd->base, "dayselector", "base", elm_widget_style_get(obj)); + _elm_theme_object_set(obj, wd->base, "dayselector", "base", + elm_widget_style_get(obj)); EINA_LIST_FOREACH(wd->items, l, it) { @@ -385,11 +391,9 @@ _item_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) EINA_LIST_FOREACH(wd->items, l, it) { - if (obj == VIEW(it)) - { - evas_object_smart_callback_call(data, SIG_CHANGED, (void *)it->day); - return ; - } + if (obj != VIEW(it)) continue; + evas_object_smart_callback_call(data, SIG_CHANGED, (void *)it->day); + return; } } @@ -426,16 +430,20 @@ _items_style_set(Evas_Object *obj) if (weekend_last >= wd->weekend_start) { if ((it->day >= wd->weekend_start) && (it->day <= weekend_last)) - eina_stringshare_replace(&it->day_style, ITEM_TYPE_WEEKEND_DEFAULT); + eina_stringshare_replace(&it->day_style, + ITEM_TYPE_WEEKEND_DEFAULT); else - eina_stringshare_replace(&it->day_style, ITEM_TYPE_WEEKDAY_DEFAULT); + eina_stringshare_replace(&it->day_style, + ITEM_TYPE_WEEKDAY_DEFAULT); } else { if ((it->day >= wd->weekend_start) || (it->day <= weekend_last)) - eina_stringshare_replace(&it->day_style, ITEM_TYPE_WEEKEND_DEFAULT); + eina_stringshare_replace(&it->day_style, + ITEM_TYPE_WEEKEND_DEFAULT); else - eina_stringshare_replace(&it->day_style, ITEM_TYPE_WEEKDAY_DEFAULT); + eina_stringshare_replace(&it->day_style, + ITEM_TYPE_WEEKDAY_DEFAULT); } } } @@ -486,6 +494,7 @@ _create_items(Evas_Object *obj) t = time(NULL); localtime_r(&t, &time_daysel); + for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++) { it = elm_widget_item_new(obj, Elm_Dayselector_Item); @@ -503,12 +512,18 @@ _create_items(Evas_Object *obj) edje_object_part_swallow(wd->base, buf, VIEW(it)); snprintf(buf, sizeof(buf), "day%d,visible", idx); edje_object_signal_emit(wd->base, buf, "elm"); - evas_object_smart_callback_add(VIEW(it), "changed", _item_clicked_cb, obj); - evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_DEL, _item_del_cb, obj); - elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_DEFAULT, "", _signal_emit_cb, obj); - elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_STYLE1, "", _signal_emit_cb, obj); - elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_DEFAULT, "", _signal_emit_cb, obj); - elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_STYLE1, "", _signal_emit_cb, obj); + evas_object_smart_callback_add(VIEW(it), "changed", _item_clicked_cb, + obj); + evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_DEL, + _item_del_cb, obj); + elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_DEFAULT, "", + _signal_emit_cb, obj); + elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_STYLE1, "", + _signal_emit_cb, obj); + elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_DEFAULT, "", + _signal_emit_cb, obj); + elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_STYLE1, "", + _signal_emit_cb, obj); } _items_style_set(obj); _update_items(obj); @@ -537,6 +552,7 @@ elm_dayselector_add(Evas_Object *parent) elm_widget_content_set_hook_set(obj, _content_set_hook); elm_widget_content_get_hook_set(obj, _content_get_hook); elm_widget_content_unset_hook_set(obj, _content_unset_hook); + wd->base = edje_object_add(e); _elm_theme_object_set(obj, wd->base, "dayselector", "base", "default"); elm_object_style_set(wd->base, "dayselector"); @@ -545,9 +561,11 @@ elm_dayselector_add(Evas_Object *parent) wd->week_start = _elm_config->week_start; wd->weekend_start = _elm_config->weekend_start; wd->weekend_len = _elm_config->weekend_len; + printf("%d %d %d\n", wd->week_start, wd->weekend_start, wd->weekend_len); _create_items(obj); - evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _dayselector_resize, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, + _dayselector_resize, obj); evas_object_smart_callbacks_descriptions_set(obj, _signals); _mirrored_set(obj, elm_widget_mirrored_get(obj)); _sizing_eval(obj); @@ -589,6 +607,7 @@ elm_dayselector_week_start_set(Evas_Object *obj, Elm_Dayselector_Day day) EINA_LIST_FOREACH(wd->items, l, it) { loc = (ELM_DAYSELECTOR_MAX - wd->week_start + it->day) % ELM_DAYSELECTOR_MAX; + printf("%d\n", loc); snprintf(buf, sizeof(buf), "day%d", loc); edje_object_part_swallow(wd->base, buf, VIEW(it)); } diff --git a/src/lib/elc_dayselector.h b/src/lib/elc_dayselector.h index 3088827..2c9e892 100644 --- a/src/lib/elc_dayselector.h +++ b/src/lib/elc_dayselector.h @@ -51,12 +51,11 @@ * the different check styles for individual days. * * The widget emits the following signals: - * - * "dayselector,changed" - This signal is emitted when the user changes - * the state of a day. + * @li "dayselector,changed" - when the user changes the state of a day. + * @li "language,changed" - the program's launguage changed * * Available styles for dayselector are: - * - @c default + * @li default * * This example shows the usage of the widget. * @li @ref dayselector_example -- 2.7.4