summaryrefslogtreecommitdiff
path: root/legacy/edje
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2011-02-27 18:09:03 +0000
committerTom Hacohen <tom@stosb.com>2011-02-27 18:09:03 +0000
commit7bf5ba8a7bb3368d90e5e92968f29c5279b9a12d (patch)
tree175cbca4164affc5f40e0c74870f9827dfcb6214 /legacy/edje
parent54f4d4bf2f8e1dcc40da31a3947163e0465329b4 (diff)
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
Diffstat (limited to 'legacy/edje')
-rw-r--r--legacy/edje/ChangeLog7
-rw-r--r--legacy/edje/src/bin/edje_cc_handlers.c50
-rw-r--r--legacy/edje/src/lib/edje_data.c4
-rw-r--r--legacy/edje/src/lib/edje_private.h2
-rw-r--r--legacy/edje/src/lib/edje_text.c12
5 files changed, 73 insertions, 2 deletions
diff --git a/legacy/edje/ChangeLog b/legacy/edje/ChangeLog
index b41b55e..6f6b21e 100644
--- a/legacy/edje/ChangeLog
+++ b/legacy/edje/ChangeLog
@@ -41,3 +41,10 @@
412011-02-25 Jihoon Kim 412011-02-25 Jihoon Kim
42 42
43 * Add edje_object_part_text_cursor_pos_{set,get} API 43 * Add edje_object_part_text_cursor_pos_{set,get} API
44
452011-02-27 Tom Hacohen (TAsn)
46
47 * Added size_range property to TEXT parts in edje files.
48 This lets you limit the size of the font that will be used.
49 Especially useful when using fit.
50
diff --git a/legacy/edje/src/bin/edje_cc_handlers.c b/legacy/edje/src/bin/edje_cc_handlers.c
index 5836704..0c97d59 100644
--- a/legacy/edje/src/bin/edje_cc_handlers.c
+++ b/legacy/edje/src/bin/edje_cc_handlers.c
@@ -198,6 +198,7 @@ static void st_collections_group_parts_part_description_text_font(void);
198static void st_collections_group_parts_part_description_text_style(void); 198static void st_collections_group_parts_part_description_text_style(void);
199static void st_collections_group_parts_part_description_text_repch(void); 199static void st_collections_group_parts_part_description_text_repch(void);
200static void st_collections_group_parts_part_description_text_size(void); 200static void st_collections_group_parts_part_description_text_size(void);
201static void st_collections_group_parts_part_description_text_size_range(void);
201static void st_collections_group_parts_part_description_text_fit(void); 202static void st_collections_group_parts_part_description_text_fit(void);
202static void st_collections_group_parts_part_description_text_min(void); 203static void st_collections_group_parts_part_description_text_min(void);
203static void st_collections_group_parts_part_description_text_max(void); 204static void st_collections_group_parts_part_description_text_max(void);
@@ -449,6 +450,7 @@ New_Statement_Handler statement_handlers[] =
449 {"collections.group.parts.part.description.text.style", st_collections_group_parts_part_description_text_style}, 450 {"collections.group.parts.part.description.text.style", st_collections_group_parts_part_description_text_style},
450 {"collections.group.parts.part.description.text.repch", st_collections_group_parts_part_description_text_repch}, 451 {"collections.group.parts.part.description.text.repch", st_collections_group_parts_part_description_text_repch},
451 {"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size}, 452 {"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size},
453 {"collections.group.parts.part.description.text.size_range", st_collections_group_parts_part_description_text_size_range},
452 {"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit}, 454 {"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit},
453 {"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min}, 455 {"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min},
454 {"collections.group.parts.part.description.text.max", st_collections_group_parts_part_description_text_max}, 456 {"collections.group.parts.part.description.text.max", st_collections_group_parts_part_description_text_max},
@@ -5345,6 +5347,54 @@ st_collections_group_parts_part_description_text_size(void)
5345 @page edcref 5347 @page edcref
5346 5348
5347 @property 5349 @property
5350 size_range
5351 @parameters
5352 [font min size in points (pt)] [font max size in points (pt)]
5353 @effect
5354 Sets the allowed font size for the text part. Setting min and max to 0
5355 means we won't restrict the sizing (default).
5356 @endproperty
5357 @since 1.1.0
5358*/
5359static void
5360st_collections_group_parts_part_description_text_size_range(void)
5361{
5362 Edje_Part_Collection *pc;
5363 Edje_Part *ep;
5364 Edje_Part_Description_Text *ed;
5365
5366 check_arg_count(2);
5367
5368 pc = eina_list_data_get(eina_list_last(edje_collections));
5369 ep = pc->parts[pc->parts_count - 1];
5370
5371 if ((ep->type != EDJE_PART_TYPE_TEXT) &&
5372 (ep->type != EDJE_PART_TYPE_TEXTBLOCK))
5373 {
5374 ERR("%s: Error. parse error %s:%i. "
5375 "text attributes in non-TEXT part.",
5376 progname, file_in, line - 1);
5377 exit(-1);
5378 }
5379
5380 ed = (Edje_Part_Description_Text*) ep->default_desc;
5381 if (ep->other.desc_count) ed = (Edje_Part_Description_Text*) ep->other.desc[ep->other.desc_count - 1];
5382
5383 ed->text.size_range_min = parse_int_range(0, 0, 255);
5384 ed->text.size_range_max = parse_int_range(1, 0, 255);
5385 if (ed->text.size_range_min > ed->text.size_range_max)
5386 {
5387 ERR("%s: Error. parse error %s:%i. "
5388 "min size is bigger than max size.",
5389 progname, file_in, line - 1);
5390 exit(-1);
5391 }
5392}
5393
5394/**
5395 @page edcref
5396
5397 @property
5348 fit 5398 fit
5349 @parameters 5399 @parameters
5350 [horizontal] [vertical] 5400 [horizontal] [vertical]
diff --git a/legacy/edje/src/lib/edje_data.c b/legacy/edje/src/lib/edje_data.c
index b10c988..23881b7 100644
--- a/legacy/edje/src/lib/edje_data.c
+++ b/legacy/edje/src/lib/edje_data.c
@@ -563,6 +563,8 @@ _edje_edd_init(void)
563 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING); 563 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING);
564 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING); 564 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING);
565 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING); 565 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING);
566 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);
567 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);
566 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING); 568 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING);
567 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT); 569 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT);
568 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR); 570 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)
593 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING); 595 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING);
594 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING); 596 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING);
595 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT); 597 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT);
598 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);
599 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);
596 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR); 600 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR);
597 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR); 601 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR);
598 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR); 602 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR);
diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h
index 16e20e9..f2236be 100644
--- a/legacy/edje/src/lib/edje_private.h
+++ b/legacy/edje/src/lib/edje_private.h
@@ -862,6 +862,8 @@ struct _Edje_Part_Description_Spec_Text
862 unsigned char min_y; /* if text size should be part min size */ 862 unsigned char min_y; /* if text size should be part min size */
863 unsigned char max_x; /* if text size should be part max size */ 863 unsigned char max_x; /* if text size should be part max size */
864 unsigned char max_y; /* if text size should be part max size */ 864 unsigned char max_y; /* if text size should be part max size */
865 int size_range_min;
866 int size_range_max; /* -1 means, no bound. */
865}; 867};
866 868
867struct _Edje_Part_Description_Spec_Box 869struct _Edje_Part_Description_Spec_Box
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c
index 655288f..ba9ecb8 100644
--- a/legacy/edje/src/lib/edje_text.c
+++ b/legacy/edje/src/lib/edje_text.c
@@ -539,9 +539,17 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
539 size = current - 1; 539 size = current - 1;
540 } 540 }
541 } 541 }
542 if (size < 1) size = 1;
543 542
544 if (!chosen_desc->text.fit_x) 543 /* Make sure the size is in range */
544 if (size < 1)
545 size = 1;
546 else if ((size > chosen_desc->text.size_range_max) &&
547 (chosen_desc->text.size_range_max > 0))
548 size = chosen_desc->text.size_range_max;
549 else if (size < chosen_desc->text.size_range_min)
550 size = chosen_desc->text.size_range_min;
551
552 /* Handle ellipsis */
545 { 553 {
546 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); 554 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
547 else evas_object_text_font_source_set(ep->object, NULL); 555 else evas_object_text_font_source_set(ep->object, NULL);