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:
authorThomas Dinges <blender@dingto.org>2009-08-15 23:40:09 +0400
committerThomas Dinges <blender@dingto.org>2009-08-15 23:40:09 +0400
commit0ce5163cc0aa32df5450752da9056059a88f1fd5 (patch)
treea5aa62f012dba91b3d78935f608a06c1b69b4ef6 /source/blender/blenkernel
parentca906df5ccdd0d1b0a600f073b5bad5251d42e07 (diff)
2.5 3D_View:
Patch [#19031] (2.5) python menus for the view3d header by Lorenzo Pierfederici (lento). Thanks! * Added CTX_data_mode_string() to find out in which mode we're in. * Added some "select" menus as a test. This patch makes it basically possible to wrap the 3D View menus to python.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_context.h2
-rw-r--r--source/blender/blenkernel/intern/context.c38
2 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index e47ad969b91..81dea204dd0 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -191,6 +191,8 @@ struct Main *CTX_data_main(const bContext *C);
struct Scene *CTX_data_scene(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
+char *CTX_data_mode_string(const bContext *C);
+
void CTX_data_main_set(bContext *C, struct Main *bmain);
void CTX_data_scene_set(bContext *C, struct Scene *bmain);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index d1e228f83b6..df5b0d766b5 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -34,6 +34,7 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
+#include "DNA_object_types.h"
#include "RNA_access.h"
@@ -43,6 +44,7 @@
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "BKE_global.h"
#include <string.h>
@@ -659,6 +661,42 @@ Scene *CTX_data_scene(const bContext *C)
return C->data.scene;
}
+char *CTX_data_mode_string(const bContext *C)
+{
+ Object *obedit= CTX_data_edit_object(C);
+
+ if(obedit) {
+ switch(obedit->type) {
+ case OB_MESH:
+ return "meshedit";
+ case OB_CURVE:
+ return "curveedit";
+ case OB_SURF:
+ return "surfaceedit";
+ case OB_FONT:
+ return "textedit";
+ case OB_ARMATURE:
+ return "armatureedit";
+ case OB_MBALL:
+ return "mballedit";
+ case OB_LATTICE:
+ return "latticeedit";
+ }
+ }
+ else {
+ Object *ob = CTX_data_active_object(C);
+
+ if(ob && (ob->flag & OB_POSEMODE)) return "posemode";
+ else if (ob && ob->mode & OB_MODE_SCULPT) return "sculpt_mode";
+ else if (G.f & G_WEIGHTPAINT) return "weightpaint";
+ else if (G.f & G_VERTEXPAINT) return "vertexpaint";
+ else if (G.f & G_TEXTUREPAINT) return "texturepaint";
+ else if(G.f & G_PARTICLEEDIT) return "particlemode";
+ }
+
+ return "objectmode";
+}
+
void CTX_data_scene_set(bContext *C, Scene *scene)
{
C->data.scene= scene;