diff options
author | David Walter Seikel | 2014-05-12 06:20:01 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-12 06:20:01 +1000 |
commit | ca86e61a1545c604e67050e395f9b3cad4fc94f0 (patch) | |
tree | 36d44ed762ba03b5e115aca8cf36a57c40d11501 /src | |
parent | Stop internal windows going under the toolbar. (diff) | |
download | SledjHamr-ca86e61a1545c604e67050e395f9b3cad4fc94f0.zip SledjHamr-ca86e61a1545c604e67050e395f9b3cad4fc94f0.tar.gz SledjHamr-ca86e61a1545c604e67050e395f9b3cad4fc94f0.tar.bz2 SledjHamr-ca86e61a1545c604e67050e395f9b3cad4fc94f0.tar.xz |
Try to calculate minimum winFang size, and fail coz no one else does.
Diffstat (limited to 'src')
-rw-r--r-- | src/GuiLua/GuiLua.c | 1 | ||||
-rw-r--r-- | src/extantz/files.c | 1 | ||||
-rw-r--r-- | src/extantz/woMan.c | 2 | ||||
-rw-r--r-- | src/libraries/winFang.c | 43 | ||||
-rw-r--r-- | src/libraries/winFang.edc | 4 | ||||
-rw-r--r-- | src/libraries/winFang.h | 3 | ||||
-rw-r--r-- | src/purkle/purkle.c | 1 |
7 files changed, 44 insertions, 11 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index b25c60f..af7e2fd 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c | |||
@@ -202,6 +202,7 @@ static int widget(lua_State *L) | |||
202 | evas_obj_position_set(x, y) | 202 | evas_obj_position_set(x, y) |
203 | ); | 203 | ); |
204 | } | 204 | } |
205 | winFangCalcMinSize(win); | ||
205 | evas_object_smart_callback_add(wid->obj, "clicked", _on_click, wid); | 206 | evas_object_smart_callback_add(wid->obj, "clicked", _on_click, wid); |
206 | 207 | ||
207 | lua_pushlightuserdata(L, (void *) wid); | 208 | lua_pushlightuserdata(L, (void *) wid); |
diff --git a/src/extantz/files.c b/src/extantz/files.c index 799f1ac..d575fea 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c | |||
@@ -267,6 +267,7 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa | |||
267 | elm_layout_box_append(me->win, WF_BOX, vbox); | 267 | elm_layout_box_append(me->win, WF_BOX, vbox); |
268 | evas_object_show(vbox); | 268 | evas_object_show(vbox); |
269 | eo_unref(vbox); | 269 | eo_unref(vbox); |
270 | winFangCalcMinSize(me); | ||
270 | 271 | ||
271 | winFangHide(me); | 272 | winFangHide(me); |
272 | return me; | 273 | return me; |
diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index b2f7ee3..2a881ce 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c | |||
@@ -280,5 +280,7 @@ winFang *woMan_add(globals *ourGlobals) | |||
280 | elm_layout_box_append(me->win, WF_BOX, bt); | 280 | elm_layout_box_append(me->win, WF_BOX, bt); |
281 | eo_unref(bt); | 281 | eo_unref(bt); |
282 | 282 | ||
283 | winFangCalcMinSize(me); | ||
284 | |||
283 | return me; | 285 | return me; |
284 | } | 286 | } |
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; |
diff --git a/src/libraries/winFang.edc b/src/libraries/winFang.edc index 4b6f05d..6942aef 100644 --- a/src/libraries/winFang.edc +++ b/src/libraries/winFang.edc | |||
@@ -61,6 +61,7 @@ collections | |||
61 | 61 | ||
62 | description | 62 | description |
63 | { state: "default" 0.0; | 63 | { state: "default" 0.0; |
64 | fixed: 0 1; | ||
64 | visible: 0; | 65 | visible: 0; |
65 | } | 66 | } |
66 | 67 | ||
@@ -90,6 +91,7 @@ collections | |||
90 | description | 91 | description |
91 | { | 92 | { |
92 | state: "default" 0.0; | 93 | state: "default" 0.0; |
94 | fixed: 0 0; | ||
93 | box{layout: "vertical";} | 95 | box{layout: "vertical";} |
94 | rel1 | 96 | rel1 |
95 | { | 97 | { |
@@ -127,7 +129,7 @@ collections | |||
127 | 129 | ||
128 | description | 130 | description |
129 | { state: "default" 0.0; | 131 | { state: "default" 0.0; |
130 | fixed: 1 1; | 132 | fixed: 0 0; |
131 | rel1 | 133 | rel1 |
132 | { | 134 | { |
133 | relative: 0.0 0.0; | 135 | relative: 0.0 0.0; |
diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h index a247375..c8b355b 100644 --- a/src/libraries/winFang.h +++ b/src/libraries/winFang.h | |||
@@ -36,7 +36,7 @@ typedef struct _winFang | |||
36 | EPhysics_Body *body; | 36 | EPhysics_Body *body; |
37 | Eina_Clist widgets; | 37 | Eina_Clist widgets; |
38 | Eina_Clist winFangs; | 38 | Eina_Clist winFangs; |
39 | int x, y, w, h; | 39 | int x, y, w, h, mw, mh; |
40 | 40 | ||
41 | Evas_Object *hand[4]; | 41 | Evas_Object *hand[4]; |
42 | 42 | ||
@@ -64,6 +64,7 @@ typedef struct _Widget | |||
64 | winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); | 64 | winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); |
65 | void winFangHide(winFang *win); | 65 | void winFangHide(winFang *win); |
66 | void winFangShow(winFang *win); | 66 | void winFangShow(winFang *win); |
67 | void winFangCalcMinSize(winFang *win); | ||
67 | void winFangDel(winFang *win); | 68 | void winFangDel(winFang *win); |
68 | 69 | ||
69 | Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title); | 70 | Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title); |
diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c index 98bfd13..33f22b3 100644 --- a/src/purkle/purkle.c +++ b/src/purkle/purkle.c | |||
@@ -39,6 +39,7 @@ static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) | |||
39 | elm_obj_entry_editable_set(EINA_TRUE) | 39 | elm_obj_entry_editable_set(EINA_TRUE) |
40 | ); | 40 | ); |
41 | elm_layout_box_append(me->win, WF_BOX, wid->obj); | 41 | elm_layout_box_append(me->win, WF_BOX, wid->obj); |
42 | winFangCalcMinSize(me); | ||
42 | 43 | ||
43 | return me; | 44 | return me; |
44 | } | 45 | } |