summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-01-14 16:29:50 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-15 10:49:58 +0100
commit1a1868ce57a3c0e45735bb3afa5aa5243ef78018 (patch)
treecacd40f4ffca99b5f5dfd429af4d2724c7f0ee73
parent76631f502a8234c04ed8124bfdebe62ed5bdf954 (diff)
efl.ui.textbox: replace hoversel with popup
efl.ui.textbox: replace hoversel with popup **I think this may need some changes, please let me know what you think** Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11072
-rw-r--r--src/lib/elementary/efl_ui_textbox.c245
1 files changed, 104 insertions, 141 deletions
diff --git a/src/lib/elementary/efl_ui_textbox.c b/src/lib/elementary/efl_ui_textbox.c
index d88f6a432c..c64c1baf03 100644
--- a/src/lib/elementary/efl_ui_textbox.c
+++ b/src/lib/elementary/efl_ui_textbox.c
@@ -15,7 +15,6 @@
15 15
16#include "elm_entry_common.h" 16#include "elm_entry_common.h"
17#include "elm_widget_entry.h" 17#include "elm_widget_entry.h"
18#include "elm_hoversel_eo.h"
19#include "efl_ui_text_part.eo.h" 18#include "efl_ui_text_part.eo.h"
20#include "elm_part_helper.h" 19#include "elm_part_helper.h"
21#include "efl_canvas_textblock_internal.h" 20#include "efl_canvas_textblock_internal.h"
@@ -32,7 +31,8 @@ struct _Efl_Ui_Textbox_Data
32{ 31{
33 Evas_Object *hit_rect, *entry_edje; 32 Evas_Object *hit_rect, *entry_edje;
34 33
35 Evas_Object *hoversel; 34 Eo *popup;
35 Eo *popup_list;
36 Eo *text_obj; 36 Eo *text_obj;
37 Eo *text_guide_obj; 37 Eo *text_guide_obj;
38 Eo *text_table; 38 Eo *text_table;
@@ -59,7 +59,6 @@ struct _Efl_Ui_Textbox_Data
59 Eina_List *sel; 59 Eina_List *sel;
60 Efl_Canvas_Textblock_Factory *item_factory; 60 Efl_Canvas_Textblock_Factory *item_factory;
61 Efl_Canvas_Textblock_Factory *item_fallback_factory; 61 Efl_Canvas_Textblock_Factory *item_fallback_factory;
62 Ecore_Job *hov_deljob;
63 Mod_Api *api; // module api if supplied 62 Mod_Api *api; // module api if supplied
64 int cursor_pos; 63 int cursor_pos;
65 Elm_Scroller_Policy policy_h, policy_v; 64 Elm_Scroller_Policy policy_h, policy_v;
@@ -841,7 +840,7 @@ _efl_ui_textbox_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Textbox_Data
841 840
842 if (_elm_config->selection_clear_enable) 841 if (_elm_config->selection_clear_enable)
843 { 842 {
844 if ((efl_text_interactive_have_selection_get(obj)) && (!sd->hoversel)) 843 if ((efl_text_interactive_have_selection_get(obj)) && (!sd->popup))
845 { 844 {
846 sd->sel_mode = EINA_FALSE; 845 sd->sel_mode = EINA_FALSE;
847 efl_ui_widget_scroll_hold_pop(obj); 846 efl_ui_widget_scroll_hold_pop(obj);
@@ -882,7 +881,7 @@ _efl_ui_textbox_efl_ui_widget_interest_region_get(const Eo *obj EINA_UNUSED, Efl
882} 881}
883 882
884static void 883static void
885_hoversel_position(Evas_Object *obj) 884_popup_position(Evas_Object *obj)
886{ 885{
887 Evas_Coord cx, cy, cw, ch, x, y, mw, mh, w, h; 886 Evas_Coord cx, cy, cw, ch, x, y, mw, mh, w, h;
888 887
@@ -902,74 +901,12 @@ _hoversel_position(Evas_Object *obj)
902 edje_object_part_text_cursor_geometry_get 901 edje_object_part_text_cursor_geometry_get
903 (sd->entry_edje, "efl.text", &cx, &cy, &cw, &ch); 902 (sd->entry_edje, "efl.text", &cx, &cy, &cw, &ch);
904 903
905 evas_object_size_hint_min_get(sd->hoversel, &mw, &mh); 904 evas_object_size_hint_min_get(sd->popup, &mw, &mh);
906 if (cx + mw > w) 905 if (cx + mw > w)
907 cx = w - mw; 906 cx = w - mw;
908 if (cy + mh > h) 907 if (cy + mh > h)
909 cy = h - mh; 908 cy = h - mh;
910 evas_object_geometry_set(sd->hoversel, x + cx, y + cy, mw, mh); 909 evas_object_geometry_set(sd->popup, x + cx, y + cy, mw, mh);
911}
912
913static void
914_hover_del_job(void *data)
915{
916 EFL_UI_TEXT_DATA_GET(data, sd);
917
918 ELM_SAFE_FREE(sd->hoversel, evas_object_del);
919 sd->hov_deljob = NULL;
920}
921
922static void
923_hover_dismissed_cb(void *data, const Efl_Event *event EINA_UNUSED)
924{
925 EFL_UI_TEXT_DATA_GET(data, sd);
926
927 sd->use_down = 0;
928 if (sd->hoversel) evas_object_hide(sd->hoversel);
929 if (sd->sel_mode)
930 {
931 if (!_elm_config->desktop_entry)
932 {
933 if (!efl_text_password_get(data))
934 edje_object_part_text_select_allow_set
935 (sd->entry_edje, "efl.text", EINA_TRUE);
936 }
937 }
938 efl_ui_widget_scroll_freeze_pop(data);
939 ecore_job_del(sd->hov_deljob);
940 sd->hov_deljob = ecore_job_add(_hover_del_job, data);
941}
942
943static void
944_hover_selected_cb(void *data,
945 Evas_Object *obj EINA_UNUSED,
946 void *event_info EINA_UNUSED)
947{
948 EFL_UI_TEXT_DATA_GET(data, sd);
949
950 if (!efl_text_interactive_selection_allowed_get(obj)) return;
951
952 sd->sel_mode = EINA_TRUE;
953 edje_object_part_text_select_none(sd->entry_edje, "efl.text");
954
955 if (!_elm_config->desktop_entry)
956 {
957 if (!efl_text_password_get(data))
958 edje_object_part_text_select_allow_set
959 (sd->entry_edje, "efl.text", EINA_TRUE);
960 }
961 efl_layout_signal_emit(sd->entry_edje, "efl,state,select,on", "efl");
962
963 if (!_elm_config->desktop_entry)
964 efl_ui_widget_scroll_hold_push(data);
965}
966
967static void
968_hoversel_item_paste_cb(void *data,
969 Evas_Object *obj EINA_UNUSED,
970 void *event_info EINA_UNUSED)
971{
972 efl_ui_textbox_selection_paste(data);
973} 910}
974 911
975static Eina_Value 912static Eina_Value
@@ -1053,43 +990,63 @@ end:
1053} 990}
1054 991
1055static void 992static void
1056_hoversel_item_cut_cb(void *data, 993_popup_dismiss( Efl_Ui_Textbox_Data *sd)
1057 Evas_Object *obj EINA_UNUSED,
1058 void *event_info EINA_UNUSED)
1059{ 994{
995 efl_del(sd->popup_list);
996 efl_del(sd->popup);
997 sd->popup = NULL;
998 sd->popup_list = NULL;
999}
1000
1001static void
1002_backwall_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
1003{
1004 EFL_UI_TEXT_DATA_GET(data, sd);
1005 _popup_dismiss(sd);
1006}
1007
1008static void
1009_popup_item_cut_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1010{
1011 EFL_UI_TEXT_DATA_GET(data, sd);
1060 efl_ui_textbox_selection_cut(data); 1012 efl_ui_textbox_selection_cut(data);
1013 _popup_dismiss(sd);
1061} 1014}
1062 1015
1063static void 1016static void
1064_hoversel_item_copy_cb(void *data, 1017_popup_item_copy_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1065 Evas_Object *obj EINA_UNUSED,
1066 void *event_info EINA_UNUSED)
1067{ 1018{
1019 EFL_UI_TEXT_DATA_GET(data, sd);
1068 efl_ui_textbox_selection_copy(data); 1020 efl_ui_textbox_selection_copy(data);
1021 _popup_dismiss(sd);
1069} 1022}
1070 1023
1071static void 1024static void
1072_hover_cancel_cb(void *data, 1025_popup_item_cancel_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1073 Evas_Object *obj EINA_UNUSED,
1074 void *event_info EINA_UNUSED)
1075{ 1026{
1076 EFL_UI_TEXT_DATA_GET(data, sd); 1027 EFL_UI_TEXT_DATA_GET(data, sd);
1077 1028
1078 sd->sel_mode = EINA_FALSE; 1029 if (!efl_text_interactive_selection_allowed_get(data)) return;
1079 if (!_elm_config->desktop_entry) 1030
1080 edje_object_part_text_select_allow_set
1081 (sd->entry_edje, "efl.text", EINA_FALSE);
1082 efl_layout_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
1083 if (!_elm_config->desktop_entry) 1031 if (!_elm_config->desktop_entry)
1084 efl_ui_widget_scroll_hold_pop(data); 1032 efl_ui_widget_scroll_hold_pop(data);
1085 edje_object_part_text_select_none(sd->entry_edje, "efl.text"); 1033
1034 sd->sel_mode = EINA_FALSE;
1035 efl_text_interactive_all_unselect(data);
1036 _popup_dismiss(sd);
1086} 1037}
1087 1038
1088static void 1039static void
1089_menu_call(Evas_Object *obj) 1040_popup_item_paste_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1090{ 1041{
1091 Evas_Object *top; 1042 EFL_UI_TEXT_DATA_GET(data, sd);
1043 efl_ui_textbox_selection_paste(data);
1044 _popup_dismiss(sd);
1045}
1092 1046
1047static void
1048_menu_call(Evas_Object *obj)
1049{
1093 EFL_UI_TEXT_DATA_GET(obj, sd); 1050 EFL_UI_TEXT_DATA_GET(obj, sd);
1094 1051
1095 if (sd->anchor_hover.hover) return; 1052 if (sd->anchor_hover.hover) return;
@@ -1102,7 +1059,6 @@ _menu_call(Evas_Object *obj)
1102 } 1059 }
1103 else if (sd->context_menu_enabled) 1060 else if (sd->context_menu_enabled)
1104 { 1061 {
1105 const char *context_menu_orientation;
1106 Eina_Bool ownersel; 1062 Eina_Bool ownersel;
1107 1063
1108 ownersel = elm_selection_selection_has_owner(obj); 1064 ownersel = elm_selection_selection_has_owner(obj);
@@ -1110,83 +1066,90 @@ _menu_call(Evas_Object *obj)
1110 if (efl_text_interactive_have_selection_get(obj) && efl_text_password_get(obj)) return; 1066 if (efl_text_interactive_have_selection_get(obj) && efl_text_password_get(obj)) return;
1111 if (_elm_config->desktop_entry && (!efl_text_interactive_have_selection_get(obj)) && ((!efl_text_interactive_editable_get(obj)) || (!ownersel))) 1067 if (_elm_config->desktop_entry && (!efl_text_interactive_have_selection_get(obj)) && ((!efl_text_interactive_editable_get(obj)) || (!ownersel)))
1112 return; 1068 return;
1113 if (sd->hoversel) evas_object_del(sd->hoversel); 1069 if (sd->popup) _popup_dismiss(sd);
1114 else efl_ui_widget_scroll_freeze_push(obj); 1070 else efl_ui_widget_scroll_freeze_push(obj);
1115 1071
1116 sd->hoversel = elm_hoversel_add(obj); 1072 sd->popup = efl_add(EFL_UI_POPUP_CLASS, obj);
1117 context_menu_orientation = efl_layout_group_data_get
1118 (sd->entry_edje, "context_menu_orientation");
1119
1120 if ((context_menu_orientation) &&
1121 (!strcmp(context_menu_orientation, "horizontal")))
1122 elm_hoversel_horizontal_set(sd->hoversel, EINA_TRUE);
1123 1073
1124 elm_object_style_set(sd->hoversel, "entry"); 1074 sd->popup_list = efl_add(EFL_UI_LIST_CLASS, sd->popup);
1125 efl_ui_widget_sub_object_add(obj, sd->hoversel); 1075 efl_content_set(sd->popup, sd->popup_list);
1126 elm_object_text_set(sd->hoversel, "Text"); 1076 efl_gfx_hint_align_set(sd->popup_list, 1.0, 1.0);
1127 top = elm_widget_top_get(obj); 1077 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1128 1078
1129 if (top) elm_hoversel_hover_parent_set(sd->hoversel, top); 1079 efl_ui_widget_sub_object_add(obj, sd->popup);
1080 efl_ui_popup_anchor_set(sd->popup, obj);
1081 efl_event_callback_add(sd->popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED, _backwall_clicked, obj);
1130 1082
1131 efl_event_callback_add
1132 (sd->hoversel, ELM_HOVERSEL_EVENT_DISMISSED, _hover_dismissed_cb, obj);
1133 if (efl_text_interactive_have_selection_get(obj)) 1083 if (efl_text_interactive_have_selection_get(obj))
1134 { 1084 {
1135 if (!efl_text_password_get(obj)) 1085 if (!efl_text_password_get(obj))
1136 { 1086 {
1137 if (efl_text_interactive_editable_get(obj)) 1087 if (efl_text_interactive_editable_get(obj))
1138 elm_hoversel_item_add 1088 {
1139 (sd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE, 1089 Eo *il = NULL;
1140 _hoversel_item_cut_cb, obj); 1090 il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, sd->popup_list);
1141 elm_hoversel_item_add 1091 efl_text_set(il, E_("Cut"));
1142 (sd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE, 1092 efl_gfx_hint_align_set(il, 1.0, 1.0);
1143 _hoversel_item_copy_cb, obj); 1093 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1144 if (efl_text_interactive_editable_get(obj) && ownersel) 1094 efl_pack_end(sd->popup_list, il);
1145 elm_hoversel_item_add 1095 efl_event_callback_add(il, EFL_UI_EVENT_SELECTED_CHANGED, _popup_item_cut_cb, obj);
1146 (sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE, 1096
1147 _hoversel_item_paste_cb, obj); 1097 il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, sd->popup_list);
1148 elm_hoversel_item_add 1098 efl_text_set(il, E_("Copy"));
1149 (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE, 1099 efl_gfx_hint_align_set(il, 1.0, 1.0);
1150 _hover_cancel_cb, obj); 1100 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1101 efl_pack_end(sd->popup_list, il);
1102 efl_event_callback_add(il, EFL_UI_EVENT_SELECTED_CHANGED, _popup_item_copy_cb, obj);
1103
1104 il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, sd->popup_list);
1105 efl_text_set(il, E_("Paste"));
1106 efl_gfx_hint_align_set(il, 1.0, 1.0);
1107 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1108 efl_pack_end(sd->popup_list, il);
1109 efl_event_callback_add(il, EFL_UI_EVENT_SELECTED_CHANGED, _popup_item_paste_cb, obj);
1110
1111 il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, sd->popup_list);
1112 efl_text_set(il, E_("Cancel"));
1113 efl_gfx_hint_align_set(il, 1.0, 1.0);
1114 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1115 efl_pack_end(sd->popup_list, il);
1116 efl_event_callback_add(il, EFL_UI_EVENT_SELECTED_CHANGED, _popup_item_cancel_cb, obj);
1117 }
1151 } 1118 }
1152 } 1119 }
1153 else 1120 else
1154 { 1121 {
1155 if (!sd->sel_mode) 1122 if (!sd->sel_mode)
1156 { 1123 {
1157 if (efl_text_interactive_selection_allowed_get(obj) && !_elm_config->desktop_entry)
1158 {
1159 if (!efl_text_password_get(obj))
1160 elm_hoversel_item_add
1161 (sd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
1162 _hover_selected_cb, obj);
1163 }
1164 if (ownersel) 1124 if (ownersel)
1165 { 1125 {
1166 if (efl_text_interactive_editable_get(obj)) 1126 if (efl_text_interactive_editable_get(obj))
1167 elm_hoversel_item_add 1127 {
1168 (sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE, 1128 Eo *il = NULL;
1169 _hoversel_item_paste_cb, obj); 1129 il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, sd->popup_list);
1130 efl_text_set(il, E_("Paste"));
1131 efl_gfx_hint_align_set(il, 1.0, 1.0);
1132 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1133 efl_pack_end(sd->popup_list, il);
1134 efl_event_callback_add(il, EFL_UI_EVENT_SELECTED_CHANGED, _popup_item_paste_cb, obj);
1135 }
1170 } 1136 }
1171 } 1137 }
1172 else 1138 else
1173 elm_hoversel_item_add 1139 {
1174 (sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE, 1140 Eo *il = NULL;
1175 _hover_cancel_cb, obj); 1141 il = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, sd->popup_list);
1176 } 1142 efl_text_set(il, E_("Cancel"));
1177 1143 efl_gfx_hint_align_set(il, 1.0, 1.0);
1178 if (sd->hoversel) 1144 efl_gfx_hint_weight_set(sd->popup_list, 1.0, 1.0);
1179 { 1145 efl_pack_end(sd->popup_list, il);
1180 _hoversel_position(obj); 1146 efl_event_callback_add(il, EFL_UI_EVENT_SELECTED_CHANGED, _popup_item_cancel_cb, obj);
1181 evas_object_show(sd->hoversel); 1147 }
1182 elm_hoversel_hover_begin(sd->hoversel);
1183 } 1148 }
1184 1149
1185 if (!_elm_config->desktop_entry) 1150 if (sd->popup)
1186 { 1151 {
1187 edje_object_part_text_select_allow_set 1152 _popup_position(obj);
1188 (sd->entry_edje, "efl.text", EINA_FALSE);
1189 edje_object_part_text_select_abort(sd->entry_edje, "efl.text");
1190 } 1153 }
1191 } 1154 }
1192} 1155}
@@ -1672,7 +1635,7 @@ _efl_ui_textbox_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Ei
1672 efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos); 1635 efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
1673 efl_gfx_entity_position_set(sd->hit_rect, pos); 1636 efl_gfx_entity_position_set(sd->hit_rect, pos);
1674 1637
1675 if (sd->hoversel) _hoversel_position(obj); 1638 if (sd->popup) _popup_position(obj);
1676} 1639}
1677 1640
1678EOLIAN static void 1641EOLIAN static void
@@ -1973,7 +1936,7 @@ _efl_ui_textbox_efl_object_destructor(Eo *obj, Efl_Ui_Textbox_Data *sd)
1973 1936
1974 eina_stringshare_del(sd->file); 1937 eina_stringshare_del(sd->file);
1975 1938
1976 ecore_job_del(sd->hov_deljob); 1939 _popup_dismiss(sd);
1977 if ((sd->api) && (sd->api->obj_unhook)) 1940 if ((sd->api) && (sd->api->obj_unhook))
1978 sd->api->obj_unhook(obj); // module - unhook 1941 sd->api->obj_unhook(obj); // module - unhook
1979 1942