summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2014-03-06 19:33:05 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-03-06 20:15:10 +0900
commitd57cda07c48741779bc8c1384afcd422c327a338 (patch)
tree0278d019f5c95435063e7eaf73b3d89d19b7e347
parent11aec4131832443f23a00b0b333a875bb23a13d2 (diff)
Fix bug of moving cursor handler
Summary: In elm entry, cursor handlers are placed and moved incorrectly if we do selection from bottom to top. Ex: In elementary_test -> Entry -> Right click -> choose Select -> do selection from bottom to top (or press Shift + <- keys to do selection). Look at selection handlers: they are incorrectly placed. Try to move selection handlers: They suddenly move to near each other. Minor: Remove unused variable. @fix Reviewers: seoz Differential Revision: https://phab.enlightenment.org/D583
-rw-r--r--src/lib/elm_entry.c111
-rw-r--r--src/lib/elm_widget_entry.h2
2 files changed, 70 insertions, 43 deletions
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index 5217940de..ab4de25bf 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -393,10 +393,10 @@ _update_selection_handler(Evas_Object *obj)
393{ 393{
394 ELM_ENTRY_DATA_GET(obj, sd); 394 ELM_ENTRY_DATA_GET(obj, sd);
395 395
396 Evas_Coord sx, sy, sw, sh; 396 Evas_Coord sx, sy, sh;
397 Evas_Coord ent_x, ent_y; 397 Evas_Coord ent_x, ent_y;
398 Evas_Coord ex, ey, ew, eh; 398 Evas_Coord ex, ey, eh;
399 int start_pos, end_pos; 399 int start_pos, end_pos, last_pos;
400 400
401 if (!sd->sel_handler_disabled) 401 if (!sd->sel_handler_disabled)
402 { 402 {
@@ -406,31 +406,39 @@ _update_selection_handler(Evas_Object *obj)
406 (sd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_END); 406 (sd->entry_edje, "elm.text", EDJE_CURSOR_SELECTION_END);
407 407
408 evas_object_geometry_get(sd->entry_edje, &ent_x, &ent_y, NULL, NULL); 408 evas_object_geometry_get(sd->entry_edje, &ent_x, &ent_y, NULL, NULL);
409 last_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
410 EDJE_CURSOR_MAIN);
409 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", 411 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
410 EDJE_CURSOR_MAIN, start_pos); 412 EDJE_CURSOR_MAIN, start_pos);
411 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", 413 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text",
412 &sx, &sy, &sw, &sh); 414 &sx, &sy, NULL, &sh);
413 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", 415 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
414 EDJE_CURSOR_MAIN, end_pos); 416 EDJE_CURSOR_MAIN, end_pos);
415 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", 417 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text",
416 &ex, &ey, &ew, &eh); 418 &ex, &ey, NULL, &eh);
417 if (sd->start_handler_down) 419 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
418 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", 420 EDJE_CURSOR_MAIN, last_pos);
419 EDJE_CURSOR_MAIN, start_pos);
420 if (!sd->start_handler_shown) 421 if (!sd->start_handler_shown)
421 { 422 {
422 edje_object_signal_emit(sd->start_handler, 423 edje_object_signal_emit(sd->start_handler,
423 "elm,handler,show", "elm"); 424 "elm,handler,show", "elm");
424 sd->start_handler_shown = EINA_TRUE; 425 sd->start_handler_shown = EINA_TRUE;
425 } 426 }
426 evas_object_move(sd->start_handler, ent_x + sx, ent_y + sy + sh); 427 if (start_pos < end_pos)
428 evas_object_move(sd->start_handler, ent_x + sx, ent_y + sy + sh);
429 else
430 evas_object_move(sd->start_handler, ent_x + ex, ent_y + ey + eh);
431
427 if (!sd->end_handler_shown) 432 if (!sd->end_handler_shown)
428 { 433 {
429 edje_object_signal_emit(sd->end_handler, 434 edje_object_signal_emit(sd->end_handler,
430 "elm,handler,show", "elm"); 435 "elm,handler,show", "elm");
431 sd->end_handler_shown = EINA_TRUE; 436 sd->end_handler_shown = EINA_TRUE;
432 } 437 }
433 evas_object_move(sd->end_handler, ent_x + ex, ent_y + ey + eh); 438 if (start_pos < end_pos)
439 evas_object_move(sd->end_handler, ent_x + ex, ent_y + ey + eh);
440 else
441 evas_object_move(sd->end_handler, ent_x + sx, ent_y + sy + sh);
434 } 442 }
435 else 443 else
436 { 444 {
@@ -3025,7 +3033,6 @@ _resize_cb(void *data,
3025 _elm_entry_resize_internal(data); 3033 _elm_entry_resize_internal(data);
3026} 3034}
3027 3035
3028Evas_Coord ox, oy;
3029static void 3036static void
3030_start_handler_mouse_down_cb(void *data, 3037_start_handler_mouse_down_cb(void *data,
3031 Evas *e EINA_UNUSED, 3038 Evas *e EINA_UNUSED,
@@ -3037,21 +3044,33 @@ _start_handler_mouse_down_cb(void *data,
3037 Evas_Event_Mouse_Down *ev = event_info; 3044 Evas_Event_Mouse_Down *ev = event_info;
3038 Evas_Coord ex, ey; 3045 Evas_Coord ex, ey;
3039 Evas_Coord cx, cy, cw, ch; 3046 Evas_Coord cx, cy, cw, ch;
3040 int pos, main_pos; 3047 int start_pos, end_pos, main_pos, pos;
3041 3048
3042 sd->start_handler_down = EINA_TRUE; 3049 sd->start_handler_down = EINA_TRUE;
3043 pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", 3050 start_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3044 EDJE_CURSOR_SELECTION_BEGIN); 3051 EDJE_CURSOR_SELECTION_BEGIN);
3052 end_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3053 EDJE_CURSOR_SELECTION_END);
3045 main_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", 3054 main_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3046 EDJE_CURSOR_MAIN); 3055 EDJE_CURSOR_MAIN);
3056 if (start_pos <= end_pos)
3057 {
3058 pos = start_pos;
3059 sd->sel_handler_cursor = EDJE_CURSOR_SELECTION_BEGIN;
3060 }
3061 else
3062 {
3063 pos = end_pos;
3064 sd->sel_handler_cursor = EDJE_CURSOR_SELECTION_END;
3065 }
3047 if (pos != main_pos) 3066 if (pos != main_pos)
3048 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", 3067 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
3049 EDJE_CURSOR_MAIN, pos); 3068 EDJE_CURSOR_MAIN, pos);
3050 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", 3069 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text",
3051 &cx, &cy, &cw, &ch); 3070 &cx, &cy, &cw, &ch);
3052 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); 3071 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
3053 ox = ev->canvas.x - (ex + cx + (cw / 2)); 3072 sd->ox = ev->canvas.x - (ex + cx + (cw / 2));
3054 oy = ev->canvas.y - (ey + cy + (ch / 2)); 3073 sd->oy = ev->canvas.y - (ey + cy + (ch / 2));
3055 3074
3056 if (_elm_config->magnifier_enable) 3075 if (_elm_config->magnifier_enable)
3057 { 3076 {
@@ -3088,22 +3107,19 @@ _start_handler_mouse_move_cb(void *data,
3088 Evas_Event_Mouse_Move *ev = event_info; 3107 Evas_Event_Mouse_Move *ev = event_info;
3089 Evas_Coord ex, ey; 3108 Evas_Coord ex, ey;
3090 Evas_Coord cx, cy, ch; 3109 Evas_Coord cx, cy, ch;
3091 int spos, epos; 3110 int pos;
3092 3111
3093 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); 3112 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
3094 cx = ev->cur.canvas.x - ox - ex; 3113 cx = ev->cur.canvas.x - sd->ox - ex;
3095 cy = ev->cur.canvas.y - oy - ey; 3114 cy = ev->cur.canvas.y - sd->oy - ey;
3096 if (cx <= 0) cx = 1; 3115 if (cx <= 0) cx = 1;
3116
3097 edje_object_part_text_cursor_coord_set(sd->entry_edje, "elm.text", 3117 edje_object_part_text_cursor_coord_set(sd->entry_edje, "elm.text",
3098 EDJE_CURSOR_SELECTION_BEGIN, cx, cy); 3118 sd->sel_handler_cursor, cx, cy);
3099 spos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", 3119 pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3100 EDJE_CURSOR_SELECTION_BEGIN); 3120 sd->sel_handler_cursor);
3101 epos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", 3121 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
3102 EDJE_CURSOR_SELECTION_END); 3122 EDJE_CURSOR_MAIN, pos);
3103 if (spos >= epos)
3104 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
3105 EDJE_CURSOR_SELECTION_BEGIN,
3106 epos - 1);
3107 edje_object_part_text_cursor_geometry_get(sd->entry_edje, 3123 edje_object_part_text_cursor_geometry_get(sd->entry_edje,
3108 "elm.text", 3124 "elm.text",
3109 &cx, &cy, NULL, &ch); 3125 &cx, &cy, NULL, &ch);
@@ -3122,11 +3138,23 @@ _end_handler_mouse_down_cb(void *data,
3122 Evas_Event_Mouse_Down *ev = event_info; 3138 Evas_Event_Mouse_Down *ev = event_info;
3123 Evas_Coord ex, ey; 3139 Evas_Coord ex, ey;
3124 Evas_Coord cx, cy, cw, ch; 3140 Evas_Coord cx, cy, cw, ch;
3125 int pos, main_pos; 3141 int pos, start_pos, end_pos, main_pos;
3126 3142
3127 sd->end_handler_down = EINA_TRUE; 3143 sd->end_handler_down = EINA_TRUE;
3128 pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", 3144 start_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3145 EDJE_CURSOR_SELECTION_BEGIN);
3146 end_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3129 EDJE_CURSOR_SELECTION_END); 3147 EDJE_CURSOR_SELECTION_END);
3148 if (start_pos < end_pos)
3149 {
3150 pos = end_pos;
3151 sd->sel_handler_cursor = EDJE_CURSOR_SELECTION_END;
3152 }
3153 else
3154 {
3155 pos = start_pos;
3156 sd->sel_handler_cursor = EDJE_CURSOR_SELECTION_BEGIN;
3157 }
3130 main_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text", 3158 main_pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3131 EDJE_CURSOR_MAIN); 3159 EDJE_CURSOR_MAIN);
3132 if (pos != main_pos) 3160 if (pos != main_pos)
@@ -3136,8 +3164,8 @@ _end_handler_mouse_down_cb(void *data,
3136 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", 3164 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text",
3137 &cx, &cy, &cw, &ch); 3165 &cx, &cy, &cw, &ch);
3138 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); 3166 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
3139 ox = ev->canvas.x - (ex + cx + (cw / 2)); 3167 sd->ox = ev->canvas.x - (ex + cx + (cw / 2));
3140 oy = ev->canvas.y - (ey + cy + (ch / 2)); 3168 sd->oy = ev->canvas.y - (ey + cy + (ch / 2));
3141 3169
3142 if (_elm_config->magnifier_enable) 3170 if (_elm_config->magnifier_enable)
3143 { 3171 {
@@ -3174,22 +3202,19 @@ _end_handler_mouse_move_cb(void *data,
3174 Evas_Event_Mouse_Move *ev = event_info; 3202 Evas_Event_Mouse_Move *ev = event_info;
3175 Evas_Coord ex, ey; 3203 Evas_Coord ex, ey;
3176 Evas_Coord cx, cy, ch; 3204 Evas_Coord cx, cy, ch;
3177 int spos, epos; 3205 int pos;
3178 3206
3179 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); 3207 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
3180 cx = ev->cur.canvas.x - ox - ex; 3208 cx = ev->cur.canvas.x - sd->ox - ex;
3181 cy = ev->cur.canvas.y - oy - ey; 3209 cy = ev->cur.canvas.y - sd->oy - ey;
3182 if (cx <= 0) cx = 1; 3210 if (cx <= 0) cx = 1;
3183 edje_object_part_text_cursor_coord_set(sd->entry_edje, "elm.text",
3184 EDJE_CURSOR_SELECTION_END, cx, cy);
3185 spos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3186 EDJE_CURSOR_SELECTION_BEGIN);
3187 epos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3188 EDJE_CURSOR_SELECTION_END);
3189 if (epos <= spos)
3190 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
3191 EDJE_CURSOR_SELECTION_END, spos + 1);
3192 3211
3212 edje_object_part_text_cursor_coord_set(sd->entry_edje, "elm.text",
3213 sd->sel_handler_cursor, cx, cy);
3214 pos = edje_object_part_text_cursor_pos_get(sd->entry_edje, "elm.text",
3215 sd->sel_handler_cursor);
3216 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
3217 EDJE_CURSOR_MAIN, pos);
3193 edje_object_part_text_cursor_geometry_get(sd->entry_edje, 3218 edje_object_part_text_cursor_geometry_get(sd->entry_edje,
3194 "elm.text", 3219 "elm.text",
3195 &cx, &cy, NULL, &ch); 3220 &cx, &cy, NULL, &ch);
diff --git a/src/lib/elm_widget_entry.h b/src/lib/elm_widget_entry.h
index dabfde30e..f6feadb0f 100644
--- a/src/lib/elm_widget_entry.h
+++ b/src/lib/elm_widget_entry.h
@@ -48,6 +48,7 @@ struct _Elm_Entry_Smart_Data
48 Elm_Text_Format format; 48 Elm_Text_Format format;
49 Evas_Coord last_w, ent_mw, ent_mh; 49 Evas_Coord last_w, ent_mw, ent_mh;
50 Evas_Coord downx, downy; 50 Evas_Coord downx, downy;
51 Evas_Coord ox, oy;
51 Eina_List *items; /** context menu item list */ 52 Eina_List *items; /** context menu item list */
52 Eina_List *item_providers; 53 Eina_List *item_providers;
53 Eina_List *markup_filters; 54 Eina_List *markup_filters;
@@ -60,6 +61,7 @@ struct _Elm_Entry_Smart_Data
60 Elm_Autocapital_Type autocapital_type; 61 Elm_Autocapital_Type autocapital_type;
61 Elm_Input_Panel_Lang input_panel_lang; 62 Elm_Input_Panel_Lang input_panel_lang;
62 Elm_Input_Panel_Return_Key_Type input_panel_return_key_type; 63 Elm_Input_Panel_Return_Key_Type input_panel_return_key_type;
64 Edje_Cursor sel_handler_cursor;
63 void *input_panel_imdata; 65 void *input_panel_imdata;
64 int input_panel_imdata_len; 66 int input_panel_imdata_len;
65 int input_panel_layout_variation; 67 int input_panel_layout_variation;