Enlightenment CVS committal Author : raster Project : e17 Module : libs/edje
Dir : e17/libs/edje/src/lib Modified Files: Edje.h edje_calc.c edje_private.h edje_util.c Log Message: allow code to specify an aspect for swallowed objects =================================================================== RCS file: /cvs/e/e17/libs/edje/src/lib/Edje.h,v retrieving revision 1.44 retrieving revision 1.45 diff -u -3 -r1.44 -r1.45 --- Edje.h 17 Jan 2006 02:41:25 -0000 1.44 +++ Edje.h 23 Jul 2006 13:50:02 -0000 1.45 @@ -175,7 +175,8 @@ EAPI void edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size); EAPI void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); EAPI void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh); - + EAPI void edje_extern_object_aspect_set(Evas_Object *obj, Evas_Coord aw, Evas_Coord ah); + /* edje_smart.c */ EAPI Evas_Object *edje_object_add (Evas *evas); =================================================================== RCS file: /cvs/e/e17/libs/edje/src/lib/edje_calc.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -3 -r1.81 -r1.82 --- edje_calc.c 17 Jul 2006 19:45:38 -0000 1.81 +++ edje_calc.c 23 Jul 2006 13:50:02 -0000 1.82 @@ -291,7 +291,7 @@ if ((params->h > 0) && (((flags | ep->calculated) & FLAG_XY) == FLAG_XY)) { - double aspect; + double aspect, amax, amin; double new_w, new_h, want_x, want_y, want_w, want_h; want_x = params->x; @@ -301,52 +301,60 @@ want_h = new_h = params->h; aspect = (double)params->w / (double)params->h; + amax = desc->aspect.max; + amin = desc->aspect.min; + if ((ep->swallow_params.aspect.w > 0) && + (ep->swallow_params.aspect.h > 0)) + amin = amax = + (double)ep->swallow_params.aspect.w / + (double)ep->swallow_params.aspect.h; + if (desc->aspect.prefer == EDJE_ASPECT_PREFER_NONE) /* keep both dimensions in check */ { /* adjust for max aspect (width / height) */ - if ((desc->aspect.max > 0.0) && (aspect > desc->aspect.max)) + if ((amax > 0.0) && (aspect > amax)) { - new_h = (params->w / desc->aspect.max); - new_w = (params->h * desc->aspect.max); + new_h = (params->w / amax); + new_w = (params->h * amax); } /* adjust for min aspect (width / height) */ - if ((desc->aspect.min > 0.0) && (aspect < desc->aspect.min)) + if ((amin > 0.0) && (aspect < amin)) { - new_h = (params->w / desc->aspect.min); - new_w = (params->h * desc->aspect.min); + new_h = (params->w / amin); + new_w = (params->h * amin); } } /* prefer vertical size as determiner */ else if (desc->aspect.prefer == EDJE_ASPECT_PREFER_VERTICAL) /* keep both dimensions in check */ { /* adjust for max aspect (width / height) */ - if ((desc->aspect.max > 0.0) && (aspect > desc->aspect.max)) - new_w = (params->h * desc->aspect.max); + if ((amax > 0.0) && (aspect > amax)) + new_w = (params->h * amax); /* adjust for min aspect (width / height) */ - if ((desc->aspect.min > 0.0) && (aspect < desc->aspect.min)) - new_w = (params->h * desc->aspect.min); + if ((amin > 0.0) && (aspect < amin)) + new_w = (params->h * amin); } /* prefer horizontal size as determiner */ else if (desc->aspect.prefer == EDJE_ASPECT_PREFER_HORIZONTAL) /* keep both dimensions in check */ { /* adjust for max aspect (width / height) */ - if ((desc->aspect.max > 0.0) && (aspect > desc->aspect.max)) - new_h = (params->w / desc->aspect.max); + if ((amax > 0.0) && (aspect > amax)) + new_h = (params->w / amax); /* adjust for min aspect (width / height) */ - if ((desc->aspect.min > 0.0) && (aspect < desc->aspect.min)) - new_h = (params->w / desc->aspect.min); + if ((amin > 0.0) && (aspect < amin)) + new_h = (params->w / amin); } else if (desc->aspect.prefer == EDJE_ASPECT_PREFER_BOTH) /* keep both dimensions in check */ { /* adjust for max aspect (width / height) */ - if ((desc->aspect.max > 0.0) && (aspect > desc->aspect.max)) + if ((amax > 0.0) && (aspect > amax)) { - new_w = (params->h * desc->aspect.max); - new_h = (params->w / desc->aspect.max); + new_w = (params->h * amax); + new_h = (params->w / amax); } /* adjust for min aspect (width / height) */ - if ((desc->aspect.min > 0.0) && (aspect < desc->aspect.min)) + if ((amin > 0.0) && (aspect < amin)) { - new_w = (params->h * desc->aspect.min); - new_h = (params->w / desc->aspect.min); + new_w = (params->h * amin); + new_h = (params->w / amin); } } /* do real adjustment */ =================================================================== RCS file: /cvs/e/e17/libs/edje/src/lib/edje_private.h,v retrieving revision 1.110 retrieving revision 1.111 diff -u -3 -r1.110 -r1.111 --- edje_private.h 3 Jul 2006 06:15:05 -0000 1.110 +++ edje_private.h 23 Jul 2006 13:50:02 -0000 1.111 @@ -581,6 +581,9 @@ struct { int w, h; } min, max; + struct { + int w, h; + } aspect; } swallow_params; unsigned char calculated; unsigned char calculating; =================================================================== RCS file: /cvs/e/e17/libs/edje/src/lib/edje_util.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -3 -r1.79 -r1.80 --- edje_util.c 29 Apr 2006 14:15:16 -0000 1.79 +++ edje_util.c 23 Jul 2006 13:50:02 -0000 1.80 @@ -744,16 +744,20 @@ rp->swallow_params.max.h = h; } { - int w1, h1, w2, h2; + int w1, h1, w2, h2, aw, ah; w1 = (int)evas_object_data_get(obj_swallow, "\377 edje.minw"); h1 = (int)evas_object_data_get(obj_swallow, "\377 edje.minh"); w2 = (int)evas_object_data_get(obj_swallow, "\377 edje.maxw"); h2 = (int)evas_object_data_get(obj_swallow, "\377 edje.maxh"); + aw = (int)evas_object_data_get(obj_swallow, "\377 edje.aspw"); + ah = (int)evas_object_data_get(obj_swallow, "\377 edje.asph"); rp->swallow_params.min.w = w1; rp->swallow_params.min.h = h1; if (w2 > 0) rp->swallow_params.max.w = w2; if (h2 > 0) rp->swallow_params.max.h = h2; + if (aw > 0) rp->swallow_params.aspect.w = aw; + if (ah > 0) rp->swallow_params.aspect.h = ah; } ed->dirty = 1; _edje_recalc(ed); @@ -807,6 +811,33 @@ evas_object_data_set(obj, "\377 edje.maxh", (void *)mh); else evas_object_data_del(obj, "\377 edje.maxh"); +} + +/** Set the object aspect size + * @param obj A valid Evas_Object handle + * @param aw The aspect radio width + * @param ah The aspect ratio height + * + * This sets the desired aspect ratio to keep an object that will be swallowed + * by Edje. The width and height define a preferred size ASPECT and the + * object may be scaled to be larger or smaller, but retaining the relative + * scale of both aspwct width and height. + */ +EAPI void +edje_extern_object_aspect_set(Evas_Object *obj, Evas_Coord aw, Evas_Coord ah) +{ + int mw, mh; + + mw = aw; + mh = ah; + if (mw >= 0) + evas_object_data_set(obj, "\377 edje.aspw", (void *)mw); + else + evas_object_data_del(obj, "\377 edje.aspw"); + if (mh >= 0) + evas_object_data_set(obj, "\377 edje.asph", (void *)mh); + else + evas_object_data_del(obj, "\377 edje.asph"); } /** Unswallow an object ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs