Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-02 07:07:00 +0300
committerCampbell Barton <campbell@blender.org>2022-03-02 07:31:50 +0300
commit4986f718482b061082936f1f6aa13929741093a2 (patch)
tree21ea0b78e1182d35b44b4955ff308b8df1148b19 /source
parent426ff481a789017bd5810a2064ec06a298a6f2dc (diff)
Event System: remove tweak events in favor of click-drag
Supporting two kinds of dragging is redundant, remove tweak events as they only supported 3 mouse buttons and added complexity from using the 'value' to store directions. Support only click-drag events (KM_CLICK_DRAG) which can be used with any keyboard or mouse button. Details: - A "direction" member has been added to keymap items and events which can be used when the event value is set to KM_CLICK_DRAG. - Keymap items are version patched. - Loading older key-maps are also updated. - Currently the key-maps stored in ./release/scripts/presets/keyconfig/ still reference tweak events & need updating. For now they are updated on load. Note that in general this wont impact add-ons as modal operators don't receive tweak events. Reviewed By: brecht Ref D14214
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c50
-rw-r--r--source/blender/editors/interface/interface_context_menu.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c12
-rw-r--r--source/blender/editors/interface/interface_icons.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_dolly.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_move.c4
-rw-r--r--source/blender/editors/transform/transform.c2
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h9
-rw-r--r--source/blender/makesrna/RNA_enum_items.h5
-rw-r--r--source/blender/makesrna/intern/rna_wm.c91
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c17
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/WM_keymap.h63
-rw-r--r--source/blender/windowmanager/WM_types.h5
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c48
-rw-r--r--source/blender/windowmanager/intern/wm.c1
-rw-r--r--source/blender/windowmanager/intern/wm_event_query.c93
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c30
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c77
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c125
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c36
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c44
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
-rw-r--r--source/blender/windowmanager/wm.h8
-rw-r--r--source/blender/windowmanager/wm_event_types.h20
26 files changed, 321 insertions, 448 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 6f22e45d8d5..a8a851bb228 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 4
+#define BLENDER_FILE_SUBVERSION 5
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 10160e9aadc..862e8a09166 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -33,6 +33,7 @@
#include "readfile.h" /* Own include. */
+#include "WM_types.h"
#include "wm_event_types.h"
/* Don't use translation strings in versioning!
@@ -363,10 +364,12 @@ static void do_version_select_mouse(UserDef *userdef, wmKeyMapItem *kmi)
kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE;
break;
case EVT_TWEAK_S:
- kmi->type = (left) ? EVT_TWEAK_L : EVT_TWEAK_R;
+ kmi->type = (left) ? LEFTMOUSE : RIGHTMOUSE;
+ kmi->val = KM_CLICK_DRAG;
break;
case EVT_TWEAK_A:
- kmi->type = (left) ? EVT_TWEAK_R : EVT_TWEAK_L;
+ kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE;
+ kmi->val = KM_CLICK_DRAG;
break;
default:
break;
@@ -385,6 +388,39 @@ static bool keymap_item_has_invalid_wm_context_data_path(wmKeyMapItem *kmi,
return false;
}
+static bool keymap_item_update_tweak_event(wmKeyMapItem *kmi, void *UNUSED(user_data))
+{
+ /* Tweak events for L M R mouse-buttons. */
+ enum {
+ EVT_TWEAK_L = 0x5002,
+ EVT_TWEAK_M = 0x5003,
+ EVT_TWEAK_R = 0x5004,
+ };
+ switch (kmi->type) {
+ case EVT_TWEAK_L:
+ kmi->type = LEFTMOUSE;
+ break;
+ case EVT_TWEAK_M:
+ kmi->type = MIDDLEMOUSE;
+ break;
+ case EVT_TWEAK_R:
+ kmi->type = RIGHTMOUSE;
+ break;
+ default:
+ kmi->direction = KM_ANY;
+ return false;
+ }
+
+ if (kmi->val >= EVT_GESTURE_N && kmi->val <= EVT_GESTURE_NW) {
+ kmi->direction = kmi->val;
+ }
+ else {
+ kmi->direction = KM_ANY;
+ }
+ kmi->val = KM_CLICK_DRAG;
+ return false;
+}
+
void blo_do_versions_userdef(UserDef *userdef)
{
/* #UserDef & #Main happen to have the same struct member. */
@@ -952,6 +988,16 @@ void blo_do_versions_userdef(UserDef *userdef)
userdef->ndof_flag |= NDOF_CAMERA_PAN_ZOOM;
}
+ if (!USER_VERSION_ATLEAST(302, 5)) {
+ BKE_keyconfig_pref_filter_items(userdef,
+ &((struct wmKeyConfigFilterItemParams){
+ .check_item = true,
+ .check_diff_item_add = true,
+ }),
+ keymap_item_update_tweak_event,
+ NULL);
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 34a20b91172..07efcdcbe38 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -201,7 +201,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
/* XXX this guess_opname can potentially return a different keymap
* than being found on adding later... */
wmKeyMap *km = WM_keymap_guess_opname(C, idname);
- wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0);
+ wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0, KM_ANY);
const int kmi_id = kmi->id;
/* This takes ownership of prop, or prop can be NULL for reset. */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c277ca2e36b..e0b64dcd4d6 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -9398,7 +9398,7 @@ static int ui_list_activate_hovered_row(bContext *C,
}
}
- const int *mouse_xy = ISTWEAK(event->type) ? event->prev_click_xy : event->xy;
+ const int *mouse_xy = (event->val == KM_CLICK_DRAG) ? event->prev_click_xy : event->xy;
uiBut *listrow = ui_list_row_find_mouse_over(region, mouse_xy);
if (listrow) {
wmOperatorType *custom_activate_optype = ui_list->dyn_data->custom_activate_optype;
@@ -9425,7 +9425,7 @@ static bool ui_list_is_hovering_draggable_but(bContext *C,
const wmEvent *event)
{
/* On a tweak event, uses the coordinates from where tweaking was started. */
- const int *mouse_xy = ISTWEAK(event->type) ? event->prev_click_xy : event->xy;
+ const int *mouse_xy = (event->val == KM_CLICK_DRAG) ? event->prev_click_xy : event->xy;
const uiBut *hovered_but = ui_but_find_mouse_over_ex(region, mouse_xy, false, NULL, NULL);
if (list->dyn_data->custom_drag_optype) {
@@ -9442,7 +9442,7 @@ static int ui_list_handle_click_drag(bContext *C,
ARegion *region,
const wmEvent *event)
{
- if (!ELEM(event->type, LEFTMOUSE, EVT_TWEAK_L)) {
+ if (event->type != LEFTMOUSE) {
return WM_HANDLER_CONTINUE;
}
@@ -9452,7 +9452,7 @@ static int ui_list_handle_click_drag(bContext *C,
bool activate = false;
bool activate_dragging = false;
- if (event->type == EVT_TWEAK_L) {
+ if (event->val == KM_CLICK_DRAG) {
if (is_draggable) {
activate_dragging = true;
activate = true;
@@ -9462,7 +9462,7 @@ static int ui_list_handle_click_drag(bContext *C,
* regular events (including mouse presses to start dragging) and this part only kicks in if it
* hasn't handled the release event. Note that if there's no overlaid button, the row selects
* on the press event already via regular #UI_BTYPE_LISTROW handling. */
- else if ((event->type == LEFTMOUSE) && (event->val == KM_CLICK)) {
+ else if (event->val == KM_CLICK) {
activate = true;
}
@@ -9549,7 +9549,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi
}
}
- if (ELEM(event->type, LEFTMOUSE, EVT_TWEAK_L)) {
+ if (event->type == LEFTMOUSE) {
retval = ui_list_handle_click_drag(C, ui_list, region, event);
}
else if (val == KM_PRESS) {
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index e99f6978f4c..9dfc9be2a30 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -573,18 +573,6 @@ int UI_icon_from_event_type(short event_type, short event_value)
else if (event_type == EVT_RIGHTALTKEY) {
event_type = EVT_LEFTALTKEY;
}
- else if (event_type == EVT_TWEAK_L) {
- event_type = LEFTMOUSE;
- event_value = KM_CLICK_DRAG;
- }
- else if (event_type == EVT_TWEAK_M) {
- event_type = MIDDLEMOUSE;
- event_value = KM_CLICK_DRAG;
- }
- else if (event_type == EVT_TWEAK_R) {
- event_type = RIGHTMOUSE;
- event_value = KM_CLICK_DRAG;
- }
DrawInfo *di = g_di_event_list;
do {
diff --git a/source/blender/editors/space_view3d/view3d_navigate_dolly.c b/source/blender/editors/space_view3d/view3d_navigate_dolly.c
index 06b616e71da..7b6b119294d 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_dolly.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_dolly.c
@@ -50,9 +50,12 @@ void viewdolly_modal_keymap(wmKeyConfig *keyconf)
/* disabled mode switching for now, can re-implement better, later on */
#if 0
- WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
- WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
- WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_MOVE);
+ WM_modalkeymap_add_item(
+ keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, KM_ANY, VIEWROT_MODAL_SWITCH_ROTATE);
+ WM_modalkeymap_add_item(
+ keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, VIEWROT_MODAL_SWITCH_ROTATE);
+ WM_modalkeymap_add_item(
+ keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, KM_ANY, VIEWROT_MODAL_SWITCH_MOVE);
#endif
/* assign map to operators */
diff --git a/source/blender/editors/space_view3d/view3d_navigate_move.c b/source/blender/editors/space_view3d/view3d_navigate_move.c
index d2fd505a703..071643e9314 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_move.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_move.c
@@ -43,8 +43,8 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
keymap = WM_modalkeymap_ensure(keyconf, "View3D Move Modal", modal_items);
/* items for modal map */
- WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
- WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, KM_ANY, VIEW_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, KM_ANY, VIEW_MODAL_CONFIRM);
/* disabled mode switching for now, can re-implement better, later on */
#if 0
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 36ffcc8cd68..fd01f708ed2 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1697,7 +1697,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* Needed to translate tweak events to mouse buttons. */
t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1;
- t->is_launch_event_drag = event ? (ISTWEAK(event->type) || event->val == KM_CLICK_DRAG) : false;
+ t->is_launch_event_drag = event ? (event->val == KM_CLICK_DRAG) : false;
/* XXX Remove this when wm_operator_call_internal doesn't use window->eventstate
* (which can have type = 0) */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 626c2b2a81f..dabef04583b 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -295,9 +295,6 @@ typedef struct wmWindow {
/** Storage for event system. */
struct wmEvent *eventstate;
- /** Internal for wm_operators.c. */
- struct wmGesture *tweak;
-
/* Input Method Editor data - complex character input (especially for Asian character input)
* Currently WIN32 and APPLE, runtime-only data. */
struct wmIMEData *ime_data;
@@ -364,7 +361,9 @@ typedef struct wmKeyMapItem {
/** Event code itself. */
short type;
/** KM_ANY, KM_PRESS, KM_NOTHING etc. */
- short val;
+ int8_t val;
+ /** Use when `val == WM_CLICK_DRAG`, */
+ int8_t direction;
/** `oskey` also known as apple, windows-key or super, value denotes order of pressed. */
short shift, ctrl, alt, oskey;
/** Raw-key modifier. */
@@ -422,7 +421,7 @@ enum {
enum {
KMI_TYPE_KEYBOARD = 0,
KMI_TYPE_MOUSE = 1,
- KMI_TYPE_TWEAK = 2,
+ /* 2 is deprecated, was tweak. */
KMI_TYPE_TEXTINPUT = 3,
KMI_TYPE_TIMER = 4,
KMI_TYPE_NDOF = 5,
diff --git a/source/blender/makesrna/RNA_enum_items.h b/source/blender/makesrna/RNA_enum_items.h
index 352ff8f1f42..31db8e39e6f 100644
--- a/source/blender/makesrna/RNA_enum_items.h
+++ b/source/blender/makesrna/RNA_enum_items.h
@@ -90,9 +90,8 @@ DEF_ENUM(rna_enum_motionpath_bake_location_items)
DEF_ENUM(rna_enum_motionpath_display_type_items)
DEF_ENUM(rna_enum_motionpath_range_items)
-DEF_ENUM(rna_enum_event_value_all_items)
-DEF_ENUM(rna_enum_event_value_keymouse_items)
-DEF_ENUM(rna_enum_event_value_tweak_items)
+DEF_ENUM(rna_enum_event_value_items)
+DEF_ENUM(rna_enum_event_direction_items)
DEF_ENUM(rna_enum_event_type_items)
DEF_ENUM(rna_enum_event_type_mask_items)
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index ae688846b95..d88f150c1dd 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -28,13 +28,6 @@
#ifdef RNA_RUNTIME
-static const EnumPropertyItem event_tweak_type_items[] = {
- {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""},
- {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""},
- {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""},
- {0, NULL, 0, NULL, NULL},
-};
-
static const EnumPropertyItem event_mouse_type_items[] = {
{LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""},
{MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""},
@@ -156,10 +149,6 @@ const EnumPropertyItem rna_enum_event_type_items[] = {
{WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", "WhIn"},
{WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", "WhOut"},
{0, "", 0, NULL, NULL},
- {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", "TwkL"},
- {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", "TwkM"},
- {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", "TwkR"},
- {0, "", 0, NULL, NULL},
{EVT_AKEY, "A", 0, "A", ""},
{EVT_BKEY, "B", 0, "B", ""},
{EVT_CKEY, "C", 0, "C", ""},
@@ -362,26 +351,7 @@ const EnumPropertyItem rna_enum_event_type_items[] = {
* This is needed for `km.keymap_items.new` value argument,
* to accept values from different types.
*/
-const EnumPropertyItem rna_enum_event_value_all_items[] = {
- {KM_ANY, "ANY", 0, "Any", ""},
- {KM_PRESS, "PRESS", 0, "Press", ""},
- {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", ""},
- {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
- {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
- {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
- {EVT_GESTURE_W, "WEST", 0, "West", ""},
- {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
- {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
- {0, NULL, 0, NULL, NULL},
-};
-
-const EnumPropertyItem rna_enum_event_value_keymouse_items[] = {
+const EnumPropertyItem rna_enum_event_value_items[] = {
{KM_ANY, "ANY", 0, "Any", ""},
{KM_PRESS, "PRESS", 0, "Press", ""},
{KM_RELEASE, "RELEASE", 0, "Release", ""},
@@ -393,7 +363,7 @@ const EnumPropertyItem rna_enum_event_value_keymouse_items[] = {
{0, NULL, 0, NULL, NULL},
};
-const EnumPropertyItem rna_enum_event_value_tweak_items[] = {
+const EnumPropertyItem rna_enum_event_direction_items[] = {
{KM_ANY, "ANY", 0, "Any", ""},
{EVT_GESTURE_N, "NORTH", 0, "North", ""},
{EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
@@ -420,7 +390,6 @@ const EnumPropertyItem rna_enum_event_type_mask_items[] = {
{EVT_TYPE_MASK_MOUSE_BUTTON, "MOUSE_BUTTON", 0, "Mouse Button", ""},
{EVT_TYPE_MASK_MOUSE, "MOUSE", 0, "Mouse", ""},
{EVT_TYPE_MASK_NDOF, "NDOF", 0, "NDOF", ""},
- {EVT_TYPE_MASK_TWEAK, "TWEAK", 0, "Tweak", ""},
{EVT_TYPE_MASK_ACTIONZONE, "ACTIONZONE", 0, "Action Zone", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -612,18 +581,6 @@ static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
return result;
}
-static const EnumPropertyItem *rna_Event_value_itemf(bContext *UNUSED(C),
- PointerRNA *ptr,
- PropertyRNA *UNUSED(prop),
- bool *UNUSED(r_free))
-{
- const wmEvent *event = ptr->data;
- if (ISTWEAK(event->type)) {
- return rna_enum_event_value_tweak_items;
- }
- return rna_enum_event_value_all_items;
-}
-
static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
{
const wmEvent *event = ptr->data;
@@ -915,10 +872,6 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
kmi->type = EVT_AKEY;
kmi->val = KM_PRESS;
break;
- case KMI_TYPE_TWEAK:
- kmi->type = EVT_TWEAK_L;
- kmi->val = KM_ANY;
- break;
case KMI_TYPE_MOUSE:
kmi->type = LEFTMOUSE;
kmi->val = KM_PRESS;
@@ -969,9 +922,6 @@ static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C),
if (map_type == KMI_TYPE_MOUSE) {
return event_mouse_type_items;
}
- if (map_type == KMI_TYPE_TWEAK) {
- return event_tweak_type_items;
- }
if (map_type == KMI_TYPE_TIMER) {
return event_timer_type_items;
}
@@ -986,24 +936,6 @@ static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C),
}
}
-static const EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C),
- PointerRNA *ptr,
- PropertyRNA *UNUSED(prop),
- bool *UNUSED(r_free))
-{
- int map_type = rna_wmKeyMapItem_map_type_get(ptr);
-
- if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF) {
- return rna_enum_event_value_keymouse_items;
- }
- if (map_type == KMI_TYPE_TWEAK) {
- return rna_enum_event_value_tweak_items;
- }
- else {
- return rna_enum_event_value_all_items;
- }
-}
-
static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C,
PointerRNA *ptr,
PropertyRNA *UNUSED(prop),
@@ -2106,8 +2038,7 @@ static void rna_def_event(BlenderRNA *brna)
/* enums */
prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "val");
- RNA_def_property_enum_items(prop, rna_enum_event_value_all_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Event_value_itemf");
+ RNA_def_property_enum_items(prop, rna_enum_event_value_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
@@ -2118,6 +2049,12 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "");
+ prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "direction");
+ RNA_def_property_enum_items(prop, rna_enum_event_direction_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Direction", "The direction (only applies to drag events)");
+
/* keyboard */
prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -2538,7 +2475,6 @@ static void rna_def_keyconfig(BlenderRNA *brna)
static const EnumPropertyItem map_type_items[] = {
{KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
- {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
{KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
{KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
{KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
@@ -2679,11 +2615,16 @@ static void rna_def_keyconfig(BlenderRNA *brna)
prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "val");
- RNA_def_property_enum_items(prop, rna_enum_event_value_all_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
+ RNA_def_property_enum_items(prop, rna_enum_event_value_items);
RNA_def_property_ui_text(prop, "Value", "");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+ prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "direction");
+ RNA_def_property_enum_items(prop, rna_enum_event_direction_items);
+ RNA_def_property_ui_text(prop, "Direction", "The direction (only applies to drag events)");
+ RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+
prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "id");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 1eb51b6ec80..0589fa7a96e 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -258,6 +258,7 @@ static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km,
int alt,
int oskey,
int keymodifier,
+ int direction,
bool repeat,
bool head)
{
@@ -275,7 +276,7 @@ static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km,
WM_operator_bl_idname(idname_bl, idname);
/* create keymap item */
- kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
+ kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier, direction);
if (!repeat) {
kmi->flag |= KMI_REPEAT_IGNORE;
@@ -324,6 +325,7 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km,
int alt,
int oskey,
int keymodifier,
+ int direction,
bool repeat)
{
/* only modal maps */
@@ -338,13 +340,14 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km,
/* not initialized yet, do delayed lookup */
if (!km->modal_items) {
- kmi = WM_modalkeymap_add_item_str(km, type, value, modifier, keymodifier, propvalue_str);
+ kmi = WM_modalkeymap_add_item_str(
+ km, type, value, modifier, keymodifier, direction, propvalue_str);
}
else {
if (RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue) == 0) {
BKE_report(reports, RPT_WARNING, "Property value not in enumeration");
}
- kmi = WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
+ kmi = WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, direction, propvalue);
}
if (!repeat) {
@@ -729,7 +732,7 @@ void RNA_api_window(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
+ parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_string(func, "unicode", NULL, 0, "", "");
RNA_def_parameter_clear_flags(parm, PROP_NEVER_NULL, 0);
@@ -1134,7 +1137,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
+ parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "any", 0, "Any", "");
RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
@@ -1142,6 +1145,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
+ RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", "");
RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
RNA_def_boolean(func,
"head",
@@ -1158,7 +1162,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
+ parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "any", 0, "Any", "");
RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
@@ -1166,6 +1170,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
+ RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", "");
RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
RNA_def_function_return(func, parm);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 07eaa2ab976..21d76ce93bd 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -1432,6 +1432,8 @@ bool WM_event_is_modal_drag_exit(const struct wmEvent *event,
bool WM_event_is_last_mousemove(const struct wmEvent *event);
bool WM_event_is_mouse_drag(const struct wmEvent *event);
bool WM_event_is_mouse_drag_or_press(const wmEvent *event);
+int WM_event_drag_direction(const wmEvent *event);
+
/**
* Detect motion between selection (callers should only use this for selection picking),
* typically mouse press/click events.
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 6e07fd7fb32..068dbb32be2 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -42,8 +42,13 @@ void WM_keymap_clear(struct wmKeyMap *keymap);
/**
* Always add item.
*/
-wmKeyMapItem *WM_keymap_add_item(
- struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction);
wmKeyMapItem *WM_keymap_add_item_copy(struct wmKeyMap *keymap, wmKeyMapItem *kmi_src);
bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
@@ -80,23 +85,43 @@ bool WM_keymap_item_compare(const struct wmKeyMapItem *k1, const struct wmKeyMap
/**
* Menu wrapper for #WM_keymap_add_item.
*/
-wmKeyMapItem *WM_keymap_add_menu(
- struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction);
/**
* Pie-menu wrapper for #WM_keymap_add_item.
*/
-wmKeyMapItem *WM_keymap_add_menu_pie(
- struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction);
/**
* Panel (popover) wrapper for #WM_keymap_add_item.
*/
-wmKeyMapItem *WM_keymap_add_panel(
- struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_panel(struct wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction);
/**
* Tool wrapper for #WM_keymap_add_item.
*/
-wmKeyMapItem *WM_keymap_add_tool(
- struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction);
wmKeyMap *WM_keymap_guess_from_context(const struct bContext *C);
@@ -128,10 +153,20 @@ wmKeyMap *WM_modalkeymap_ensure(struct wmKeyConfig *keyconf,
const char *idname,
const struct EnumPropertyItem *items);
wmKeyMap *WM_modalkeymap_find(struct wmKeyConfig *keyconf, const char *idname);
-wmKeyMapItem *WM_modalkeymap_add_item(
- struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
-wmKeyMapItem *WM_modalkeymap_add_item_str(
- struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value);
+wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction,
+ int value);
+wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction,
+ const char *value);
const wmKeyMapItem *WM_modalkeymap_find_propvalue(const wmKeyMap *km, int propvalue);
void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 26462402e3d..b2e214782f0 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -494,7 +494,6 @@ typedef struct wmNotifier {
/* ************** Gesture Manager data ************** */
/* wmGesture->type */
-#define WM_GESTURE_TWEAK 0
#define WM_GESTURE_LINES 1
#define WM_GESTURE_RECT 2
#define WM_GESTURE_CROSS_RECT 3
@@ -504,7 +503,6 @@ typedef struct wmNotifier {
/**
* wmGesture is registered to #wmWindow.gesture, handled by operator callbacks.
- * Tweak gesture is builtin feature.
*/
typedef struct wmGesture {
struct wmGesture *next, *prev;
@@ -660,6 +658,9 @@ typedef struct wmEvent {
*/
uint8_t modifier;
+ /** The direction (for #KM_CLICK_DRAG events only). */
+ int8_t direction;
+
/** Raw-key modifier (allow using any key as a modifier). */
short keymodifier;
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index c46a2b6afe5..2971cdf40c3 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -640,24 +640,29 @@ wmKeyMap *wm_gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf)
keymap = WM_modalkeymap_ensure(keyconf, name, modal_items);
/* items for modal map */
- WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL);
- WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL);
+ WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CANCEL);
+ WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CANCEL);
- WM_modalkeymap_add_item(keymap, EVT_RETKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM);
- WM_modalkeymap_add_item(keymap, EVT_PADENTER, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, EVT_RETKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CONFIRM);
+ WM_modalkeymap_add_item(keymap, EVT_PADENTER, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CONFIRM);
WM_modalkeymap_add_item(
- keymap, EVT_RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON);
+ keymap, EVT_RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_ON);
WM_modalkeymap_add_item(
- keymap, EVT_RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF);
- WM_modalkeymap_add_item(keymap, EVT_LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON);
+ keymap, EVT_RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_OFF);
WM_modalkeymap_add_item(
- keymap, EVT_LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF);
+ keymap, EVT_LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_ON);
+ WM_modalkeymap_add_item(
+ keymap, EVT_LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_OFF);
- WM_modalkeymap_add_item(keymap, EVT_RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON);
- WM_modalkeymap_add_item(keymap, EVT_RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF);
- WM_modalkeymap_add_item(keymap, EVT_LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON);
- WM_modalkeymap_add_item(keymap, EVT_LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF);
+ WM_modalkeymap_add_item(
+ keymap, EVT_RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_ON);
+ WM_modalkeymap_add_item(
+ keymap, EVT_RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_OFF);
+ WM_modalkeymap_add_item(
+ keymap, EVT_LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_ON);
+ WM_modalkeymap_add_item(
+ keymap, EVT_LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_OFF);
WM_modalkeymap_assign(keymap, "GIZMOGROUP_OT_gizmo_tweak");
@@ -709,24 +714,26 @@ static wmKeyMap *WM_gizmogroup_keymap_template_select_ex(
const int select_tweak = (U.flag & USER_LMOUSESELECT) ? EVT_TWEAK_L : EVT_TWEAK_R;
const int action_mouse = (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE;
#else
- const int select_mouse = RIGHTMOUSE;
- const int select_tweak = EVT_TWEAK_R;
- const int action_mouse = LEFTMOUSE;
+ const int select_mouse = RIGHTMOUSE, select_mouse_val = KM_PRESS;
+ const int select_tweak = RIGHTMOUSE, select_tweak_val = KM_CLICK_DRAG;
+ const int action_mouse = LEFTMOUSE, action_mouse_val = KM_PRESS;
#endif
if (do_init) {
- WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", action_mouse, KM_PRESS, KM_ANY, 0);
- WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", select_tweak, KM_ANY, 0, 0);
+ WM_keymap_add_item(
+ km, "GIZMOGROUP_OT_gizmo_tweak", action_mouse, action_mouse_val, KM_ANY, 0, KM_ANY);
+ WM_keymap_add_item(
+ km, "GIZMOGROUP_OT_gizmo_tweak", select_tweak, select_tweak_val, 0, 0, KM_ANY);
}
if (do_init) {
wmKeyMapItem *kmi = WM_keymap_add_item(
- km, "GIZMOGROUP_OT_gizmo_select", select_mouse, KM_PRESS, 0, 0);
+ km, "GIZMOGROUP_OT_gizmo_select", select_mouse, select_mouse_val, 0, 0, KM_ANY);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_boolean_set(kmi->ptr, "deselect", false);
RNA_boolean_set(kmi->ptr, "toggle", false);
kmi = WM_keymap_add_item(
- km, "GIZMOGROUP_OT_gizmo_select", select_mouse, KM_PRESS, KM_SHIFT, 0);
+ km, "GIZMOGROUP_OT_gizmo_select", select_mouse, select_mouse_val, KM_SHIFT, 0, KM_ANY);
RNA_boolean_set(kmi->ptr, "extend", false);
RNA_boolean_set(kmi->ptr, "deselect", false);
RNA_boolean_set(kmi->ptr, "toggle", true);
@@ -1129,7 +1136,8 @@ void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup)
ARegion *region = CTX_wm_region(C);
BLI_assert(region->gizmo_map == gzmap);
/* Check if the tweak event originated from this region. */
- if ((win->tweak != NULL) && BLI_rcti_compare(&region->winrct, &win->tweak->winrct)) {
+ if ((win->eventstate != NULL) && (win->event_queue_check_drag) &&
+ BLI_rcti_isect_pt_v(&region->winrct, win->eventstate->prev_click_xy)) {
/* We need to run refresh again. */
gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH;
WM_gizmomap_tag_refresh_drawstep(gzmap, WM_gizmomap_drawstep_from_gizmo_group(gzgroup));
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 13bf902f02c..c333d8149ed 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -156,7 +156,6 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
win->gpuctx = NULL;
win->eventstate = NULL;
win->cursor_keymap_status = NULL;
- win->tweak = NULL;
#if defined(WIN32) || defined(__APPLE__)
win->ime_data = NULL;
#endif
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index ddca10a8382..e56d3fb3886 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -47,12 +47,7 @@ static void event_ids_from_type_and_value(const short type,
RNA_enum_identifier(rna_enum_event_type_items, type, r_type_id);
/* Value. */
- if (ISTWEAK(type)) {
- RNA_enum_identifier(rna_enum_event_value_tweak_items, val, r_val_id);
- }
- else {
- RNA_enum_identifier(rna_enum_event_value_all_items, val, r_val_id);
- }
+ RNA_enum_identifier(rna_enum_event_value_items, val, r_val_id);
}
void WM_event_print(const wmEvent *event)
@@ -160,13 +155,6 @@ bool WM_event_type_mask_test(const int event_type, const enum eEventType_Mask ma
}
}
- /* Tweak. */
- if (mask & EVT_TYPE_MASK_TWEAK) {
- if (ISTWEAK(event_type)) {
- return true;
- }
- }
-
/* Action Zone. */
if (mask & EVT_TYPE_MASK_ACTIONZONE) {
if (IS_EVENT_ACTIONZONE(event_type)) {
@@ -192,12 +180,6 @@ bool WM_event_is_modal_drag_exit(const wmEvent *event,
if (U.flag & USER_RELEASECONFIRM) {
/* option on, so can exit with km-release */
if (event->val == KM_RELEASE) {
- switch (init_event_type) {
- case EVT_TWEAK_L:
- case EVT_TWEAK_M:
- case EVT_TWEAK_R:
- return 1;
- }
if ((init_event_val == KM_CLICK_DRAG) && (event->type == init_event_type)) {
return 1;
}
@@ -205,8 +187,7 @@ bool WM_event_is_modal_drag_exit(const wmEvent *event,
else {
/* If the initial event wasn't a drag event then
* ignore #USER_RELEASECONFIRM setting: see T26756. */
- if ((ELEM(init_event_type, EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R) ||
- init_event_val == KM_CLICK_DRAG) == 0) {
+ if (init_event_val != KM_CLICK_DRAG) {
return 1;
}
}
@@ -234,7 +215,7 @@ bool WM_event_is_last_mousemove(const wmEvent *event)
bool WM_event_is_mouse_drag(const wmEvent *event)
{
- return ISTWEAK(event->type) || (ISMOUSE_BUTTON(event->type) && (event->val == KM_CLICK_DRAG));
+ return (ISMOUSE_BUTTON(event->type) && (event->val == KM_CLICK_DRAG));
}
bool WM_event_is_mouse_drag_or_press(const wmEvent *event)
@@ -243,6 +224,68 @@ bool WM_event_is_mouse_drag_or_press(const wmEvent *event)
(ISMOUSE_BUTTON(event->type) && (event->val == KM_PRESS));
}
+int WM_event_drag_direction(const wmEvent *event)
+{
+ const int delta[2] = {
+ event->xy[0] - event->prev_click_xy[0],
+ event->xy[1] - event->prev_click_xy[1],
+ };
+
+ int theta = round_fl_to_int(4.0f * atan2f((float)delta[1], (float)delta[0]) / (float)M_PI);
+ int val = EVT_GESTURE_W;
+
+ if (theta == 0) {
+ val = EVT_GESTURE_E;
+ }
+ else if (theta == 1) {
+ val = EVT_GESTURE_NE;
+ }
+ else if (theta == 2) {
+ val = EVT_GESTURE_N;
+ }
+ else if (theta == 3) {
+ val = EVT_GESTURE_NW;
+ }
+ else if (theta == -1) {
+ val = EVT_GESTURE_SE;
+ }
+ else if (theta == -2) {
+ val = EVT_GESTURE_S;
+ }
+ else if (theta == -3) {
+ val = EVT_GESTURE_SW;
+ }
+
+#if 0
+ /* debug */
+ if (val == 1) {
+ printf("tweak north\n");
+ }
+ if (val == 2) {
+ printf("tweak north-east\n");
+ }
+ if (val == 3) {
+ printf("tweak east\n");
+ }
+ if (val == 4) {
+ printf("tweak south-east\n");
+ }
+ if (val == 5) {
+ printf("tweak south\n");
+ }
+ if (val == 6) {
+ printf("tweak south-west\n");
+ }
+ if (val == 7) {
+ printf("tweak west\n");
+ }
+ if (val == 8) {
+ printf("tweak north-west\n");
+ }
+#endif
+ return val;
+}
+
bool WM_cursor_test_motion_and_update(const int mval[2])
{
static int mval_prev[2] = {-1, -1};
@@ -316,12 +359,6 @@ int WM_userdef_event_map(int kmitype)
int WM_userdef_event_type_from_keymap_type(int kmitype)
{
switch (kmitype) {
- case EVT_TWEAK_L:
- return LEFTMOUSE;
- case EVT_TWEAK_M:
- return MIDDLEMOUSE;
- case EVT_TWEAK_R:
- return RIGHTMOUSE;
case WHEELOUTMOUSE:
return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELUPMOUSE : WHEELDOWNMOUSE;
case WHEELINMOUSE:
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index b3b99b0b7fc..017af86e401 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2029,6 +2029,14 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
}
}
+ if (kmi->val == KM_CLICK_DRAG) {
+ if (kmi->direction != KM_ANY) {
+ if (kmi->direction != winevent->direction) {
+ return false;
+ }
+ }
+ }
+
const bool shift = (winevent->modifier & KM_SHIFT) != 0;
const bool ctrl = (winevent->modifier & KM_CTRL) != 0;
const bool alt = (winevent->modifier & KM_ALT) != 0;
@@ -2775,7 +2783,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
{
/* Drag events use the previous click location to highlight the gizmos,
* Get the highlight again in case the user dragged off the gizmo. */
- const bool is_event_drag = ISTWEAK(event->type) || (event->val == KM_CLICK_DRAG);
+ const bool is_event_drag = (event->val == KM_CLICK_DRAG);
const bool is_event_modifier = ISKEYMODIFIER(event->type);
/* Only keep the highlight if the gizmo becomes modal as result of event handling.
* Without this check, even un-handled drag events will set the highlight if the drag
@@ -2886,15 +2894,10 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
wmEvent event_test_click_drag = *event;
event_test_click_drag.val = KM_CLICK_DRAG;
- wmEvent event_test_tweak = *event;
- event_test_tweak.type = EVT_TWEAK_L + (event->type - LEFTMOUSE);
- event_test_tweak.val = KM_ANY;
-
LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
if ((kmi->flag & KMI_INACTIVE) == 0) {
if (wm_eventmatch(&event_test_click, kmi) ||
- wm_eventmatch(&event_test_click_drag, kmi) ||
- wm_eventmatch(&event_test_tweak, kmi)) {
+ wm_eventmatch(&event_test_click_drag, kmi)) {
wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0);
if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) {
is_event_handle_all = true;
@@ -3165,6 +3168,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (win->event_queue_check_drag) {
if (WM_event_drag_test(event, event->prev_click_xy)) {
win->event_queue_check_drag_handled = true;
+ const int direction = WM_event_drag_direction(event);
const int prev_xy[2] = {UNPACK2(event->xy)};
const short prev_val = event->val;
@@ -3177,6 +3181,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
event->type = event->prev_type;
event->modifier = event->prev_click_modifier;
event->keymodifier = event->prev_click_keymodifier;
+ event->direction = direction;
CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG");
@@ -3184,6 +3189,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
action |= wm_handlers_do_intern(C, win, event, handlers);
+ event->direction = 0;
event->keymodifier = prev_keymodifier;
event->modifier = prev_modifier;
event->val = prev_val;
@@ -3712,9 +3718,7 @@ void wm_event_do_handlers(bContext *C)
/* Check dragging, creates new event or frees, adds draw tag. */
wm_event_drag_and_drop_test(wm, win, event);
- /* Builtin tweak, if action is break it removes tweak. */
- wm_tweakevent_test(C, event, action);
-
+ /* Builtin drag: #KM_CLICK_DRAG. */
if (action & WM_HANDLER_BREAK) {
win->event_queue_check_drag = false;
}
@@ -5515,15 +5519,15 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win)
} event_data[] = {
{0, 0, LEFTMOUSE, KM_PRESS},
{0, 0, LEFTMOUSE, KM_CLICK},
- {0, 1, EVT_TWEAK_L, KM_ANY},
+ {0, 0, LEFTMOUSE, KM_CLICK_DRAG},
{1, 0, MIDDLEMOUSE, KM_PRESS},
{1, 0, MIDDLEMOUSE, KM_CLICK},
- {1, 1, EVT_TWEAK_M, KM_ANY},
+ {1, 0, MIDDLEMOUSE, KM_CLICK_DRAG},
{2, 0, RIGHTMOUSE, KM_PRESS},
{2, 0, RIGHTMOUSE, KM_CLICK},
- {2, 1, EVT_TWEAK_R, KM_ANY},
+ {2, 0, RIGHTMOUSE, KM_CLICK_DRAG},
};
for (int button_index = 0; button_index < 3; button_index++) {
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 86ada4aaf2a..a6fbad8b171 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -52,7 +52,6 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent
if (ELEM(type,
WM_GESTURE_RECT,
WM_GESTURE_CROSS_RECT,
- WM_GESTURE_TWEAK,
WM_GESTURE_CIRCLE,
WM_GESTURE_STRAIGHTLINE)) {
rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new");
@@ -83,9 +82,6 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent
void WM_gesture_end(wmWindow *win, wmGesture *gesture)
{
- if (win->tweak == gesture) {
- win->tweak = NULL;
- }
BLI_remlink(&win->gesture, gesture);
MEM_freeN(gesture->customdata);
WM_generic_user_data_free(&gesture->user_data);
@@ -114,74 +110,6 @@ bool WM_gesture_is_modal_first(const wmGesture *gesture)
return (gesture->is_active_prev == false);
}
-int wm_gesture_evaluate(wmGesture *gesture, const wmEvent *event)
-{
- if (gesture->type == WM_GESTURE_TWEAK) {
- rcti *rect = gesture->customdata;
- const int delta[2] = {
- BLI_rcti_size_x(rect),
- BLI_rcti_size_y(rect),
- };
-
- if (WM_event_drag_test_with_delta(event, delta)) {
- int theta = round_fl_to_int(4.0f * atan2f((float)delta[1], (float)delta[0]) / (float)M_PI);
- int val = EVT_GESTURE_W;
-
- if (theta == 0) {
- val = EVT_GESTURE_E;
- }
- else if (theta == 1) {
- val = EVT_GESTURE_NE;
- }
- else if (theta == 2) {
- val = EVT_GESTURE_N;
- }
- else if (theta == 3) {
- val = EVT_GESTURE_NW;
- }
- else if (theta == -1) {
- val = EVT_GESTURE_SE;
- }
- else if (theta == -2) {
- val = EVT_GESTURE_S;
- }
- else if (theta == -3) {
- val = EVT_GESTURE_SW;
- }
-
-#if 0
- /* debug */
- if (val == 1) {
- printf("tweak north\n");
- }
- if (val == 2) {
- printf("tweak north-east\n");
- }
- if (val == 3) {
- printf("tweak east\n");
- }
- if (val == 4) {
- printf("tweak south-east\n");
- }
- if (val == 5) {
- printf("tweak south\n");
- }
- if (val == 6) {
- printf("tweak south-west\n");
- }
- if (val == 7) {
- printf("tweak west\n");
- }
- if (val == 8) {
- printf("tweak north-west\n");
- }
-#endif
- return val;
- }
- }
- return 0;
-}
-
/* ******************* gesture draw ******************* */
static void wm_gesture_draw_line_active_side(rcti *rect, const bool flip)
@@ -511,11 +439,6 @@ void wm_gesture_draw(wmWindow *win)
if (gt->type == WM_GESTURE_RECT) {
wm_gesture_draw_rect(gt);
}
-#if 0
- else if (gt->type == WM_GESTURE_TWEAK) {
- wm_gesture_draw_line(gt);
- }
-#endif
else if (gt->type == WM_GESTURE_CIRCLE) {
wm_gesture_draw_circle(gt);
}
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index cd41cffe1f0..1fdc8bbe2c8 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -471,131 +471,6 @@ void WM_OT_circle_gesture(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Tweak Gesture
- * \{ */
-
-static void gesture_tweak_modal(bContext *C, const wmEvent *event)
-{
- wmWindow *window = CTX_wm_window(C);
- wmGesture *gesture = window->tweak;
- rcti *rect = gesture->customdata;
- bool gesture_end = false;
-
- switch (event->type) {
- case MOUSEMOVE:
- case INBETWEEN_MOUSEMOVE: {
-
- rect->xmax = event->xy[0] - gesture->winrct.xmin;
- rect->ymax = event->xy[1] - gesture->winrct.ymin;
-
- const int val = wm_gesture_evaluate(gesture, event);
- if (val != 0) {
- wmEvent tevent;
-
- wm_event_init_from_window(window, &tevent);
- /* We want to get coord from start of drag,
- * not from point where it becomes a tweak event, see T40549. */
- tevent.xy[0] = rect->xmin + gesture->winrct.xmin;
- tevent.xy[1] = rect->ymin + gesture->winrct.ymin;
- if (gesture->event_type == LEFTMOUSE) {
- tevent.type = EVT_TWEAK_L;
- }
- else if (gesture->event_type == RIGHTMOUSE) {
- tevent.type = EVT_TWEAK_R;
- }
- else {
- tevent.type = EVT_TWEAK_M;
- }
- tevent.val = val;
- tevent.modifier = gesture->event_modifier;
- tevent.keymodifier = gesture->event_keymodifier;
- tevent.flag = 0;
- /* mouse coords! */
-
- /* important we add immediately after this event, so future mouse releases
- * (which may be in the queue already), are handled in order, see T44740 */
- wm_event_add_ex(window, &tevent, event);
-
- gesture_end = true;
- }
-
- break;
- }
-
- case LEFTMOUSE:
- case RIGHTMOUSE:
- case MIDDLEMOUSE:
- if (gesture->event_type == event->type) {
- gesture_end = true;
-
- /* when tweak fails we should give the other keymap entries a chance */
-
- /* XXX, assigning to readonly, BAD JUJU! */
- ((wmEvent *)event)->val = KM_RELEASE;
- }
- break;
- default:
- if (ISTIMER(event->type)) {
- /* Ignore timers. */
- }
- else if (event->type == EVENT_NONE) {
- /* Ignore none events. */
- }
- else if ((event->val == KM_RELEASE) &&
- (ISKEYMODIFIER(event->type) || (event->type == event->prev_click_keymodifier))) {
- /* Support releasing modifier keys without canceling the drag event, see T89989.
- * NOTE: this logic is replicated for drag events. */
- }
- else {
- gesture_end = true;
- }
- break;
- }
-
- if (gesture_end) {
- /* Frees gesture itself, and unregisters from window. */
- WM_gesture_end(window, gesture);
-
- /* This isn't very nice but needed to redraw gizmos which are hidden while tweaking,
- * See #WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK for details. */
- ARegion *region = CTX_wm_region(C);
- if ((region != NULL) && (region->gizmo_map != NULL)) {
- if (WM_gizmomap_tag_delay_refresh_for_tweak_check(region->gizmo_map)) {
- ED_region_tag_redraw(region);
- }
- }
- }
-}
-
-void wm_tweakevent_test(bContext *C, const wmEvent *event, int action)
-{
- wmWindow *win = CTX_wm_window(C);
-
- if (win->tweak == NULL) {
- const ARegion *region = CTX_wm_region(C);
-
- if (region) {
- if (event->val == KM_PRESS) {
- if (ELEM(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) {
- win->tweak = WM_gesture_new(win, region, event, WM_GESTURE_TWEAK);
- }
- }
- }
- }
- else {
- /* no tweaks if event was handled */
- if (action & WM_HANDLER_BREAK) {
- WM_gesture_end(win, win->tweak);
- }
- else {
- gesture_tweak_modal(C, event);
- }
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Lasso Gesture
* \{ */
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index f7bc138f163..ffac585cde7 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -169,6 +169,7 @@ static bool wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b)
return (wm_keymap_item_equals_result(a, b) && a->type == b->type && a->val == b->val &&
a->shift == b->shift && a->ctrl == b->ctrl && a->alt == b->alt && a->oskey == b->oskey &&
a->keymodifier == b->keymodifier && a->maptype == b->maptype &&
+ ((a->val != KM_CLICK_DRAG) || (a->direction == b->direction)) &&
((ISKEYBOARD(a->type) == 0) ||
(a->flag & KMI_REPEAT_IGNORE) == (b->flag & KMI_REPEAT_IGNORE)));
}
@@ -195,9 +196,6 @@ int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi)
if (ISKEYBOARD(kmi->type)) {
return KMI_TYPE_KEYBOARD;
}
- if (ISTWEAK(kmi->type)) {
- return KMI_TYPE_TWEAK;
- }
if (ISMOUSE(kmi->type)) {
return KMI_TYPE_MOUSE;
}
@@ -459,11 +457,12 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
}
static void keymap_event_set(
- wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier)
+ wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier, int direction)
{
kmi->type = type;
kmi->val = val;
kmi->keymodifier = keymodifier;
+ kmi->direction = direction;
if (modifier == KM_ANY) {
kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
@@ -497,15 +496,20 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi)
}
}
-wmKeyMapItem *WM_keymap_add_item(
- wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&keymap->items, kmi);
BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
- keymap_event_set(kmi, type, val, modifier, keymodifier);
+ keymap_event_set(kmi, type, val, modifier, keymodifier, direction);
wm_keymap_item_properties_set(kmi);
keymap_item_set_id(keymap, kmi);
@@ -919,14 +923,14 @@ wmKeyMap *WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
}
wmKeyMapItem *WM_modalkeymap_add_item(
- wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value)
+ wmKeyMap *km, int type, int val, int modifier, int keymodifier, int direction, int value)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&km->items, kmi);
kmi->propvalue = value;
- keymap_event_set(kmi, type, val, modifier, keymodifier);
+ keymap_event_set(kmi, type, val, modifier, keymodifier, direction);
keymap_item_set_id(km, kmi);
@@ -935,15 +939,20 @@ wmKeyMapItem *WM_modalkeymap_add_item(
return kmi;
}
-wmKeyMapItem *WM_modalkeymap_add_item_str(
- wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value)
+wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction,
+ const char *value)
{
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&km->items, kmi);
BLI_strncpy(kmi->propvalue_str, value, sizeof(kmi->propvalue_str));
- keymap_event_set(kmi, type, val, modifier, keymodifier);
+ keymap_event_set(kmi, type, val, modifier, keymodifier, direction);
keymap_item_set_id(km, kmi);
@@ -1730,6 +1739,9 @@ bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2)
if (k1->val != k2->val) {
return 0;
}
+ if (k1->val == KM_CLICK_DRAG && (k1->direction != k2->direction)) {
+ return 0;
+ }
}
if (k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift) {
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index 4bd5fea91e6..24c221221d1 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -29,40 +29,60 @@
/** \name Wrappers for #WM_keymap_add_item
* \{ */
-wmKeyMapItem *WM_keymap_add_menu(
- wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction)
{
wmKeyMapItem *kmi = WM_keymap_add_item(
- keymap, "WM_OT_call_menu", type, val, modifier, keymodifier);
+ keymap, "WM_OT_call_menu", type, val, modifier, keymodifier, direction);
RNA_string_set(kmi->ptr, "name", idname);
return kmi;
}
-wmKeyMapItem *WM_keymap_add_menu_pie(
- wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction)
{
wmKeyMapItem *kmi = WM_keymap_add_item(
- keymap, "WM_OT_call_menu_pie", type, val, modifier, keymodifier);
+ keymap, "WM_OT_call_menu_pie", type, val, modifier, keymodifier, direction);
RNA_string_set(kmi->ptr, "name", idname);
return kmi;
}
-wmKeyMapItem *WM_keymap_add_panel(
- wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_panel(wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction)
{
wmKeyMapItem *kmi = WM_keymap_add_item(
- keymap, "WM_OT_call_panel", type, val, modifier, keymodifier);
+ keymap, "WM_OT_call_panel", type, val, modifier, keymodifier, direction);
RNA_string_set(kmi->ptr, "name", idname);
/* TODO: we might want to disable this. */
RNA_boolean_set(kmi->ptr, "keep_open", false);
return kmi;
}
-wmKeyMapItem *WM_keymap_add_tool(
- wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
+wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap,
+ const char *idname,
+ int type,
+ int val,
+ int modifier,
+ int keymodifier,
+ int direction)
{
wmKeyMapItem *kmi = WM_keymap_add_item(
- keymap, "WM_OT_tool_set_by_id", type, val, modifier, keymodifier);
+ keymap, "WM_OT_tool_set_by_id", type, val, modifier, keymodifier, direction);
RNA_string_set(kmi->ptr, "name", idname);
return kmi;
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 6b8f7309d80..6e0bf911555 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -911,9 +911,9 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
ret_value = op->type->exec(C, op);
OPERATOR_RETVAL_CHECK(ret_value);
-
op->customdata = POINTER_FROM_INT((int)event->type);
if (ret_value & OPERATOR_RUNNING_MODAL) {
+ printf("Starting modal: %s\n", op->idname);
WM_event_add_modal_handler(C, op);
}
return ret_value | OPERATOR_PASS_THROUGH;
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 68b16d46746..172a879e118 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -74,16 +74,8 @@ void wm_gesture_draw(struct wmWindow *win);
/**
* Tweak and line gestures.
*/
-int wm_gesture_evaluate(wmGesture *gesture, const struct wmEvent *event);
void wm_gesture_tag_redraw(struct wmWindow *win);
-/* wm_gesture_ops.c */
-
-/**
- * Standard tweak, called after window handlers passed on event.
- */
-void wm_tweakevent_test(bContext *C, const wmEvent *event, int action);
-
/* wm_jobs.c */
/**
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index c5764ad7a5e..1e907578e52 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -325,16 +325,6 @@ enum {
/* NOTE: these values are saved in key-map files, do not change them but just add new ones. */
- /* Tweak events:
- * Sent as additional event with the mouse coordinates
- * from where the initial click was placed. */
-
- /* Tweak events for L M R mouse-buttons. */
- EVT_TWEAK_L = 0x5002, /* 20482 */
- EVT_TWEAK_M = 0x5003, /* 20483 */
- EVT_TWEAK_R = 0x5004, /* 20484 */
- /* 0x5010 (and lower) should be left to add other tweak types in the future. */
-
/* 0x5011 is taken, see EVT_ACTIONZONE_FULLSCREEN */
/* Misc Blender internals: 0x502x */
@@ -394,9 +384,6 @@ enum {
BUTTON6MOUSE, \
BUTTON7MOUSE))
-/** Test whether the event is tweak event. */
-#define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_TWEAK_R)
-
/** Test whether the event is a NDOF event. */
#define ISNDOF(event_type) ((event_type) >= _NDOF_MIN && (event_type) <= _NDOF_MAX)
@@ -423,14 +410,11 @@ enum eEventType_Mask {
EVT_TYPE_MASK_MOUSE = (1 << 5),
/** #ISNDOF */
EVT_TYPE_MASK_NDOF = (1 << 6),
- /** #ISTWEAK */
- EVT_TYPE_MASK_TWEAK = (1 << 7),
/** #IS_EVENT_ACTIONZONE */
- EVT_TYPE_MASK_ACTIONZONE = (1 << 8),
+ EVT_TYPE_MASK_ACTIONZONE = (1 << 7),
};
#define EVT_TYPE_MASK_ALL \
- (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF | EVT_TYPE_MASK_TWEAK | \
- EVT_TYPE_MASK_ACTIONZONE)
+ (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF | EVT_TYPE_MASK_ACTIONZONE)
#define EVT_TYPE_MASK_HOTKEY_INCLUDE \
(EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF)