diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-11-26 01:59:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-11-26 02:00:24 +0400 |
commit | 02f90c000115d5d2ab330005e20d02419defe35a (patch) | |
tree | 932763725edb3642e3e3da0905e02676f42a54e8 | |
parent | 07bde9e797c73a0cdbeef315755874ff711a6414 (diff) |
User Interface: don't show macro args in tooltips
was often making much too big strings to show in a tip.
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 12 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 16 |
9 files changed, 35 insertions, 22 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6a8a248a58f..4701cd5b537 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1549,7 +1549,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char *str; opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr); + str = WM_operator_pystring_ex(C, NULL, false, true, but->optype, opptr); WM_clipboard_text_set(str, 0); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 346a54cf4eb..28055ba6c26 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2969,7 +2969,7 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem) BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */ if (but->optype) { - char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, but->optype, but->opptr); + char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, true, but->optype, but->opptr); BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : ""); MEM_freeN(opstr); } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index f869c5de8e6..984904acb26 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -539,7 +539,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* so the context is passed to itemf functions (some py itemf functions use it) */ WM_operator_properties_sanitize(opptr, false); - str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr); + str = WM_operator_pystring_ex(C, NULL, false, false, but->optype, opptr); /* operator info */ if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 88b326914e1..79e3d7acab6 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -1038,11 +1038,11 @@ char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *p char *RNA_pointer_as_string_id(struct bContext *C, PointerRNA *ptr); char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop); char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, - const bool skip_optional_value, const bool all_args, + const bool skip_optional_value, const bool all_args, const bool nested_args, const int max_prop_length, PropertyRNA *iterprop); char *RNA_pointer_as_string_keywords(struct bContext *C, PointerRNA *ptr, - const bool skip_optional_value, const bool all_args, + const bool skip_optional_value, const bool all_args, const bool nested_args, const int max_prop_length); char *RNA_function_as_string_keywords(struct bContext *C, FunctionRNA *func, const bool as_function, const bool all_args, diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 6c216936190..1811f2e1a5f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -5040,7 +5040,7 @@ char *RNA_pointer_as_string(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *p /* context can be NULL */ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, - const bool as_function, const bool all_args, + const bool as_function, const bool all_args, const bool nested_args, const int max_prop_length, PropertyRNA *iterprop) { @@ -5069,6 +5069,10 @@ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, continue; } + if ((nested_args == false) && (RNA_property_type(prop) == PROP_POINTER)) { + continue; + } + if (as_function && (flag & PROP_REQUIRED)) { /* required args don't have useful defaults */ BLI_dynstr_appendf(dynstr, first_iter ? "%s" : ", %s", arg_name); @@ -5113,14 +5117,14 @@ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, } char *RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr, - const bool as_function, const bool all_args, + const bool as_function, const bool all_args, const bool nested_args, const int max_prop_length) { PropertyRNA *iterprop; iterprop = RNA_struct_iterator_property(ptr->type); - return RNA_pointer_as_string_keywords_ex(C, ptr, as_function, all_args, + return RNA_pointer_as_string_keywords_ex(C, ptr, as_function, all_args, nested_args, max_prop_length, iterprop); } @@ -5137,7 +5141,7 @@ char *RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, RNA_struct_iterator_property(funcptr.type); - return RNA_pointer_as_string_keywords_ex(C, &funcptr, as_function, all_args, + return RNA_pointer_as_string_keywords_ex(C, &funcptr, as_function, all_args, true, max_prop_length, iterprop); } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 754952cd65f..e867aa00958 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -313,6 +313,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) char *opname; PyObject *kw = NULL; /* optional args */ int all_args = 1; + int macro_args = 1; int error_val = 0; char *buf = NULL; @@ -325,7 +326,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) return NULL; } - if (!PyArg_ParseTuple(args, "s|O!i:_bpy.ops.as_string", &opname, &PyDict_Type, &kw, &all_args)) + if (!PyArg_ParseTuple(args, "s|O!ii:_bpy.ops.as_string", &opname, &PyDict_Type, &kw, &all_args, ¯o_args)) return NULL; ot = WM_operatortype_find(opname, true); @@ -345,7 +346,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) error_val = pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: "); if (error_val == 0) - buf = WM_operator_pystring_ex(C, NULL, all_args, ot, &ptr); + buf = WM_operator_pystring_ex(C, NULL, all_args, macro_args, ot, &ptr); WM_operator_properties_free(&ptr); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 507202b9116..0e202fda9ab 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -272,9 +272,11 @@ bool WM_operator_last_properties_store(struct wmOperator *op); /* operator as a python command (resultuing string must be freed) */ -char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, +char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, + const bool all_args, const bool macro_args, struct wmOperatorType *ot, struct PointerRNA *opptr); -char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args); +char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, + const bool all_args, const bool macro_args); char *WM_prop_pystring_assign(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2f959c926e0..ef1f6c7a34a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -491,8 +491,8 @@ int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context) static void wm_operator_print(bContext *C, wmOperator *op) { /* context is needed for enum function */ - char *buf = WM_operator_pystring(C, op, false); - printf("%s\n", buf); + char *buf = WM_operator_pystring(C, op, false, true); + puts(buf); MEM_freeN(buf); } @@ -626,7 +626,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal if (op->type->flag & OPTYPE_REGISTER) { if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */ /* Report the python string representation of the operator */ - char *buf = WM_operator_pystring(C, op, false); + char *buf = WM_operator_pystring(C, op, false, true); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } @@ -660,7 +660,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) if (repeat == 0) { if (G.debug & G_DEBUG_WM) { - char *buf = WM_operator_pystring(C, op, false); + char *buf = WM_operator_pystring(C, op, false, true); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 33b1a98b710..a9c7610bf8a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -528,7 +528,8 @@ void WM_operator_bl_idname(char *to, const char *from) * * Note: both op and opptr may be NULL (op is only used for macro operators). */ -char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, wmOperatorType *ot, PointerRNA *opptr) +char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, const bool macro_args, + wmOperatorType *ot, PointerRNA *opptr) { char idname_py[OP_MAX_TYPENAME]; @@ -547,7 +548,10 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, /* Special handling for macros, else we only get default values in this case... */ wmOperator *opm; bool first_op = true; - for (opm = op->macro.first; opm; opm = opm->next) { + + opm = macro_args ? op->macro.first : NULL; + + for (; opm; opm = opm->next) { PointerRNA *opmptr = opm->ptr; PointerRNA opmptr_default; if (opmptr == NULL) { @@ -573,13 +577,14 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, else { /* only to get the orginal props for comparisons */ PointerRNA opptr_default; + const bool macro_args_test = ot->macro.first ? macro_args : true; if (opptr == NULL) { WM_operator_properties_create_ptr(&opptr_default, ot); opptr = &opptr_default; } - cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, all_args, max_prop_length); + cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, all_args, macro_args_test, max_prop_length); BLI_dynstr_append(dynstr, cstring_args); MEM_freeN(cstring_args); @@ -595,9 +600,10 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, return cstring; } -char *WM_operator_pystring(bContext *C, wmOperator *op, const bool all_args) +char *WM_operator_pystring(bContext *C, wmOperator *op, + const bool all_args, const bool macro_args) { - return WM_operator_pystring_ex(C, op, all_args, op->type, op->ptr); + return WM_operator_pystring_ex(C, op, all_args, macro_args, op->type, op->ptr); } /* return NULL if no match is found */ |