aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/edje
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-11-06 16:52:53 +0200
committerDaniel Hirt <hirt.danny@gmail.com>2018-11-06 18:33:56 +0200
commitface90632e7796c146b18e31a93c164cbda43122 (patch)
tree9f562a695f47b8ffd639a9a71e4baed1bd757bc0 /src/lib/edje
parentEfl text style: remove 'underline2_type' property (diff)
downloadefl-face90632e7796c146b18e31a93c164cbda43122.tar.gz
Canvas layout: support more Efl.Text.* with efl_part
This adds many Efl.Text.* that are useful for manipulating the underlying TEXTBLOCK object's propeties using efl_part. This has been implemented as part of the "user-defined" properties of the layout part, so that the changes on the part persist across load of different groups. Note that text styles have precedence over the TEXTBLOCK (Canvas.Text) object's properties. if an edc provides a style, the properties it manipulates as part of the "base:" string would not be affected by this API. In general, this helps reducing the amount of styles for objects (or modes of the same objects) that share the same setup, but are different in some properties (e.g. ellipsis, wrap etc). @feature Canvas layout: add text part "expand" property This adds "expansion modes", which are essentially the same as min/max hints in the edje part's 'description.text' fields. The user can then customize his widget to different modes without being forced to create a new edje group in the theme. Note that there is an added check in case one of the min/max text flags are provided from the theme. In such case, all flags from this new API will be ignored. This fortifies misuse where the flags are set both in theme and the API. @feature
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_load.c24
-rw-r--r--src/lib/edje/edje_part_text.c528
-rw-r--r--src/lib/edje/edje_private.h70
-rw-r--r--src/lib/edje/edje_textblock.c83
-rw-r--r--src/lib/edje/edje_util.c75
-rw-r--r--src/lib/edje/efl_canvas_layout_part_text.eo50
6 files changed, 803 insertions, 27 deletions
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index c974342fc7..6d865d4408 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1645,6 +1645,25 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
}
eina_stringshare_del(eud->u.string.text);
break;
+
+ case EDJE_USER_TEXT_STYLE:
+ {
+ Edje_Part_Text_Prop *prop;
+ EINA_LIST_FREE(eud->u.text_style.props, prop)
+ {
+ _canvas_layout_user_text_apply(eud, obj,
+ prop);
+ free(prop);
+ }
+ }
+ break;
+ case EDJE_USER_TEXT_EXPAND:
+ {
+ efl_canvas_layout_part_text_expand_set(
+ efl_part(obj, eud->part),
+ eud->u.text_expand.expand);
+ }
+ break;
}
if (eud) _edje_user_definition_remove(eud, child);
}
@@ -1840,10 +1859,15 @@ _edje_object_collect(Edje *ed)
edje_object_part_unswallow(NULL, eud->u.swallow.child);
break;
+ case EDJE_USER_TEXT_STYLE:
+ _canvas_layout_user_text_collect(ed, eud);
+ break;
+
case EDJE_USER_DRAG_STEP:
case EDJE_USER_DRAG_PAGE:
case EDJE_USER_DRAG_VALUE:
case EDJE_USER_DRAG_SIZE:
+ case EDJE_USER_TEXT_EXPAND:
break;
}
}
diff --git a/src/lib/edje/edje_part_text.c b/src/lib/edje/edje_part_text.c
index 6e8e231ae2..31678a3697 100644
--- a/src/lib/edje/edje_part_text.c
+++ b/src/lib/edje/edje_part_text.c
@@ -197,5 +197,533 @@ _efl_canvas_layout_part_text_efl_text_markup_cursor_markup_insert(Eo *obj,
// FIXME: entry should report the length of inserted text (after filtering)
}
+/* More Efl.Text.* API (@since 1.22) */
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_backing_type_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ Efl_Text_Style_Backing_Type type)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_NONE;
+ efl_text_backing_type_set(pd->rp->object, type);
+}
+
+EOLIAN static Efl_Text_Style_Backing_Type
+_efl_canvas_layout_part_text_efl_text_style_backing_type_get(const Eo *obj,
+ void *_pd EINA_UNUSED)
+{
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT)
+ return EFL_TEXT_STYLE_BACKING_TYPE_DISABLED;
+
+ return efl_text_backing_type_get(pd->rp->object);
+}
+
+#define TEXT_COLOR_IMPL(x, X) \
+EOLIAN static void \
+_efl_canvas_layout_part_text_efl_text_style_ ##x ##_color_set(Eo *obj, \
+ void *_pd EINA_UNUSED, \
+ unsigned char r, unsigned char g, unsigned char b, unsigned char a) \
+{ \
+ Edje_User_Defined *eud; \
+ \
+ PROXY_DATA_GET(obj, pd); \
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return; \
+ \
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part); \
+ \
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_COLOR_ ##X; \
+ efl_text_ ##x ##_color_set(pd->rp->object, r, g, b, a); \
+} \
+\
+EOLIAN static void \
+_efl_canvas_layout_part_text_efl_text_style_ ##x ##_color_get(const Eo *obj, \
+ void *_pd EINA_UNUSED, \
+ unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) \
+{ \
+ PROXY_DATA_GET(obj, pd); \
+ *r = *g = *b = *a = 0; \
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return; \
+ efl_text_ ##x ##_color_get(pd->rp->object, r, g, b, a); \
+}
+
+TEXT_COLOR_IMPL(backing, BACKING)
+TEXT_COLOR_IMPL(glow, GLOW)
+TEXT_COLOR_IMPL(glow2, GLOW2)
+TEXT_COLOR_IMPL(normal, NORMAL)
+TEXT_COLOR_IMPL(outline, OUTLINE)
+TEXT_COLOR_IMPL(shadow, SHADOW)
+TEXT_COLOR_IMPL(strikethrough, STRIKETHROUGH)
+TEXT_COLOR_IMPL(underline, UNDERLINE)
+TEXT_COLOR_IMPL(underline2, UNDERLINE2)
+TEXT_COLOR_IMPL(underline_dashed, UNDERLINE_DASHED)
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_effect_type_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ Efl_Text_Style_Effect_Type type)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_EFFECT_TYPE;
+ efl_text_effect_type_set(pd->rp->object, type);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_format_ellipsis_set(Eo *obj,
+ void *_pd EINA_UNUSED, double value)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_ELLIPSIS;
+ efl_text_ellipsis_set(pd->rp->object, value);
+}
+
+EOLIAN static double
+_efl_canvas_layout_part_text_efl_text_format_ellipsis_get(const Eo *obj,
+ void *_pd EINA_UNUSED)
+{
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return 0.0;
+
+ return efl_text_ellipsis_get(pd->rp->object);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_font_font_set(Eo *obj,
+ void *_pd EINA_UNUSED, const char *font, Efl_Font_Size size)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_FONT;
+ efl_text_font_set(pd->rp->object, font, size);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_font_font_get(const Eo *obj,
+ void *_pd EINA_UNUSED, const char **font, Efl_Font_Size *size)
+{
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ efl_text_font_get(pd->rp->object, font, size);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_shadow_direction_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ Efl_Text_Style_Shadow_Direction type)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_SHADOW_DIRECTION;
+ efl_text_shadow_direction_set(pd->rp->object, type);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_strikethrough_type_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ Efl_Text_Style_Strikethrough_Type type)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE;
+ efl_text_strikethrough_type_set(pd->rp->object, type);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_underline_type_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ Efl_Text_Style_Underline_Type type)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types = EDJE_PART_TEXT_PROP_UNDERLINE_TYPE;
+ efl_text_underline_type_set(pd->rp->object, type);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_underline_height_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ double value)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT;
+ efl_text_underline_height_set(pd->rp->object, value);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_underline_dashed_width_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ int value)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH;
+ efl_text_underline_dashed_width_set(pd->rp->object, value);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_style_underline_dashed_gap_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ int value)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP;
+ efl_text_underline_dashed_gap_set(pd->rp->object, value);
+}
+
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_format_wrap_set(Eo *obj,
+ void *_pd EINA_UNUSED, Efl_Text_Format_Wrap wrap)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
+
+ eud->u.text_style.types |= EDJE_PART_TEXT_PROP_WRAP;
+ efl_text_wrap_set(pd->rp->object, wrap);
+}
+
+EOLIAN static Efl_Text_Format_Wrap
+_efl_canvas_layout_part_text_efl_text_format_wrap_get(const Eo *obj,
+ void *_pd EINA_UNUSED)
+{
+ PROXY_DATA_GET(obj, pd);
+
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT)
+ return EFL_TEXT_FORMAT_WRAP_NONE;
+
+ return efl_text_wrap_get(pd->rp->object);
+}
+
+static Edje_Part_Text_Prop *
+_prop_new(Eina_List **props, Edje_Part_Text_Prop_Type type)
+{
+ Edje_Part_Text_Prop *prop;
+
+ prop = malloc(sizeof(*prop));
+ prop->type = type;
+
+ *props = eina_list_append(*props, prop);
+
+ return prop;
+}
+
+void
+_canvas_layout_user_text_collect(Edje *ed, Edje_User_Defined *eud)
+{
+ Edje_Real_Part *rp;
+ Eina_List **props = &eud->u.text_style.props;
+
+ rp = _edje_real_part_recursive_get(&ed, eud->part);
+ if (eud->u.text_style.types == EDJE_PART_TEXT_PROP_NONE) return;
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_BACKING_TYPE)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_BACKING_TYPE);
+ prop->val.backing = efl_text_backing_type_get(rp->object);
+ }
+#define STYLE_COLOR_COLLECT(x, X) \
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_COLOR_ ##X) \
+ { \
+ Edje_Part_Text_Prop *prop; \
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_COLOR_ ##X); \
+ efl_text_ ##x ##_color_get(rp->object, \
+ &prop->val.color.r, &prop->val.color.g, \
+ &prop->val.color.b, &prop->val.color.a); \
+ } \
+
+ STYLE_COLOR_COLLECT(backing, BACKING)
+ STYLE_COLOR_COLLECT(glow, GLOW)
+ STYLE_COLOR_COLLECT(glow2, GLOW2)
+ STYLE_COLOR_COLLECT(normal, NORMAL)
+ STYLE_COLOR_COLLECT(outline, OUTLINE)
+ STYLE_COLOR_COLLECT(shadow, SHADOW)
+ STYLE_COLOR_COLLECT(strikethrough, STRIKETHROUGH)
+ STYLE_COLOR_COLLECT(underline, UNDERLINE)
+ STYLE_COLOR_COLLECT(underline2, UNDERLINE2)
+ STYLE_COLOR_COLLECT(underline_dashed, UNDERLINE_DASHED)
+#undef STYLE_COLOR_COLLECT
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_EFFECT_TYPE)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_EFFECT_TYPE);
+ prop->val.effect = efl_text_effect_type_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_ELLIPSIS)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_ELLIPSIS);
+ prop->val.nd = efl_text_ellipsis_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_FONT)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_FONT);
+ efl_text_font_get(rp->object, &prop->val.font.font,
+ &prop->val.font.size);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_SHADOW_DIRECTION)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_SHADOW_DIRECTION);
+ prop->val.shadow = efl_text_shadow_direction_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE);
+ prop->val.strikethrough_type = efl_text_strikethrough_type_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP);
+ prop->val.ni = efl_text_underline_dashed_gap_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH);
+ prop->val.ni = efl_text_underline_dashed_width_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_TYPE)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_TYPE);
+ prop->val.ni = efl_text_underline_type_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT);
+ prop->val.ni = efl_text_underline_height_get(rp->object);
+ }
+
+ if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_WRAP)
+ {
+ Edje_Part_Text_Prop *prop;
+
+ prop = _prop_new(props, EDJE_PART_TEXT_PROP_WRAP);
+ prop->val.wrap = efl_text_wrap_get(rp->object);
+
+ }
+}
+
+void
+_canvas_layout_user_text_apply(Edje_User_Defined *eud, Eo *obj,
+ Edje_Part_Text_Prop *prop)
+{
+ switch (prop->type)
+ {
+
+ case EDJE_PART_TEXT_PROP_BACKING_TYPE:
+ efl_text_backing_type_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.backing);
+ break;
+
+#define STYLE_COLOR_CASE(x, X) \
+ case EDJE_PART_TEXT_PROP_COLOR_##X : \
+ efl_text_##x ##_color_set(efl_part(obj, \
+ eud->part), \
+ prop->val.color.r, \
+ prop->val.color.g, \
+ prop->val.color.b, \
+ prop->val.color.a); \
+ break;
+
+ STYLE_COLOR_CASE(backing, BACKING)
+ STYLE_COLOR_CASE(glow, GLOW)
+ STYLE_COLOR_CASE(glow2, GLOW2)
+ STYLE_COLOR_CASE(normal, NORMAL)
+ STYLE_COLOR_CASE(outline, OUTLINE)
+ STYLE_COLOR_CASE(shadow, SHADOW)
+ STYLE_COLOR_CASE(strikethrough, STRIKETHROUGH)
+ STYLE_COLOR_CASE(underline, UNDERLINE)
+ STYLE_COLOR_CASE(underline2, UNDERLINE2)
+ STYLE_COLOR_CASE(underline_dashed, UNDERLINE_DASHED)
+#undef STYLE_COLOR_CASE
+
+ case EDJE_PART_TEXT_PROP_EFFECT_TYPE:
+ efl_text_effect_type_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.effect);
+ break;
+
+ case EDJE_PART_TEXT_PROP_ELLIPSIS:
+ efl_text_ellipsis_set(efl_part(obj,
+ eud->part),
+ prop->val.nd);
+ break;
+
+ case EDJE_PART_TEXT_PROP_FONT:
+ efl_text_font_set(efl_part(obj,
+ eud->part),
+ prop->val.font.font,
+ prop->val.font.size);
+ break;
+
+ case EDJE_PART_TEXT_PROP_SHADOW_DIRECTION:
+ efl_text_shadow_direction_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.shadow);
+ break;
+
+ case EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE:
+ efl_text_strikethrough_type_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.strikethrough_type);
+ break;
+
+ case EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH:
+ efl_text_underline_dashed_width_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.ni);
+ break;
+
+ case EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP:
+ efl_text_underline_dashed_gap_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.ni);
+ break;
+
+ case EDJE_PART_TEXT_PROP_UNDERLINE_TYPE:
+ efl_text_underline_type_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.underline_type);
+ break;
+
+ case EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT:
+ efl_text_underline_height_set(
+ efl_part(obj,
+ eud->part),
+ prop->val.nd);
+ break;
+
+ case EDJE_PART_TEXT_PROP_WRAP:
+ efl_text_wrap_set(efl_part(obj,
+ eud->part),
+ prop->val.wrap);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+EOLIAN static void
+_efl_canvas_layout_part_text_text_expand_set(Eo *obj,
+ void *_pd EINA_UNUSED,
+ Efl_Canvas_Layout_Part_Text_Expand type)
+{
+ Edje_User_Defined *eud;
+
+ PROXY_DATA_GET(obj, pd);
+ if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
+
+ eud = _edje_user_text_expand_definition_fetch(pd->ed, pd->part);
+ eud->u.text_expand.expand = type;
+ pd->rp->typedata.text->expand = type;
+
+}
+
+EOLIAN static Efl_Canvas_Layout_Part_Text_Expand
+_efl_canvas_layout_part_text_text_expand_get(const Eo *obj,
+ void *_pd EINA_UNUSED)
+{
+ PROXY_DATA_GET(obj, pd);
+ return pd->rp->typedata.text->expand;
+}
+
#include "efl_canvas_layout_part_text.eo.c"
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 8429175a97..6b95b8dc1b 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1974,6 +1974,7 @@ struct _Edje_Real_Part_Text
const char *style; // 4
Edje_Position offset; // 8
short size; // 2
+ Efl_Canvas_Layout_Part_Text_Expand expand;
struct {
unsigned char fit_x, fit_y; // 2
short in_size; // 2
@@ -2252,6 +2253,58 @@ struct _Edje_Patterns
unsigned int finals[];
};
+typedef enum
+{
+ EDJE_PART_TEXT_PROP_NONE = 0, // never used
+ EDJE_PART_TEXT_PROP_BACKING_TYPE = 1,
+ EDJE_PART_TEXT_PROP_COLOR_BACKING = 1 << 2,
+ EDJE_PART_TEXT_PROP_COLOR_GLOW = 1 << 3,
+ EDJE_PART_TEXT_PROP_COLOR_GLOW2 = 1 << 4,
+ EDJE_PART_TEXT_PROP_COLOR_NORMAL = 1 << 5,
+ EDJE_PART_TEXT_PROP_COLOR_OUTLINE = 1 << 6,
+ EDJE_PART_TEXT_PROP_COLOR_SHADOW = 1 << 7,
+ EDJE_PART_TEXT_PROP_COLOR_STRIKETHROUGH = 1 << 8,
+ EDJE_PART_TEXT_PROP_COLOR_UNDERLINE = 1 << 9,
+ EDJE_PART_TEXT_PROP_COLOR_UNDERLINE2 = 1 << 10,
+ EDJE_PART_TEXT_PROP_COLOR_UNDERLINE_DASHED = 1 << 11,
+ EDJE_PART_TEXT_PROP_EFFECT_TYPE = 1 << 12,
+ EDJE_PART_TEXT_PROP_ELLIPSIS = 1 << 13,
+ EDJE_PART_TEXT_PROP_FONT = 1 << 14,
+ EDJE_PART_TEXT_PROP_SHADOW_DIRECTION = 1 << 15,
+ EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE = 1 << 16,
+ EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP = 1 << 17,
+ EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH = 1 << 18,
+ EDJE_PART_TEXT_PROP_UNDERLINE_TYPE = 1 << 19,
+ EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT = 1 << 20,
+ EDJE_PART_TEXT_PROP_WRAP = 1 << 21
+} Edje_Part_Text_Prop_Type;
+
+typedef struct
+{
+ Edje_Part_Text_Prop_Type type;
+ union
+ {
+ int ni; // number integer
+ int nd; // number double
+ Efl_Text_Format_Wrap wrap;
+ Efl_Text_Style_Backing_Type backing;
+ Efl_Text_Style_Underline_Type underline;
+ struct
+ {
+ unsigned char r, g, b, a;
+ } color;
+ struct
+ {
+ const char *font;
+ Efl_Font_Size size;
+ } font;
+ Efl_Text_Style_Effect_Type effect;
+ Efl_Text_Style_Shadow_Direction shadow;
+ Efl_Text_Style_Strikethrough_Type strikethrough_type;
+ Efl_Text_Style_Underline_Type underline_type;
+ } val;
+} Edje_Part_Text_Prop;
+
typedef enum _Edje_User_Defined_Type
{
EDJE_USER_SWALLOW,
@@ -2261,7 +2314,9 @@ typedef enum _Edje_User_Defined_Type
EDJE_USER_DRAG_STEP,
EDJE_USER_DRAG_PAGE,
EDJE_USER_DRAG_VALUE,
- EDJE_USER_DRAG_SIZE
+ EDJE_USER_DRAG_SIZE,
+ EDJE_USER_TEXT_STYLE,
+ EDJE_USER_TEXT_EXPAND,
} Edje_User_Defined_Type;
typedef struct _Edje_User_Defined Edje_User_Defined;
@@ -2296,6 +2351,13 @@ struct _Edje_User_Defined
struct {
double w, h;
} drag_size;
+ struct {
+ Eina_List *props;
+ Edje_Part_Text_Prop_Type types;
+ } text_style;
+ struct {
+ Efl_Canvas_Layout_Part_Text_Expand expand;
+ } text_expand;
} u;
};
@@ -2968,9 +3030,15 @@ Eina_Bool _edje_multisense_internal_vibration_sample_play(Edje *ed, const char *
void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state);
+Edje_User_Defined * _edje_user_definition_fetch(Edje *ed, const char *part, Edje_User_Defined_Type type);
+Edje_User_Defined * _edje_user_text_style_definition_fetch(Edje *ed, const char *part);
+Edje_User_Defined * _edje_user_text_expand_definition_fetch(Edje *ed, const char *part);
void _edje_user_definition_remove(Edje_User_Defined *eud, Evas_Object *child);
void _edje_user_definition_free(Edje_User_Defined *eud);
+void _canvas_layout_user_text_apply(Edje_User_Defined *eud, Eo *obj, Edje_Part_Text_Prop *prop);
+void _canvas_layout_user_text_collect(Edje *ed, Edje_User_Defined *eud);
+
extern Efl_Observable *_edje_color_class_member;
extern Efl_Observable *_edje_text_class_member;
extern Efl_Observable *_edje_size_class_member;
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index 6786b0d91a..add799f954 100644
--- a/src/lib/edje/edje_textblock.c
+++ b/src/lib/edje/edje_textblock.c
@@ -35,14 +35,30 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
int *maxw, int *maxh)
{
Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
+ unsigned char minx2 = 0, miny2 = 0, maxx2 = 0, maxy2 = 0;
+
+ minx2 = chosen_desc->text.min_x;
+ miny2 = chosen_desc->text.min_y;
+ maxx2 = chosen_desc->text.max_x;
+ maxy2 = chosen_desc->text.max_y;
+
+ // Do not use size from new api if min/max are non-zero in the theme
+ if (!chosen_desc->text.min_x && !chosen_desc->text.min_y &&
+ !chosen_desc->text.max_x && !chosen_desc->text.max_y)
+ {
+ minx2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X;
+ miny2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y;
+ maxx2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X;
+ maxy2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y;
+ }
/* Legacy code for Textblock min/max calculation */
- if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
+ if (minx2 || miny2)
{
int mw = 0, mh = 0;
tw = th = 0;
- if (!chosen_desc->text.min_x)
+ if (!minx2)
{
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
@@ -53,22 +69,22 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
&ins_r, &ins_t, &ins_b);
mw = ins_l + tw + ins_r;
mh = ins_t + th + ins_b;
- if (minw && chosen_desc->text.min_x)
+ if (minw && minx2)
{
if (mw > *minw) *minw = mw;
}
- if (minh && chosen_desc->text.min_y)
+ if (minh && miny2)
{
if (mh > *minh) *minh = mh;
}
}
- if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
+ if ((maxx2) || (maxy2))
{
int mw = 0, mh = 0;
tw = th = 0;
- if (!chosen_desc->text.max_x)
+ if (!maxx2)
{
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
@@ -79,12 +95,12 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
&ins_t, &ins_b);
mw = ins_l + tw + ins_r;
mh = ins_t + th + ins_b;
- if (maxw && chosen_desc->text.max_x)
+ if (maxw && maxx2)
{
if (mw > *maxw) *maxw = mw;
if (minw && (*maxw < *minw)) *maxw = *minw;
}
- if (maxh && chosen_desc->text.max_y)
+ if (maxh && maxy2)
{
if (mh > *maxh) *maxh = mh;
if (minh && (*maxh < *minh)) *maxh = *minh;
@@ -102,18 +118,35 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
Evas_Coord min_calc_w = 0, min_calc_h = 0;
+ unsigned char dminx, dminy, dmaxx, dmaxy;
+
+ dminx = chosen_desc->text.min_x;
+ dminy = chosen_desc->text.min_y;
+ dmaxx = chosen_desc->text.max_x;
+ dmaxy = chosen_desc->text.max_y;
+
+ // Do not use size from new api if min/max are non-zero in the theme
+ if (!chosen_desc->text.min_x && !chosen_desc->text.min_y &&
+ !chosen_desc->text.max_x && !chosen_desc->text.max_y)
+ {
+ dminx = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X;
+ dminy = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y;
+ dmaxx = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X;
+ dmaxy = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y;
+ }
+
/* min_calc_* values need to save calculated minumum size
* for maximum size calculation */
if (minw) min_calc_w = *minw;
if (minh) min_calc_h = *minh;
- if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
+ if (dminx || dminy)
{
evas_object_textblock_style_insets_get(ep->object, &ins_l,
&ins_r, &ins_t, &ins_b);
tw = th = 0;
- if (!chosen_desc->text.min_x)
+ if (!dminx)
{
/* text.min: 0 1
* text.max: X X */
@@ -122,11 +155,11 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
if (min_calc_w > temp_w)
temp_w = min_calc_w;
- if ((!chosen_desc->text.max_x) &&
+ if ((!dmaxx) &&
maxw && (*maxw > -1) && (*maxw < temp_w))
temp_w = *maxw;
- if (chosen_desc->text.max_y)
+ if (dmaxy)
{
/* text.min: 0 1
* text.max: X 1 */
@@ -161,7 +194,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
{
/* text.min: 1 X
* text.max: X X */
- if (chosen_desc->text.min_y && (!chosen_desc->text.max_x) &&
+ if (dminy && (!dmaxx) &&
maxw && (*maxw > -1))
{
/* text.min: 1 1
@@ -174,7 +207,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
if (min_calc_w > temp_w)
temp_w = min_calc_w;
- if ((!chosen_desc->text.max_y) && maxh && (*maxh > -1))
+ if ((!dmaxy) && maxh && (*maxh > -1))
{
/* text.min: 1 1
* text.max: 0 0
@@ -210,7 +243,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
tw += ins_l + ins_r;
th += ins_t + ins_b;
- if (!chosen_desc->text.max_x &&
+ if (!dmaxx &&
(maxw && (*maxw > -1) && (*maxw < tw)))
{
/* text.min: 1 0
@@ -222,23 +255,23 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
if (tw > min_calc_w) min_calc_w = tw;
if (th > min_calc_h) min_calc_h = th;
- if (chosen_desc->text.min_x && minw) *minw = min_calc_w;
- if (chosen_desc->text.min_y && minh) *minh = min_calc_h;
+ if (dminx && minw) *minw = min_calc_w;
+ if (dminy && minh) *minh = min_calc_h;
}
- if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
+ if ((dmaxx) || (dmaxy))
{
evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
&ins_t, &ins_b);
tw = th = 0;
- if (!chosen_desc->text.max_x)
+ if (!dmaxx)
{
/* text.min: X X
* text.max: 0 1 */
int temp_w, temp_h;
- if (chosen_desc->text.min_y)
+ if (dminy)
{
/* text.min: X 1
* text.max: 0 1
@@ -284,7 +317,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
else
{
/* text.max: 1 X */
- if (chosen_desc->text.min_x)
+ if (dminx)
{
/* text.min: 1 X
* text.max: 1 X
@@ -298,7 +331,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
{
/* text.min: 0 X
* text.max: 1 X */
- if (chosen_desc->text.max_y)
+ if (dmaxy)
{
/* text.min: 0 X
* text.max: 1 1 */
@@ -312,7 +345,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
if (min_calc_h > temp_h)
temp_h = min_calc_h;
- if (chosen_desc->text.min_y)
+ if (dminy)
{
/* text.min: 0 1
* text.max: 1 1
@@ -370,12 +403,12 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
}
}
- if (maxw && chosen_desc->text.max_x)
+ if (maxw && dmaxx)
{
if (tw > *maxw) *maxw = tw;
if (minw && (*maxw < *minw)) *maxw = *minw;
}
- if (maxh && chosen_desc->text.max_y)
+ if (maxh && dmaxy)
{
if (th > *maxh) *maxh = th;
if (minh && (*maxh < *minh)) *maxh = *minh;
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 35de55b3f7..c85f485a1c 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -136,6 +136,16 @@ _edje_user_definition_free(Edje_User_Defined *eud)
if (rp) _edje_child_remove(eud->ed, rp, child);
break;
+ case EDJE_USER_TEXT_STYLE:
+ {
+ Edje_Part_Text_Prop *prop;
+ EINA_LIST_FREE(eud->u.text_style.props, prop)
+ {
+ free(prop);
+ }
+ break;
+ }
+
case EDJE_USER_STRING:
case EDJE_USER_DRAG_STEP:
case EDJE_USER_DRAG_PAGE:
@@ -1993,6 +2003,71 @@ _edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, c
EINA_FALSE, EINA_TRUE);
}
+Edje_User_Defined *
+_edje_user_definition_fetch(Edje *ed,
+ const char *part, Edje_User_Defined_Type type)
+{
+ Edje_User_Defined *eud;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(ed->user_defined, l, eud)
+ {
+ if (eud->type == type && !strcmp(eud->part, part))
+ {
+ return eud;
+ }
+ }
+ eud = _edje_user_definition_new(type, part, ed);
+ return eud;
+}
+
+Edje_User_Defined *
+_edje_user_text_style_definition_fetch(Edje *ed, const char *part)
+{
+ Edje_User_Defined *eud;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(ed->user_defined, l, eud)
+ {
+ if (eud->type == EDJE_USER_TEXT_STYLE && !strcmp(eud->part, part))
+ {
+ break;
+ }
+ }
+
+ if (!eud)
+ {
+ eud = _edje_user_definition_new(EDJE_USER_TEXT_STYLE, part, ed);
+ eud->u.text_style.types = EDJE_PART_TEXT_PROP_NONE;
+ eud->u.text_style.props = NULL;
+ }
+
+ return eud;
+}
+
+Edje_User_Defined *
+_edje_user_text_expand_definition_fetch(Edje *ed, const char *part)
+{
+ Edje_User_Defined *eud;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(ed->user_defined, l, eud)
+ {
+ if (eud->type == EDJE_USER_TEXT_EXPAND && !strcmp(eud->part, part))
+ {
+ break;
+ }
+ }
+
+ if (!eud)
+ {
+ eud = _edje_user_definition_new(EDJE_USER_TEXT_EXPAND, part, ed);
+ eud->u.text_expand.expand = EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_NONE;
+ }
+
+ return eud;
+}
+
void
_edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type)
{
diff --git a/src/lib/edje/efl_canvas_layout_part_text.eo b/src/lib/edje/efl_canvas_layout_part_text.eo
index b59f470a5b..4ea5d32349 100644
--- a/src/lib/edje/efl_canvas_layout_part_text.eo
+++ b/src/lib/edje/efl_canvas_layout_part_text.eo
@@ -1,11 +1,38 @@
+enum Efl.Canvas.Layout_Part_Text_Expand
+{
+ [[Text layout policy to enforce. If none is set, min/max descriptions
+ are taken in considerations solely.
+ ]]
+ none = 0, [[No policy. Use default description parameters.]]
+ min_x = 1,
+ min_y = 1 << 1,
+ max_x = 1 << 2,
+ max_y = 1 << 3,
+}
+
class Efl.Canvas.Layout_Part_Text (Efl.Canvas.Layout_Part, Efl.Text,
-Efl.Text_Markup, Efl.Text_Cursor)
+Efl.Text_Markup, Efl.Text_Cursor, Efl.Text_Format, Efl.Text_Font,
+Efl.Text_Style)
{
[[Represents a TEXT part of a layout
Its lifetime is limited to one function call only, unless an extra
reference is explicitly held.
]]
+ methods {
+ @property text_expand {
+ [[Sizing policy for text parts.
+
+ This will determine whether to consider height or width
+ constraints, if text-specific behaviors occur (such as ellipsis,
+ line-wrapping etc.
+ ]]
+ values {
+ type: Efl.Canvas.Layout_Part_Text_Expand;
+ }
+ }
+
+ }
data: null;
implements {
Efl.Text.text { set; get; }
@@ -24,5 +51,26 @@ Efl.Text_Markup, Efl.Text_Cursor)
Efl.Text_Cursor.cursor_content { get; }
Efl.Text_Cursor.cursor_geometry { get; }
Efl.Text_Markup.cursor_markup_insert;
+ Efl.Text_Format.ellipsis { set; get; }
+ Efl.Text_Format.wrap { set; get; }
+ Efl.Text_Font.font { set; get; }
+ Efl.Text_Style.normal_color { set; get; }
+ Efl.Text_Style.backing_type { set; get; }
+ Efl.Text_Style.backing_color { set; get;}
+ Efl.Text_Style.underline_type { set; }
+ Efl.Text_Style.underline_color { set; get; }
+ Efl.Text_Style.underline2_color { set; get; }
+ Efl.Text_Style.underline_dashed_color { set; get; }
+ Efl.Text_Style.underline_height { set; }
+ Efl.Text_Style.underline_dashed_width { set; }
+ Efl.Text_Style.underline_dashed_gap { set; }
+ Efl.Text_Style.strikethrough_type { set; }
+ Efl.Text_Style.strikethrough_color { set; get; }
+ Efl.Text_Style.effect_type { set; }
+ Efl.Text_Style.shadow_direction { set; }
+ Efl.Text_Style.outline_color { set; get; }
+ Efl.Text_Style.shadow_color { set; get; }
+ Efl.Text_Style.glow_color { set; get; }
+ Efl.Text_Style.glow2_color { set; get; }
}
}