[Bf-blender-cvs] [2a8e5128c16] master: WM: support setting the operators idle cursor

Campbell Barton noreply at git.blender.org
Mon Oct 18 08:30:58 CEST 2021


Commit: 2a8e5128c16c17a7b2f6fc5325dc8f5abb4427d4
Author: Campbell Barton
Date:   Mon Oct 18 17:01:32 2021 +1100
Branches: master
https://developer.blender.org/rB2a8e5128c16c17a7b2f6fc5325dc8f5abb4427d4

WM: support setting the operators idle cursor

Support setting a cursor when an operator is waiting for input.

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

M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_operator_type.c

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

diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index f82b6d7c691..f46e4a0e7a6 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -1958,6 +1958,16 @@ static void rna_def_operator_common(StructRNA *srna)
   RNA_def_property_enum_items(prop, rna_enum_operator_type_flag_items);
   RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
   RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
+
+  prop = RNA_def_property(srna, "bl_cursor_pending", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "type->cursor_pending");
+  RNA_def_property_enum_items(prop, rna_enum_window_cursor_items);
+  RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+  RNA_def_property_ui_text(
+      prop,
+      "Idle Cursor",
+      "Cursor to use when waiting for the user to select a location to activate the operator "
+      "(when ``bl_options`` has ``DEPENDS_ON_CURSOR`` set)");
 }
 
 static void rna_def_operator(BlenderRNA *brna)
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index c4612485e5a..b5f6caf4cb7 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -903,6 +903,9 @@ typedef struct wmOperatorType {
   /** RNA integration */
   ExtensionRNA rna_ext;
 
+  /** Cursor to use when waiting for cursor input, see: #OPTYPE_DEPENDS_ON_CURSOR. */
+  int cursor_pending;
+
   /** Flag last for padding */
   short flag;
 
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f07f2637a74..3ea61812b8a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1809,7 +1809,7 @@ void WM_operator_name_call_ptr_with_depends_on_cursor(
     }
   }
 
-  WM_cursor_modal_set(win, WM_CURSOR_PICK_AREA);
+  WM_cursor_modal_set(win, ot->cursor_pending);
 
   uiOperatorWaitForInput *opwait = MEM_callocN(sizeof(*opwait), __func__);
   opwait->optype_params.optype = ot;
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 39435721d1a..0e30df4ec99 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -110,6 +110,7 @@ static wmOperatorType *wm_operatortype_append__begin(void)
   /* Set the default i18n context now, so that opfunc can redefine it if needed! */
   RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
   ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
+  ot->cursor_pending = WM_CURSOR_PICK_AREA;
 
   return ot;
 }



More information about the Bf-blender-cvs mailing list