Enlightenment CVS committal Author : lordchaos Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_iconbox.c ewl_image.c ewl_image.h Log Message: * Add a 'constrain' setting to Ewl_Image. If an image exceeds a certain size, proportionally constrain the size of the image to the 'constrain size'. Allows intelligent automatic scaling regardless of dimensions. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -3 -r1.57 -r1.58 --- ewl_iconbox.c 26 Oct 2005 11:02:23 -0000 1.57 +++ ewl_iconbox.c 29 Oct 2005 06:24:17 -0000 1.58 @@ -684,8 +684,7 @@ EWL_ICONBOX_ICON(ib)->icon_box_parent = iconbox; /* Set our parent */ - /*printf("Setting fill policy..\n");*/ - ewl_object_fill_policy_set(EWL_OBJECT(ib), EWL_FLAG_FILL_FILL); + //ewl_object_fill_policy_set(EWL_OBJECT(ib), EWL_FLAG_FILL_FILL); ewl_object_fill_policy_set(EWL_OBJECT(EWL_ICONBOX_ICON(ib)->floater), EWL_FLAG_FILL_SHRINK); ewl_container_child_append(EWL_CONTAINER(EWL_ICONBOX_ICON(ib)->floater), ib); @@ -693,10 +692,6 @@ /* Make the image */ /*printf("MMaking image..\n");*/ ewl_iconbox_icon_image_set(EWL_ICONBOX_ICON(ib), icon_file); - - - /* Put the image into the border */ - /*printf("Adding image to box..\n");*/ ewl_container_child_append(EWL_CONTAINER(ib), EWL_ICONBOX_ICON(ib)->image); @@ -746,8 +741,8 @@ void ewl_iconbox_icon_image_set(Ewl_IconBox_Icon* icon, char* filename) { - ewl_image_file_set(EWL_IMAGE(icon->image), filename, NULL); + ewl_image_constrain_set(EWL_IMAGE(icon->image), 64); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_image.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ewl_image.c 24 Oct 2005 00:39:25 -0000 1.15 +++ ewl_image.c 29 Oct 2005 06:24:17 -0000 1.16 @@ -77,6 +77,8 @@ i->sw = 1.0; i->sh = 1.0; + i->cs = 0; + i->tile.x = 0; i->tile.y = 0; i->tile.w = 0; @@ -167,6 +169,26 @@ } /** + * @param i: the image to change constrain setting + * @param size: the minimum constrain size + * @return Returns no value. + * @brief Set a size which, if the image is bigger than, scale proportionally + * + * Sets a size to scale to proportionally if the image exceeds this size + */ +void ewl_image_constrain_set(Ewl_Image* i, int size) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("i", i); + DCHECK_TYPE("i", i, "image"); + + i->cs = size; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + + +/** * @param i: the image to change proportional setting * @param p: the boolean indicator of proportionality * @return Returns no value. @@ -312,6 +334,14 @@ evas_object_image_size_get(i->image, &i->ow, &i->oh); } + /*Constrain settings*/ + if (i->cs && (i->ow > i->cs || i->oh > i->cs)) { + double cp = i->cs / (double)i->ow; + printf("Cp is %f\n", cp); + ewl_image_scale(i, cp,cp); + + } + evas_object_layer_set(i->image, ewl_widget_layer_sum_get(w)); if (w->fx_clip_box) evas_object_clip_set(i->image, w->fx_clip_box); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_image.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_image.h 24 Oct 2005 00:39:25 -0000 1.7 +++ ewl_image.h 29 Oct 2005 06:24:17 -0000 1.8 @@ -40,6 +40,7 @@ char proportional; int ow, oh; double sw, sh; + int cs; Evas_Coord aw, ah; struct { @@ -57,6 +58,7 @@ void ewl_image_scale_to(Ewl_Image *i, int w, int h); void ewl_image_tile_set(Ewl_Image *i, int x, int y, int w, int h); +void ewl_image_constrain_set(Ewl_Image* i, int size); /* * Internally used callbacks, override at your own risk. ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs