2 # include "elementary_config.h"
4 #include <Elementary.h>
8 static int try_num = 0;
11 _timer_del(void *data EINA_UNUSED,
14 void *event_info EINA_UNUSED)
16 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
18 ecore_timer_del(timer);
22 cb_plug_connect(void *data)
24 Evas_Object *obj = data;
27 if (!obj) return ECORE_CALLBACK_CANCEL;
30 if (try_num > MAX_TRY) return ECORE_CALLBACK_CANCEL;
32 timer= evas_object_data_get(obj, "test-timer");
33 if (!timer) return ECORE_CALLBACK_CANCEL;
35 if (elm_plug_connect(obj, "ello", 0, EINA_FALSE))
37 printf("plug connect to server[ello]\n");
38 evas_object_data_del(obj, "test-timer");
39 return ECORE_CALLBACK_CANCEL;
42 ecore_timer_interval_set(timer, 1);
43 return ECORE_CALLBACK_RENEW;
47 cb_plug_disconnected(void *data EINA_UNUSED,
49 void *event_info EINA_UNUSED)
51 Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
54 ecore_timer_del(timer);
55 evas_object_data_del(obj, "test-timer");
58 timer = ecore_timer_add(1, cb_plug_connect, obj);
59 evas_object_data_set(obj, "test-timer", timer);
63 cb_plug_resized(void *data EINA_UNUSED,
64 Evas_Object *obj EINA_UNUSED,
67 Evas_Coord_Size *size = event_info;
68 printf("server image resized to %dx%d\n", size->w, size->h);
72 cb_mouse_down(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event_info)
74 Evas_Event_Mouse_Down *ev = event_info;
76 if (ev->button == 1) elm_object_focus_set(obj, EINA_TRUE);
80 cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event_info)
82 Evas_Event_Mouse_Move *ev = event_info;
83 Evas_Object *orig = data;
88 if (!ev->buttons) return;
89 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
91 x + (ev->cur.canvas.x - ev->prev.output.x),
92 y + (ev->cur.canvas.y - ev->prev.output.y));
93 evas_object_image_size_get(orig, &w, &h);
95 evas_object_map_enable_set(orig, EINA_TRUE);
96 evas_object_raise(orig);
97 for (i = 0; i < 4; i++)
102 snprintf(key, sizeof(key), "h-%i\n", i);
103 hand = evas_object_data_get(orig, key);
104 evas_object_raise(hand);
105 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
108 evas_map_point_coord_set(p, i, x, y, 0);
109 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
110 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
111 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
112 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
114 evas_object_map_set(orig, p);
119 create_handles(Evas_Object *obj)
122 Evas_Coord x, y, w, h;
124 evas_object_geometry_get(obj, &x, &y, &w, &h);
125 for (i = 0; i < 4; i++)
131 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
132 evas_object_resize(hand, 31, 31);
133 snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get());
134 evas_object_image_file_set(hand, buf, NULL);
135 if (i == 0) evas_object_move(hand, x - 15, y - 15);
136 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
137 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
138 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
139 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
140 evas_object_show(hand);
141 snprintf(key, sizeof(key), "h-%i\n", i);
142 evas_object_data_set(obj, key, hand);
147 test_win_plug(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
149 Evas_Object *win, *bg, *plug;
152 win = elm_win_add(NULL, "window-plug", ELM_WIN_BASIC);
153 elm_win_title_set(win, "Window Plug");
154 elm_win_autodel_set(win, EINA_TRUE);
156 bg = elm_bg_add(win);
157 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
158 elm_bg_file_set(bg, buf, NULL);
159 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
160 elm_win_resize_object_add(win, bg);
161 evas_object_show(bg);
163 plug = elm_plug_add(win);
164 evas_object_event_callback_add(elm_plug_image_object_get(plug), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL);
165 evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL, _timer_del, NULL);
166 if (!elm_plug_connect(plug, "ello", 0, EINA_FALSE))
168 printf("Cannot connect plug\n");
172 evas_object_smart_callback_add(plug, "image,deleted", cb_plug_disconnected, NULL);
173 evas_object_smart_callback_add(plug, "image,resized", cb_plug_resized, NULL);
175 evas_object_resize(plug, 380, 500);
176 evas_object_move(plug, 10, 10);
177 evas_object_show(plug);
179 create_handles(elm_plug_image_object_get(plug));
181 evas_object_resize(win, 400, 600);
182 evas_object_show(win);