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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-12-24 10:46:40 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-24 10:46:40 +0300
commit4d0c10d5ca9f2fb03a6183e77ed0265ed2218cae (patch)
tree1bbf438029cb2e01bddcdbc0dce093b04489009f /source
parentc0339029c76b53461edad9ab2ebdae4bce61dfee (diff)
presets for operators, re-using same preset system as render, cloth etc use.
- operators need to enable the option OPTYPE_PRESET or 'PRESET' in python. - hidden properties are not written. - currently this only works in the file selector (enabled for FBX/OBJ export) - currently the menu label doesnt change when presets are selected, this is a TODO, not so simple since the UI is defined in C and the label in python. - presets save in "scripts/presets/operators/*id*/*.py"
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_layout.c21
-rw-r--r--source/blender/makesrna/intern/rna_wm.c1
-rw-r--r--source/blender/windowmanager/WM_types.h1
3 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 559015715ef..46dfd34d2ba 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2702,7 +2702,26 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
int empty;
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
-
+
+ /* menu */
+ if(op->type->flag & OPTYPE_PRESET) {
+ /* XXX, no simple way to get WM_MT_operator_presets.bl_label from python! Label remains the same always! */
+ PointerRNA op_ptr;
+ uiLayout *row;
+
+ row= uiLayoutRow(layout, TRUE);
+ uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NULL);
+
+ WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add");
+ RNA_string_set(&op_ptr, "operator", op->type->idname);
+ op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMIN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+
+ WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add");
+ RNA_string_set(&op_ptr, "operator", op->type->idname);
+ RNA_boolean_set(&op_ptr, "remove_active", 1);
+ op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMOUT, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ }
+
/* main draw call */
empty= uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index b6b73b9885d..a7870243afc 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -265,6 +265,7 @@ EnumPropertyItem operator_flag_items[] = {
{OPTYPE_BLOCKING, "BLOCKING", 0, "Finished", ""},
{OPTYPE_MACRO, "MACRO", 0, "Macro", ""},
{OPTYPE_GRAB_POINTER, "GRAB_POINTER", 0, "Grab Pointer", ""},
+ {OPTYPE_PRESET, "PRESET", 0, "Preset", ""},
{0, NULL, 0, NULL, NULL}};
EnumPropertyItem operator_return_items[] = {
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 0ca8c5e7f4f..bbd22cae0f3 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -55,6 +55,7 @@ struct ImBuf;
#define OPTYPE_BLOCKING 4 /* let blender grab all input from the WM (X11) */
#define OPTYPE_MACRO 8
#define OPTYPE_GRAB_POINTER 16 /* */
+#define OPTYPE_PRESET 32 /* show preset menu */
/* context to call operator in for WM_operator_name_call */
/* rna_ui.c contains EnumPropertyItem's of these, keep in sync */