diff options
Diffstat (limited to '')
-rw-r--r-- | src/libraries/winFang.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c index 0d1137f..560145b 100644 --- a/src/libraries/winFang.c +++ b/src/libraries/winFang.c | |||
@@ -3,13 +3,13 @@ | |||
3 | 3 | ||
4 | static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) | 4 | static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) |
5 | { | 5 | { |
6 | Evas_Object *img = win->win, *test; | 6 | Evas_Object *test; |
7 | Eina_List *objs, *this; | 7 | Eina_List *objs, *this; |
8 | Evas_Coord mw, mh; | 8 | Evas_Coord mw, mh; |
9 | int padding = 1, i = 0, overs[4][2]; | 9 | int padding = 1, i = 0, overs[4][2]; |
10 | 10 | ||
11 | // Sanity check. | 11 | // Sanity check. |
12 | if ((20 > w) || (20 > h)) | 12 | if ((win->mw > w) || (win->mh > h)) |
13 | return; | 13 | return; |
14 | 14 | ||
15 | overs[0][0] = x - padding; overs[0][1] = y - padding; | 15 | overs[0][0] = x - padding; overs[0][1] = y - padding; |
@@ -44,7 +44,9 @@ static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Co | |||
44 | // All good, do it. | 44 | // All good, do it. |
45 | win->x = x; win->y = y; | 45 | win->x = x; win->y = y; |
46 | win->w = w; win->h = h; | 46 | win->w = w; win->h = h; |
47 | evas_object_geometry_set(img, x, y, w, h); | 47 | evas_object_geometry_set(win->layout, x, y, w, h); |
48 | evas_object_resize(win->title, w, 15); | ||
49 | elm_layout_sizing_eval(win->layout); | ||
48 | for (i = 0; i < 4; i++) | 50 | for (i = 0; i < 4; i++) |
49 | { | 51 | { |
50 | int cx = win->x, cy = win->y; | 52 | int cx = win->x, cy = win->y; |
@@ -61,14 +63,13 @@ static void _onHandleMove(void *data, Evas *evas, Evas_Object *obj, void *event_ | |||
61 | Evas_Event_Mouse_Move *ev = event_info; | 63 | Evas_Event_Mouse_Move *ev = event_info; |
62 | winFang *win = data; | 64 | winFang *win = data; |
63 | Evas_Coord x, y, w, h, dx, dy; | 65 | Evas_Coord x, y, w, h, dx, dy; |
64 | Evas_Object *img = win->win; | ||
65 | int i; | 66 | int i; |
66 | 67 | ||
67 | if (!ev->buttons) return; | 68 | if (!ev->buttons) return; |
68 | 69 | ||
69 | dx = ev->cur.canvas.x - ev->prev.output.x; | 70 | dx = ev->cur.canvas.x - ev->prev.output.x; |
70 | dy = ev->cur.canvas.y - ev->prev.output.y; | 71 | dy = ev->cur.canvas.y - ev->prev.output.y; |
71 | evas_object_geometry_get(img, &x, &y, &w, &h); | 72 | evas_object_geometry_get(win->layout, &x, &y, &w, &h); |
72 | for (i = 0; i < 4; i++) | 73 | for (i = 0; i < 4; i++) |
73 | { | 74 | { |
74 | if (obj == win->hand[i]) | 75 | if (obj == win->hand[i]) |
@@ -106,14 +107,13 @@ static void _onBgMove(void *data, Evas *evas, Evas_Object *obj, void *event_info | |||
106 | { | 107 | { |
107 | Evas_Event_Mouse_Move *ev = event_info; | 108 | Evas_Event_Mouse_Move *ev = event_info; |
108 | winFang *win = data; | 109 | winFang *win = data; |
109 | Evas_Object *img = win->win; | ||
110 | Evas_Coord x, y, w, h; | 110 | Evas_Coord x, y, w, h; |
111 | 111 | ||
112 | if (1 != ev->buttons) return; | 112 | if (1 != ev->buttons) return; |
113 | 113 | ||
114 | // Looks like ePhysics wont cooperate about coords and other things, so plan B. | 114 | // Looks like ePhysics wont cooperate about coords and other things, so plan B. |
115 | 115 | ||
116 | evas_object_geometry_get(img, &x, &y, &w, &h); | 116 | evas_object_geometry_get(win->layout, &x, &y, &w, &h); |
117 | _checkWindowBounds(win, x + ev->cur.canvas.x - ev->prev.output.x, y + ev->cur.canvas.y - ev->prev.output.y, w, h); | 117 | _checkWindowBounds(win, x + ev->cur.canvas.x - ev->prev.output.x, y + ev->cur.canvas.y - ev->prev.output.y, w, h); |
118 | } | 118 | } |
119 | 119 | ||
@@ -250,8 +250,8 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch | |||
250 | } | 250 | } |
251 | 251 | ||
252 | result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->layout, | 252 | result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->layout, |
253 | evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), | 253 | evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), |
254 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), | 254 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), |
255 | evas_obj_visibility_set(EINA_TRUE) | 255 | evas_obj_visibility_set(EINA_TRUE) |
256 | ); | 256 | ); |
257 | elm_object_style_set(result->title, "slide_bounce"); | 257 | elm_object_style_set(result->title, "slide_bounce"); |
@@ -294,10 +294,35 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch | |||
294 | 294 | ||
295 | evas_object_resize(result->win, result->w, result->h); | 295 | evas_object_resize(result->win, result->w, result->h); |
296 | evas_object_show(result->win); | 296 | evas_object_show(result->win); |
297 | winFangCalcMinSize(result); | ||
297 | 298 | ||
298 | return result; | 299 | return result; |
299 | } | 300 | } |
300 | 301 | ||
302 | void winFangCalcMinSize(winFang *win) | ||
303 | { | ||
304 | Evas_Object *edje = elm_layout_edje_get(win->layout); | ||
305 | int w, h; | ||
306 | |||
307 | // Would be nice if everything properly set their minimums, but they don't. | ||
308 | // Actually it looks like BOX gets it's minimum width set to the width of the window. | ||
309 | win->mw = 0; win->mh = 0; | ||
310 | evas_object_size_hint_min_get(edje_object_part_object_get(edje, WF_BOX), &w, &h); | ||
311 | if (w > win->mw) win->mw = w; | ||
312 | if (h > win->mh) win->mh = h; | ||
313 | // SWALLOW just returns 0. | ||
314 | evas_object_size_hint_min_get(edje_object_part_object_get(edje, WF_SWALLOW), &w, &h); | ||
315 | if (w > win->mw) win->mw = w; | ||
316 | if (h > win->mh) win->mh = h; | ||
317 | if (win->title) | ||
318 | { | ||
319 | // This at least returns proper values. | ||
320 | evas_object_size_hint_min_get(win->title, &w, &h); | ||
321 | if (w > win->mw) win->mw = w; | ||
322 | win->mh += h; | ||
323 | } | ||
324 | } | ||
325 | |||
301 | void winFangDel(winFang *win) | 326 | void winFangDel(winFang *win) |
302 | { | 327 | { |
303 | winFang *wf; | 328 | winFang *wf; |