summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2016-05-09 17:28:02 +0900
committerThiep Ha <thiepha@gmail.com>2016-05-09 17:32:12 +0900
commitb39d869b7a6fc80a33ec6ec531efab68097e7c7a (patch)
tree8bc2e8f28fb83dcfcf5b953fb10c2d2225dca37a
parent07507864ca7e383b2dbf5600f8a4d58cb687e142 (diff)
elm entry: add more control for dnd
Adding dnd's enter, leave, position callbacks to let users know when drag item is entered, leaved; move cursor to follow drag item's position.
-rw-r--r--src/lib/elementary/elm_entry.c114
1 files changed, 77 insertions, 37 deletions
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c
index d193a533c6..f26e80369f 100644
--- a/src/lib/elementary/elm_entry.c
+++ b/src/lib/elementary/elm_entry.c
@@ -698,8 +698,48 @@ _selection_data_cb(void *data EINA_UNUSED,
698 return EINA_TRUE; 698 return EINA_TRUE;
699} 699}
700 700
701static void
702_dnd_enter_cb(void *data EINA_UNUSED,
703 Evas_Object *obj)
704{
705 elm_object_focus_set(obj, EINA_TRUE);
706}
707
708static void
709_dnd_leave_cb(void *data EINA_UNUSED,
710 Evas_Object *obj)
711{
712 if (_elm_config->desktop_entry)
713 elm_object_focus_set(obj, EINA_FALSE);
714}
715
716static void
717_dnd_pos_cb(void *data EINA_UNUSED,
718 Evas_Object *obj,
719 Evas_Coord x,
720 Evas_Coord y,
721 Elm_Xdnd_Action action EINA_UNUSED)
722{
723 int pos;
724 Evas_Coord ox, oy, ex, ey;
725
726 ELM_ENTRY_DATA_GET(obj, sd);
727
728 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
729 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
730 x = x + ox - ex;
731 y = y + oy - ey;
732
733 edje_object_part_text_cursor_coord_set
734 (sd->entry_edje, "elm.text", EDJE_CURSOR_USER, x, y);
735 pos = edje_object_part_text_cursor_pos_get
736 (sd->entry_edje, "elm.text", EDJE_CURSOR_USER);
737 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text",
738 EDJE_CURSOR_MAIN, pos);
739}
740
701static Eina_Bool 741static Eina_Bool
702_drag_drop_cb(void *data EINA_UNUSED, 742_dnd_drop_cb(void *data EINA_UNUSED,
703 Evas_Object *obj, 743 Evas_Object *obj,
704 Elm_Selection_Data *drop) 744 Elm_Selection_Data *drop)
705{ 745{
@@ -732,10 +772,10 @@ EOLIAN static Eina_Bool
732_elm_entry_elm_widget_disable(Eo *obj, Elm_Entry_Data *sd) 772_elm_entry_elm_widget_disable(Eo *obj, Elm_Entry_Data *sd)
733{ 773{
734 elm_drop_target_del(obj, sd->drop_format, 774 elm_drop_target_del(obj, sd->drop_format,
735 NULL, NULL, 775 _dnd_enter_cb, NULL,
736 NULL, NULL, 776 _dnd_leave_cb, NULL,
737 NULL, NULL, 777 _dnd_pos_cb, NULL,
738 _drag_drop_cb, NULL); 778 _dnd_drop_cb, NULL);
739 if (elm_object_disabled_get(obj)) 779 if (elm_object_disabled_get(obj))
740 { 780 {
741 edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm"); 781 edje_object_signal_emit(sd->entry_edje, "elm,state,disabled", "elm");
@@ -757,10 +797,10 @@ _elm_entry_elm_widget_disable(Eo *obj, Elm_Entry_Data *sd)
757 sd->disabled = EINA_FALSE; 797 sd->disabled = EINA_FALSE;
758 sd->drop_format = _get_drop_format(obj); 798 sd->drop_format = _get_drop_format(obj);
759 elm_drop_target_add(obj, sd->drop_format, 799 elm_drop_target_add(obj, sd->drop_format,
760 NULL, NULL, 800 _dnd_enter_cb, NULL,
761 NULL, NULL, 801 _dnd_leave_cb, NULL,
762 NULL, NULL, 802 _dnd_pos_cb, NULL,
763 _drag_drop_cb, NULL); 803 _dnd_drop_cb, NULL);
764 } 804 }
765 805
766 return EINA_TRUE; 806 return EINA_TRUE;
@@ -3479,10 +3519,10 @@ _elm_entry_evas_object_smart_add(Eo *obj, Elm_Entry_Data *priv)
3479 3519
3480 priv->drop_format = ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE; 3520 priv->drop_format = ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
3481 elm_drop_target_add(obj, priv->drop_format, 3521 elm_drop_target_add(obj, priv->drop_format,
3482 NULL, NULL, 3522 _dnd_enter_cb, NULL,
3483 NULL, NULL, 3523 _dnd_leave_cb, NULL,
3484 NULL, NULL, 3524 _dnd_pos_cb, NULL,
3485 _drag_drop_cb, NULL); 3525 _dnd_drop_cb, NULL);
3486 3526
3487 if (!elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj))) 3527 if (!elm_layout_theme_set(obj, "entry", "base", elm_widget_style_get(obj)))
3488 CRI("Failed to set layout!"); 3528 CRI("Failed to set layout!");
@@ -3898,10 +3938,10 @@ _elm_entry_password_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool password)
3898 sd->password = password; 3938 sd->password = password;
3899 3939
3900 elm_drop_target_del(obj, sd->drop_format, 3940 elm_drop_target_del(obj, sd->drop_format,
3901 NULL, NULL, 3941 _dnd_enter_cb, NULL,
3902 NULL, NULL, 3942 _dnd_leave_cb, NULL,
3903 NULL, NULL, 3943 _dnd_pos_cb, NULL,
3904 _drag_drop_cb, NULL); 3944 _dnd_drop_cb, NULL);
3905 if (password) 3945 if (password)
3906 { 3946 {
3907 sd->single_line = EINA_TRUE; 3947 sd->single_line = EINA_TRUE;
@@ -3914,10 +3954,10 @@ _elm_entry_password_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool password)
3914 { 3954 {
3915 sd->drop_format = _get_drop_format(obj); 3955 sd->drop_format = _get_drop_format(obj);
3916 elm_drop_target_add(obj, sd->drop_format, 3956 elm_drop_target_add(obj, sd->drop_format,
3917 NULL, NULL, 3957 _dnd_enter_cb, NULL,
3918 NULL, NULL, 3958 _dnd_leave_cb, NULL,
3919 NULL, NULL, 3959 _dnd_pos_cb, NULL,
3920 _drag_drop_cb, NULL); 3960 _dnd_drop_cb, NULL);
3921 3961
3922 elm_entry_input_hint_set(obj, ((sd->input_hints | ELM_INPUT_HINT_AUTO_COMPLETE) & ~ELM_INPUT_HINT_SENSITIVE_DATA)); 3962 elm_entry_input_hint_set(obj, ((sd->input_hints | ELM_INPUT_HINT_AUTO_COMPLETE) & ~ELM_INPUT_HINT_SENSITIVE_DATA));
3923 _entry_selection_callbacks_register(obj); 3963 _entry_selection_callbacks_register(obj);
@@ -4041,18 +4081,18 @@ _elm_entry_editable_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool editable)
4041 elm_obj_widget_theme_apply(obj); 4081 elm_obj_widget_theme_apply(obj);
4042 4082
4043 elm_drop_target_del(obj, sd->drop_format, 4083 elm_drop_target_del(obj, sd->drop_format,
4044 NULL, NULL, 4084 _dnd_enter_cb, NULL,
4045 NULL, NULL, 4085 _dnd_leave_cb, NULL,
4046 NULL, NULL, 4086 _dnd_pos_cb, NULL,
4047 _drag_drop_cb, NULL); 4087 _dnd_drop_cb, NULL);
4048 if (editable) 4088 if (editable)
4049 { 4089 {
4050 sd->drop_format = _get_drop_format(obj); 4090 sd->drop_format = _get_drop_format(obj);
4051 elm_drop_target_add(obj, sd->drop_format, 4091 elm_drop_target_add(obj, sd->drop_format,
4052 NULL, NULL, 4092 _dnd_enter_cb, NULL,
4053 NULL, NULL, 4093 _dnd_leave_cb, NULL,
4054 NULL, NULL, 4094 _dnd_pos_cb, NULL,
4055 _drag_drop_cb, NULL); 4095 _dnd_drop_cb, NULL);
4056 } 4096 }
4057} 4097}
4058 4098
@@ -4733,16 +4773,16 @@ _elm_entry_cnp_mode_set(Eo *obj, Elm_Entry_Data *sd, Elm_Cnp_Mode cnp_mode)
4733 format |= ELM_SEL_FORMAT_IMAGE; 4773 format |= ELM_SEL_FORMAT_IMAGE;
4734 4774
4735 elm_drop_target_del(obj, sd->drop_format, 4775 elm_drop_target_del(obj, sd->drop_format,
4736 NULL, NULL, 4776 _dnd_enter_cb, NULL,
4737 NULL, NULL, 4777 _dnd_leave_cb, NULL,
4738 NULL, NULL, 4778 _dnd_pos_cb, NULL,
4739 _drag_drop_cb, NULL); 4779 _dnd_drop_cb, NULL);
4740 sd->drop_format = format; 4780 sd->drop_format = format;
4741 elm_drop_target_add(obj, sd->drop_format, 4781 elm_drop_target_add(obj, sd->drop_format,
4742 NULL, NULL, 4782 _dnd_enter_cb, NULL,
4743 NULL, NULL, 4783 _dnd_leave_cb, NULL,
4744 NULL, NULL, 4784 _dnd_pos_cb, NULL,
4745 _drag_drop_cb, NULL); 4785 _dnd_drop_cb, NULL);
4746} 4786}
4747 4787
4748EOLIAN static Elm_Cnp_Mode 4788EOLIAN static Elm_Cnp_Mode