More work on Drag Immediate:
authorMartin Poirier <theeth@yahoo.com>
Sat, 3 Apr 2010 17:38:43 +0000 (17:38 +0000)
committerMartin Poirier <theeth@yahoo.com>
Sat, 3 Apr 2010 17:38:43 +0000 (17:38 +0000)
- Rename option and flag to something more sane
- Add property to manipulator operator and set true by default

Confirm on Release can now be forced true or false per operator, in which case it won't use the default value (the user preference).

source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_ops.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_event_system.c

index 45675d44d31b0a76567782c6d7175e03d87556c0..12ba14ab189e3b123a4ae9bb2696990cdc89f974 100644 (file)
@@ -2376,8 +2376,8 @@ void VIEW3D_OT_manipulator(wmOperatorType *ot)
 
        ot->poll= ED_operator_view3d_active;
 
-       /* rna later */
-       RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
+       /* properties to pass to transform */
+       Transform_Properties(ot, P_CONSTRAINT);
 }
 
 static int enable_manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event)
index ccc2717556d8bf5ebbcf1b7f90c7ad4ff9db9df0..d2fda2f2f76e0824fa8ef1bb36c0b0996eeaca23 100644 (file)
@@ -115,7 +115,8 @@ void view3d_keymap(wmKeyConfig *keyconf)
        /* only for region 3D window */
        keymap= WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
        
-       WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+       kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+       RNA_boolean_set(kmi->ptr, "release_confirm", 1);
        /*
         * Doesn't work with KM_SHIFT, have to use KM_ANY and filter in invoke
         * */
index 13684708f8e6acd10b2afeaa73e60455cb4f1759..498313838df98afb9a5aac7a94dcd141488c59ce 100644 (file)
@@ -1032,7 +1032,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                }
 
                /* confirm transform if launch key is released after mouse move */
-               if (t->flag & T_RELEASE_CONFIRM || t->state != TRANS_STARTING)
+               if (t->flag & T_RELEASE_CONFIRM)
                {
                        /* XXX Keyrepeat bug in Xorg fucks this up, will test when fixed */
                        if (event->type == t->launch_event && (t->launch_event == LEFTMOUSE || t->launch_event == RIGHTMOUSE))
index e9ee45259e91d283f4cd50c5e1e4172aef069e2c..8bbeec6315598eea13f1f3c4bf713b4781ba70cf 100644 (file)
@@ -1000,7 +1000,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
        }
        else
        {
-               if (U.flag & USER_DRAGIMMEDIATE)
+               if (U.flag & USER_RELEASECONFIRM)
                {
                        t->flag |= T_RELEASE_CONFIRM;
                }
index 5e7c6fc9d3d52e3041bbdc5142d1950039876005..b11f35dd363e30c5b6fcd45404b6aadd3adf5e6d 100644 (file)
@@ -1551,6 +1551,8 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, short *mval, float ho
        return 0;
 }
 
+int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports);
+
 /* return 0; nothing happened */
 int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
 {
@@ -1564,6 +1566,9 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
        if(!(v3d->twflag & V3D_USE_MANIPULATOR)) return 0;
        if(!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return 0;
 
+       /* Force orientation */
+       RNA_enum_set(op->ptr, "constraint_orientation", v3d->twmode);
+
        // find the hotspots first test narrow hotspot
        val= manipulator_selectbuf(sa, ar, event->mval, 0.5f*(float)U.tw_hotspot);
        if(val) {
@@ -1603,6 +1608,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
                        }
                        RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
                        WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr);
+                       //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL);
                }
                else if (drawflags & MAN_SCALE_C) {
                        switch(drawflags) {
@@ -1633,8 +1639,10 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
                        }
                        RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
                        WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr);
+                       //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL);
                }
                else if (drawflags == MAN_ROT_T) { /* trackball need special case, init is different */
+                       //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, op->ptr, NULL);
                        WM_operator_name_call(C, "TRANSFORM_OT_trackball", WM_OP_INVOKE_DEFAULT, op->ptr);
                }
                else if (drawflags & MAN_ROT_C) {
@@ -1651,6 +1659,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
                        }
                        RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
                        WM_operator_name_call(C, "TRANSFORM_OT_rotate", WM_OP_INVOKE_DEFAULT, op->ptr);
