aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/winFang.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/extantz/winFang.c')
-rw-r--r--src/extantz/winFang.c83
1 files changed, 58 insertions, 25 deletions
diff --git a/src/extantz/winFang.c b/src/extantz/winFang.c
index 3d2b6ef..3c4cc22 100644
--- a/src/extantz/winFang.c
+++ b/src/extantz/winFang.c
@@ -49,31 +49,22 @@ static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_
49 evas_map_free(p); 49 evas_map_free(p);
50} 50}
51 51
52static void create_handles(Evas_Object *obj) 52void winFangHide(winFang *win)
53{ 53{
54 int i; 54 int i;
55 Evas_Coord x, y, w, h;
56 55
57 evas_object_geometry_get(obj, &x, &y, &w, &h); 56 evas_object_hide(win->win);
58 for (i = 0; i < 4; i++) 57 for (i = 0; i < 4; i++)
59 { 58 evas_object_hide(win->hand[i]);
60 Evas_Object *hand; 59}
61 char buf[PATH_MAX];
62 char key[32];
63 60
64 hand = evas_object_image_filled_add(evas_object_evas_get(obj)); 61void winFangShow(winFang *win)
65 evas_object_resize(hand, 31, 31); 62{
66 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); 63 int i;
67 evas_object_image_file_set(hand, buf, NULL); 64
68 if (i == 0) evas_object_move(hand, x - 15, y - 15); 65 evas_object_show(win->win);
69 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15); 66 for (i = 0; i < 4; i++)
70 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15); 67 evas_object_show(win->hand[i]);
71 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
72 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
73 evas_object_show(hand);
74 snprintf(key, sizeof(key), "h-%i\n", i);
75 evas_object_data_set(obj, key, hand);
76 }
77} 68}
78 69
79winFang *winFangAdd(globals *ourGlobals) 70winFang *winFangAdd(globals *ourGlobals)
@@ -107,14 +98,56 @@ winFang *winFangAdd(globals *ourGlobals)
107 98
108void winFangComplete(globals *ourGlobals, winFang *win, int x, int y, int w, int h) 99void winFangComplete(globals *ourGlobals, winFang *win, int x, int y, int w, int h)
109{ 100{
101 Evas_Object *obj = elm_win_inlined_image_object_get(win->win);
102 Evas_Object *obj2 = evas_object_evas_get(obj);
103 char buf[PATH_MAX];
104 int i;
105
106 win->x = x;
107 win->y = y;
108 win->w = w;
109 win->h = h;
110 // image object for win is unlinked to its pos/size - so manual control 110 // image object for win is unlinked to its pos/size - so manual control
111 // this allows also for using map and other things with it. 111 // this allows also for using map and other things with it.
112 evas_object_move(elm_win_inlined_image_object_get(win->win), x, y); 112 evas_object_move(obj, x, y);
113 // Odd, it needs to be resized twice. WTF? 113 // Odd, it needs to be resized twice. WTF?
114 evas_object_resize(win->win, w, h); 114 evas_object_resize(win->win, w, h);
115 evas_object_resize(elm_win_inlined_image_object_get(win->win), w, h); 115 evas_object_resize(obj, w, h);
116 evas_object_show(win->win); 116 evas_object_show(win->win);
117 create_handles(elm_win_inlined_image_object_get(win->win)); 117
118 // Create corner handles.
119 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get());
120 for (i = 0; i < 4; i++)
121 {
122 char key[32];
123 int cx = x, cy = y;
124
125 if (i == 1) cx += w;
126 else if (i == 2) {cx += w; cy += h;}
127 else if (i == 3) cy += h;
128 snprintf(key, sizeof(key), "h-%i\n", i);
129#if 1
130 win->hand[i] = evas_object_image_filled_add(obj2);
131 evas_object_image_file_set(win->hand[i], buf, NULL);
132 evas_object_resize(win->hand[i], 31, 31);
133 evas_object_move(win->hand[i], cx - 15, cy - 15);
134 evas_object_data_set(obj, key, win->hand[i]);
135 evas_object_show(win->hand[i]);
136 evas_object_event_callback_add(win->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
137#else
138// TODO - No idea why, but using this version makes the window vanish when you click on a handle.
139 win->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, obj2,
140 evas_obj_image_filled_set(EINA_TRUE),
141 evas_obj_image_file_set(buf, NULL),
142 evas_obj_size_set(31, 31),
143 evas_obj_position_set(cx - 15, cy - 15),
144 eo_key_data_set(key, win->hand[i], NULL),
145 evas_obj_visibility_set(EINA_TRUE)
146 );
147 evas_object_event_callback_add(win->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
148 eo_unref(win->hand[i]);
149#endif
150 }
118} 151}
119 152
120void winFangDel(globals *ourGlobals, winFang *win) 153void winFangDel(globals *ourGlobals, winFang *win)