summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2014-01-21 22:12:53 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-01-21 22:12:53 +0900
commit5eee2aa4162193c600764fcd81248b6fde305cb2 (patch)
treeadc1c8633156ee73fa42ff070bd4c7d689d14b5e
parent689763485b3a0bfb520dd6e84aeba2c5da056ef7 (diff)
spinner: Create an internal entry when it is really needed.
Do not create the internal entry on smart add. Create that when it is needed with editable mode.
-rw-r--r--src/lib/elm_spinner.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c
index 99311a7d5..9fb3c7ebb 100644
--- a/src/lib/elm_spinner.c
+++ b/src/lib/elm_spinner.c
@@ -258,24 +258,46 @@ _entry_value_apply(Evas_Object *obj)
258} 258}
259 259
260static void 260static void
261_entry_toggle_cb(void *data, 261_entry_activated_cb(void *data,
262 Evas_Object *obj EINA_UNUSED, 262 Evas_Object *obj EINA_UNUSED,
263 void *event_info EINA_UNUSED)
264{
265 ELM_SPINNER_DATA_GET(data, sd);
266
267 _entry_value_apply(data);
268 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
269 if (sd->delay_timer) ecore_timer_del(sd->delay_timer);
270 sd->delay_timer = ecore_timer_add(0.2, _delay_change, data);
271}
272
273static void
274_entry_toggle_cb(void *data EINA_UNUSED,
275 Evas_Object *obj,
263 const char *emission EINA_UNUSED, 276 const char *emission EINA_UNUSED,
264 const char *source EINA_UNUSED) 277 const char *source EINA_UNUSED)
265{ 278{
266 ELM_SPINNER_DATA_GET(data, sd); 279 ELM_SPINNER_DATA_GET(obj, sd);
267 280
268 if (sd->dragging) 281 if (sd->dragging)
269 { 282 {
270 sd->dragging = 0; 283 sd->dragging = 0;
271 return; 284 return;
272 } 285 }
273 if (elm_widget_disabled_get(data)) return; 286 if (elm_widget_disabled_get(obj)) return;
274 if (!sd->editable) return; 287 if (!sd->editable) return;
275 if (sd->entry_visible) _entry_value_apply(data); 288 if (sd->entry_visible) _entry_value_apply(obj);
276 else 289 else
277 { 290 {
278 elm_layout_signal_emit(data, "elm,state,active", "elm"); 291 if (!sd->ent)
292 {
293 sd->ent = elm_entry_add(obj);
294 elm_entry_single_line_set(sd->ent, EINA_TRUE);
295 evas_object_smart_callback_add
296 (sd->ent, "activated", _entry_activated_cb, obj);
297 elm_layout_content_set(obj, "elm.swallow.entry", sd->ent);
298 }
299
300 elm_layout_signal_emit(obj, "elm,state,active", "elm");
279 _entry_show(sd); 301 _entry_show(sd);
280 elm_entry_select_all(sd->ent); 302 elm_entry_select_all(sd->ent);
281 elm_widget_focus_set(sd->ent, EINA_TRUE); 303 elm_widget_focus_set(sd->ent, EINA_TRUE);
@@ -402,19 +424,6 @@ _button_dec_stop_cb(void *data,
402} 424}
403 425
404static void 426static void
405_entry_activated_cb(void *data,
406 Evas_Object *obj EINA_UNUSED,
407 void *event_info EINA_UNUSED)
408{
409 ELM_SPINNER_DATA_GET(data, sd);
410
411 _entry_value_apply(data);
412 evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
413 if (sd->delay_timer) ecore_timer_del(sd->delay_timer);
414 sd->delay_timer = ecore_timer_add(0.2, _delay_change, data);
415}
416
417static void
418_elm_spinner_smart_sizing_eval(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 427_elm_spinner_smart_sizing_eval(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
419{ 428{
420 Evas_Coord minw = -1, minh = -1; 429 Evas_Coord minw = -1, minh = -1;
@@ -482,7 +491,7 @@ _elm_spinner_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
482 (!strcmp(ev->key, "KP_Enter")) || 491 (!strcmp(ev->key, "KP_Enter")) ||
483 (!strcmp(ev->key, "space"))) 492 (!strcmp(ev->key, "space")))
484 { 493 {
485 _entry_toggle_cb(obj, NULL, NULL, NULL); 494 _entry_toggle_cb(NULL, obj, NULL, NULL);
486 } 495 }
487 } 496 }
488 else if (type == EVAS_CALLBACK_KEY_UP) 497 else if (type == EVAS_CALLBACK_KEY_UP)
@@ -710,14 +719,8 @@ _elm_spinner_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
710 edje_object_part_drag_value_set 719 edje_object_part_drag_value_set
711 (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0); 720 (wd->resize_obj, "elm.dragable.slider", 0.0, 0.0);
712 721
713 priv->ent = elm_entry_add(obj);
714 elm_entry_single_line_set(priv->ent, EINA_TRUE);
715 evas_object_smart_callback_add
716 (priv->ent, "activated", _entry_activated_cb, obj);
717
718 elm_layout_content_set(obj, "elm.swallow.entry", priv->ent);
719 elm_layout_signal_callback_add 722 elm_layout_signal_callback_add
720 (obj, "elm,action,entry,toggle", "*", _entry_toggle_cb, obj); 723 (obj, "elm,action,entry,toggle", "*", _entry_toggle_cb, NULL);
721 724
722 _label_write(obj); 725 _label_write(obj);
723 elm_widget_can_focus_set(obj, EINA_TRUE); 726 elm_widget_can_focus_set(obj, EINA_TRUE);