2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
9 static int try_num = 0;
12 _timer_del(void *data __UNUSED__,
15 void *event_info __UNUSED__)
17 Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
19 ecore_timer_del(timer);
23 cb_plug_connect(void *data)
25 Evas_Object *obj = data;
28 if (!obj) return ECORE_CALLBACK_CANCEL;
31 if (try_num > MAX_TRY) return ECORE_CALLBACK_CANCEL;
33 timer= evas_object_data_get(obj, "test-timer");
34 if (!timer) return ECORE_CALLBACK_CANCEL;
36 if (elm_plug_connect(obj, "ello", 0, EINA_FALSE))
38 printf("plug connect to server[ello]\n");
39 return ECORE_CALLBACK_CANCEL;
42 ecore_timer_interval_set(timer, 1);
43 return ECORE_CALLBACK_RENEW;
47 cb_plug_disconnected(void *data __UNUSED__,
49 void *event_info __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_mouse_down(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
65 Evas_Event_Mouse_Down *ev = event_info;
67 if (ev->button == 1) elm_object_focus_set(obj, EINA_TRUE);
71 cb_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
73 Evas_Event_Mouse_Move *ev = event_info;
74 Evas_Object *orig = data;
79 if (!ev->buttons) return;
80 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
82 x + (ev->cur.canvas.x - ev->prev.output.x),
83 y + (ev->cur.canvas.y - ev->prev.output.y));
84 evas_object_image_size_get(orig, &w, &h);
86 evas_object_map_enable_set(orig, EINA_TRUE);
87 evas_object_raise(orig);
88 for (i = 0; i < 4; i++)
93 snprintf(key, sizeof(key), "h-%i\n", i);
94 hand = evas_object_data_get(orig, key);
95 evas_object_raise(hand);
96 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
99 evas_map_point_coord_set(p, i, x, y, 0);
100 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
101 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
102 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
103 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
105 evas_object_map_set(orig, p);
110 create_handles(Evas_Object *obj)
113 Evas_Coord x, y, w, h;
115 evas_object_geometry_get(obj, &x, &y, &w, &h);
116 for (i = 0; i < 4; i++)
122 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
123 evas_object_resize(hand, 31, 31);
124 snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get());
125 evas_object_image_file_set(hand, buf, NULL);
126 if (i == 0) evas_object_move(hand, x - 15, y - 15);
127 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
128 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
129 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
130 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
131 evas_object_show(hand);
132 snprintf(key, sizeof(key), "h-%i\n", i);
133 evas_object_data_set(obj, key, hand);
138 test_win_plug(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
140 Evas_Object *win, *bg, *plug;
143 win = elm_win_add(NULL, "window-plug", ELM_WIN_BASIC);
144 elm_win_title_set(win, "Window Plug");
145 elm_win_autodel_set(win, EINA_TRUE);
147 bg = elm_bg_add(win);
148 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
149 elm_bg_file_set(bg, buf, NULL);
150 elm_win_resize_object_add(win, bg);
151 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
152 evas_object_show(bg);
154 plug = elm_plug_add(win);
155 evas_object_event_callback_add(elm_plug_image_object_get(plug), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL);
156 evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL, _timer_del, NULL);
157 if (!elm_plug_connect(plug, "ello", 0, EINA_FALSE))
159 printf("Cannot connect plug\n");
163 evas_object_smart_callback_add(plug, "image.deleted", cb_plug_disconnected, NULL);
165 evas_object_resize(plug, 380, 500);
166 evas_object_move(plug, 10, 10);
167 evas_object_show(plug);
169 create_handles(elm_plug_image_object_get(plug));
171 evas_object_resize(win, 400, 600);
172 evas_object_show(win);