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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-08 20:59:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-08 20:59:06 +0400
commit5f40c0e9a5b5665e559b441c7659050ff861931d (patch)
treea1ab1fe645405794053a16a1f2d0c6ea5b1d3839
parent51ead63ae6a9e032af892058f132f12933f4c138 (diff)
- operator presets now work in the 3D view as well as the file selector.
to enable from python: bl_options = {'REGISTER', 'UNDO', 'PRESET'} from C: ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_PRESET; - added context member 'active_operator' - enable this for 'Add Torus' for testing.
-rw-r--r--release/scripts/startup/bl_operators/add_mesh_torus.py2
-rw-r--r--release/scripts/startup/bl_operators/presets.py5
-rw-r--r--source/blender/editors/screen/screen_context.c24
3 files changed, 27 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py
index 056b3478c2b..5b28cdf44ae 100644
--- a/release/scripts/startup/bl_operators/add_mesh_torus.py
+++ b/release/scripts/startup/bl_operators/add_mesh_torus.py
@@ -86,7 +86,7 @@ class AddTorus(Operator):
'''Add a torus mesh'''
bl_idname = "mesh.primitive_torus_add"
bl_label = "Add Torus"
- bl_options = {'REGISTER', 'UNDO'}
+ bl_options = {'REGISTER', 'UNDO', 'PRESET'}
major_radius = FloatProperty(
name="Major Radius",
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index ac19bab4c66..dca96b302fb 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -395,9 +395,8 @@ class AddPresetOperator(AddPresetBase, Operator):
options={'HIDDEN'},
)
- # XXX, not ideal
preset_defines = [
- "op = bpy.context.space_data.operator",
+ "op = bpy.context.active_operator",
]
@property
@@ -432,7 +431,7 @@ class WM_MT_operator_presets(Menu):
bl_label = "Operator Presets"
def draw(self, context):
- self.operator = context.space_data.operator.bl_idname
+ self.operator = context.active_operator.bl_idname
Menu.draw_preset(self, context)
@property
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index cb42cd786ed..581c1e3597b 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -35,6 +35,8 @@
#include "DNA_sequence_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
#include "BLI_utildefines.h"
@@ -50,6 +52,8 @@
#include "ED_object.h"
#include "ED_armature.h"
+#include "WM_api.h"
+
#include "screen_intern.h"
const char *screen_context_dir[] = {
@@ -62,6 +66,7 @@ const char *screen_context_dir[] = {
"sculpt_object", "vertex_paint_object", "weight_paint_object",
"image_paint_object", "particle_edit_object",
"sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */
+ "active_operator",
NULL};
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
@@ -387,6 +392,25 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
}
+ else if(CTX_data_equals(member, "active_operator")) {
+ wmOperator *op= NULL;
+
+ SpaceFile *sfile= CTX_wm_space_file(C);
+ if(sfile) {
+ op= sfile->op;
+ }
+ else {
+ /* note, this checks poll, could be a problem, but this also
+ * happens for the toolbar */
+ op= WM_operator_last_redo(C);
+ }
+ /* TODO, get the operator from popup's */
+
+ if (op && op->ptr) {
+ CTX_data_pointer_set(result, NULL, &RNA_Operator, op);
+ return 1;
+ }
+ }
else {
return 0; /* not found */
}