From 71840e45d5c16b593ad124a1f2f2b232513398a2 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Tue, 30 Oct 2012 13:11:53 +0000 Subject: [PATCH] elementary - sorry i pushed together which should not be SVN revision: 78654 --- legacy/elementary/src/bin/test_notify.c | 175 +-------- legacy/elementary/src/lib/elm_deprecated.h | 32 -- legacy/elementary/src/lib/elm_notify.c | 201 +++++----- legacy/elementary/src/lib/elm_notify.h | 73 ++-- legacy/elementary/src/lib/elm_priv.h | 5 - legacy/elementary/src/lib/elm_scroller.c | 3 +- legacy/elementary/src/lib/elm_util.c | 370 ------------------ legacy/elementary/src/lib/elm_widget_notify.h | 1 - legacy/elementary/src/lib/els_scroller.c | 5 +- 9 files changed, 174 insertions(+), 691 deletions(-) diff --git a/legacy/elementary/src/bin/test_notify.c b/legacy/elementary/src/bin/test_notify.c index c3cb8bfe93..b8ea9acd01 100644 --- a/legacy/elementary/src/bin/test_notify.c +++ b/legacy/elementary/src/bin/test_notify.c @@ -50,10 +50,8 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(tb); - // Notify top notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.5, 0.0); bx = elm_box_add(win); elm_object_content_set(notify, bx); @@ -72,18 +70,15 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Top"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 2, 1, 1, 1); + elm_table_pack(tb, bt, 1, 0, 1, 1); evas_object_show(bt); - // Notify bottom notify = elm_notify_add(win); elm_notify_allow_events_set(notify, EINA_FALSE); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.5, 1.0); - + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM); elm_notify_timeout_set(notify, 5.0); evas_object_smart_callback_add(notify, "timeout", _notify_timeout, NULL); evas_object_smart_callback_add(notify, "block,clicked", _notify_block, NULL); @@ -106,16 +101,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Bottom"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 2, 3, 1, 1); + elm_table_pack(tb, bt, 1, 2, 1, 1); evas_object_show(bt); - // Notify left notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.0, 0.5); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_LEFT); elm_notify_timeout_set(notify, 10.0); evas_object_smart_callback_add(notify, "timeout", _notify_timeout, NULL); @@ -136,16 +129,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Left"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 1, 2, 1, 1); + elm_table_pack(tb, bt, 0, 1, 1, 1); evas_object_show(bt); - // Notify center notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.5, 0.5); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_CENTER); elm_notify_timeout_set(notify, 10.0); evas_object_smart_callback_add(notify, "timeout", _notify_timeout, NULL); @@ -166,16 +157,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Center"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 2, 2, 1, 1); + elm_table_pack(tb, bt, 1, 1, 1, 1); evas_object_show(bt); - // Notify right notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 1.0, 0.5); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_RIGHT); bx = elm_box_add(win); elm_object_content_set(notify, bx); @@ -194,16 +183,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Right"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 3, 2, 1, 1); + elm_table_pack(tb, bt, 2, 1, 1, 1); evas_object_show(bt); - // Notify top left notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.0, 0.0); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_TOP_LEFT); bx = elm_box_add(win); elm_object_content_set(notify, bx); @@ -222,16 +209,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Top Left"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 1, 1, 1, 1); + elm_table_pack(tb, bt, 0, 0, 1, 1); evas_object_show(bt); - // Notify top right notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 1.0, 0.0); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_TOP_RIGHT); bx = elm_box_add(win); elm_object_content_set(notify, bx); @@ -250,16 +235,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Top Right"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 3, 1, 1, 1); + elm_table_pack(tb, bt, 2, 0, 1, 1); evas_object_show(bt); - // Notify bottom left notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.0, 1.0); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM_LEFT); bx = elm_box_add(win); elm_object_content_set(notify, bx); @@ -278,16 +261,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Bottom Left"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 1, 3, 1, 1); + elm_table_pack(tb, bt, 0, 2, 1, 1); evas_object_show(bt); - // Notify bottom right notify = elm_notify_add(win); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 1.0, 1.0); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM_RIGHT); bx = elm_box_add(win); elm_object_content_set(notify, bx); @@ -306,132 +287,14 @@ test_notify(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_show(bt); bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_text_set(bt, "Bottom Right"); evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 3, 3, 1, 1); - evas_object_show(bt); - - // Notify top fill - notify = elm_notify_add(win); - evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, ELM_NOTIFY_ALIGN_FILL, 0.0); - elm_notify_timeout_set(notify, 5.0); - - bx = elm_box_add(win); - elm_object_content_set(notify, bx); - elm_box_horizontal_set(bx, EINA_TRUE); - evas_object_show(bx); - - lb = elm_label_add(win); - elm_object_text_set(lb, "Fill top. This notify fills horizontal area.
" - "elm_notify_align_set(notify, ELM_NOTIFY_ALIGN_FILL, 0.0); "); - elm_box_pack_end(bx, lb); - evas_object_show(lb); - - bt = elm_button_add(win); - elm_object_text_set(bt, "Close"); - evas_object_smart_callback_add(bt, "clicked", _bt_close, notify); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); - elm_object_text_set(bt, "Top fill"); - evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 1, 0, 3, 1); - evas_object_show(bt); - - // Notify bottom fill - notify = elm_notify_add(win); - evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, ELM_NOTIFY_ALIGN_FILL, 1.0); - elm_notify_timeout_set(notify, 5.0); - - bx = elm_box_add(win); - elm_object_content_set(notify, bx); - elm_box_horizontal_set(bx, EINA_TRUE); - evas_object_show(bx); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(lb, 0.0, 0.5); - elm_object_text_set(lb, "Fill Bottom. This notify fills horizontal area.
" - "elm_notify_align_set(notify, ELM_NOTIFY_ALIGN_FILL, 1.0); "); - elm_box_pack_end(bx, lb); - evas_object_show(lb); - - bt = elm_button_add(win); - elm_object_text_set(bt, "Close"); - evas_object_smart_callback_add(bt, "clicked", _bt_close, notify); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5); - elm_object_text_set(bt, "Bottom fill"); - evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 1, 4, 3, 1); - evas_object_show(bt); - - // Notify left fill - notify = elm_notify_add(win); - evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 0.0, EVAS_HINT_FILL); - elm_notify_timeout_set(notify, 5.0); - - bx = elm_box_add(win); - elm_object_content_set(notify, bx); - evas_object_show(bx); - - lb = elm_label_add(win); - elm_object_text_set(lb, "Left fill."); - elm_box_pack_end(bx, lb); - evas_object_show(lb); - - bt = elm_button_add(win); - elm_object_text_set(bt, "Close"); - evas_object_smart_callback_add(bt, "clicked", _bt_close, notify); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, 0.5, EVAS_HINT_FILL); - elm_object_text_set(bt, "Left fill"); - evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 0, 1, 1, 3); - evas_object_show(bt); - - // Notify right fill - notify = elm_notify_add(win); - evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_notify_align_set(notify, 1.0, EVAS_HINT_FILL); - elm_notify_timeout_set(notify, 5.0); - - bx = elm_box_add(win); - elm_object_content_set(notify, bx); - evas_object_show(bx); - - lb = elm_label_add(win); - elm_object_text_set(lb, "Right fill."); - elm_box_pack_end(bx, lb); - evas_object_show(lb); - - bt = elm_button_add(win); - elm_object_text_set(bt, "Close"); - evas_object_smart_callback_add(bt, "clicked", _bt_close, notify); - elm_box_pack_end(bx, bt); - evas_object_show(bt); - - bt = elm_button_add(win); - evas_object_size_hint_align_set(bt, 0.5, EVAS_HINT_FILL); - elm_object_text_set(bt, "Right fill"); - evas_object_smart_callback_add(bt, "clicked", _bt, notify); - elm_table_pack(tb, bt, 4, 1, 1, 3); + elm_table_pack(tb, bt, 2, 2, 1, 1); evas_object_show(bt); evas_object_show(win); - evas_object_resize(win, 400, 400); + evas_object_resize(win, 300, 350); } #endif + diff --git a/legacy/elementary/src/lib/elm_deprecated.h b/legacy/elementary/src/lib/elm_deprecated.h index cc3ea346da..49f88c2a78 100644 --- a/legacy/elementary/src/lib/elm_deprecated.h +++ b/legacy/elementary/src/lib/elm_deprecated.h @@ -421,35 +421,3 @@ EINA_DEPRECATED EAPI void elm_calendar_day_selection_disabled_se */ EINA_DEPRECATED EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj); -/** - * @deprecated Possible orient values for notify. - * - * This values should be used in conjunction to elm_notify_orient_set() to - * set the position in which the notify should appear(relative to its parent) - * and in conjunction with elm_notify_orient_get() to know where the notify - * is appearing. - */ -typedef enum -{ - ELM_NOTIFY_ORIENT_TOP, /**< Notify should appear in the top of parent, default */ - ELM_NOTIFY_ORIENT_CENTER, /**< Notify should appear in the center of parent */ - ELM_NOTIFY_ORIENT_BOTTOM, /**< Notify should appear in the bottom of parent */ - ELM_NOTIFY_ORIENT_LEFT, /**< Notify should appear in the left of parent */ - ELM_NOTIFY_ORIENT_RIGHT, /**< Notify should appear in the right of parent */ - ELM_NOTIFY_ORIENT_TOP_LEFT, /**< Notify should appear in the top left of parent */ - ELM_NOTIFY_ORIENT_TOP_RIGHT, /**< Notify should appear in the top right of parent */ - ELM_NOTIFY_ORIENT_BOTTOM_LEFT, /**< Notify should appear in the bottom left of parent */ - ELM_NOTIFY_ORIENT_BOTTOM_RIGHT, /**< Notify should appear in the bottom right of parent */ - ELM_NOTIFY_ORIENT_LAST /**< Sentinel value, @b don't use */ -} Elm_Notify_Orient; - - -/** - * @deprecated Use elm_notify_align_set instead. - */ -EINA_DEPRECATED EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient); - -/** - * @deprecated Use elm_notify_align_get instead. - */ -EINA_DEPRECATED EAPI Elm_Notify_Orient elm_notify_orient_get(const Evas_Object *obj); diff --git a/legacy/elementary/src/lib/elm_notify.c b/legacy/elementary/src/lib/elm_notify.c index 16ec68b8ef..25866e9ed9 100644 --- a/legacy/elementary/src/lib/elm_notify.c +++ b/legacy/elementary/src/lib/elm_notify.c @@ -73,24 +73,56 @@ static void _notify_theme_apply(Evas_Object *obj) { const char *style = elm_widget_style_get(obj); - double ax, ay; ELM_NOTIFY_DATA_GET(obj, sd); - ax = sd->horizontal_align; - ay = sd->vertical_align; - if ((elm_widget_mirrored_get(obj)) && (ax != ELM_NOTIFY_ALIGN_FILL)) ax = 1.0 - ax; + switch (sd->orient) + { + case ELM_NOTIFY_ORIENT_TOP: + elm_widget_theme_object_set(obj, sd->notify, "notify", "top", style); + break; - if (ay == 0.0) - elm_widget_theme_object_set(obj, sd->notify, "notify", "top", style); - else if (ay == 1.0) - elm_widget_theme_object_set(obj, sd->notify, "notify", "bottom", style); - else if (ax == 0.0) - elm_widget_theme_object_set(obj, sd->notify, "notify", "left", style); - else if (ax == 1.0) - elm_widget_theme_object_set(obj, sd->notify, "notify", "right", style); - else - elm_widget_theme_object_set(obj, sd->notify, "notify", "center", style); + case ELM_NOTIFY_ORIENT_CENTER: + elm_widget_theme_object_set + (obj, sd->notify, "notify", "center", style); + break; + + case ELM_NOTIFY_ORIENT_BOTTOM: + elm_widget_theme_object_set + (obj, sd->notify, "notify", "bottom", style); + break; + + case ELM_NOTIFY_ORIENT_LEFT: + elm_widget_theme_object_set(obj, sd->notify, "notify", "left", style); + break; + + case ELM_NOTIFY_ORIENT_RIGHT: + elm_widget_theme_object_set(obj, sd->notify, "notify", "right", style); + break; + + case ELM_NOTIFY_ORIENT_TOP_LEFT: + elm_widget_theme_object_set + (obj, sd->notify, "notify", "top_left", style); + break; + + case ELM_NOTIFY_ORIENT_TOP_RIGHT: + elm_widget_theme_object_set + (obj, sd->notify, "notify", "top_right", style); + break; + + case ELM_NOTIFY_ORIENT_BOTTOM_LEFT: + elm_widget_theme_object_set + (obj, sd->notify, "notify", "bottom_left", style); + break; + + case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT: + elm_widget_theme_object_set + (obj, sd->notify, "notify", "bottom_right", style); + break; + + case ELM_NOTIFY_ORIENT_LAST: + break; + } } /** @@ -108,27 +140,60 @@ _notify_theme_apply(Evas_Object *obj) static void _notify_move_to_orientation(Evas_Object *obj) { + int offx; + int offy; Evas_Coord minw = -1, minh = -1; Evas_Coord x, y, w, h; - double ax, ay; ELM_NOTIFY_DATA_GET(obj, sd); evas_object_geometry_get(obj, &x, &y, &w, &h); edje_object_size_min_get(sd->notify, &minw, &minh); edje_object_size_min_restricted_calc(sd->notify, &minw, &minh, minw, minh); + offx = (w - minw) / 2; + offy = (h - minh) / 2; - ax = sd->horizontal_align; - ay = sd->vertical_align; - if ((elm_widget_mirrored_get(obj)) && (ax != ELM_NOTIFY_ALIGN_FILL)) ax = 1.0 - ax; + switch (_notify_orientation_rtl_fix(obj, sd->orient)) + { + case ELM_NOTIFY_ORIENT_TOP: + evas_object_move(sd->notify, x + offx, y); + break; - if (ax == ELM_NOTIFY_ALIGN_FILL) minw = w; - if (ay == ELM_NOTIFY_ALIGN_FILL) minh = h; + case ELM_NOTIFY_ORIENT_CENTER: + evas_object_move(sd->notify, x + offx, y + offy); + break; - x = x + ((w - minw) * ax); - y = y + ((h - minh) * ay); + case ELM_NOTIFY_ORIENT_BOTTOM: + evas_object_move(sd->notify, x + offx, y + h - minh); + break; - evas_object_move(sd->notify, x, y); + case ELM_NOTIFY_ORIENT_LEFT: + evas_object_move(sd->notify, x, y + offy); + break; + + case ELM_NOTIFY_ORIENT_RIGHT: + evas_object_move(sd->notify, x + w - minw, y + offy); + break; + + case ELM_NOTIFY_ORIENT_TOP_LEFT: + evas_object_move(sd->notify, x, y); + break; + + case ELM_NOTIFY_ORIENT_TOP_RIGHT: + evas_object_move(sd->notify, x + w - minw, y); + break; + + case ELM_NOTIFY_ORIENT_BOTTOM_LEFT: + evas_object_move(sd->notify, x, y + h - minh); + break; + + case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT: + evas_object_move(sd->notify, x + w - minw, y + h - minh); + break; + + case ELM_NOTIFY_ORIENT_LAST: + break; + } } static void @@ -197,9 +262,6 @@ _calc(Evas_Object *obj) edje_object_size_min_get(sd->notify, &minw, &minh); edje_object_size_min_restricted_calc(sd->notify, &minw, &minh, minw, minh); - if (sd->horizontal_align == ELM_NOTIFY_ALIGN_FILL) minw = w; - if (sd->vertical_align == ELM_NOTIFY_ALIGN_FILL) minh = h; - if (sd->content) { _notify_move_to_orientation(obj); @@ -216,6 +278,15 @@ _changed_size_hints_cb(void *data, _calc(data); } +static void +_content_resize_cb(void *data, + Evas *e __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + _calc(data); +} + static Eina_Bool _elm_notify_smart_sub_object_del(Evas_Object *obj, Evas_Object *sobj) @@ -230,6 +301,8 @@ _elm_notify_smart_sub_object_del(Evas_Object *obj, evas_object_event_callback_del_full (sobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints_cb, obj); + evas_object_event_callback_del_full + (sobj, EVAS_CALLBACK_RESIZE, _content_resize_cb, obj); sd->content = NULL; } @@ -409,6 +482,8 @@ _elm_notify_smart_content_set(Evas_Object *obj, evas_object_event_callback_add (content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints_cb, obj); + evas_object_event_callback_add + (content, EVAS_CALLBACK_RESIZE, _content_resize_cb, obj); edje_object_part_swallow(sd->notify, "elm.swallow.content", content); } @@ -458,14 +533,12 @@ _elm_notify_smart_add(Evas_Object *obj) priv->notify = edje_object_add(evas_object_evas_get(obj)); priv->orient = -1; - priv->horizontal_align = 0.5; - priv->vertical_align = 0.0; evas_object_event_callback_add (obj, EVAS_CALLBACK_RESTACK, _restack_cb, obj); elm_widget_can_focus_set(obj, EINA_FALSE); - elm_notify_align_set(obj, 0.5, 0.0); + elm_notify_orient_set(obj, ELM_NOTIFY_ORIENT_TOP); } static void @@ -601,7 +674,7 @@ elm_notify_parent_get(const Evas_Object *obj) return sd->parent; } -EINA_DEPRECATED EAPI void +EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient) { @@ -611,50 +684,11 @@ elm_notify_orient_set(Evas_Object *obj, if (sd->orient == orient) return; sd->orient = orient; - switch (_notify_orientation_rtl_fix(obj, sd->orient)) - { - case ELM_NOTIFY_ORIENT_TOP: - elm_notify_align_set(obj, 0.5, 0.0); - break; - - case ELM_NOTIFY_ORIENT_CENTER: - elm_notify_align_set(obj, 0.5, 0.5); - break; - - case ELM_NOTIFY_ORIENT_BOTTOM: - elm_notify_align_set(obj, 0.5, 1.0); - break; - - case ELM_NOTIFY_ORIENT_LEFT: - elm_notify_align_set(obj, 0.0, 0.5); - break; - - case ELM_NOTIFY_ORIENT_RIGHT: - elm_notify_align_set(obj, 1.0, 0.5); - break; - - case ELM_NOTIFY_ORIENT_TOP_LEFT: - elm_notify_align_set(obj, 0.0, 0.0); - break; - - case ELM_NOTIFY_ORIENT_TOP_RIGHT: - elm_notify_align_set(obj, 1.0, 0.0); - break; - - case ELM_NOTIFY_ORIENT_BOTTOM_LEFT: - elm_notify_align_set(obj, 0.0, 1.0); - break; - - case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT: - elm_notify_align_set(obj, 1.0, 1.0); - break; - - case ELM_NOTIFY_ORIENT_LAST: - break; - } + _notify_theme_apply(obj); + _calc(obj); } -EINA_DEPRECATED EAPI Elm_Notify_Orient +EAPI Elm_Notify_Orient elm_notify_orient_get(const Evas_Object *obj) { ELM_NOTIFY_CHECK(obj) - 1; @@ -713,26 +747,3 @@ elm_notify_allow_events_get(const Evas_Object *obj) return sd->allow_events; } - -EAPI void -elm_notify_align_set(Evas_Object *obj, double horizontal, double vertical) -{ - ELM_NOTIFY_CHECK(obj); - ELM_NOTIFY_DATA_GET(obj, sd); - - sd->horizontal_align = horizontal; - sd->vertical_align = vertical; - - _notify_theme_apply(obj); - _calc(obj); -} - -EAPI void -elm_notify_align_get(const Evas_Object *obj, double *horizontal, double *vertical) -{ - ELM_NOTIFY_CHECK(obj); - ELM_NOTIFY_DATA_GET(obj, sd); - - *horizontal = sd->horizontal_align; - *vertical = sd->vertical_align; -} diff --git a/legacy/elementary/src/lib/elm_notify.h b/legacy/elementary/src/lib/elm_notify.h index 9a1bc22bed..945dc11402 100644 --- a/legacy/elementary/src/lib/elm_notify.h +++ b/legacy/elementary/src/lib/elm_notify.h @@ -32,7 +32,27 @@ * @{ */ -#define ELM_NOTIFY_ALIGN_FILL -1.0 /**< Use with elm_notify_align_set() */ +/** + * @brief Possible orient values for notify. + * + * This values should be used in conjunction to elm_notify_orient_set() to + * set the position in which the notify should appear(relative to its parent) + * and in conjunction with elm_notify_orient_get() to know where the notify + * is appearing. + */ +typedef enum +{ + ELM_NOTIFY_ORIENT_TOP, /**< Notify should appear in the top of parent, default */ + ELM_NOTIFY_ORIENT_CENTER, /**< Notify should appear in the center of parent */ + ELM_NOTIFY_ORIENT_BOTTOM, /**< Notify should appear in the bottom of parent */ + ELM_NOTIFY_ORIENT_LEFT, /**< Notify should appear in the left of parent */ + ELM_NOTIFY_ORIENT_RIGHT, /**< Notify should appear in the right of parent */ + ELM_NOTIFY_ORIENT_TOP_LEFT, /**< Notify should appear in the top left of parent */ + ELM_NOTIFY_ORIENT_TOP_RIGHT, /**< Notify should appear in the top right of parent */ + ELM_NOTIFY_ORIENT_BOTTOM_LEFT, /**< Notify should appear in the bottom left of parent */ + ELM_NOTIFY_ORIENT_BOTTOM_RIGHT, /**< Notify should appear in the bottom right of parent */ + ELM_NOTIFY_ORIENT_LAST /**< Sentinel value, @b don't use */ +} Elm_Notify_Orient; /** * @brief Add a new notify to the parent @@ -69,6 +89,32 @@ EAPI void elm_notify_parent_set(Evas_Object *obj, Evas_O */ EAPI Evas_Object *elm_notify_parent_get(const Evas_Object *obj); +/** + * @brief Set the orientation + * + * @param obj The notify object + * @param orient The new orientation + * + * Sets the position in which the notify will appear in its parent. + * + * @see @ref Elm_Notify_Orient for possible values. + * + * @ingroup Notify + */ +EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient); + +/** + * @brief Return the orientation + * @param obj The notify object + * @return The orientation of the notification + * + * @see elm_notify_orient_set() + * @see Elm_Notify_Orient + * + * @ingroup Notify + */ +EAPI Elm_Notify_Orient elm_notify_orient_get(const Evas_Object *obj); + /** * @brief Set the time interval after which the notify window is going to be * hidden. @@ -127,31 +173,6 @@ EAPI void elm_notify_allow_events_set(Evas_Object *obj, */ EAPI Eina_Bool elm_notify_allow_events_get(const Evas_Object *obj); -/** - * @brief Set the alignment of the notify object - * - * @param obj The notify object - * @param horizontal The horizontal alignment of the notification - * @param vertical The vertical alignment of the notification - * - * Sets the alignment in which the notify will appear in its parent. - * - * @ingroup Notify - */ -EAPI void elm_notify_align_set(Evas_Object *obj, double horizontal, double vertical); - -/** - * @brief Get the alignment of the notify object - * @param obj The notify object - * @param horizontal The horizontal alignment of the notification - * @param vertical The vertical alignment of the notification - * - * @see elm_notify_align_set() - * - * @ingroup Notify - */ -EAPI void elm_notify_align_get(const Evas_Object *obj, double *horizontal, double *vertical); - /** * @} */ diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index 61040e1f3d..f2de5ec6dd 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -433,9 +433,4 @@ void _elm_entry_entry_paste(Evas_Object *obj, const char *entry); double _elm_atof(const char *s); -typedef struct _Scrol_Effect Scroll_Effect; -Scroll_Effect * elm_scrl_effect_add(Evas_Object *target); -void elm_scrl_effect_del(Scroll_Effect *se); - - #endif diff --git a/legacy/elementary/src/lib/elm_scroller.c b/legacy/elementary/src/lib/elm_scroller.c index eee9e0c09f..62f24da716 100644 --- a/legacy/elementary/src/lib/elm_scroller.c +++ b/legacy/elementary/src/lib/elm_scroller.c @@ -710,6 +710,7 @@ elm_scroller_add(Evas_Object *parent) { Evas *e; Evas_Object *obj; + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); e = evas_object_evas_get(parent); @@ -720,8 +721,6 @@ elm_scroller_add(Evas_Object *parent) if (!elm_widget_sub_object_add(parent, obj)) ERR("could not add %p as sub object of %p", obj, parent); - //elm_scrl_effect_add(obj); - return obj; } diff --git a/legacy/elementary/src/lib/elm_util.c b/legacy/elementary/src/lib/elm_util.c index 7e9bcf580c..7e36860511 100644 --- a/legacy/elementary/src/lib/elm_util.c +++ b/legacy/elementary/src/lib/elm_util.c @@ -4,376 +4,6 @@ #include #include "elm_priv.h" -#define SLICE_CNT 30 -#define ZOOM_SEC 0.75 - -typedef struct _Slice -{ - Evas_Object *obj; - Evas_Coord x[4]; - Evas_Coord y[4]; - float zoom_end; - float zoom_end2; - float zoom_cur; - float zoom_cur2; - float zoom_begin; - float zoom_begin2; - int color_end; - int color_end2; - int color_begin; - int color_begin2; - int color_cur; - int color_cur2; -} Slice; - -struct _Scrol_Effect -{ - Evas_Object *target; - Slice slices[SLICE_CNT]; - Elm_Transit *transit; - int slice_idx; -}; - -static void -_slices_new(Scroll_Effect *se) -{ - Evas *e = evas_object_evas_get(se->target); - for (int i = 0; i < SLICE_CNT; i++) - { - if (!se->slices[i].obj) - se->slices[i].obj = evas_object_image_add(e); - evas_object_image_smooth_scale_set(se->slices[i].obj, EINA_TRUE); - se->slices[i].zoom_cur = 0; - se->slices[i].zoom_cur2 = 0; - se->slices[i].color_cur = 255; - se->slices[i].color_cur2 = 255; - } -} - -static void -_transit_del_cb(void *data, Elm_Transit *transit __UNUSED__) -{ - Scroll_Effect *se = data; - se->transit = NULL; -} - -static void -_zoom_out_cb(void *data, Elm_Transit *transit __UNUSED__, double progress) -{ - Scroll_Effect *se = data; - int i; - Evas_Coord x, y, w, h; - int color, color2; - - evas_object_geometry_get(se->target, &x, &y, &w, &h); - - Evas_Coord slice_h = h / SLICE_CNT; - - Evas_Map *map = evas_map_new(4); - if (!map) return; - - for(i = 0; i < SLICE_CNT; ++i) - { - Evas_Coord offset = slice_h * i; - Evas_Coord offset2 = offset + slice_h; - - if (i == SLICE_CNT - 1) - offset2 += (h - SLICE_CNT * slice_h); - - evas_object_image_fill_set(se->slices[i].obj, 0, offset, w, offset2); - evas_object_image_source_set(se->slices[i].obj, se->target); - evas_object_image_source_visible_set(se->slices[i].obj, EINA_FALSE); - evas_object_image_source_events_set(se->slices[i].obj, EINA_TRUE); - evas_object_resize(se->slices[i].obj, w, h); - evas_object_move(se->slices[i].obj, x, y); - - se->slices[i].zoom_cur = se->slices[i].zoom_begin + (se->slices[i].zoom_end - se->slices[i].zoom_begin) * progress; - se->slices[i].zoom_cur2 = se->slices[i].zoom_begin2 + (se->slices[i].zoom_end2 - se->slices[i].zoom_begin2) * progress; - - evas_map_point_coord_set(map, 0, x + se->slices[i].zoom_cur, y + offset, 0); - evas_map_point_coord_set(map, 1, x + w - se->slices[i].zoom_cur, y + offset, 0); - evas_map_point_coord_set(map, 2, x + w - se->slices[i].zoom_cur2, y + offset2, 0); - evas_map_point_coord_set(map, 3, x + se->slices[i].zoom_cur2, y + offset2, 0); - - evas_map_point_image_uv_set(map, 0, 0, offset); - evas_map_point_image_uv_set(map, 1, w, offset); - evas_map_point_image_uv_set(map, 2, w, offset2); - evas_map_point_image_uv_set(map, 3, 0, offset2); - - color = se->slices[i].color_begin + (se->slices[i].color_end - se->slices[i].color_begin) * progress; - color2 = se->slices[i].color_begin2 + (se->slices[i].color_end2 - se->slices[i].color_begin2) * progress; - - if (color < 200) color = 200; - if (color2 < 200) color2 = 200; - - evas_map_point_color_set(map, 0, color, color, color, 255); - evas_map_point_color_set(map, 1, color, color, color, 255); - evas_map_point_color_set(map, 2, color2, color2, color2, 255); - evas_map_point_color_set(map, 3, color2, color2, color2, 255); - - se->slices[i].color_cur = color; - se->slices[i].color_cur2 = color2; - evas_object_map_set(se->slices[i].obj, map); - evas_object_map_enable_set(se->slices[i].obj, EINA_TRUE); - evas_object_show(se->slices[i].obj); - } - evas_map_free(map); -} - -static void -_zoom_out(Scroll_Effect *se) -{ - for(int i = 0; i < SLICE_CNT; ++i) - { - se->slices[i].zoom_begin = se->slices[i].zoom_cur; - se->slices[i].zoom_begin2 = se->slices[i].zoom_cur2; - se->slices[i].color_begin = se->slices[i].color_cur; - se->slices[i].color_begin2 = se->slices[i].color_cur2; - } - - if (se->transit) elm_transit_del(se->transit); - se->transit = elm_transit_add(); - elm_transit_del_cb_set(se->transit, _transit_del_cb, se); - elm_transit_effect_add(se->transit, _zoom_out_cb, se, NULL); - elm_transit_duration_set(se->transit, ZOOM_SEC); - elm_transit_tween_mode_set(se->transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE); - elm_transit_event_enabled_set(se->transit, EINA_TRUE); - elm_transit_go(se->transit); -} - -static void -_zoom_in_cb(void *data, Elm_Transit *transit __UNUSED__, double progress) -{ - Scroll_Effect *se = data; - - int i; - Evas_Coord x, y, w, h; - int color, color2; - - evas_object_geometry_get(se->target, &x, &y, &w, &h); - Evas_Coord slice_h = h / SLICE_CNT; - - Evas_Map *map = evas_map_new(4); - if (!map) return; - - for(i = 0; i < SLICE_CNT; ++i) - { - Evas_Coord offset = slice_h * i; - Evas_Coord offset2 = offset + slice_h; - - if (i == SLICE_CNT - 1) - offset2 += (h - SLICE_CNT * slice_h); - - evas_object_image_fill_set(se->slices[i].obj, 0, offset, w, offset2); - evas_object_image_source_set(se->slices[i].obj, se->target); - - se->slices[i].zoom_cur = se->slices[i].zoom_begin + se->slices[i].zoom_end * progress; - se->slices[i].zoom_cur2 = se->slices[i].zoom_begin2 + se->slices[i].zoom_end2 * progress; - - evas_map_point_coord_set(map, 0, x + se->slices[i].zoom_cur, y + offset, 0); - evas_map_point_coord_set(map, 1, x + w - se->slices[i].zoom_cur, y + offset, 0); - evas_map_point_coord_set(map, 2, x + w - se->slices[i].zoom_cur2, y + offset2, 0); - evas_map_point_coord_set(map, 3, x + se->slices[i].zoom_cur2, y + offset2, 0); - - - evas_map_point_image_uv_set(map, 0, 0, offset); - evas_map_point_image_uv_set(map, 1, w, offset); - evas_map_point_image_uv_set(map, 2, w, offset2); - evas_map_point_image_uv_set(map, 3, 0, offset2); - - color = se->slices[i].color_begin + se->slices[i].color_end * progress; - color2 = se->slices[i].color_begin2 + se->slices[i].color_end2 * progress; - - if (color < 200) color = 200; - if (color2 < 200) color2 = 200; - - evas_map_point_color_set(map, 0, color, color, color, 255); - evas_map_point_color_set(map, 1, color, color, color, 255); - evas_map_point_color_set(map, 2, color2, color2, color2, 255); - evas_map_point_color_set(map, 3, color2, color2, color2, 255); - - se->slices[i].color_cur = color; - se->slices[i].color_cur2 = color2; - - evas_object_map_enable_set(se->slices[i].obj, EINA_TRUE); - evas_object_map_set(se->slices[i].obj, map); - evas_object_show(se->slices[i].obj); - } - evas_map_free(map); -} - -static void -_zoom_in(Scroll_Effect *se) -{ - for(int i = 0; i < SLICE_CNT; ++i) - { - se->slices[i].zoom_begin = se->slices[i].zoom_cur; - se->slices[i].zoom_begin2 = se->slices[i].zoom_cur2; - se->slices[i].zoom_end = -se->slices[i].zoom_cur; - se->slices[i].zoom_end2 = -se->slices[i].zoom_cur2; - se->slices[i].color_begin = se->slices[i].color_cur; - se->slices[i].color_begin2 = se->slices[i].color_cur2; - se->slices[i].color_end = 255 - se->slices[i].color_cur; - se->slices[i].color_end2 = 255 - se->slices[i].color_cur2; - } - - if (se->transit) elm_transit_del(se->transit); - se->transit = elm_transit_add(); - elm_transit_del_cb_set(se->transit, _transit_del_cb, se); - elm_transit_effect_add(se->transit, _zoom_in_cb, se, NULL); - elm_transit_duration_set(se->transit, ZOOM_SEC); - elm_transit_event_enabled_set(se->transit, EINA_TRUE); - elm_transit_tween_mode_set(se->transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE); - elm_transit_go(se->transit); -} - -float degree_to_radian( const float degree ) -{ - const int PI = 3.141592; - return degree / 180 * PI; -} - -static void -_lookup_index(Scroll_Effect *se, Evas_Coord pt) -{ - Evas_Coord y, h; - evas_object_geometry_get(se->target, NULL, &y, NULL, &h); - - y = pt - y; - - Evas_Coord slice_h = h / SLICE_CNT; - - y -= (y % slice_h); - y /= slice_h; - - se->slice_idx = y; -} - -static void -_update_slices_property(Scroll_Effect *se, Eina_Bool move) -{ - float degree; - Evas_Coord w; - evas_object_geometry_get(se->target, NULL, NULL, &w, NULL); - - Evas_Coord half_w = (w >> 1); - float depth = 0.2 * half_w; - - //First Slice - degree = 90 - (((fabs(se->slice_idx)) / (SLICE_CNT)) * 90); - se->slices[0].zoom_end = sin(degree_to_radian(degree)) * depth; - - degree = 90 - (((fabs(se->slice_idx - 1)) / (SLICE_CNT)) * 90); - se->slices[0].zoom_end2 = sin(degree_to_radian(degree)) * depth; - - se->slices[0].color_end = 255 * ((se->slices[0].zoom_end / depth) * 0.5 + 0.5); - se->slices[0].color_end2 = 255 * ((se->slices[0].zoom_end2 / depth) * 0.5 + 0.5); - - if (move) - { - se->slices[0].zoom_begin = se->slices[0].zoom_cur = se->slices[0].zoom_end; - se->slices[0].zoom_begin2 = se->slices[0].zoom_cur2 = se->slices[0].zoom_end2; - } - - //Last Slices - for(int i = 1; i < SLICE_CNT; ++i) - { - degree = 90 - (((fabs(se->slice_idx - (i + 1))) / (SLICE_CNT)) * 90); - - se->slices[i].zoom_end = se->slices[i - 1].zoom_end2; - se->slices[i].zoom_end2 = sin(degree_to_radian(degree)) * depth; - - se->slices[i].color_end = se->slices[i - 1].color_end2; - se->slices[i].color_end2 = 255 * ((se->slices[i].zoom_end2 / depth) * 0.5 + 0.5); - - if (move) - { - se->slices[i].zoom_begin = se->slices[i].zoom_cur = se->slices[i].zoom_end; - se->slices[i].zoom_begin2 = se->slices[i].zoom_cur2 = se->slices[i].zoom_end2; - } - } -} - -static void -_target_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) -{ - printf("mouse down!!\n"); - Evas_Event_Mouse_Down *ev = event_info; - _lookup_index(data, ev->canvas.y); - _update_slices_property(data, EINA_FALSE); - _zoom_out(data); -} - -static void -_target_mouse_move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Evas_Event_Mouse_Move *ev = event_info; - printf("mouse move!!\n"); - - if (!ev->buttons) return; - - Scroll_Effect *se = data; - - _lookup_index(data, ev->cur.canvas.y); - - if (se->transit) - _update_slices_property(data, EINA_FALSE); - else - { - _update_slices_property(data, EINA_TRUE); - _zoom_out_cb(se, NULL, 1); - } -} - -static void -_target_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - printf("mouse up!!\n"); - _zoom_in(data); -} - -static void -_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Scroll_Effect *se = data; - - for (int i = 0; i < SLICE_CNT; i++) - { - if (!se->slices[i].obj) continue; - evas_object_del(se->slices[i].obj); - se->slices[i].obj = NULL; - } -} - -Scroll_Effect * -elm_scrl_effect_add(Evas_Object *target) -{ - Scroll_Effect *se = calloc(1, sizeof(Scroll_Effect)); - if (!se) return NULL; - - se->target = target; - _slices_new(se); - - evas_object_event_callback_add(target, EVAS_CALLBACK_MOUSE_DOWN, _target_mouse_down, se); - evas_object_event_callback_add(target, EVAS_CALLBACK_MOUSE_MOVE, _target_mouse_move, se); - evas_object_event_callback_add(target, EVAS_CALLBACK_MOUSE_UP, _target_mouse_up, se); - evas_object_event_callback_add(target, EVAS_CALLBACK_DEL, _target_del, se); - - return se; -} - -void -elm_scrl_effect_del(Scroll_Effect *se) -{ - for (int i = 0; i < SLICE_CNT; i++) - { - if (!se->slices[i].obj) continue; - evas_object_del(se->slices[i].obj); - } - - free(se); -} - char * _str_ncpy(char *dest, const char *src, size_t count) { diff --git a/legacy/elementary/src/lib/elm_widget_notify.h b/legacy/elementary/src/lib/elm_widget_notify.h index bdc5aef394..7fc3dc710e 100644 --- a/legacy/elementary/src/lib/elm_widget_notify.h +++ b/legacy/elementary/src/lib/elm_widget_notify.h @@ -128,7 +128,6 @@ struct _Elm_Notify_Smart_Data Elm_Notify_Orient orient; double timeout; - double horizontal_align, vertical_align; Ecore_Timer *timer; Eina_Bool allow_events : 1; diff --git a/legacy/elementary/src/lib/els_scroller.c b/legacy/elementary/src/lib/els_scroller.c index 0a562fe41c..8ee0c64d14 100644 --- a/legacy/elementary/src/lib/els_scroller.c +++ b/legacy/elementary/src/lib/els_scroller.c @@ -166,7 +166,6 @@ struct _Smart_Data Evas_Object *pan_obj; Evas_Object *edje_obj; Evas_Object *event_obj; - Evas_Object *effect_obj; Evas_Object *widget; @@ -255,7 +254,6 @@ struct _Smart_Data double pagerel_h, pagerel_v; Evas_Coord pagesize_h, pagesize_v; - Scroll_Effect *se; Eina_Bool hbar_visible : 1; Eina_Bool vbar_visible : 1; @@ -3060,6 +3058,7 @@ _smart_add(Evas_Object *obj) sd = calloc(1, sizeof(Smart_Data)); if (!sd) return; evas_object_smart_data_set(obj, sd); + sd->smart_obj = obj; sd->x = 0; sd->y = 0; @@ -3118,7 +3117,6 @@ _smart_add(Evas_Object *obj) sd->pan_func.gravity_get = _elm_smart_pan_gravity_get; _smart_scrollbar_reset(sd); - sd->se = elm_scrl_effect_add(obj); } static void @@ -3136,7 +3134,6 @@ _smart_del(Evas_Object *obj) if (sd->down.bounce_y_animator) ecore_animator_del(sd->down.bounce_y_animator); if (sd->scrollto.x.animator) ecore_animator_del(sd->scrollto.x.animator); if (sd->scrollto.y.animator) ecore_animator_del(sd->scrollto.y.animator); - elm_scrl_effect_del(sd->se); free(sd); evas_object_smart_data_set(obj, NULL); }