diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-07 18:08:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-07 18:08:55 +0300 |
commit | 38232871791e88eb8294441c013171113cb61012 (patch) | |
tree | 5c8a12011840a9991411e0b790a4dfc3b6b9bd91 | |
parent | 8dc33a81b09a403e57f7830d993d4484f6d85c40 (diff) | |
parent | d274c64d22da51473839d87618ba0dc0a0f1fa42 (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | source/blender/editors/interface/interface_region_menu_pie.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 26 |
4 files changed, 39 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c index 0c43b787a84..504e1807a8f 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.c +++ b/source/blender/editors/interface/interface_region_menu_pie.c @@ -150,8 +150,16 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co } pie->layout = UI_block_layout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style); - pie->mx = event->x; - pie->my = event->y; + + /* Open from where we started dragging. */ + if (event->val == KM_CLICK_DRAG) { + pie->mx = event->prevclickx; + pie->my = event->prevclicky; + } + else { + pie->mx = event->x; + pie->my = event->y; + } /* create title button */ if (title[0]) { diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 0fa7f53da9b..3aa59ca564f 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -53,6 +53,7 @@ static const EnumPropertyItem event_keymouse_value_items[] = { {KM_RELEASE, "RELEASE", 0, "Release", ""}, {KM_CLICK, "CLICK", 0, "Click", ""}, {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""}, + {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""}, {0, NULL, 0, NULL, NULL} }; @@ -391,6 +392,7 @@ const EnumPropertyItem rna_enum_event_value_items[] = { {KM_RELEASE, "RELEASE", 0, "Release", ""}, {KM_CLICK, "CLICK", 0, "Click", ""}, {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""}, + {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""}, {EVT_GESTURE_N, "NORTH", 0, "North", ""}, {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""}, {EVT_GESTURE_E, "EAST", 0, "East", ""}, diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 856694276a9..929617aab04 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -200,6 +200,7 @@ typedef enum eOperatorPropTags { #define KM_RELEASE 2 #define KM_CLICK 3 #define KM_DBL_CLICK 4 +#define KM_CLICK_DRAG 5 /* ************** UI Handler ***************** */ @@ -475,6 +476,7 @@ typedef struct wmEvent { /* set in case a KM_PRESS went by unhandled */ char check_click; + char check_drag; char is_motion_absolute; /* keymap item, set by handler (weak?) */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index be8e420e570..02c585fc677 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2526,8 +2526,30 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if (CTX_wm_window(C) == NULL) return action; - if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE, EVENT_NONE) && !ISTIMER(event->type)) { + if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { + if (event->check_drag) { + wmWindow *win = CTX_wm_window(C); + if ((abs(event->x - win->eventstate->prevclickx)) >= U.tweak_threshold || + (abs(event->y - win->eventstate->prevclicky)) >= U.tweak_threshold) + { + short val = event->val; + short type = event->type; + event->val = KM_CLICK_DRAG; + event->type = win->eventstate->type; + + CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG"); + + action |= wm_handlers_do_intern(C, event, handlers); + event->val = val; + event->type = type; + + win->eventstate->check_click = 0; + win->eventstate->check_drag = 0; + } + } + } + else if (!ELEM(event->type, EVENT_NONE) && !ISTIMER(event->type)) { /* test for CLICK events */ if (wm_action_not_handled(action)) { wmWindow *win = CTX_wm_window(C); @@ -2537,6 +2559,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if (win && event->val == KM_PRESS) { win->eventstate->check_click = true; + win->eventstate->check_drag = true; } if (win && win->eventstate->prevtype == event->type) { @@ -2558,6 +2581,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } else { win->eventstate->check_click = 0; + win->eventstate->check_drag = 0; } } else if (event->val == KM_DBL_CLICK) { |