diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index c118914331..b123bc8fd1 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -1394,3 +1394,7 @@ 2013-06-06 Ryuan Choi (ryuan) * Up/down step of hour decimal of elm_clock is changed to 12 not to touch hour unit at editing mode. + +2013-06-07 Thiep Ha + + * Add magnifier to entry. diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index 369b44997e..4757161040 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -72,6 +72,7 @@ Additions: * Add support elm_object_item_signal_emit() for elm_list. * Add ELM_INPUT_PANEL_LAYOUT_DATETIME. * Add elm_config_glayer_long_tap_start_timeout_set/get, elm_config_glayer_double_tap_timeout_set/get + * Add magnifier to entry. Improvements: diff --git a/legacy/elementary/config/default/base.src b/legacy/elementary/config/default/base.src index 592280e632..445a3cd09d 100644 --- a/legacy/elementary/config/default/base.src +++ b/legacy/elementary/config/default/base.src @@ -77,6 +77,8 @@ group "Elm_Config" struct { value "auto_dump_withdrawn" uchar: 0; value "auto_throttle" uchar: 0; value "auto_throttle_amount" double: 0.1; + value "magnifier_enable" uchar: 1; + value "magnifier_scale" double: 1.5; group "color_palette" list { group "Elm_Custom_Palette" struct { value "palette_name" string: "default"; diff --git a/legacy/elementary/config/mobile/base.src b/legacy/elementary/config/mobile/base.src index d29bfcebe3..a3453cec6c 100644 --- a/legacy/elementary/config/mobile/base.src +++ b/legacy/elementary/config/mobile/base.src @@ -81,6 +81,8 @@ group "Elm_Config" struct { value "indicator_service_90" string: "elm_indicator_landscape"; value "indicator_service_180" string: "elm_indicator_portrait"; value "indicator_service_270" string: "elm_indicator_landscape"; + value "magnifier_enable" uchar: 1; + value "magnifier_scale" double: 1.5; group "color_palette" list { group "Elm_Custom_Palette" struct { value "palette_name" string: "default"; diff --git a/legacy/elementary/config/standard/base.src b/legacy/elementary/config/standard/base.src index 5d86646d8a..e159689897 100644 --- a/legacy/elementary/config/standard/base.src +++ b/legacy/elementary/config/standard/base.src @@ -77,6 +77,8 @@ group "Elm_Config" struct { value "auto_dump_withdrawn" uchar: 1; value "auto_throttle" uchar: 0; value "auto_throttle_amount" double: 0.0333333333; + value "magnifier_enable" uchar: 0; + value "magnifier_scale" double: 1.5; group "color_palette" list { group "Elm_Custom_Palette" struct { value "palette_name" string: "default"; diff --git a/legacy/elementary/data/themes/Makefile.am b/legacy/elementary/data/themes/Makefile.am index 5575508aaa..09166902f6 100644 --- a/legacy/elementary/data/themes/Makefile.am +++ b/legacy/elementary/data/themes/Makefile.am @@ -174,6 +174,8 @@ images/cur_shine.png \ images/cur_glow.png \ images/handler_start.png \ images/handler_end.png \ +images/magnifier_bg.png \ +images/magnifier_line.png \ images/bubble.png \ images/bubble_3.png \ images/bubble_shine3.png \ diff --git a/legacy/elementary/data/themes/images/magnifier_bg.png b/legacy/elementary/data/themes/images/magnifier_bg.png new file mode 100644 index 0000000000..286e37e664 Binary files /dev/null and b/legacy/elementary/data/themes/images/magnifier_bg.png differ diff --git a/legacy/elementary/data/themes/images/magnifier_line.png b/legacy/elementary/data/themes/images/magnifier_line.png new file mode 100644 index 0000000000..b61985fa9a Binary files /dev/null and b/legacy/elementary/data/themes/images/magnifier_line.png differ diff --git a/legacy/elementary/data/themes/widgets/entry.edc b/legacy/elementary/data/themes/widgets/entry.edc index ff9adf24d3..00fcc96172 100644 --- a/legacy/elementary/data/themes/widgets/entry.edc +++ b/legacy/elementary/data/themes/widgets/entry.edc @@ -1541,3 +1541,85 @@ group { name: "elm/entry/handler/end/default"; } } } + +group { name: "elm/entry/magnifier/default"; + images { + image: "magnifier_bg.png" COMP; + image: "magnifier_line.png" COMP; + } + parts { + part { name: "bg"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 100 55; + fixed: 1 1; + align: 0 0; + image { + normal: "magnifier_bg.png"; + } + image.middle: SOLID; + fill.smooth: 1; + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "swallow"; + type: SWALLOW; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + rel1 { + to: "bg"; + offset: 4 4; + } + rel2 { + to: "bg"; + offset: -8 -8; + } + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "outline"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + image { + normal: "magnifier_line.png"; + } + image.middle: SOLID; + fill.smooth: 1; + rel1.to: "bg"; + rel2.to: "bg"; + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + } + programs { + program { name: "magnifier_show"; + signal: "elm,action,show,magnifier"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg"; + target: "swallow"; + target: "outline"; + } + program { name: "magnifier_hide"; + signal: "elm,action,hide,magnifier"; + source: "elm"; + action: STATE_SET "hidden" 0.0; + target: "bg"; + target: "swallow"; + target: "outline"; + } + } +} diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index c356b125f2..53bab983f9 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/src/lib/elm_config.c @@ -436,6 +436,8 @@ _desc_init(void) ELM_CONFIG_VAL(D, T, indicator_service_270, T_STRING); ELM_CONFIG_VAL(D, T, disable_external_menu, T_UCHAR); ELM_CONFIG_VAL(D, T, clouseau_enable, T_UCHAR); + ELM_CONFIG_VAL(D, T, magnifier_enable, T_UCHAR); + ELM_CONFIG_VAL(D, T, magnifier_scale, T_DOUBLE); #undef T #undef D #undef T_INT @@ -1176,6 +1178,8 @@ _config_load(void) _elm_config->indicator_service_180 = eina_stringshare_add("elm_indicator_portrait"); _elm_config->indicator_service_270 = eina_stringshare_add("elm_indicator_landscape"); _elm_config->disable_external_menu = EINA_FALSE; + _elm_config->magnifier_enable = EINA_TRUE; + _elm_config->magnifier_scale = 1.5; } static const char * @@ -1725,6 +1729,10 @@ _env_get(void) s = getenv("ELM_CLOUSEAU"); if (s) _elm_config->clouseau_enable = atoi(s); + s = getenv("ELM_MAGNIFIER_ENABLE"); + if (s) _elm_config->magnifier_enable = !!atoi(s); + s = getenv("ELM_MAGNIFIER_SCALE"); + if (s) _elm_config->magnifier_scale = _elm_atof(s); } EAPI Eina_Bool @@ -2359,6 +2367,30 @@ elm_config_glayer_double_tap_timeout_set(double double_tap_timeout) _elm_config->glayer_double_tap_timeout = double_tap_timeout; } +EAPI Eina_Bool +elm_config_magnifier_enable_get(void) +{ + return _elm_config->magnifier_enable; +} + +EAPI void +elm_config_magnifier_enable_set(Eina_Bool enable) +{ + _elm_config->magnifier_enable = !!enable; +} + +EAPI double +elm_config_magnifier_scale_get(void) +{ + return _elm_config->magnifier_scale; +} + +EAPI void +elm_config_magnifier_scale_set(double scale) +{ + _elm_config->magnifier_scale = scale; +} + EAPI void elm_config_all_flush(void) { diff --git a/legacy/elementary/src/lib/elm_entry.c b/legacy/elementary/src/lib/elm_entry.c index 4163d2934b..8008100307 100644 --- a/legacy/elementary/src/lib/elm_entry.c +++ b/legacy/elementary/src/lib/elm_entry.c @@ -1340,14 +1340,124 @@ _menu_call(Evas_Object *obj) } } +static void +_magnifier_create(void *data) +{ + ELM_ENTRY_DATA_GET(data, sd); + + double scale = _elm_config->magnifier_scale; + Evas_Coord w, h, mw, mh; + + if (sd->mgf_proxy) + { + evas_object_image_source_unset(sd->mgf_proxy); + evas_object_clip_unset(sd->mgf_proxy); + evas_object_del(sd->mgf_proxy); + } + if (sd->mgf_bg) evas_object_del(sd->mgf_bg); + if (sd->mgf_clip) evas_object_del(sd->mgf_clip); + + sd->mgf_bg = edje_object_add(evas_object_evas_get(data)); + _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier", "default"); + evas_object_show(sd->mgf_bg); + + sd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data)); + evas_object_color_set(sd->mgf_clip, 255, 255, 255, 255); + edje_object_part_swallow(sd->mgf_bg, "swallow", sd->mgf_clip); + + if (sd->scroll) + { + sd->mgf_proxy = evas_object_image_add(evas_object_evas_get(sd->scr_edje)); + evas_object_image_source_set(sd->mgf_proxy, sd->scr_edje); + evas_object_geometry_get(sd->scr_edje, NULL, NULL, &w, &h); + } + else + { + sd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data)); + evas_object_image_source_set(sd->mgf_proxy, data); + evas_object_geometry_get(data, NULL, NULL, &w, &h); + } + + mw = (Evas_Coord)(scale * (float) w); + mh = (Evas_Coord)(scale * (float) h); + if ((mw <= 0) || (mh <= 0)) + return; + + evas_object_resize(sd->mgf_proxy, mw, mh); + evas_object_image_fill_set(sd->mgf_proxy, 0, 0, mw, mh); + evas_object_color_set(sd->mgf_proxy, 255, 255, 255, 255); + evas_object_pass_events_set(sd->mgf_proxy, EINA_TRUE); + evas_object_show(sd->mgf_proxy); + evas_object_clip_set(sd->mgf_proxy, sd->mgf_clip); + + evas_object_layer_set(sd->mgf_bg, EVAS_LAYER_MAX); + evas_object_layer_set(sd->mgf_proxy, EVAS_LAYER_MAX); +} + +static void +_magnifier_move(void *data, Evas_Coord px, Evas_Coord py) +{ + ELM_ENTRY_DATA_GET(data, sd); + + Evas_Coord x, y, w, h; + Evas_Coord ex, ey; + Evas_Coord sx, sy; + const Evas_Object *obj_bg; + double scale = _elm_config->magnifier_scale; + + obj_bg = edje_object_part_object_get(sd->mgf_bg, "bg"); + evas_object_geometry_get(obj_bg, NULL, NULL, &w, &h); + evas_object_move(sd->mgf_bg, px - w/2, py - h); + + obj_bg = edje_object_part_object_get(sd->mgf_bg, "swallow"); + evas_object_geometry_get(obj_bg, &x, &y, &w, &h); + sx = px - (x + w/2); + sy = py - (y + h/2); + + if (sd->scroll) + { + evas_object_geometry_get(sd->scr_edje, &ex, &ey, NULL, NULL); + } + else + { + evas_object_geometry_get(data, &ex, &ey, NULL, NULL); + } + evas_object_move(sd->mgf_proxy, ex * scale - (px * scale - px) - sx, + ey * scale - (py * scale - py) - sy); +} + +static void +_magnifier_hide(void *data) +{ + ELM_ENTRY_DATA_GET(data, sd); + edje_object_signal_emit(sd->mgf_bg, "elm,action,hide,magnifier", "elm"); + elm_widget_scroll_freeze_pop(data); +} + +static void +_magnifier_show(void *data) +{ + ELM_ENTRY_DATA_GET(data, sd); + edje_object_signal_emit(sd->mgf_bg, "elm,action,show,magnifier", "elm"); + elm_widget_scroll_freeze_push(data); +} + static Eina_Bool _long_press_cb(void *data) { ELM_ENTRY_DATA_GET(data, sd); - if (!_elm_config->desktop_entry) + if (_elm_config->magnifier_enable) + { + _magnifier_create(data); + _magnifier_show(data); + _magnifier_move(data, sd->downx, sd->downy); + } + else if (!_elm_config->desktop_entry) _menu_call(data); + sd->long_pressed = EINA_TRUE; + sd->longpress_timer = NULL; evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL); @@ -1380,12 +1490,15 @@ _mouse_down_cb(void *data, if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; sd->downx = ev->canvas.x; sd->downy = ev->canvas.y; - if (ev->button == 1) - { - if (sd->longpress_timer) ecore_timer_del(sd->longpress_timer); - sd->longpress_timer = ecore_timer_add - (_elm_config->longpress_timeout, _long_press_cb, data); - } + sd->long_pressed = EINA_FALSE; + + if (ev->button == 1) + { + ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); + sd->longpress_timer = ecore_timer_add + (_elm_config->longpress_timeout, _long_press_cb, data); + sd->long_pressed = EINA_FALSE; + } else if (ev->button == 3) { if (_elm_config->desktop_entry) @@ -1407,6 +1520,11 @@ _mouse_up_cb(void *data, if (ev->button == 1) { ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); + if ((sd->long_pressed) && (_elm_config->magnifier_enable)) + { + _magnifier_hide(data); + _menu_call(data); + } } else if ((ev->button == 3) && (!_elm_config->desktop_entry)) { @@ -1426,6 +1544,11 @@ _mouse_move_cb(void *data, ELM_ENTRY_DATA_GET(data, sd); if (sd->disabled) return; + if (ev->buttons == 1) + { + if ((sd->long_pressed) && (_elm_config->magnifier_enable)) + _magnifier_move(data, ev->cur.canvas.x, ev->cur.canvas.y); + } if (!sd->sel_mode) { if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) @@ -2973,6 +3096,15 @@ _elm_entry_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED) if ((sd->api) && (sd->api->obj_unhook)) sd->api->obj_unhook(obj); // module - unhook + if (sd->mgf_proxy) + { + evas_object_image_source_unset(sd->mgf_proxy); + evas_object_clip_unset(sd->mgf_proxy); + evas_object_del(sd->mgf_proxy); + } + if (sd->mgf_bg) evas_object_del(sd->mgf_bg); + if (sd->mgf_clip) evas_object_del(sd->mgf_clip); + entries = eina_list_remove(entries, obj); #ifdef HAVE_ELEMENTARY_X if (sd->sel_notify_handler) diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index 4da2eed0a2..6100b6f039 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -243,6 +243,8 @@ struct _Elm_Config unsigned char selection_clear_enable; unsigned char disable_external_menu; unsigned char clouseau_enable; + unsigned char magnifier_enable; + double magnifier_scale; /* Not part of the EET file */ Eina_Bool is_mirrored : 1; diff --git a/legacy/elementary/src/lib/elm_widget_entry.h b/legacy/elementary/src/lib/elm_widget_entry.h index ddb0e543b4..bfa8918d28 100644 --- a/legacy/elementary/src/lib/elm_widget_entry.h +++ b/legacy/elementary/src/lib/elm_widget_entry.h @@ -26,6 +26,9 @@ struct _Elm_Entry_Smart_Data Evas_Object *hit_rect, *entry_edje, *scr_edje; Evas_Object *hoversel; + Evas_Object *mgf_bg; + Evas_Object *mgf_clip; + Evas_Object *mgf_proxy; Ecore_Job *deferred_recalc_job; Ecore_Event_Handler *sel_notify_handler; Ecore_Event_Handler *sel_clear_handler; @@ -76,6 +79,7 @@ struct _Elm_Entry_Smart_Data Eina_Bool have_selection : 1; Eina_Bool deferred_cur : 1; Eina_Bool context_menu : 1; + Eina_Bool long_pressed : 1; Eina_Bool cur_changed : 1; Eina_Bool single_line : 1; Eina_Bool can_write : 1;