From 03b0681fe513c12fda0a377984a1a81afb9fdb8f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jan 2012 19:33:14 +0000 Subject: running operators now uses last used settings, added reset button to set defaults. details - uses redo stack to get recent settings from. - adds a flag to IDProperties so RNA_property_is_set() can return false even if the property is exists. - PROP_SKIP_SAVE option skips these settings from getting reset (as with presets). --- .../blender/editors/interface/interface_layout.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/interface') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 5e42b06e1a7..a01efa25d19 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2742,6 +2742,11 @@ const char *uiLayoutIntrospect(uiLayout *layout) return str; } +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); +} + /* 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,int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag) { @@ -2803,7 +2808,22 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in uiItemL(layout, IFACE_("No Properties"), ICON_NONE); } } - + + /* 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 */ + if (op->properties->len) { + uiBlock *block; + uiBut *but; + uiLayout *col; /* needed to avoid alignment errors with previous buttons */ + + col= uiLayoutColumn(layout, 0); + block= uiLayoutGetBlock(col); + but = uiDefIconTextBut(block , BUT, 0, ICON_FILE_REFRESH, "Reset", 0, 0, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0, + "Reset operator defaults"); + uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL); + } + /* set various special settings for buttons */ { uiBut *but; -- cgit v1.2.3