summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-01-16 11:55:59 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-16 16:36:39 +0100
commit250c7bd30dc8aab54047e4d1fac480c17565b922 (patch)
tree7be2a3551537bf2ddc23c212ded1b62a670f3d5e
parent2f4ca46544c93a7d7bbbded0cf37cb34f1672b53 (diff)
efl.ui.textbox: theme code cleanup
>You should not theme in _efl_ui_textbox_efl_object_finalize, but rather in theme_apply >All part swallow things should be done in theme_apply. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11103
-rw-r--r--src/lib/elementary/efl_ui_textbox.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/lib/elementary/efl_ui_textbox.c b/src/lib/elementary/efl_ui_textbox.c
index 7d34929e89..79796977a3 100644
--- a/src/lib/elementary/efl_ui_textbox.c
+++ b/src/lib/elementary/efl_ui_textbox.c
@@ -623,6 +623,9 @@ _efl_ui_textbox_efl_ui_widget_disabled_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Ein
623{ 623{
624 const char *emission; 624 const char *emission;
625 625
626 if (efl_ui_widget_disabled_get(obj) == disabled)
627 return;
628
626 efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); 629 efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled);
627 630
628 elm_drop_target_del(obj, sd->drop_format, 631 elm_drop_target_del(obj, sd->drop_format,
@@ -659,11 +662,11 @@ _efl_ui_textbox_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Textbox_Data *sd)
659 662
660 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 663 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
661 664
662 // Note: We are skipping elm_layout here! This is by design. 665 theme_apply = efl_ui_widget_theme_apply(efl_super(obj,MY_CLASS));
663 // This assumes the following inheritance: my_class -> layout -> widget ...
664 theme_apply = efl_ui_widget_theme_apply(efl_cast(obj, EFL_UI_WIDGET_CLASS));
665 if (theme_apply == EFL_UI_THEME_APPLY_ERROR_GENERIC) return EFL_UI_THEME_APPLY_ERROR_GENERIC; 666 if (theme_apply == EFL_UI_THEME_APPLY_ERROR_GENERIC) return EFL_UI_THEME_APPLY_ERROR_GENERIC;
666 667
668 _update_text_theme(obj, sd);
669
667 efl_event_freeze(obj); 670 efl_event_freeze(obj);
668 671
669 edje_object_mirrored_set 672 edje_object_mirrored_set
@@ -707,6 +710,15 @@ _efl_ui_textbox_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Textbox_Data *sd)
707 710
708 efl_unref(obj); 711 efl_unref(obj);
709 712
713 if (efl_content_get(efl_part(sd->entry_edje, "efl.text")) == NULL && !sd->scroller)
714 {
715 efl_pack_table(sd->text_table, sd->text_obj, 0, 0, 1, 1);
716 efl_pack_table(sd->text_table, sd->text_guide_obj, 0, 0, 1, 1);
717 efl_content_set(efl_part(sd->entry_edje, "efl.text"), sd->text_table);
718 }
719
720 _create_text_cursors(obj, sd);
721
710 return theme_apply; 722 return theme_apply;
711} 723}
712 724
@@ -1772,25 +1784,25 @@ _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd)
1772 1784
1773 // Main Text 1785 // Main Text
1774 // font_set 1786 // font_set
1775 font_name = edje_object_data_get(wd->resize_obj, "font.name"); 1787 font_name = efl_layout_group_data_get(wd->resize_obj, "font.name");
1776 font_size = edje_object_data_get(wd->resize_obj, "font.size"); 1788 font_size = efl_layout_group_data_get(wd->resize_obj, "font.size");
1777 font_size_n = font_size ? atoi(font_size) : 0; 1789 font_size_n = font_size ? atoi(font_size) : 0;
1778 efl_text_font_family_set(sd->text_obj, font_name); 1790 efl_text_font_family_set(sd->text_obj, font_name);
1779 efl_text_font_size_set(sd->text_obj, font_size_n); 1791 efl_text_font_size_set(sd->text_obj, font_size_n);
1780 1792
1781 // color 1793 // color
1782 if (disabled) 1794 if (disabled)
1783 colorcode = edje_object_data_get(wd->resize_obj, "style.color_disabled"); 1795 colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color_disabled");
1784 if (!colorcode) 1796 if (!colorcode)
1785 colorcode = edje_object_data_get(wd->resize_obj, "style.color"); 1797 colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color");
1786 if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a)) 1798 if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a))
1787 { 1799 {
1788 efl_text_color_set(sd->text_obj, r, g, b, a); 1800 efl_text_color_set(sd->text_obj, r, g, b, a);
1789 } 1801 }
1790 1802
1791 // Guide Text 1803 // Guide Text
1792 font_name = edje_object_data_get(wd->resize_obj, "guide.font.name"); 1804 font_name = efl_layout_group_data_get(wd->resize_obj, "guide.font.name");
1793 font_size = edje_object_data_get(wd->resize_obj, "guide.font.size"); 1805 font_size = efl_layout_group_data_get(wd->resize_obj, "guide.font.size");
1794 font_size_n = font_size ? atoi(font_size) : 0; 1806 font_size_n = font_size ? atoi(font_size) : 0;
1795 efl_text_font_family_set(sd->text_guide_obj, font_name); 1807 efl_text_font_family_set(sd->text_guide_obj, font_name);
1796 efl_text_font_size_set(sd->text_guide_obj, font_size_n); 1808 efl_text_font_size_set(sd->text_guide_obj, font_size_n);
@@ -1798,9 +1810,9 @@ _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd)
1798 colorcode = NULL; 1810 colorcode = NULL;
1799 // color 1811 // color
1800 if (disabled) 1812 if (disabled)
1801 colorcode = edje_object_data_get(wd->resize_obj, "guide.style.color_disabled"); 1813 colorcode = efl_layout_group_data_get(wd->resize_obj, "guide.style.color_disabled");
1802 if (!colorcode) 1814 if (!colorcode)
1803 colorcode = edje_object_data_get(wd->resize_obj, "guide.style.color"); 1815 colorcode = efl_layout_group_data_get(wd->resize_obj, "guide.style.color");
1804 if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a)) 1816 if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a))
1805 { 1817 {
1806 efl_text_color_set(sd->text_guide_obj, r, g, b, a); 1818 efl_text_color_set(sd->text_guide_obj, r, g, b, a);
@@ -1850,33 +1862,14 @@ _efl_ui_textbox_efl_object_finalize(Eo *obj,
1850{ 1862{
1851 obj = efl_finalize(efl_super(obj, MY_CLASS)); 1863 obj = efl_finalize(efl_super(obj, MY_CLASS));
1852 1864
1853 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
1854
1855 elm_drop_target_add(obj, sd->drop_format, 1865 elm_drop_target_add(obj, sd->drop_format,
1856 _dnd_enter_cb, NULL, 1866 _dnd_enter_cb, NULL,
1857 _dnd_leave_cb, NULL, 1867 _dnd_leave_cb, NULL,
1858 _dnd_pos_cb, NULL, 1868 _dnd_pos_cb, NULL,
1859 _dnd_drop_cb, NULL); 1869 _dnd_drop_cb, NULL);
1860 1870
1861 if (elm_widget_theme_object_set(obj, wd->resize_obj,
1862 elm_widget_theme_klass_get(obj),
1863 elm_widget_theme_element_get(obj),
1864 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
1865 CRI("Failed to set layout!");
1866
1867 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY); 1871 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY);
1868 1872
1869 //TODO: complete the usage of the text theme
1870 _update_text_theme(obj, sd);
1871 //efl_text_font_set(sd->text_obj, "Sans", 12);
1872
1873 efl_pack_table(sd->text_table, sd->text_obj, 0, 0, 1, 1);
1874 efl_pack_table(sd->text_table, sd->text_guide_obj, 0, 0, 1, 1);
1875
1876 //edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
1877 //edje_object_part_swallow(sd->entry_edje, "efl.text_guide", sd->text_guide_obj);
1878 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
1879
1880 _update_guide_text(obj, sd); 1873 _update_guide_text(obj, sd);
1881 1874
1882 sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj); 1875 sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
@@ -1920,10 +1913,6 @@ _efl_ui_textbox_efl_object_finalize(Eo *obj,
1920 efl_input_text_predictable_set(obj, EINA_TRUE); 1913 efl_input_text_predictable_set(obj, EINA_TRUE);
1921 efl_input_text_input_hint_set(obj, EFL_INPUT_TEXT_HINTS_TYPE_AUTO_COMPLETE); 1914 efl_input_text_input_hint_set(obj, EFL_INPUT_TEXT_HINTS_TYPE_AUTO_COMPLETE);
1922 1915
1923 _mirrored_set(obj, efl_ui_mirrored_get(obj));
1924
1925 _create_text_cursors(obj, sd);
1926
1927 sd->calc_force = EINA_TRUE; 1916 sd->calc_force = EINA_TRUE;
1928 1917
1929 return obj; 1918 return obj;