* Added an 'enable manipulator' operator, with boolean properties for each of
authorMatt Ebb <matt@mke3.net>
Thu, 14 Jan 2010 05:29:25 +0000 (05:29 +0000)
committerMatt Ebb <matt@mke3.net>
Thu, 14 Jan 2010 05:29:25 +0000 (05:29 +0000)
translate/rotate/scale, for people to bind to shortcut keys.

wm.context_set doesn't work well here since it just toggles each component on/off.

Fixes [#19730] Missing/conflicting keymaps for "Change Manipulator Mode" function

Good defaults for this can be decided on for an updated 2.5 key layout.

source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_ops.c

index 9bb7d35f96d5a83aaa5d6777cc3070170ec88829..d565199ef55e6c61a8cb2c809d4d1158b06736d4 100644 (file)
@@ -2283,7 +2283,40 @@ void VIEW3D_OT_manipulator(wmOperatorType *ot)
        RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
 }
 
+static int enable_manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       View3D *v3d = CTX_wm_view3d(C);
+
+       v3d->twtype=0;
+       
+       if (RNA_boolean_get(op->ptr, "translate"))
+               v3d->twtype |= V3D_MANIP_TRANSLATE;
+       if (RNA_boolean_get(op->ptr, "rotate"))
+               v3d->twtype |= V3D_MANIP_ROTATE;
+       if (RNA_boolean_get(op->ptr, "scale"))
+               v3d->twtype |= V3D_MANIP_SCALE;
+               
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
+
+       return OPERATOR_FINISHED;
+}
 
+void VIEW3D_OT_enable_manipulator(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Enable 3D Manipulator";
+       ot->description = "Enable the transform manipulator for use.";
+       ot->idname= "VIEW3D_OT_enable_manipulator";
+       
+       /* api callbacks */
+       ot->invoke= enable_manipulator_invoke;
+       ot->poll= ED_operator_view3d_active;
+       
+       /* rna later */
+       RNA_def_boolean(ot->srna, "translate", 0, "Translate", "Enable the translate manipulator");
+       RNA_def_boolean(ot->srna, "rotate", 0, "Rotate", "Enable the rotate manipulator");
+       RNA_def_boolean(ot->srna, "scale", 0, "Scale", "Enable the scale manipulator");
+}
 
 /* ************************* below the line! *********************** */
 
index 7d2f6294041a67db457830fde4927dad79e0c105..81de9ac7d34378b1912fb77489141185a2da5e72 100644 (file)
@@ -81,6 +81,7 @@ void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
 void VIEW3D_OT_clip_border(struct wmOperatorType *ot);
 void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
 void VIEW3D_OT_manipulator(struct wmOperatorType *ot);
+void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot);
 void VIEW3D_OT_render_border(struct wmOperatorType *ot);
 void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
 void VIEW3D_OT_drawtype(struct wmOperatorType *ot);
index a673efb0499cd19c3186559b862f482a85ab3862..ad5bdcf0095cd5a6a89f13dec45a7f05161aecc3 100644 (file)
@@ -80,6 +80,7 @@ void view3d_operatortypes(void)
        WM_operatortype_append(VIEW3D_OT_render_border);
        WM_operatortype_append(VIEW3D_OT_zoom_border);
        WM_operatortype_append(VIEW3D_OT_manipulator);
+       WM_operatortype_append(VIEW3D_OT_enable_manipulator);
        WM_operatortype_append(VIEW3D_OT_cursor3d);
        WM_operatortype_append(VIEW3D_OT_select_lasso);
        WM_operatortype_append(VIEW3D_OT_setcameratoview);
@@ -264,7 +265,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
        
        WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
-
+       
        /* context ops */
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
        RNA_string_set(kmi->ptr, "path", "space_data.pivot_point");