remove 'Reset' button from operator UI, instead have 'Restore Defaults' in preset menu.

If this is needed we can add the reset button back as an option for certain operators,
but AFAICS any operator with enough settings that resetting them all would be annoying - could have presets enabled.
This commit is contained in:
Campbell Barton
2012-11-12 21:44:48 +00:00
parent d3c3f07133
commit 1c32617f1e
3 changed files with 38 additions and 0 deletions

View File

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

View File

@@ -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 */
{

View File

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