summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-05 19:09:43 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-08 19:56:40 +0200
commitd8f32042c46e0090178249c6556d26277650313c (patch)
tree5235a13bb51e4e48b6747468d68e3004d83b8895
parent7ddd286f7b3c454b9499f2a1357f8e4f7335710e (diff)
efl_ui_spin_button: make theme consistent
this reduces the amount of code needed in the widget itself, additionally, the theme now follows a scheme. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9230
-rw-r--r--data/elementary/themes/edc/efl/spin_button.edc14
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c75
2 files changed, 16 insertions, 73 deletions
diff --git a/data/elementary/themes/edc/efl/spin_button.edc b/data/elementary/themes/edc/efl/spin_button.edc
index 417d002154..cca7f1d479 100644
--- a/data/elementary/themes/edc/efl/spin_button.edc
+++ b/data/elementary/themes/edc/efl/spin_button.edc
@@ -202,7 +202,7 @@ group { "efl/spin_button/vertical";
202 } 202 }
203} 203}
204 204
205group { "efl/spin_button/inc_button"; 205group { "efl/spin_button/horizontal/inc_button";
206 images.image: "sym_right_light_normal.png" COMP; 206 images.image: "sym_right_light_normal.png" COMP;
207 images.image: "sym_right_glow_normal.png" COMP; 207 images.image: "sym_right_glow_normal.png" COMP;
208 images.image: "sym_right_dark_normal.png" COMP; 208 images.image: "sym_right_dark_normal.png" COMP;
@@ -352,13 +352,13 @@ group { "efl/spin_button/inc_button";
352 } 352 }
353} 353}
354 354
355group { "efl/spin_button/entry"; 355group { "efl/spin_button/horizontal/entry";
356 alias: "efl/spin_button/vertical/entry"; 356 alias: "efl/spin_button/vertical/entry";
357 inherit: "efl/text"; 357 inherit: "efl/text";
358} 358}
359 359
360group { "efl/spin_button/dec_button"; 360group { "efl/spin_button/horizontal/dec_button";
361 inherit: "efl/spin_button/inc_button"; 361 inherit: "efl/spin_button/horizontal/inc_button";
362 images.image: "sym_left_light_normal.png" COMP; 362 images.image: "sym_left_light_normal.png" COMP;
363 images.image: "sym_left_glow_normal.png" COMP; 363 images.image: "sym_left_glow_normal.png" COMP;
364 images.image: "sym_left_dark_normal.png" COMP; 364 images.image: "sym_left_dark_normal.png" COMP;
@@ -382,7 +382,7 @@ group { "efl/spin_button/dec_button";
382 } 382 }
383} 383}
384 384
385group { "efl/spin_button/text_button"; 385group { "efl/spin_button/horizontal/text_button";
386 alias: "efl/spin_button/vertical/text_button"; 386 alias: "efl/spin_button/vertical/text_button";
387 parts { 387 parts {
388 part { name: "bg"; 388 part { name: "bg";
@@ -460,7 +460,7 @@ group { "efl/spin_button/text_button";
460} 460}
461 461
462group { "efl/spin_button/vertical/inc_button"; 462group { "efl/spin_button/vertical/inc_button";
463 inherit: "efl/spin_button/inc_button"; 463 inherit: "efl/spin_button/horizontal/inc_button";
464 images.image: "sym_up_light_normal.png" COMP; 464 images.image: "sym_up_light_normal.png" COMP;
465 images.image: "sym_up_glow_normal.png" COMP; 465 images.image: "sym_up_glow_normal.png" COMP;
466 images.image: "sym_up_dark_normal.png" COMP; 466 images.image: "sym_up_dark_normal.png" COMP;
@@ -485,7 +485,7 @@ group { "efl/spin_button/vertical/inc_button";
485} 485}
486 486
487group { "efl/spin_button/vertical/dec_button"; 487group { "efl/spin_button/vertical/dec_button";
488 inherit: "efl/spin_button/dec_button"; 488 inherit: "efl/spin_button/horizontal/dec_button";
489 images.image: "sym_down_light_normal.png" COMP; 489 images.image: "sym_down_light_normal.png" COMP;
490 images.image: "sym_down_glow_normal.png" COMP; 490 images.image: "sym_down_glow_normal.png" COMP;
491 images.image: "sym_down_dark_normal.png" COMP; 491 images.image: "sym_down_dark_normal.png" COMP;
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index fa45e84d2e..34de0b7d7e 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -357,10 +357,6 @@ _toggle_entry(Evas_Object *obj)
357 // filter feature implemented. 357 // filter feature implemented.
358 // (Current efl_ui_text has missed filter feature.) 358 // (Current efl_ui_text has missed filter feature.)
359 sd->ent = elm_entry_add(obj); 359 sd->ent = elm_entry_add(obj);
360 Eina_Strbuf *buf = eina_strbuf_new();
361 eina_strbuf_append_printf(buf, "spinner/%s", elm_widget_style_get(obj));
362 elm_widget_style_set(sd->ent, eina_strbuf_string_get(buf));
363 eina_strbuf_free(buf);
364 evas_object_event_callback_add 360 evas_object_event_callback_add
365 (sd->ent, EVAS_CALLBACK_SHOW, _entry_show_cb, obj); 361 (sd->ent, EVAS_CALLBACK_SHOW, _entry_show_cb, obj);
366 elm_entry_single_line_set(sd->ent, EINA_TRUE); 362 elm_entry_single_line_set(sd->ent, EINA_TRUE);
@@ -371,6 +367,7 @@ _toggle_entry(Evas_Object *obj)
371 elm_entry_markup_filter_append(sd->ent, _min_max_validity_filter, obj); 367 elm_entry_markup_filter_append(sd->ent, _min_max_validity_filter, obj);
372 efl_event_callback_add(sd->ent, ELM_ENTRY_EVENT_ACTIVATED, 368 efl_event_callback_add(sd->ent, ELM_ENTRY_EVENT_ACTIVATED,
373 _entry_activated_cb, obj); 369 _entry_activated_cb, obj);
370 elm_widget_element_update(obj, sd->ent, "entry");
374 } 371 }
375 372
376 efl_event_callback_add(sd->ent, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED, 373 efl_event_callback_add(sd->ent, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
@@ -602,71 +599,21 @@ _access_spinner_register(Evas_Object *obj, Eina_Bool is_access)
602 } 599 }
603} 600}
604 601
605static const char * 602static void
606_theme_group_modify_pos_get(const char *cur_group, const char *search, size_t len) 603_sync_widget_theme_klass(Eo *obj, Efl_Ui_Spin_Button_Data *pd)
607{
608 const char *pos = NULL;
609 const char *temp_str = NULL;
610
611 temp_str = cur_group + len - strlen(search);
612 if (temp_str >= cur_group)
613 {
614 if (!strcmp(temp_str, search))
615 pos = temp_str;
616 }
617
618 return pos;
619}
620
621static char *
622_efl_ui_spin_button_theme_group_get(Evas_Object *obj, Efl_Ui_Spin_Button_Data *sd)
623{ 604{
624 const char *pos = NULL; 605 if (efl_ui_layout_orientation_is_horizontal(pd->dir, EINA_TRUE))
625 const char *cur_group = elm_widget_theme_element_get(obj); 606 elm_widget_theme_klass_set(obj, "spin_button/horizontal");
626 Eina_Strbuf *new_group = eina_strbuf_new();
627 size_t len = 0;
628
629 if (cur_group)
630 {
631 len = strlen(cur_group);
632 pos = _theme_group_modify_pos_get(cur_group, "horizontal", len);
633 if (!pos)
634 pos = _theme_group_modify_pos_get(cur_group, "vertical", len);
635
636 // TODO: change separator when it is decided.
637 // can skip when prev_group == cur_group
638 if (!pos)
639 {
640 eina_strbuf_append(new_group, cur_group);
641 eina_strbuf_append(new_group, "/");
642 }
643 else
644 {
645 eina_strbuf_append_length(new_group, cur_group, pos - cur_group);
646 }
647 }
648
649 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE))
650 eina_strbuf_append(new_group, "horizontal");
651 else 607 else
652 eina_strbuf_append(new_group, "vertical"); 608 elm_widget_theme_klass_set(obj, "spin_button/vertical");
653
654 return eina_strbuf_release(new_group);
655} 609}
656 610
657
658EOLIAN static Eina_Error 611EOLIAN static Eina_Error
659_efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED) 612_efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED)
660{ 613{
661 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC; 614 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
662 char *group;
663 615
664 group = _efl_ui_spin_button_theme_group_get(obj, sd); 616 _sync_widget_theme_klass(obj, sd);
665 if (group)
666 {
667 elm_widget_theme_element_set(obj, group);
668 free(group);
669 }
670 617
671 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 618 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
672 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; 619 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
@@ -694,23 +641,19 @@ _efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *
694EOLIAN static Eo * 641EOLIAN static Eo *
695_efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd) 642_efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
696{ 643{
697 char *group;
698 644
699 obj = efl_constructor(efl_super(obj, MY_CLASS)); 645 obj = efl_constructor(efl_super(obj, MY_CLASS));
700 elm_widget_theme_klass_set(obj, "spin_button"); 646 _sync_widget_theme_klass(obj, sd);
701 647
702 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); 648 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
703 649
704 group = _efl_ui_spin_button_theme_group_get(obj, sd);
705 if (elm_widget_theme_object_set(obj, wd->resize_obj, 650 if (elm_widget_theme_object_set(obj, wd->resize_obj,
706 elm_widget_theme_klass_get(obj), 651 elm_widget_theme_klass_get(obj),
707 group, 652 elm_widget_theme_element_get(obj),
708 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC) 653 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
709 CRI("Failed to set layout!"); 654 CRI("Failed to set layout!");
710 655
711 656
712 free(group);
713
714 sd->inc_button = efl_add(EFL_UI_BUTTON_CLASS, obj, 657 sd->inc_button = efl_add(EFL_UI_BUTTON_CLASS, obj,
715 efl_ui_autorepeat_enabled_set(efl_added, EINA_TRUE), 658 efl_ui_autorepeat_enabled_set(efl_added, EINA_TRUE),
716 efl_ui_autorepeat_initial_timeout_set(efl_added, _elm_config->longpress_timeout), 659 efl_ui_autorepeat_initial_timeout_set(efl_added, _elm_config->longpress_timeout),