forked from enlightenment/efl
Evas textblock: Added user style support.
This should make it easier to override the style set in textblock. SVN revision: 67473
This commit is contained in:
parent
a5b728d53d
commit
98c61bfe6c
|
@ -660,3 +660,10 @@
|
||||||
rotation on the image object 3) Corresponding image
|
rotation on the image object 3) Corresponding image
|
||||||
object has alpha disabled.
|
object has alpha disabled.
|
||||||
|
|
||||||
|
2012-01-23 Tom Hacohen (TAsn)
|
||||||
|
|
||||||
|
* Textblock: Added evas_object_textblock_style_user_set/get.
|
||||||
|
This is used to override the default style set for an evas object.
|
||||||
|
For example, this can be used to nicely change the font and size
|
||||||
|
in a text editor.
|
||||||
|
|
||||||
|
|
|
@ -8285,6 +8285,28 @@ EAPI void evas_object_textblock_style_set(Evas_Object *o
|
||||||
*/
|
*/
|
||||||
EAPI const Evas_Textblock_Style *evas_object_textblock_style_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
EAPI const Evas_Textblock_Style *evas_object_textblock_style_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the objects user style to ts.
|
||||||
|
*
|
||||||
|
* The user style overrides the corresponding elements of the regular style.
|
||||||
|
* This is the proper way to do theme overrides in code.
|
||||||
|
* @param obj the Evas object to set the style to.
|
||||||
|
* @param ts the style to set.
|
||||||
|
* @return Returns no value.
|
||||||
|
* @see evas_object_textblock_style_set
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
EAPI void evas_object_textblock_style_user_set(Evas_Object *obj, Evas_Textblock_Style *ts) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the user style of an object.
|
||||||
|
* @param obj the object to get the style from.
|
||||||
|
* @return the style of the object.
|
||||||
|
* @see evas_object_textblock_style_get
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
EAPI const Evas_Textblock_Style *evas_object_textblock_style_user_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the "replacement character" to use for the given textblock object.
|
* @brief Set the "replacement character" to use for the given textblock object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -430,6 +430,7 @@ struct _Evas_Object_Textblock
|
||||||
{
|
{
|
||||||
DATA32 magic;
|
DATA32 magic;
|
||||||
Evas_Textblock_Style *style;
|
Evas_Textblock_Style *style;
|
||||||
|
Evas_Textblock_Style *style_user;
|
||||||
Evas_Textblock_Cursor *cursor;
|
Evas_Textblock_Cursor *cursor;
|
||||||
Eina_List *cursors;
|
Eina_List *cursors;
|
||||||
Evas_Object_Textblock_Node_Text *text_nodes;
|
Evas_Object_Textblock_Node_Text *text_nodes;
|
||||||
|
@ -4185,10 +4186,26 @@ _layout(const Evas_Object *obj, int w, int h, int *w_ret, int *h_ret)
|
||||||
|
|
||||||
/* Start of logical layout creation */
|
/* Start of logical layout creation */
|
||||||
/* setup default base style */
|
/* setup default base style */
|
||||||
|
{
|
||||||
|
Eina_Bool finalize = EINA_FALSE;
|
||||||
if ((c->o->style) && (c->o->style->default_tag))
|
if ((c->o->style) && (c->o->style->default_tag))
|
||||||
{
|
{
|
||||||
c->fmt = _layout_format_push(c, NULL, NULL);
|
c->fmt = _layout_format_push(c, NULL, NULL);
|
||||||
_format_fill(c->obj, c->fmt, c->o->style->default_tag);
|
_format_fill(c->obj, c->fmt, c->o->style->default_tag);
|
||||||
|
finalize = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c->o->style_user) && (c->o->style_user->default_tag))
|
||||||
|
{
|
||||||
|
if (!c->fmt)
|
||||||
|
{
|
||||||
|
c->fmt = _layout_format_push(c, NULL, NULL);
|
||||||
|
}
|
||||||
|
_format_fill(c->obj, c->fmt, c->o->style_user->default_tag);
|
||||||
|
finalize = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finalize)
|
||||||
_format_finalize(c->obj, c->fmt);
|
_format_finalize(c->obj, c->fmt);
|
||||||
}
|
}
|
||||||
if (!c->fmt)
|
if (!c->fmt)
|
||||||
|
@ -4576,13 +4593,15 @@ evas_textblock_style_get(const Evas_Textblock_Style *ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* textblock styles */
|
/* textblock styles */
|
||||||
EAPI void
|
|
||||||
evas_object_textblock_style_set(Evas_Object *obj, Evas_Textblock_Style *ts)
|
static void
|
||||||
|
_textblock_style_generic_set(Evas_Object *obj, Evas_Textblock_Style *ts,
|
||||||
|
Evas_Textblock_Style **obj_ts)
|
||||||
{
|
{
|
||||||
TB_HEAD();
|
TB_HEAD();
|
||||||
if (ts == o->style) return;
|
if (ts == *obj_ts) return;
|
||||||
if ((ts) && (ts->delete_me)) return;
|
if ((ts) && (ts->delete_me)) return;
|
||||||
if (o->style)
|
if (*obj_ts)
|
||||||
{
|
{
|
||||||
Evas_Textblock_Style *old_ts;
|
Evas_Textblock_Style *old_ts;
|
||||||
if (o->markup_text)
|
if (o->markup_text)
|
||||||
|
@ -4591,7 +4610,7 @@ evas_object_textblock_style_set(Evas_Object *obj, Evas_Textblock_Style *ts)
|
||||||
o->markup_text = NULL;
|
o->markup_text = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_ts = o->style;
|
old_ts = *obj_ts;
|
||||||
old_ts->objects = eina_list_remove(old_ts->objects, obj);
|
old_ts->objects = eina_list_remove(old_ts->objects, obj);
|
||||||
if ((old_ts->delete_me) && (!old_ts->objects))
|
if ((old_ts->delete_me) && (!old_ts->objects))
|
||||||
evas_textblock_style_free(old_ts);
|
evas_textblock_style_free(old_ts);
|
||||||
|
@ -4600,12 +4619,19 @@ evas_object_textblock_style_set(Evas_Object *obj, Evas_Textblock_Style *ts)
|
||||||
{
|
{
|
||||||
ts->objects = eina_list_append(ts->objects, obj);
|
ts->objects = eina_list_append(ts->objects, obj);
|
||||||
}
|
}
|
||||||
o->style = ts;
|
*obj_ts = ts;
|
||||||
|
|
||||||
_evas_textblock_invalidate_all(o);
|
_evas_textblock_invalidate_all(o);
|
||||||
_evas_textblock_changed(o, obj);
|
_evas_textblock_changed(o, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
evas_object_textblock_style_set(Evas_Object *obj, Evas_Textblock_Style *ts)
|
||||||
|
{
|
||||||
|
TB_HEAD();
|
||||||
|
_textblock_style_generic_set(obj, ts, &(o->style));
|
||||||
|
}
|
||||||
|
|
||||||
EAPI const Evas_Textblock_Style *
|
EAPI const Evas_Textblock_Style *
|
||||||
evas_object_textblock_style_get(const Evas_Object *obj)
|
evas_object_textblock_style_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -4613,6 +4639,20 @@ evas_object_textblock_style_get(const Evas_Object *obj)
|
||||||
return o->style;
|
return o->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
evas_object_textblock_style_user_set(Evas_Object *obj, Evas_Textblock_Style *ts)
|
||||||
|
{
|
||||||
|
TB_HEAD();
|
||||||
|
_textblock_style_generic_set(obj, ts, &(o->style_user));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI const Evas_Textblock_Style *
|
||||||
|
evas_object_textblock_style_user_get(const Evas_Object *obj)
|
||||||
|
{
|
||||||
|
TB_HEAD_RETURN(NULL);
|
||||||
|
return o->style_user;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
evas_object_textblock_replace_char_set(Evas_Object *obj, const char *ch)
|
evas_object_textblock_replace_char_set(Evas_Object *obj, const char *ch)
|
||||||
{
|
{
|
||||||
|
@ -4902,7 +4942,7 @@ evas_object_textblock_text_markup_set(Evas_Object *obj, const char *text)
|
||||||
o->markup_text = NULL;
|
o->markup_text = NULL;
|
||||||
}
|
}
|
||||||
_nodes_clear(obj);
|
_nodes_clear(obj);
|
||||||
if (!o->style)
|
if (!o->style && !o->style_user)
|
||||||
{
|
{
|
||||||
if (text != o->markup_text)
|
if (text != o->markup_text)
|
||||||
{
|
{
|
||||||
|
@ -7241,7 +7281,13 @@ _evas_textblock_node_format_new(Evas_Object_Textblock *o, const char *_format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match = _style_match_tag(o->style, format, format_len, &replace_len);
|
if (!o->style_user || !(match = _style_match_tag(o->style_user, format,
|
||||||
|
format_len, &replace_len)))
|
||||||
|
{
|
||||||
|
match = _style_match_tag(o->style, format, format_len,
|
||||||
|
&replace_len);
|
||||||
|
}
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
if (match[0] != '-')
|
if (match[0] != '-')
|
||||||
|
|
Loading…
Reference in New Issue