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:
authorNicholas Bishop <nicholasbishop@gmail.com>2009-08-16 09:48:07 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2009-08-16 09:48:07 +0400
commitd86663ee1a4e845afd15752bac6dfb05dd675f69 (patch)
treef81003eabb6326214bb03e3180426053b29ccdd9 /source/blender/editors/object
parent128cf1522453c8f800d31fd663ac9027f56ec151 (diff)
2.5/Modes:
* Added OBJECT_OT_mode_set for setting the object mode. Takes one property, "mode", which can be any of the OB_MODE_* flags. The available modes are limited based on the active object (e.g. only meshes can have sculptmode, and so forth.) * Set the icon properties in the object mode enum RNA TODO: At this point I think everything is ready to start ripping out the ugly hacks in view3d_header for setting the mode :)
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_edit.c80
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_ops.c1
3 files changed, 82 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 302c4c1bdce..581b870d0b4 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -127,6 +127,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
/* for menu/popup icons etc etc*/
#include "UI_interface.h"
@@ -7031,6 +7032,85 @@ void hookmenu(Scene *scene, View3D *v3d)
}
}
+static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, int *free)
+{
+ EnumPropertyItem *input = object_mode_items;
+ EnumPropertyItem *item= NULL;
+ Object *ob = CTX_data_active_object(C);
+ int totitem= 0;
+
+ if(!C) /* needed for docs */
+ return object_mode_items;
+
+ while(ob && input->identifier) {
+ if((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) ||
+ (ob->type == OB_CURVE) || (ob->type == OB_SURF) ||
+ (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) ||
+ (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) ||
+ (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) ||
+ ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT ||
+ input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) ||
+ (input->value == OB_MODE_OBJECT))
+ RNA_enum_item_add(&item, &totitem, input);
+ ++input;
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+
+ *free= 1;
+
+ return item;
+}
+
+static int object_mode_set_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ int mode = RNA_enum_get(op->ptr, "mode");
+
+ if(!ob)
+ return OPERATOR_CANCELLED;
+
+ if((mode == OB_MODE_EDIT) == !(ob->mode & OB_MODE_EDIT))
+ WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if((mode == OB_MODE_SCULPT) == !(ob->mode & OB_MODE_SCULPT))
+ WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if((mode == OB_MODE_VERTEX_PAINT) == !(ob->mode & OB_MODE_VERTEX_PAINT))
+ WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if((mode == OB_MODE_WEIGHT_PAINT) == !(ob->mode & OB_MODE_WEIGHT_PAINT))
+ WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if((mode == OB_MODE_TEXTURE_PAINT) == !(ob->mode & OB_MODE_TEXTURE_PAINT))
+ WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if((mode == OB_MODE_PARTICLE_EDIT) == !(ob->mode & OB_MODE_PARTICLE_EDIT))
+ WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+ if((mode == OB_MODE_POSE) == !(ob->mode & OB_MODE_POSE))
+ WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_mode_set(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name= "Set Object Mode";
+ ot->description = "Sets the object interaction mode.";
+ ot->idname= "OBJECT_OT_mode_set";
+
+ /* api callbacks */
+ ot->exec= object_mode_set_exec;
+
+ ot->poll= ED_operator_object_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ prop= RNA_def_enum(ot->srna, "mode", object_mode_items, 0, "Mode", "");
+ RNA_def_enum_funcs(prop, object_mode_set_itemsf);
+}
+
+
+
void ED_object_toggle_modes(bContext *C, int mode)
{
if(mode & OB_MODE_SCULPT)
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 17d4f5deaae..e47087a3c27 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -39,6 +39,7 @@ struct Mesh;
/* object_edit.c */
+void OBJECT_OT_mode_set(struct wmOperatorType *ot);
void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot);
void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot);
void OBJECT_OT_parent_set(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index c1509e78502..f2e048284f4 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -65,6 +65,7 @@ void ED_operatortypes_object(void)
{
wmOperatorType *ot;
+ WM_operatortype_append(OBJECT_OT_mode_set);
WM_operatortype_append(OBJECT_OT_editmode_toggle);
WM_operatortype_append(OBJECT_OT_posemode_toggle);
WM_operatortype_append(OBJECT_OT_parent_set);