From e89c590b0d72bdc5dd8cc4de115095516cdc6938 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 21 Feb 2010 06:53:44 +0000 Subject: [PATCH] add border_scale option for images - image border will scale based on edje scale factors. this is independant of scale: per part. SVN revision: 46341 --- legacy/edje/src/bin/edje_cc_handlers.c | 41 ++++++++++++++++++++++++++ legacy/edje/src/lib/edje_calc.c | 4 +++ legacy/edje/src/lib/edje_data.c | 1 + legacy/edje/src/lib/edje_private.h | 1 + 4 files changed, 47 insertions(+) diff --git a/legacy/edje/src/bin/edje_cc_handlers.c b/legacy/edje/src/bin/edje_cc_handlers.c index b7db13770d..fdb727a78f 100644 --- a/legacy/edje/src/bin/edje_cc_handlers.c +++ b/legacy/edje/src/bin/edje_cc_handlers.c @@ -162,6 +162,7 @@ static void st_collections_group_parts_part_description_image_normal(void); static void st_collections_group_parts_part_description_image_tween(void); static void st_collections_group_parts_part_description_image_border(void); static void st_collections_group_parts_part_description_image_middle(void); +static void st_collections_group_parts_part_description_image_border_scale(void); static void st_collections_group_parts_part_description_image_scale_hint(void); static void st_collections_group_parts_part_description_fill_smooth(void); static void st_collections_group_parts_part_description_fill_origin_relative(void); @@ -383,6 +384,7 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.image.images.image", st_images_image}, /* dup */ {"collections.group.parts.part.description.image.border", st_collections_group_parts_part_description_image_border}, {"collections.group.parts.part.description.image.middle", st_collections_group_parts_part_description_image_middle}, + {"collections.group.parts.part.description.image.border_scale", st_collections_group_parts_part_description_image_border_scale}, {"collections.group.parts.part.description.image.scale_hint", st_collections_group_parts_part_description_image_scale_hint}, {"collections.group.parts.part.description.fill.smooth", st_collections_group_parts_part_description_fill_smooth}, {"collections.group.parts.part.description.fill.origin.relative", st_collections_group_parts_part_description_fill_origin_relative}, @@ -4111,6 +4113,45 @@ st_collections_group_parts_part_description_image_middle(void) NULL); } +/** + @page edcref + @property + scale + @parameters + 0, 1 + @effect + If border is set, this value tells Edje if the border should be scaled + by the object/global edje scale factors + @endproperty +*/ +static void +st_collections_group_parts_part_description_image_border_scale(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description *ed; + + check_arg_count(1); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = eina_list_data_get(eina_list_last(pc->parts)); + + if (ep->type != EDJE_PART_TYPE_IMAGE) + { + ERR("%s: Error. parse error %s:%i. " + "image attributes in non-IMAGE part.", + progname, file_in, line - 1); + exit(-1); + } + + ed = ep->default_desc; + if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc)); + ed->border.scale = parse_enum(0, + "1", 0, + "0", 1, + NULL); +} + /** @page edcref @property diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c index e700f97216..2f688debdf 100644 --- a/legacy/edje/src/lib/edje_calc.c +++ b/legacy/edje/src/lib/edje_calc.c @@ -1501,10 +1501,14 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj { int image_id; int image_count, image_num; + FLOAT_T sc; + sc = ed->scale; + if (sc == 0.0) sc = _edje_scale; evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y, p3->type.common.fill.w, p3->type.common.fill.h); evas_object_image_smooth_scale_set(ep->object, p3->smooth); + evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc)); evas_object_image_border_set(ep->object, p3->type.common.spec.image.l, p3->type.common.spec.image.r, p3->type.common.spec.image.t, p3->type.common.spec.image.b); if (chosen_desc->border.no_fill == 0) diff --git a/legacy/edje/src/lib/edje_data.c b/legacy/edje/src/lib/edje_data.c index 8ed33ade49..7f63c2c272 100644 --- a/legacy/edje/src/lib/edje_data.c +++ b/legacy/edje/src/lib/edje_data.c @@ -284,6 +284,7 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "border.t", border.t, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "border.b", border.b, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "border.no_fill", border.no_fill, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "border.scale", border.scale, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fill.smooth", fill.smooth, EET_T_CHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fill.pos_rel_x", fill.pos_rel_x, EDJE_T_FLOAT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fill.pos_abs_x", fill.pos_abs_x, EET_T_INT); diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index ebdeab97ed..e72886b245 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -609,6 +609,7 @@ struct _Edje_Part_Description struct { int l, r, t, b; /* border scaling on image fill */ unsigned char no_fill; /* do we fill the center of the image if bordered? 1 == NO!!!! */ + unsigned char scale; /* scale image border by same as scale factor */ } border; struct {