From ca86e61a1545c604e67050e395f9b3cad4fc94f0 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 12 May 2014 06:20:01 +1000 Subject: Try to calculate minimum winFang size, and fail coz no one else does. --- src/libraries/winFang.c | 43 ++++++++++++++++++++++++++++++++++--------- src/libraries/winFang.edc | 4 +++- src/libraries/winFang.h | 3 ++- 3 files changed, 39 insertions(+), 11 deletions(-) (limited to 'src/libraries') 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 @@ static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { - Evas_Object *img = win->win, *test; + Evas_Object *test; Eina_List *objs, *this; Evas_Coord mw, mh; int padding = 1, i = 0, overs[4][2]; // Sanity check. - if ((20 > w) || (20 > h)) + if ((win->mw > w) || (win->mh > h)) return; 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 // All good, do it. win->x = x; win->y = y; win->w = w; win->h = h; - evas_object_geometry_set(img, x, y, w, h); + evas_object_geometry_set(win->layout, x, y, w, h); + evas_object_resize(win->title, w, 15); + elm_layout_sizing_eval(win->layout); for (i = 0; i < 4; i++) { int cx = win->x, cy = win->y; @@ -61,14 +63,13 @@ static void _onHandleMove(void *data, Evas *evas, Evas_Object *obj, void *event_ Evas_Event_Mouse_Move *ev = event_info; winFang *win = data; Evas_Coord x, y, w, h, dx, dy; - Evas_Object *img = win->win; int i; if (!ev->buttons) return; dx = ev->cur.canvas.x - ev->prev.output.x; dy = ev->cur.canvas.y - ev->prev.output.y; - evas_object_geometry_get(img, &x, &y, &w, &h); + evas_object_geometry_get(win->layout, &x, &y, &w, &h); for (i = 0; i < 4; i++) { if (obj == win->hand[i]) @@ -106,14 +107,13 @@ static void _onBgMove(void *data, Evas *evas, Evas_Object *obj, void *event_info { Evas_Event_Mouse_Move *ev = event_info; winFang *win = data; - Evas_Object *img = win->win; Evas_Coord x, y, w, h; if (1 != ev->buttons) return; // Looks like ePhysics wont cooperate about coords and other things, so plan B. - evas_object_geometry_get(img, &x, &y, &w, &h); + evas_object_geometry_get(win->layout, &x, &y, &w, &h); _checkWindowBounds(win, x + ev->cur.canvas.x - ev->prev.output.x, y + ev->cur.canvas.y - ev->prev.output.y, w, h); } @@ -250,8 +250,8 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch } result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->layout, - evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), - evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), + evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), + evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), evas_obj_visibility_set(EINA_TRUE) ); 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 evas_object_resize(result->win, result->w, result->h); evas_object_show(result->win); + winFangCalcMinSize(result); return result; } +void winFangCalcMinSize(winFang *win) +{ + Evas_Object *edje = elm_layout_edje_get(win->layout); + int w, h; + + // Would be nice if everything properly set their minimums, but they don't. + // Actually it looks like BOX gets it's minimum width set to the width of the window. + win->mw = 0; win->mh = 0; + evas_object_size_hint_min_get(edje_object_part_object_get(edje, WF_BOX), &w, &h); + if (w > win->mw) win->mw = w; + if (h > win->mh) win->mh = h; + // SWALLOW just returns 0. + evas_object_size_hint_min_get(edje_object_part_object_get(edje, WF_SWALLOW), &w, &h); + if (w > win->mw) win->mw = w; + if (h > win->mh) win->mh = h; + if (win->title) + { + // This at least returns proper values. + evas_object_size_hint_min_get(win->title, &w, &h); + if (w > win->mw) win->mw = w; + win->mh += h; + } +} + void winFangDel(winFang *win) { 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 description { state: "default" 0.0; + fixed: 0 1; visible: 0; } @@ -90,6 +91,7 @@ collections description { state: "default" 0.0; + fixed: 0 0; box{layout: "vertical";} rel1 { @@ -127,7 +129,7 @@ collections description { state: "default" 0.0; - fixed: 1 1; + fixed: 0 0; rel1 { 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 EPhysics_Body *body; Eina_Clist widgets; Eina_Clist winFangs; - int x, y, w, h; + int x, y, w, h, mw, mh; Evas_Object *hand[4]; @@ -64,6 +64,7 @@ typedef struct _Widget winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); void winFangHide(winFang *win); void winFangShow(winFang *win); +void winFangCalcMinSize(winFang *win); void winFangDel(winFang *win); Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title); -- cgit v1.1