Gizmo: add flag for gizmos to ignore keymap events

Needed for the snap gizmo not to steal mouse events from the tool.
This commit is contained in:
Campbell Barton
2020-05-28 14:28:06 +10:00
parent cdcbcca25e
commit d35a33ef72
3 changed files with 17 additions and 8 deletions

View File

@@ -401,6 +401,7 @@ RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OF
RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN);
RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT);
RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_keymap, flag, WM_GIZMO_HIDDEN_KEYMAP);
RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR);
RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND);
RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_operator_tool_properties,
@@ -1203,6 +1204,12 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set");
RNA_def_property_ui_text(prop, "Hide Select", "");
RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
/* WM_GIZMO_HIDDEN_KEYMAP */
prop = RNA_def_property(srna, "hide_keymap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(
prop, "rna_Gizmo_flag_hide_keymap_get", "rna_Gizmo_flag_hide_keymap_set");
RNA_def_property_ui_text(prop, "Hide Keymap", "Ignore the key-map for this gizmo");
RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
/* WM_GIZMO_MOVE_CURSOR */
prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(

View File

@@ -67,31 +67,33 @@ typedef enum eWM_GizmoFlag {
WM_GIZMO_DRAW_VALUE = (1 << 2),
WM_GIZMO_HIDDEN = (1 << 3),
WM_GIZMO_HIDDEN_SELECT = (1 << 4),
/** Ignore the key-map for this gizmo. */
WM_GIZMO_HIDDEN_KEYMAP = (1 << 5),
/**
* When set 'scale_final' value also scales the offset.
* Use when offset is to avoid screen-space overlap instead of absolute positioning. */
WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 5),
WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 6),
/**
* User should still use 'scale_final' for any handles and UI elements.
* This simply skips scale when calculating the final matrix.
* Needed when the gizmo needs to align with the interface underneath it. */
WM_GIZMO_DRAW_NO_SCALE = (1 << 6),
WM_GIZMO_DRAW_NO_SCALE = (1 << 7),
/**
* Hide the cursor and lock it's position while interacting with this gizmo.
*/
WM_GIZMO_MOVE_CURSOR = (1 << 7),
WM_GIZMO_MOVE_CURSOR = (1 << 8),
/** Don't write into the depth buffer when selecting. */
WM_GIZMO_SELECT_BACKGROUND = (1 << 8),
WM_GIZMO_SELECT_BACKGROUND = (1 << 9),
/** Use the active tools operator properties when running as an operator. */
WM_GIZMO_OPERATOR_TOOL_INIT = (1 << 9),
WM_GIZMO_OPERATOR_TOOL_INIT = (1 << 10),
/** Don't pass through events to other handlers
* (allows click/drag not to have it's events stolen by press events in other keymaps). */
WM_GIZMO_EVENT_HANDLE_ALL = (1 << 10),
WM_GIZMO_EVENT_HANDLE_ALL = (1 << 11),
/** Don't use tool-tips for this gizmo (can be distracting). */
WM_GIZMO_NO_TOOLTIP = (1 << 11),
WM_GIZMO_NO_TOOLTIP = (1 << 12),
} eWM_GizmoFlag;
/**

View File

@@ -2602,7 +2602,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
if (handle_keymap) {
/* Handle highlight gizmo. */
if (gz != NULL) {
if ((gz != NULL) && (gz->flag & WM_GIZMO_HIDDEN_KEYMAP) == 0) {
bool keymap_poll = false;
wmGizmoGroup *gzgroup = gz->parent_gzgroup;
wmKeyMap *keymap = WM_keymap_active(wm, gz->keymap ? gz->keymap : gzgroup->type->keymap);