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 <campbell@blender.org>2022-02-24 14:48:34 +0300
committerCampbell Barton <campbell@blender.org>2022-02-25 09:58:22 +0300
commitad0b3abf539bbb358f799d3f36649b5d46f222c8 (patch)
treed7aff552c5541880ca1ce2648595455418cafc56 /source/blender/editors/space_outliner
parente7cae5187773f41e62830be597c6f598bff0653f (diff)
Cleanup: use flags for wmEvent modifier keys
Using flags makes checking multiple modifiers at once more convenient and avoids macros/functions such as IS_EVENT_MOD & WM_event_modifier_flag which have been removed. It also simplifies checking if modifier keys have changed.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.cc2
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.cc33
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.cc16
3 files changed, 30 insertions, 21 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc
index 765661aa9d5..f38f6c2855d 100644
--- a/source/blender/editors/space_outliner/outliner_collections.cc
+++ b/source/blender/editors/space_outliner/outliner_collections.cc
@@ -1071,7 +1071,7 @@ static int collection_isolate_exec(bContext *C, wmOperator *op)
static int collection_isolate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "extend");
- if (!RNA_property_is_set(op->ptr, prop) && (event->shift)) {
+ if (!RNA_property_is_set(op->ptr, prop) && (event->modifier & KM_SHIFT)) {
RNA_property_boolean_set(op->ptr, prop, true);
}
return collection_isolate_exec(C, op);
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc
index 0d8ee76d2f0..edd2e5f304f 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.cc
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc
@@ -319,7 +319,7 @@ static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
}
if (!allow_parenting_without_modifier_key(space_outliner)) {
- if (!event->shift) {
+ if ((event->modifier & KM_SHIFT) == 0) {
return false;
}
}
@@ -417,8 +417,12 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ListBase *lb = reinterpret_cast<ListBase *>(event->customdata);
wmDrag *drag = reinterpret_cast<wmDrag *>(lb->first);
- parent_drop_set_parents(
- C, op->reports, reinterpret_cast<wmDragID *>(drag->ids.first), par, PAR_OBJECT, event->alt);
+ parent_drop_set_parents(C,
+ op->reports,
+ reinterpret_cast<wmDragID *>(drag->ids.first),
+ par,
+ PAR_OBJECT,
+ event->modifier & KM_ALT);
return OPERATOR_FINISHED;
}
@@ -446,7 +450,7 @@ static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
if (!allow_parenting_without_modifier_key(space_outliner)) {
- if (!event->shift) {
+ if ((event->modifier & KM_SHIFT) == 0) {
return false;
}
}
@@ -471,7 +475,7 @@ static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
case ID_OB:
return ELEM(tselem->type, TSE_MODIFIER_BASE, TSE_CONSTRAINT_BASE);
case ID_GR:
- return event->shift || ELEM(tselem->type, TSE_LIBRARY_OVERRIDE_BASE);
+ return (event->modifier & KM_SHIFT) || ELEM(tselem->type, TSE_LIBRARY_OVERRIDE_BASE);
default:
return true;
}
@@ -496,7 +500,8 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
if (GS(drag_id->id->name) == ID_OB) {
Object *object = (Object *)drag_id->id;
- ED_object_parent_clear(object, event->alt ? CLEAR_PARENT_KEEP_TRANSFORM : CLEAR_PARENT_ALL);
+ ED_object_parent_clear(
+ object, (event->modifier & KM_ALT) ? CLEAR_PARENT_KEEP_TRANSFORM : CLEAR_PARENT_ALL);
}
}
@@ -1166,10 +1171,11 @@ static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event
&space_outliner->tree, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false);
CollectionDrop data;
- if (!event->shift && collection_drop_init(C, drag, event->xy, event->ctrl, &data)) {
+ if (((event->modifier & KM_SHIFT) == 0) &&
+ collection_drop_init(C, drag, event->xy, event->modifier & KM_CTRL, &data)) {
TreeElement *te = data.te;
TreeStoreElem *tselem = TREESTORE(te);
- if (!data.from || event->ctrl) {
+ if (!data.from || event->modifier & KM_CTRL) {
tselem->flag |= TSE_DRAG_INTO;
changed = true;
}
@@ -1210,9 +1216,10 @@ static char *collection_drop_tooltip(bContext *C,
const wmEvent *event = win ? win->eventstate : nullptr;
CollectionDrop data;
- if (event && !event->shift && collection_drop_init(C, drag, xy, event->ctrl, &data)) {
+ if (event && ((event->modifier & KM_SHIFT) == 0) &&
+ collection_drop_init(C, drag, xy, event->modifier & KM_CTRL, &data)) {
TreeElement *te = data.te;
- if (!data.from || event->ctrl) {
+ if (!data.from || event->modifier & KM_CTRL) {
return BLI_strdup(TIP_("Link inside Collection"));
}
switch (data.insert_type) {
@@ -1263,7 +1270,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
wmDrag *drag = reinterpret_cast<wmDrag *>(lb->first);
CollectionDrop data;
- if (!collection_drop_init(C, drag, event->xy, event->ctrl, &data)) {
+ if (!collection_drop_init(C, drag, event->xy, event->modifier & KM_CTRL, &data)) {
return OPERATOR_CANCELLED;
}
@@ -1291,7 +1298,9 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
/* Ctrl enables linking, so we don't need a from collection then. */
- Collection *from = (event->ctrl) ? nullptr : collection_parent_from_ID(drag_id->from_parent);
+ Collection *from = (event->modifier & KM_CTRL) ?
+ nullptr :
+ collection_parent_from_ID(drag_id->from_parent);
if (GS(drag_id->id->name) == ID_OB) {
/* Move/link object into collection. */
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index bc58ad226ee..2da416c8671 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -166,7 +166,7 @@ static void restrictbutton_bone_visibility_fn(bContext *C, void *poin, void *UNU
{
Bone *bone = (Bone *)poin;
- if (CTX_wm_window(C)->eventstate->shift) {
+ if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
restrictbutton_recursive_bone(bone, BONE_HIDDEN_P, (bone->flag & BONE_HIDDEN_P) != 0);
}
}
@@ -178,7 +178,7 @@ static void restrictbutton_bone_select_fn(bContext *C, void *UNUSED(poin), void
bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
- if (CTX_wm_window(C)->eventstate->shift) {
+ if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
restrictbutton_recursive_bone(bone, BONE_UNSELECTABLE, (bone->flag & BONE_UNSELECTABLE) != 0);
}
@@ -194,7 +194,7 @@ static void restrictbutton_ebone_select_fn(bContext *C, void *poin, void *poin2)
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
- if (CTX_wm_window(C)->eventstate->shift) {
+ if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
restrictbutton_recursive_ebone(
arm, ebone, BONE_UNSELECTABLE, (ebone->flag & BONE_UNSELECTABLE) != 0);
}
@@ -210,7 +210,7 @@ static void restrictbutton_ebone_visibility_fn(bContext *C, void *poin, void *po
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
- if (CTX_wm_window(C)->eventstate->shift) {
+ if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
restrictbutton_recursive_ebone(arm, ebone, BONE_HIDDEN_A, (ebone->flag & BONE_HIDDEN_A) != 0);
}
@@ -250,7 +250,7 @@ static void outliner_object_set_flag_recursive_fn(bContext *C,
ViewLayer *view_layer = CTX_data_view_layer(C);
PointerRNA ptr;
- bool extend = (win->eventstate->shift != 0);
+ bool extend = (win->eventstate->modifier & KM_SHIFT);
if (!extend) {
return;
@@ -571,8 +571,8 @@ static void outliner_collection_set_flag_recursive_fn(bContext *C,
ViewLayer *view_layer = CTX_data_view_layer(C);
PointerRNA ptr;
- bool do_isolate = (win->eventstate->ctrl != 0);
- bool extend = (win->eventstate->shift != 0);
+ bool do_isolate = (win->eventstate->modifier & KM_CTRL);
+ bool extend = (win->eventstate->modifier & KM_SHIFT);
if (!ELEM(true, do_isolate, extend)) {
return;
@@ -2043,7 +2043,7 @@ static void outliner_mode_toggle_fn(bContext *C, void *tselem_poin, void *UNUSED
const bool object_data_shared = (ob->data == tvc.obact->data);
wmWindow *win = CTX_wm_window(C);
- const bool do_extend = win->eventstate->ctrl != 0 && !object_data_shared;
+ const bool do_extend = (win->eventstate->modifier & KM_CTRL) && !object_data_shared;
outliner_item_mode_toggle(C, &tvc, te, do_extend);
}