diff options
author | Daniel Hirt <daniel.hirt@samsung.com> | 2016-03-17 14:56:02 +0200 |
---|---|---|
committer | Daniel Hirt <daniel.hirt@samsung.com> | 2016-04-04 17:33:23 +0300 |
commit | 44686eb27114b41015c153eafa6e1029fe75fc74 (patch) | |
tree | 7c08ae752bfa6e97b437276ed70e40a573b6eb0d | |
parent | b655341899c7c33eb35dee2ae6027942e187d871 (diff) | |
download | efl-44686eb27114b41015c153eafa6e1029fe75fc74.tar.gz |
Entry: Move theming back to ctor and update sizes only when finalized
Moving back the theming code to the ctor. We defer all calculation until
the finalization stage.
This not only prevent redundant calculation calls during the
construction stage, but also handles properly additional setup from the
user side during eo_add, for example:
Eo *entry = eo_add(ELM_ENTRY_CLASS, parent,
elm_obj_entry_single_line_set(eo_self, EINA_FALSE));
-rw-r--r-- | src/lib/elementary/elm_entry.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index bd0957bf34..06174223d0 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -790,10 +790,8 @@ _elm_entry_background_switch(Evas_Object *from_edje, Evas_Object *to_edje) } } -/* we can't issue the layout's theming code here, cause it assumes an - * unique edje object, always */ -EOLIAN static Eina_Bool -_elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) +static inline Eina_Bool +_entry_theme_apply(Eo *obj, Elm_Entry_Data *sd) { const char *str; const char *t; @@ -919,6 +917,17 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) evas_object_unref(obj); return EINA_TRUE; + +} + +/* we can't issue the layout's theming code here, cause it assumes an + * unique edje object, always */ +EOLIAN static Eina_Bool +_elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) +{ + if (!eo_finalized_get(obj)) return EINA_TRUE; + + return _entry_theme_apply(obj, sd); } static void @@ -939,12 +948,13 @@ _cursor_geometry_recalc(Evas_Object *obj) } } -EOLIAN static void -_elm_entry_elm_layout_sizing_eval(Eo *obj, Elm_Entry_Data *sd) +static inline void +_entry_sizing_eval(Eo *obj, Elm_Entry_Data *sd) { Evas_Coord minw = -1, minh = -1; Evas_Coord resw, resh; + evas_object_geometry_get(obj, NULL, NULL, &resw, &resh); if (sd->line_wrap) @@ -1090,6 +1100,15 @@ _elm_entry_elm_layout_sizing_eval(Eo *obj, Elm_Entry_Data *sd) } _cursor_geometry_recalc(obj); + +} + +EOLIAN static void +_elm_entry_elm_layout_sizing_eval(Eo *obj, Elm_Entry_Data *sd) +{ + if (!eo_finalized_get(obj)) return; + + _entry_sizing_eval(obj, sd); } static void @@ -3832,16 +3851,17 @@ _elm_entry_eo_base_constructor(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED) eo_event_callback_add(obj, EO_BASE_EVENT_CALLBACK_ADD, _cb_added, NULL); eo_event_callback_add(obj, EO_BASE_EVENT_CALLBACK_DEL, _cb_deleted, NULL); + if (!elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj))) + CRI("Failed to set layout!"); + return obj; } EOLIAN static Eo * -_elm_entry_eo_base_finalize(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED) +_elm_entry_eo_base_finalize(Eo *obj, Elm_Entry_Data *_pd) { - if (!elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj))) - CRI("Failed to set layout!"); elm_layout_text_set(obj, "elm.text", ""); - elm_layout_sizing_eval(obj); + _entry_theme_apply(obj, _pd); return obj; } |