+static void
+_magnifier_hide(void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd) return;
+
+ evas_object_hide(wd->mgf_bg);
+ evas_object_hide(wd->mgf_clip);
+
+ if (wd->scroll)
+ elm_smart_scroller_freeze_set(wd->scroller, EINA_FALSE);
+}
+
+static void
+_magnifier_show(void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd) return;
+
+ evas_object_show(wd->mgf_bg);
+ evas_object_show(wd->mgf_clip);
+}
+
+static void
+_magnifier_move(void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd) return;
+
+ Evas_Coord x, y, w, h;
+ Evas_Coord cx, cy, cw, ch, ox, oy;
+
+ edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
+
+ if (wd->scroll)
+ {
+ evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
+ elm_smart_scroller_child_pos_get(wd->scroller, &ox, &oy);
+ cx -= ox;
+ cy -= oy;
+ }
+ else
+ evas_object_geometry_get(data, &x, &y, &w, &h);
+
+ ox = oy = 0;
+
+ if ((cy + y) - wd->mgf_height < 0)
+ oy = -1 * ((cy + y) - wd->mgf_height);
+
+ if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
+ evas_object_move(wd->mgf_bg, (cx + x + cw/2) + ox, (cy + y) - wd->mgf_height + oy);
+ else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
+ evas_object_move(wd->mgf_bg, x, (cy + y) - wd->mgf_height + oy);
+ else
+ return;
+
+ evas_object_move(wd->mgf_proxy, (1 - wd->mgf_scale) * cx + x + ox, (1 - wd->mgf_scale) * cy + y - wd->mgf_height/2 - ch/2 + oy);
+}
+
+static void
+_magnifier_create(void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ Evas_Coord x, y, w, h, mw, mh;
+ const char* key_data = NULL;
+ double elm_scale;
+
+ if (!wd) return;
+
+ if (wd->mgf_proxy)
+ {
+ evas_object_image_source_unset(wd->mgf_proxy);
+ evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 0);
+ evas_object_hide(wd->mgf_proxy);
+ evas_object_clip_unset(wd->mgf_proxy);
+ evas_object_del(wd->mgf_proxy);
+ }
+ if (wd->mgf_bg) evas_object_del(wd->mgf_bg);
+ if (wd->mgf_clip) evas_object_del(wd->mgf_clip);
+
+ if (wd->scroll)
+ evas_object_geometry_get(wd->scroller, &x, &y, &w, &h);
+ else
+ evas_object_geometry_get(data, &x, &y, &w, &h);
+
+ if ((w <= 0) || (h <= 0))
+ return;
+
+ wd->mgf_bg = edje_object_add(evas_object_evas_get(data));
+
+ if (wd->mgf_type == _ENTRY_MAGNIFIER_FIXEDSIZE)
+ _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fixed-size");
+ else if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
+ _elm_theme_object_set(data, wd->mgf_bg, "entry", "magnifier", "fill-width");
+ else
+ return;
+
+ wd->mgf_clip = evas_object_rectangle_add(evas_object_evas_get(data));
+ evas_object_color_set(wd->mgf_clip, 255, 255, 255, 255);
+ edje_object_part_swallow(wd->mgf_bg, "swallow", wd->mgf_clip);
+
+ key_data = edje_object_data_get(wd->mgf_bg, "height");
+ if (key_data) wd->mgf_height = atoi(key_data);
+ key_data = edje_object_data_get(wd->mgf_bg, "scale");
+ if (key_data) wd->mgf_scale = atof(key_data);
+
+ elm_scale = elm_config_scale_get();
+ wd->mgf_height = (int)((float)wd->mgf_height * elm_scale);
+
+ if (wd->mgf_type == _ENTRY_MAGNIFIER_FILLWIDTH)
+ evas_object_resize(wd->mgf_bg, w, wd->mgf_height);
+
+ if (wd->scroll)
+ {
+ elm_smart_scroller_freeze_set(wd->scroller, EINA_TRUE);
+ wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(wd->scroller));
+ evas_object_image_source_set(wd->mgf_proxy, wd->scroller);
+ }
+ else
+ {
+ wd->mgf_proxy = evas_object_image_add(evas_object_evas_get(data));
+ evas_object_image_source_set(wd->mgf_proxy, data);
+ }
+
+ mw = (Evas_Coord)((float)w * wd->mgf_scale);
+ mh = (Evas_Coord)((float)h * wd->mgf_scale);
+ if ((mw <= 0) || (mh <= 0))
+ return;
+
+ evas_object_resize(wd->mgf_proxy, mw, mh);
+ evas_object_image_fill_set(wd->mgf_proxy, 0, 0, mw, mh);
+ evas_object_color_set(wd->mgf_proxy, 255, 255, 255, 255);
+ evas_object_pass_events_set(wd->mgf_proxy, EINA_TRUE);
+ evas_object_show(wd->mgf_proxy);
+ evas_object_clip_set(wd->mgf_proxy, wd->mgf_clip);
+
+ evas_object_layer_set(wd->mgf_bg, EVAS_LAYER_MAX);
+ evas_object_layer_set(wd->mgf_proxy, EVAS_LAYER_MAX);
+}
+
+static void
+_signal_long_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+
+ if (!wd) return;
+ wd->long_pressed = EINA_TRUE;
+ _cancel(data, NULL, NULL);
+ if (wd->magnifier_enabled)
+ {
+ _magnifier_create(data);
+ _magnifier_move(data);
+ _magnifier_show(data);
+ elm_object_scroll_freeze_push(data);
+ }
+}
+