diff options
author | Tom Hacohen <tom@stosb.com> | 2016-06-13 13:56:54 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2016-06-13 13:56:54 +0100 |
commit | 8010761b3cd6882f8cd55fe22902e42c082e242a (patch) | |
tree | 9b42d667f897b4ab4d5a6f646fb2e31b1cb52f14 | |
parent | 45b77aec7eff5086be86f068286f95aea8f9003a (diff) | |
download | efl-8010761b3cd6882f8cd55fe22902e42c082e242a.tar.gz |
Canvas text: Change style to be keyed instead of default and stack.
-rw-r--r-- | src/lib/elementary/efl_ui_text.c | 2 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_canvas_text.eo | 54 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_textblock.c | 93 |
3 files changed, 40 insertions, 109 deletions
diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c index d6914c6ccc..91edc2b215 100644 --- a/src/lib/elementary/efl_ui_text.c +++ b/src/lib/elementary/efl_ui_text.c @@ -3823,7 +3823,7 @@ _efl_ui_text_evas_object_smart_add(Eo *obj, Efl_Ui_Text_Data *priv) text_obj = eo_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj); eo_composite_attach(obj, text_obj); edje_object_part_swallow(priv->entry_edje, "elm.text", text_obj); - efl_canvas_text_style_set(text_obj, "font=Sans font_size=14 color=#fff wrap=word"); + efl_canvas_text_style_set(text_obj, NULL, "DEFAULT='font=Sans font_size=14 color=#fff wrap=word'"); eo_event_callback_add(text_obj, EFL_UI_TEXT_INTERACTIVE_EVENT_CHANGED_USER, _efl_ui_text_changed_cb, obj); eo_event_callback_add(text_obj, EFL_UI_TEXT_INTERACTIVE_EVENT_SELECTION_CHANGED, diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo index bc85ff2f03..0e073bda56 100644 --- a/src/lib/evas/canvas/efl_canvas_text.eo +++ b/src/lib/evas/canvas/efl_canvas_text.eo @@ -53,15 +53,27 @@ class Efl.Canvas.Text (Evas.Object, Efl.Text) } } @property style { - [[The text style of the object]] + [[The text style of the object. + + $key is how you reference the style (for deletion or fetching). $NULL + as key indicates the style has the highest priority (default style). + The style priority is the order of creation, styles created first + are applied first with the exception of $NULL which is implicitly + first. + + Set $style to $NULL to delete it. + ]] set { legacy: null; } get { legacy: null; } + keys { + key: string; [[The name to the style. $NULL is the default style]] + } values { - ts: string; [[The style.]] + style: string; [[The style.]] } } @property size_formatted { @@ -136,44 +148,6 @@ class Efl.Canvas.Text (Evas.Object, Efl.Text) is_empty: bool; [[$true if empty]] } } - style_user_pop { - [[Del the from the top of the user style stack. - - See also @.style.get. - - @since 1.2 - ]] - legacy: null; - } - style_user_peek @const { - [[Get (don't remove) the style at the top of the user style stack. - - See also @.style.get. - - @since 1.2 - ]] - legacy: null; - return: string; [[The style of the object.]] - } - style_user_push { - [[Push ts to the top of the user style stack. - - FIXME: API is solid but currently only supports 1 style in the - stack. - - The user style overrides the corresponding elements of the - regular style. This is the proper way to do theme overrides - in code. - - See also @.style.set. - - @since 1.2 - ]] - legacy: null; - params { - @in style: string; [[The style to set.]] - } - } obstacle_add { [[Add obstacle evas object $eo_obs to be observed during layout of text. diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 504d0f7d6f..9672dd9696 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -504,8 +504,6 @@ struct _Evas_Object_Textblock { Evas_Textblock_Style *style; Evas_Textblock_Style *style_user; - Evas_Textblock_Style *current_style; - Evas_Textblock_Style *current_user_style; Eo *cursor; Eina_List *cursors; Evas_Object_Textblock_Node_Text *text_nodes; @@ -6529,10 +6527,10 @@ _textblock_format_node_from_style_tag(Efl_Canvas_Text_Data *o, Evas_Object_Textb static void _textblock_style_generic_set(Evas_Object *eo_obj, Evas_Textblock_Style *ts, - Evas_Textblock_Style **obj_ts, Eina_Bool legacy) + Evas_Textblock_Style **obj_ts) { TB_HEAD(); - if (legacy && (ts == *obj_ts)) return; + if (ts == *obj_ts) return; if ((ts) && (ts->delete_me)) return; if (*obj_ts) { @@ -6594,32 +6592,30 @@ evas_object_textblock_style_set(Eo *eo_obj, const Evas_Textblock_Style *ts) Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); evas_object_async_block(obj); Efl_Canvas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); - _textblock_style_generic_set(eo_obj, (Evas_Textblock_Style *) ts, &(o->style), - EINA_TRUE); + _textblock_style_generic_set(eo_obj, (Evas_Textblock_Style *) ts, &(o->style)); } EOLIAN static void -_efl_canvas_text_style_set(Eo *eo_obj, Efl_Canvas_Text_Data *o, const char *style) +_efl_canvas_text_style_set(Eo *eo_obj, Efl_Canvas_Text_Data *o, const char *key, const char *style) { + // FIXME: Make key value behaviour. Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); evas_object_async_block(obj); - int len = strlen(style); - if (!o->current_style) - { - o->current_style = evas_textblock_style_new(); - } - if (o->current_style->default_tag) free(o->current_style->default_tag); - if (!style) + Evas_Textblock_Style *ts; + + ts = evas_textblock_style_new(); + + evas_textblock_style_set(ts, style); + + if (key) { - o->current_style->default_tag = NULL; + _textblock_style_generic_set(eo_obj, ts, &(o->style_user)); } else { - o->current_style->default_tag = strndup(style, len); + _textblock_style_generic_set(eo_obj, ts, &(o->style)); } - o->current_style->default_tag = strndup(style, len); - _textblock_style_generic_set(eo_obj, o->current_style, &(o->style), EINA_FALSE); } EAPI Evas_Textblock_Style * @@ -6632,9 +6628,16 @@ evas_object_textblock_style_get(const Eo *eo_obj EINA_UNUSED) } EOLIAN static const char * -_efl_canvas_text_style_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o) +_efl_canvas_text_style_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o, const char *key) { - return o->current_style ? o->current_style->default_tag : NULL; + if (key) + { + return o->style_user->style_text; + } + else + { + return o->style->style_text; + } } EAPI void @@ -6643,31 +6646,7 @@ evas_object_textblock_style_user_push(Eo *eo_obj, Evas_Textblock_Style *ts) Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); evas_object_async_block(obj); Efl_Canvas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); - _textblock_style_generic_set(eo_obj, ts, &(o->style_user), EINA_TRUE); -} - -EOLIAN static void -_efl_canvas_text_style_user_push(Eo *eo_obj, Efl_Canvas_Text_Data *o, const char *style) -{ - //XXX: needs stack behavior - Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); - evas_object_async_block(obj); - int len = strlen(style); - - if (!o->current_user_style) - { - o->current_user_style = evas_textblock_style_new(); - } - if (o->current_user_style->default_tag) free(o->current_user_style->default_tag); - if (!style) - { - o->current_user_style->default_tag = NULL; - } - else - { - o->current_user_style->default_tag = strndup(style, len); - } - _textblock_style_generic_set(eo_obj, o->current_user_style, &(o->style_user), EINA_FALSE); + _textblock_style_generic_set(eo_obj, ts, &(o->style_user)); } EAPI const Evas_Textblock_Style* @@ -6679,29 +6658,13 @@ evas_object_textblock_style_user_peek(const Eo *eo_obj) return o->style; } -EOLIAN static const char * -_efl_canvas_text_style_user_peek(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o) -{ - return o->current_user_style ? o->current_user_style->default_tag : NULL; -} - EAPI void evas_object_textblock_style_user_pop(Eo *eo_obj) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); evas_object_async_block(obj); Efl_Canvas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); - _textblock_style_generic_set(eo_obj, NULL, &(o->style_user), EINA_TRUE); -} - -EOLIAN static void -_efl_canvas_text_style_user_pop(Eo *eo_obj, Efl_Canvas_Text_Data *o) -{ - //XXX: needs stack behavior - Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); - evas_object_async_block(obj); - if (o->current_user_style->default_tag) free(o->current_user_style->default_tag); - _textblock_style_generic_set(eo_obj, NULL, &(o->style_user), EINA_FALSE); + _textblock_style_generic_set(eo_obj, NULL, &(o->style_user)); } EOLIAN static void @@ -12578,12 +12541,6 @@ evas_object_textblock_free(Evas_Object *eo_obj) _dicts_hyphen_detach(eo_obj); } #endif - - /* free the style if exists */ - if (o->current_style) - { - evas_textblock_style_free(o->current_style); - } } static void |