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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-28 07:33:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-28 07:40:12 +0300
commit13f292d10d3bb19aa9aa694cecbde499f93e7a54 (patch)
treeb12dffe51f9649c24642f18131b47bedca169438 /source/blender/windowmanager/gizmo
parent2e22cfd08a0d589e8894e322ed29d5c3227ca04d (diff)
Gizmo: only highlight when held modifier keys are used
Check the current events modifiers against the gizmo keymap, only highlighting when keymap items match. Needed to resolve T63996
Diffstat (limited to 'source/blender/windowmanager/gizmo')
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c47
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h8
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c9
3 files changed, 58 insertions, 6 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index e491b86ea18..1918fc952f1 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -168,13 +168,47 @@ int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr)
}
}
-wmGizmo *wm_gizmogroup_find_intersected_gizmo(const wmGizmoGroup *gzgroup,
+static bool wm_gizmo_keymap_uses_event_modifier(wmWindowManager *wm,
+ const wmGizmoGroup *gzgroup,
+ wmGizmo *gz,
+ const int event_modifier,
+ int *r_gzgroup_keymap_uses_modifier)
+{
+ if (gz->keymap) {
+ wmKeyMap *keymap = WM_keymap_active(wm, gz->keymap);
+ if (!WM_keymap_uses_event_modifier(keymap, event_modifier)) {
+ return false;
+ }
+ }
+ else if (gzgroup->type->keymap) {
+ if (*r_gzgroup_keymap_uses_modifier == -1) {
+ wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap);
+ *r_gzgroup_keymap_uses_modifier = WM_keymap_uses_event_modifier(keymap, event_modifier);
+ }
+ if (*r_gzgroup_keymap_uses_modifier == 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
+wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm,
+ const wmGizmoGroup *gzgroup,
bContext *C,
+ const int event_modifier,
const int mval[2],
int *r_part)
{
+ int gzgroup_keymap_uses_modifier = -1;
+
for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
if (gz->type->test_select && (gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) {
+
+ if (!wm_gizmo_keymap_uses_event_modifier(
+ wm, gzgroup, gz, event_modifier, &gzgroup_keymap_uses_modifier)) {
+ continue;
+ }
+
if ((*r_part = gz->type->test_select(C, gz, mval)) != -1) {
return gz;
}
@@ -188,14 +222,23 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(const wmGizmoGroup *gzgroup,
* Adds all gizmos of \a gzgroup that can be selected to the head of \a listbase.
* Added items need freeing!
*/
-void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *gzgroup,
+void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm,
+ const wmGizmoGroup *gzgroup,
+ const int event_modifier,
BLI_Buffer *visible_gizmos)
{
+ int gzgroup_keymap_uses_modifier = -1;
for (wmGizmo *gz = gzgroup->gizmos.last; gz; gz = gz->prev) {
if ((gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) {
if (((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) &&
(gz->type->draw_select || gz->type->test_select)) ||
((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && gz->type->test_select)) {
+
+ if (!wm_gizmo_keymap_uses_event_modifier(
+ wm, gzgroup, gz, event_modifier, &gzgroup_keymap_uses_modifier)) {
+ continue;
+ }
+
BLI_buffer_append(visible_gizmos, wmGizmo *, gz);
}
}
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
index 9874b0e12af..2a0233d79b1 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
@@ -61,11 +61,15 @@ struct wmGizmoGroup *wm_gizmogroup_new_from_type(struct wmGizmoMap *gzmap,
struct wmGizmoGroupType *gzgt);
void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *gzgroup);
void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *gzgroup, struct wmGizmo *gz);
-struct wmGizmo *wm_gizmogroup_find_intersected_gizmo(const struct wmGizmoGroup *gzgroup,
+struct wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm,
+ const struct wmGizmoGroup *gzgroup,
struct bContext *C,
+ const int event_modifier,
const int mval[2],
int *r_part);
-void wm_gizmogroup_intersectable_gizmos_to_list(const struct wmGizmoGroup *gzgroup,
+void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm,
+ const struct wmGizmoGroup *gzgroup,
+ const int event_modifier,
struct BLI_Buffer *visible_gizmos);
bool wm_gizmogroup_is_visible_in_drawstep(const struct wmGizmoGroup *gzgroup,
const eWM_GizmoFlagMapDrawStep drawstep);
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 56de2202731..20fe9728be7 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -679,6 +679,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
const wmEvent *event,
int *r_part)
{
+ wmWindowManager *wm = CTX_wm_manager(C);
wmGizmo *gz = NULL;
BLI_buffer_declare_static(wmGizmo *, visible_3d_gizmos, BLI_BUFFER_NOP, 128);
bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX];
@@ -696,6 +697,8 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
do_step[i] = WM_gizmo_context_check_drawstep(C, i);
}
+ const int event_modifier = WM_event_modifier_flag(event);
+
for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
/* If it were important we could initialize here,
@@ -721,10 +724,12 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
/* cleared below */
}
if (step == WM_GIZMOMAP_DRAWSTEP_3D) {
- wm_gizmogroup_intersectable_gizmos_to_list(gzgroup, &visible_3d_gizmos);
+ wm_gizmogroup_intersectable_gizmos_to_list(
+ wm, gzgroup, event_modifier, &visible_3d_gizmos);
}
else if (step == WM_GIZMOMAP_DRAWSTEP_2D) {
- if ((gz = wm_gizmogroup_find_intersected_gizmo(gzgroup, C, mval, r_part))) {
+ if ((gz = wm_gizmogroup_find_intersected_gizmo(
+ wm, gzgroup, C, event_modifier, mval, r_part))) {
break;
}
}