[Bf-blender-cvs] [8a2b329a21d] geometry-nodes: Geometry Nodes: Always use the active modifier for shortcuts

Hans Goudey noreply at git.blender.org
Tue Nov 24 22:58:07 CET 2020


Commit: 8a2b329a21d6f996ba574d73db074d7d825eee3d
Author: Hans Goudey
Date:   Tue Nov 24 16:57:45 2020 -0500
Branches: geometry-nodes
https://developer.blender.org/rB8a2b329a21d6f996ba574d73db074d7d825eee3d

Geometry Nodes: Always use the active modifier for shortcuts

Based on discussion with the team, summarized in T82691, it makes sense
to simplify the shortcut behavior and remove the way the shortcuts
currently activate on hover if there is no active modifier. This commit
also removes the behavior of clearing the active modifier when you
click on blank space in the modifier tab.

===================================================================

M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_modifier.c

===================================================================

diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index c5783135323..e6ef53a3d65 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -161,10 +161,6 @@ bool edit_modifier_invoke_properties_with_hover_no_active(struct bContext *C,
                                                           struct wmOperator *op,
                                                           const struct wmEvent *event,
                                                           int *r_retval);
-bool edit_modifier_invoke_properties_with_hover(struct bContext *C,
-                                                struct wmOperator *op,
-                                                const struct wmEvent *event,
-                                                int *r_retval);
 
 struct ModifierData *edit_modifier_property_get(struct wmOperator *op,
                                                 struct Object *ob,
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 1a499075d5d..864b3357ea2 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -1131,82 +1131,54 @@ static bool edit_modifier_properties_active(bContext *C, wmOperator *op)
   return false;
 }
 
-/**
- * Check the custom data of panels under the mouse for a modifier.
- */
-static bool edit_modifier_properties_hover(bContext *C,
-                                           wmOperator *op,
-                                           const wmEvent *event,
-                                           int *r_retval)
+bool edit_modifier_invoke_properties(bContext *C, wmOperator *op)
 {
-  PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event);
-
-  if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) {
-    if (RNA_struct_is_a(panel_ptr->type, &RNA_Modifier)) {
-      ModifierData *md = panel_ptr->data;
-      RNA_string_set(op->ptr, "modifier", md->name);
-      return true;
-    }
-    BLI_assert(r_retval != NULL); /* We need the return value in this case. */
-    if (r_retval != NULL) {
-      *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED);
-    }
-    return false;
+  if (edit_modifier_properties_base(C, op)) {
+    return true;
   }
-
-  if (r_retval != NULL) {
-    *r_retval = OPERATOR_CANCELLED;
+  if (edit_modifier_properties_active(C, op)) {
+    return true;
   }
 
   return false;
 }
 
 /**
+ * Run the regular invoke properties, then also check the custom data
+ * of panels under the mouse for a modifier.
+ *
  * \param event: If this isn't NULL, the operator will also look for panels underneath
  * the cursor with customdata set to a modifier.
  * \param r_retval: This should be used if #event is used in order to to return
  * #OPERATOR_PASS_THROUGH to check other operators with the same key set.
  */
-bool edit_modifier_invoke_properties(bContext *C, wmOperator *op)
-{
-  if (edit_modifier_properties_base(C, op)) {
-    return true;
-  }
-  if (edit_modifier_properties_active(C, op)) {
-    return true;
-  }
-
-  return false;
-}
-
 bool edit_modifier_invoke_properties_with_hover_no_active(bContext *C,
                                                           wmOperator *op,
                                                           const wmEvent *event,
                                                           int *r_retval)
 {
+
   if (edit_modifier_properties_base(C, op)) {
     return true;
   }
-  if (edit_modifier_properties_hover(C, op, event, r_retval)) {
-    return true;
-  }
 
-  return false;
-}
+  PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event);
 
-bool edit_modifier_invoke_properties_with_hover(bContext *C,
-                                                wmOperator *op,
-                                                const wmEvent *event,
-                                                int *r_retval)
-{
-  if (edit_modifier_properties_base(C, op)) {
-    return true;
-  }
-  if (edit_modifier_properties_active(C, op)) {
-    return true;
+  if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) {
+    if (RNA_struct_is_a(panel_ptr->type, &RNA_Modifier)) {
+      ModifierData *md = panel_ptr->data;
+      RNA_string_set(op->ptr, "modifier", md->name);
+      return true;
+    }
+    BLI_assert(r_retval != NULL); /* We need the return value in this case. */
+    if (r_retval != NULL) {
+      *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED);
+    }
+    return false;
   }
-  if (edit_modifier_properties_hover(C, op, event, r_retval)) {
-    return true;
+
+  if (r_retval != NULL) {
+    *r_retval = OPERATOR_CANCELLED;
   }
 
   return false;
@@ -1271,13 +1243,12 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
-static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_remove_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 void OBJECT_OT_modifier_remove(wmOperatorType *ot)
@@ -1317,13 +1288,12 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
-static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_move_up_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
@@ -1362,13 +1332,12 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
-static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_move_down_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
@@ -1405,13 +1374,12 @@ static int modifier_move_to_index_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
-static int modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_move_to_index_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 void OBJECT_OT_modifier_move_to_index(wmOperatorType *ot)
@@ -1510,13 +1478,12 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
   return modifier_apply_exec_ex(C, op, MODIFIER_APPLY_DATA, false);
 }
 
-static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_apply_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 void OBJECT_OT_modifier_apply(wmOperatorType *ot)
@@ -1554,13 +1521,14 @@ static int modifier_apply_as_shapekey_exec(bContext *C, wmOperator *op)
   return modifier_apply_exec_ex(C, op, MODIFIER_APPLY_SHAPE, keep);
 }
 
-static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_apply_as_shapekey_invoke(bContext *C,
+                                             wmOperator *op,
+                                             const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_apply_as_shapekey_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 static char *modifier_apply_as_shapekey_get_description(struct bContext *UNUSED(C),
@@ -1666,13 +1634,12 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
-static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
-  int retval;
-  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
+  if (edit_modifier_invoke_properties(C, op)) {
     return modifier_copy_exec(C, op);
   }
-  return retval;
+  return OPERATOR_CANCELLED;
 }
 
 void OBJECT_OT_modifier_copy(wmOperatorType *ot)
@@ -1696,17 +1663,6 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot)
 /** \name Set Active Modifier Operator
  * \{ */
 
-static int object_modifier_clear_active(bContext *C)
-{
-  Object *ob = ED_object_active_context(C);
-
-  BKE_object_modifier_set_active(ob, NULL);
-
-  WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
-  return OPERATOR_FINISHED;
-}
-
 static int modifier_set_active_exec(bContext *C, wmOperator *op)
 {
   Object *ob = ED_object_active_context(C);
@@ -1722,21 +1678,11 @@ static int modifier_set_active_exec(bContext *C, wmOperator *op)
 
 static int modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
-  int retval; /* Dummy variable, this operator always clears the active if no modifier is set. */
+  int retval;
   if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) {
     return modifier_set_active_exec(C, op);
   }
 
-  /* In the modifier tab (not for grease pencil), allow any event to clear 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list