aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-12 06:20:01 +1000
committerDavid Walter Seikel2014-05-12 06:20:01 +1000
commitca86e61a1545c604e67050e395f9b3cad4fc94f0 (patch)
tree36d44ed762ba03b5e115aca8cf36a57c40d11501 /src/libraries
parentStop internal windows going under the toolbar. (diff)
downloadSledjHamr-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/libraries')
-rw-r--r--src/libraries/winFang.c43
-rw-r--r--src/libraries/winFang.edc4
-rw-r--r--src/libraries/winFang.h3
3 files changed, 39 insertions, 11 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
4static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 4static 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
302void 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
301void winFangDel(winFang *win) 326void 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
64winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); 64winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world);
65void winFangHide(winFang *win); 65void winFangHide(winFang *win);
66void winFangShow(winFang *win); 66void winFangShow(winFang *win);
67void winFangCalcMinSize(winFang *win);
67void winFangDel(winFang *win); 68void winFangDel(winFang *win);
68 69
69Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title); 70Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title);