Edje text: Added size_range to limit the font size range.
This lets you limit the allowed sizes of the TEXT part (font sizes) to a specific range. This is especially useful in combination with the "fit" property. SVN revision: 57395
This commit is contained in:
parent
54f4d4bf2f
commit
7bf5ba8a7b
|
@ -41,3 +41,10 @@
|
|||
2011-02-25 Jihoon Kim
|
||||
|
||||
* Add edje_object_part_text_cursor_pos_{set,get} API
|
||||
|
||||
2011-02-27 Tom Hacohen (TAsn)
|
||||
|
||||
* Added size_range property to TEXT parts in edje files.
|
||||
This lets you limit the size of the font that will be used.
|
||||
Especially useful when using fit.
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ static void st_collections_group_parts_part_description_text_font(void);
|
|||
static void st_collections_group_parts_part_description_text_style(void);
|
||||
static void st_collections_group_parts_part_description_text_repch(void);
|
||||
static void st_collections_group_parts_part_description_text_size(void);
|
||||
static void st_collections_group_parts_part_description_text_size_range(void);
|
||||
static void st_collections_group_parts_part_description_text_fit(void);
|
||||
static void st_collections_group_parts_part_description_text_min(void);
|
||||
static void st_collections_group_parts_part_description_text_max(void);
|
||||
|
@ -449,6 +450,7 @@ New_Statement_Handler statement_handlers[] =
|
|||
{"collections.group.parts.part.description.text.style", st_collections_group_parts_part_description_text_style},
|
||||
{"collections.group.parts.part.description.text.repch", st_collections_group_parts_part_description_text_repch},
|
||||
{"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size},
|
||||
{"collections.group.parts.part.description.text.size_range", st_collections_group_parts_part_description_text_size_range},
|
||||
{"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit},
|
||||
{"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min},
|
||||
{"collections.group.parts.part.description.text.max", st_collections_group_parts_part_description_text_max},
|
||||
|
@ -5341,6 +5343,54 @@ st_collections_group_parts_part_description_text_size(void)
|
|||
ed->text.size = parse_int_range(0, 0, 255);
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
|
||||
@property
|
||||
size_range
|
||||
@parameters
|
||||
[font min size in points (pt)] [font max size in points (pt)]
|
||||
@effect
|
||||
Sets the allowed font size for the text part. Setting min and max to 0
|
||||
means we won't restrict the sizing (default).
|
||||
@endproperty
|
||||
@since 1.1.0
|
||||
*/
|
||||
static void
|
||||
st_collections_group_parts_part_description_text_size_range(void)
|
||||
{
|
||||
Edje_Part_Collection *pc;
|
||||
Edje_Part *ep;
|
||||
Edje_Part_Description_Text *ed;
|
||||
|
||||
check_arg_count(2);
|
||||
|
||||
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||
ep = pc->parts[pc->parts_count - 1];
|
||||
|
||||
if ((ep->type != EDJE_PART_TYPE_TEXT) &&
|
||||
(ep->type != EDJE_PART_TYPE_TEXTBLOCK))
|
||||
{
|
||||
ERR("%s: Error. parse error %s:%i. "
|
||||
"text attributes in non-TEXT part.",
|
||||
progname, file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
ed = (Edje_Part_Description_Text*) ep->default_desc;
|
||||
if (ep->other.desc_count) ed = (Edje_Part_Description_Text*) ep->other.desc[ep->other.desc_count - 1];
|
||||
|
||||
ed->text.size_range_min = parse_int_range(0, 0, 255);
|
||||
ed->text.size_range_max = parse_int_range(1, 0, 255);
|
||||
if (ed->text.size_range_min > ed->text.size_range_max)
|
||||
{
|
||||
ERR("%s: Error. parse error %s:%i. "
|
||||
"min size is bigger than max size.",
|
||||
progname, file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
|
||||
|
|
|
@ -563,6 +563,8 @@ _edje_edd_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size_range_min", text.size_range_min, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size_range_max", text.size_range_max, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR);
|
||||
|
@ -593,6 +595,8 @@ _edje_edd_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size_range_min", text.size_range_min, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size_range_max", text.size_range_max, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR);
|
||||
|
|
|
@ -862,6 +862,8 @@ struct _Edje_Part_Description_Spec_Text
|
|||
unsigned char min_y; /* if text size should be part min size */
|
||||
unsigned char max_x; /* if text size should be part max size */
|
||||
unsigned char max_y; /* if text size should be part max size */
|
||||
int size_range_min;
|
||||
int size_range_max; /* -1 means, no bound. */
|
||||
};
|
||||
|
||||
struct _Edje_Part_Description_Spec_Box
|
||||
|
|
|
@ -539,9 +539,17 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
|||
size = current - 1;
|
||||
}
|
||||
}
|
||||
if (size < 1) size = 1;
|
||||
|
||||
if (!chosen_desc->text.fit_x)
|
||||
/* Make sure the size is in range */
|
||||
if (size < 1)
|
||||
size = 1;
|
||||
else if ((size > chosen_desc->text.size_range_max) &&
|
||||
(chosen_desc->text.size_range_max > 0))
|
||||
size = chosen_desc->text.size_range_max;
|
||||
else if (size < chosen_desc->text.size_range_min)
|
||||
size = chosen_desc->text.size_range_min;
|
||||
|
||||
/* Handle ellipsis */
|
||||
{
|
||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||
else evas_object_text_font_source_set(ep->object, NULL);
|
||||
|
|
Loading…
Reference in New Issue