summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2016-03-09 15:55:39 +0200
committerDaniel Hirt <daniel.hirt@samsung.com>2016-03-15 11:33:19 +0200
commite7e6e4e1ceea50cc4787e7110b553da6415fbf5c (patch)
treec669235506fac3828aba3160866e7627bcf99161
parentc36132c5678a36efc30046e3614549160861c158 (diff)
Label: inherit from Entry (part 1)
- Remove text_set - Remove sizing_eval - Move theming and eval calls from smart_add to finalize (like entry) To be continued.
-rw-r--r--src/lib/elm_label.c99
-rw-r--r--src/lib/elm_label.eo5
2 files changed, 9 insertions, 95 deletions
diff --git a/src/lib/elm_label.c b/src/lib/elm_label.c
index 6887a5f8e..16b6293f8 100644
--- a/src/lib/elm_label.c
+++ b/src/lib/elm_label.c
@@ -195,33 +195,6 @@ _elm_label_elm_widget_theme_apply(Eo *obj, Elm_Label_Data *sd)
195 return int_ret; 195 return int_ret;
196} 196}
197 197
198EOLIAN static void
199_elm_label_elm_layout_sizing_eval(Eo *obj, Elm_Label_Data *_pd EINA_UNUSED)
200{
201 Evas_Coord minw = -1, minh = -1;
202 Evas_Coord resw, resh;
203
204 ELM_LABEL_DATA_GET(obj, sd);
205 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
206
207 if (sd->linewrap)
208 {
209 evas_object_geometry_get(wd->resize_obj, NULL, NULL, &resw, &resh);
210 if (resw == sd->lastw) return;
211 sd->lastw = resw;
212 _recalc(obj);
213 }
214 else
215 {
216 evas_event_freeze(evas_object_evas_get(obj));
217 edje_object_size_min_calc(wd->resize_obj, &minw, &minh);
218 if (sd->wrap_w > 0 && minw > sd->wrap_w) minw = sd->wrap_w;
219 evas_object_size_hint_min_set(obj, minw, minh);
220 evas_event_thaw(evas_object_evas_get(obj));
221 evas_event_thaw_eval(evas_object_evas_get(obj));
222 }
223}
224
225static void 198static void
226_on_label_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 199_on_label_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
227{ 200{
@@ -322,24 +295,6 @@ _stringshare_key_value_replace(const char **srcstring, const char *key, const ch
322 return 0; 295 return 0;
323} 296}
324 297
325EOLIAN static Eina_Bool
326_elm_label_elm_layout_text_set(Eo *obj, Elm_Label_Data *sd, const char *part, const char *label)
327{
328 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
329 Eina_Bool int_ret = EINA_FALSE;
330
331 if (!label) label = "";
332 _label_format_set(wd->resize_obj, sd->format);
333
334 int_ret = elm_obj_layout_text_set(eo_super(obj, MY_CLASS), part, label);
335 if (int_ret)
336 {
337 sd->lastw = -1;
338 elm_obj_layout_sizing_eval(obj);
339 }
340 return int_ret;
341}
342
343static char * 298static char *
344_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj) 299_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
345{ 300{
@@ -392,12 +347,6 @@ _elm_label_evas_object_smart_add(Eo *obj, Elm_Label_Data *priv)
392 E_("Label")); 347 E_("Label"));
393 _elm_access_callback_set(_elm_access_info_get(obj), ELM_ACCESS_INFO, 348 _elm_access_callback_set(_elm_access_info_get(obj), ELM_ACCESS_INFO,
394 _access_info_cb, NULL); 349 _access_info_cb, NULL);
395
396 if (!elm_layout_theme_set(obj, "label", "base", elm_widget_style_get(obj)))
397 CRI("Failed to set layout!");
398
399 elm_layout_text_set(obj, NULL, "<br>");
400 elm_layout_sizing_eval(obj);
401} 350}
402 351
403EAPI Evas_Object * 352EAPI Evas_Object *
@@ -419,48 +368,14 @@ _elm_label_eo_base_constructor(Eo *obj, Elm_Label_Data *_pd EINA_UNUSED)
419 return obj; 368 return obj;
420} 369}
421 370
422EOLIAN static void 371EOLIAN static Eo *
423_elm_label_line_wrap_set(Eo *obj, Elm_Label_Data *sd, Elm_Wrap_Type wrap) 372_elm_label_eo_base_finalize(Eo *obj, Elm_Label_Data *_pd EINA_UNUSED)
424{ 373{
425 const char *wrap_str, *text; 374 if (!elm_layout_theme_set(obj, "entry", "base-noedit", elm_widget_style_get(obj)))
426 int len; 375 CRI("Failed to set layout!");
427 376 elm_layout_text_set(obj, NULL, "<br>");
428 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 377 elm_layout_sizing_eval(obj);
429 378 return obj;
430 if (sd->linewrap == wrap) return;
431
432 sd->linewrap = wrap;
433 text = elm_layout_text_get(obj, NULL);
434 if (!text) return;
435
436 len = strlen(text);
437 if (len <= 0) return;
438
439 switch (wrap)
440 {
441 case ELM_WRAP_CHAR:
442 wrap_str = "char";
443 break;
444
445 case ELM_WRAP_WORD:
446 wrap_str = "word";
447 break;
448
449 case ELM_WRAP_MIXED:
450 wrap_str = "mixed";
451 break;
452
453 default:
454 wrap_str = "none";
455 break;
456 }
457
458 if (_stringshare_key_value_replace(&sd->format, "wrap", wrap_str, 0) == 0)
459 {
460 sd->lastw = -1;
461 _label_format_set(wd->resize_obj, sd->format);
462 elm_layout_sizing_eval(obj);
463 }
464} 379}
465 380
466EOLIAN static Elm_Wrap_Type 381EOLIAN static Elm_Wrap_Type
diff --git a/src/lib/elm_label.eo b/src/lib/elm_label.eo
index a93b98f98..23e5a7662 100644
--- a/src/lib/elm_label.eo
+++ b/src/lib/elm_label.eo
@@ -8,7 +8,7 @@ enum Elm.Label.Slide_Mode
8 always [[Slide always.]] 8 always [[Slide always.]]
9} 9}
10 10
11class Elm.Label (Elm.Layout) 11class Elm.Label (Elm.Entry)
12{ 12{
13 eo_prefix: elm_obj_label; 13 eo_prefix: elm_obj_label;
14 methods { 14 methods {
@@ -121,13 +121,12 @@ class Elm.Label (Elm.Layout)
121 implements { 121 implements {
122 class.constructor; 122 class.constructor;
123 Eo.Base.constructor; 123 Eo.Base.constructor;
124 Eo.Base.finalize;
124 Evas.Object_Smart.add; 125 Evas.Object_Smart.add;
125 Elm.Widget.focus_next_manager_is; 126 Elm.Widget.focus_next_manager_is;
126 Elm.Widget.focus_direction_manager_is; 127 Elm.Widget.focus_direction_manager_is;
127 Elm.Widget.theme_apply; 128 Elm.Widget.theme_apply;
128 Elm.Layout.text.set;
129 Elm.Layout.text_aliases.get; 129 Elm.Layout.text_aliases.get;
130 Elm.Layout.sizing_eval;
131 } 130 }
132 events { 131 events {
133 slide,end; 132 slide,end;