Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_operators/presets.py6
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c26
3 files changed, 38 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index b7adf53dbf1..4e7003fd453 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -554,6 +554,12 @@ class WM_MT_operator_presets(Menu):
def draw(self, context):
self.operator = context.active_operator.bl_idname
+
+ # dummy 'default' menu item
+ layout = self.layout
+ layout.operator("wm.operator_defaults")
+ layout.seperator()
+
Menu.draw_preset(self, context)
@property
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 52d909a34c0..9eec7c195b2 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -68,6 +68,8 @@
#define EM_SEPR_X 6
#define EM_SEPR_Y 6
+// #define USE_OP_RESET_BUT // we may want to make this optional, disable for now.
+
#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \
if (ot == NULL) { \
ui_item_disabled(layout, _opname); \
@@ -2840,10 +2842,12 @@ const char *uiLayoutIntrospect(uiLayout *layout)
return str;
}
+#ifdef USE_OP_RESET_BUT
static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt, void *UNUSED(arg_dummy2))
{
WM_operator_properties_reset((wmOperator *)op_pt);
}
+#endif
/* this function does not initialize the layout, functions can be called on the layout before and after */
void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,
@@ -2911,6 +2915,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,
}
}
+#ifdef USE_OP_RESET_BUT
/* its possible that reset can do nothing if all have PROP_SKIP_SAVE enabled
* but this is not so important if this button is drawn in those cases
* (which isn't all that likely anyway) - campbell */
@@ -2925,6 +2930,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults"));
uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL);
}
+#endif
/* set various special settings for buttons */
{
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index f25603ff622..09dbedf4284 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1280,6 +1280,31 @@ static void WM_OT_debug_menu(wmOperatorType *ot)
RNA_def_int(ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000);
}
+/* ***************** Operator defaults ************************* */
+static int wm_operator_defaults_exec(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "active_operator", &RNA_Operator);
+
+ if (!ptr.data) {
+ BKE_report(op->reports, RPT_ERROR, "No operator in context");
+ return OPERATOR_CANCELLED;
+ }
+
+ WM_operator_properties_reset((wmOperator *)ptr.data);
+ return OPERATOR_FINISHED;
+}
+
+/* used by operator preset menu. pre-2.65 this was a 'Reset' button */
+static void WM_OT_operator_defaults(wmOperatorType *ot)
+{
+ ot->name = "Restore Defaults";
+ ot->idname = "WM_OT_operator_defaults";
+ ot->description = "Set the active operator to its default values";
+
+ ot->exec = wm_operator_defaults_exec;
+
+ ot->flag = OPTYPE_INTERNAL;
+}
/* ***************** Splash Screen ************************* */
@@ -3748,6 +3773,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_memory_statistics);
WM_operatortype_append(WM_OT_dependency_relations);
WM_operatortype_append(WM_OT_debug_menu);
+ WM_operatortype_append(WM_OT_operator_defaults);
WM_operatortype_append(WM_OT_splash);
WM_operatortype_append(WM_OT_search_menu);
WM_operatortype_append(WM_OT_call_menu);