operator report function so python operators can report errors
TODO - reports are currently shown upside down.
This commit is contained in:
@@ -60,7 +60,7 @@ struct uiLayout;
|
||||
#define OP_MAX_TYPENAME 64
|
||||
#define KMAP_MAX_NAME 64
|
||||
|
||||
|
||||
/* keep in sync with 'wm_report_items' in wm_rna.c */
|
||||
typedef enum ReportType {
|
||||
RPT_DEBUG = 1<<0,
|
||||
RPT_INFO = 1<<1,
|
||||
|
||||
@@ -72,6 +72,8 @@ extern EnumPropertyItem space_type_items[];
|
||||
|
||||
extern EnumPropertyItem keymap_propvalue_items[];
|
||||
|
||||
extern EnumPropertyItem wm_report_items[];
|
||||
|
||||
struct bContext;
|
||||
struct PointerRNA;
|
||||
EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
|
||||
@@ -251,6 +251,18 @@ EnumPropertyItem operator_return_items[] = {
|
||||
{OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", ""}, // used as a flag
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
/* flag/enum */
|
||||
EnumPropertyItem wm_report_items[] = {
|
||||
{RPT_DEBUG, "DEBUG", 0, "Debug", ""},
|
||||
{RPT_INFO, "INFO", 0, "Info", ""},
|
||||
{RPT_OPERATOR, "OPERATOR", 0, "Operator", ""},
|
||||
{RPT_WARNING, "WARNING", 0, "Warning", ""},
|
||||
{RPT_ERROR, "ERROR", 0, "Error", ""},
|
||||
{RPT_ERROR_INVALID_INPUT, "ERROR_INVALID_INPUT", 0, "Invalid Input", ""},\
|
||||
{RPT_ERROR_INVALID_CONTEXT, "ERROR_INVALID_CONTEXT", 0, "Invalid Context", ""},
|
||||
{RPT_ERROR_OUT_OF_MEMORY, "ERROR_OUT_OF_MEMORY", 0, "Out of Memory", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
#define KMI_TYPE_KEYBOARD 0
|
||||
#define KMI_TYPE_MOUSE 1
|
||||
#define KMI_TYPE_TWEAK 2
|
||||
@@ -601,10 +613,13 @@ static void rna_def_operator(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Properties", "");
|
||||
RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL);
|
||||
|
||||
RNA_api_operator(srna);
|
||||
|
||||
srna= RNA_def_struct(brna, "OperatorProperties", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator.");
|
||||
RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
|
||||
RNA_def_struct_idproperties_func(srna, "rna_OperatorProperties_idproperties");
|
||||
|
||||
}
|
||||
|
||||
static void rna_def_macro_operator(BlenderRNA *brna)
|
||||
|
||||
@@ -134,6 +134,11 @@ static wmKeyMapItem *rna_KeyMap_add_item(wmKeyMap *km, ReportList *reports, char
|
||||
return WM_keymap_add_item(km, idname, type, value, modifier, keymodifier);
|
||||
}
|
||||
|
||||
static void rna_Operator_report(wmOperator *op, int type, char *msg)
|
||||
{
|
||||
BKE_report(op->reports, type, msg);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void RNA_api_wm(StructRNA *srna)
|
||||
@@ -177,6 +182,18 @@ void RNA_api_wm(StructRNA *srna)
|
||||
parm= RNA_def_int(func, "height", 20, 0, INT_MAX, "", "Height of the popup.", 0, INT_MAX);
|
||||
}
|
||||
|
||||
void RNA_api_operator(StructRNA *srna)
|
||||
{
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
func= RNA_def_function(srna, "report", "rna_Operator_report");
|
||||
parm= RNA_def_enum(func, "type", wm_report_items, 0, "Type", "");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_ENUM_FLAG);
|
||||
parm= RNA_def_string(func, "message", "", 0, "Report Message", "");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
|
||||
void RNA_api_keyconfig(StructRNA *srna)
|
||||
{
|
||||
FunctionRNA *func;
|
||||
|
||||
Reference in New Issue
Block a user