WM: support setting the operators idle cursor

Support setting a cursor when an operator is waiting for input.
This commit is contained in:
Campbell Barton 2021-10-18 17:01:32 +11:00
parent 6bf8c95e52
commit 2a8e5128c1
4 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;
}