+                       //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_rotate", 0), event, op->ptr, NULL);
                }
        }
        /* after transform, restore drawflags */
index 53cbfd208b6a8ac2b25554bc82ce820f99126105..6059d9d46973e662cbcb46adf301fb708f1ba547 100644 (file)
@@ -381,23 +381,10 @@ static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
        }
 }
 
-#define P_MIRROR               (1 << 0)
-#define P_PROPORTIONAL (1 << 1)
-#define P_AXIS                 (1 << 2)
-#define P_SNAP                 (1 << 3)
-#define P_GEO_SNAP             (P_SNAP|(1 << 4))
-#define P_ALIGN_SNAP   (P_GEO_SNAP|(1 << 5))
-#define P_CONSTRAINT   (1 << 6)
-
-
 void Transform_Properties(struct wmOperatorType *ot, int flags)
 {
        PropertyRNA *prop;
 
-       // Add confirm method all the time
-       prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Confirm operation when releasing button");
-       RNA_def_property_flag(prop, PROP_HIDDEN);
-
        if (flags & P_AXIS)
        {
                prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
@@ -440,6 +427,10 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
                        }
                }
        }
+
+       // Add confirm method all the time. At the end because it's not really that important and should be hidden
+       prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
+       //RNA_def_property_flag(prop, PROP_HIDDEN);
 }
 
 void TRANSFORM_OT_translate(struct wmOperatorType *ot)
index e0a32d9ce6cec5869ae68a2776d5adef21be2067..d5a2b504962cbf129044c59128b174a4f109040a 100644 (file)
@@ -408,7 +408,7 @@ extern UserDef U; /* from blenkernel blender.c */
 #define USER_ADD_EDITMODE              (1 << 18)
 #define USER_ADD_VIEWALIGNED   (1 << 19)
 #define USER_RELPATHS                  (1 << 20)
-#define USER_DRAGIMMEDIATE             (1 << 21)
+#define USER_RELEASECONFIRM            (1 << 21)
 #define USER_SCRIPT_AUTOEXEC_DISABLE   (1 << 22)
 #define USER_FILENOUI                  (1 << 23)
 #define USER_NONEGFRAMES               (1 << 24)
index 68e6c20d8aa560247809df3338d0f058ad51a5f2..6b78ddaeae1db0524333af9906e6acad2ca712fc 100644 (file)
@@ -2085,8 +2085,8 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Enter Edit Mode", "Enter Edit Mode automatically after adding a new object");
 
        prop= RNA_def_property(srna, "drag_immediately", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_DRAGIMMEDIATE);
-       RNA_def_property_ui_text(prop, "Drag Immediately", "Moving things with a mouse drag doesn't require a click to confirm (Best for tablet users)");
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_RELEASECONFIRM);
+       RNA_def_property_ui_text(prop, "Release confirm", "Moving things with a mouse drag confirms when releasing the button");
        
        /* Undo */
        prop= RNA_def_property(srna, "undo_steps", PROP_INT, PROP_NONE);
index da1f71f49da9b8183d54ee8645308e82d70868e1..19a7ae38b7fb2c52c1f69e9e52c352b4fffd51c7 100644 (file)
@@ -551,7 +551,7 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event)
        }
 }
 
-static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports)
+int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
        int retval= OPERATOR_PASS_THROUGH;
@@ -1930,7 +1930,8 @@ void WM_event_add_mousemove(bContext *C)
 int WM_modal_tweak_exit(wmEvent *evt, int tweak_event)
 {
        /* user preset or keymap? dunno... */
-       int tweak_modal= (U.flag & USER_DRAGIMMEDIATE)==0;
+       // XXX WTH is this?
+       int tweak_modal= (U.flag & USER_RELEASECONFIRM)==0;
        
        switch(tweak_event) {
                case EVT_TWEAK_L: