Made select operator return FINISHED only when it did something (only PASSTHROUGH...
authorMartin Poirier <theeth@yahoo.com>
Tue, 24 Nov 2009 04:59:52 +0000 (04:59 +0000)
committerMartin Poirier <theeth@yahoo.com>
Tue, 24 Nov 2009 04:59:52 +0000 (04:59 +0000)
source/blender/editors/armature/editarmature.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_curve.h
source/blender/editors/include/ED_mball.h
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_object.h
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/metaball/mball_edit.c
source/blender/editors/object/object_lattice.c
source/blender/editors/space_view3d/view3d_select.c

index db499c72908ff4f36c69cc06c2c7301b5f650fd2..78ba73ce5d5630bc6206b08247500d9ff0ee01cd 100644 (file)
@@ -1875,7 +1875,7 @@ void ED_armature_deselectall(Object *obedit, int toggle, int doundo)
 
 
 /* context: editmode armature in view3d */
-void mouse_armature(bContext *C, short mval[2], int extend)
+int mouse_armature(bContext *C, short mval[2], int extend)
 {
        Object *obedit= CTX_data_edit_object(C);
        bArmature *arm= obedit->data;
@@ -1946,7 +1946,10 @@ void mouse_armature(bContext *C, short mval[2], int extend)
                }
                
                WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
+               return 1;
        }
+
+       return 0;
 }
 
 void ED_armature_edit_free(struct Object *ob)
index 7801168dd835ed7e90051e054773e58a3ecf7967..e53b419c6ea91e758c6d5ea344e0382042f1315e 100644 (file)
@@ -3055,7 +3055,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot)
 
 /***************** pick select from 3d view **********************/
 
-void mouse_nurb(bContext *C, short mval[2], int extend)
+int mouse_nurb(bContext *C, short mval[2], int extend)
 {
        Object *obedit= CTX_data_edit_object(C); 
        Curve *cu= obedit->data;
@@ -3111,12 +3111,15 @@ void mouse_nurb(bContext *C, short mval[2], int extend)
 
                }
 
-       }
+               if(nu!=get_actNurb(obedit))
+                       set_actNurb(obedit, nu);
 
-       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
+
+               return 1;
+       }
        
-       if(nu!=get_actNurb(obedit))
-               set_actNurb(obedit, nu);
+       return 0;
 }
 
 /******************** spin operator ***********************/
index 1836729e4193b517c71516509fc05610801e3ed6..2aa47311515a7e437714a5855e9584bc2450980d 100644 (file)
@@ -107,7 +107,7 @@ void ED_armature_deselectall(struct Object *obedit, int toggle, int doundo);
 
 int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, 
                                                        short hits, short extend);
-void mouse_armature(struct bContext *C, short mval[2], int extend);
+int mouse_armature(struct bContext *C, short mval[2], int extend);
 int join_armature_exec(struct bContext *C, struct wmOperator *op);
 struct Bone *get_indexed_bone (struct Object *ob, int index);
 float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]);
index fea684971b23e833a1aa274df072253398917044..66a481ca5ac5d511e9cc895d60b03cfffa0b8139 100644 (file)
@@ -50,7 +50,7 @@ void  load_editNurb   (struct Object *obedit);
 void   make_editNurb   (struct Object *obedit);
 void   free_editNurb   (struct Object *obedit);
 
-void   mouse_nurb              (struct bContext *C, short mval[2], int extend);
+int    mouse_nurb              (struct bContext *C, short mval[2], int extend);
 
 struct Nurb *add_nurbs_primitive(struct bContext *C, int type, int newname);
 
index 6708a73e0889d7ed27bf662501635a35eb8575dd..b21bcb0cc09f96df765fea29a565b95f346886c9 100644 (file)
@@ -35,7 +35,7 @@ void ED_keymap_metaball(struct wmKeyConfig *keyconf);
 
 struct MetaElem *add_metaball_primitive(struct bContext *C, int type, int newname);
 
-void mouse_mball(struct bContext *C, short mval[2], int extend);
+int mouse_mball(struct bContext *C, short mval[2], int extend);
 
 void free_editMball(struct Object *obedit);
 void make_editMball(struct Object *obedit);
index fa47426c70ac718218292ae099b2eac5c0123ba2..35e1f10b5162563ca1192160c22273eda245d5f1 100644 (file)
@@ -149,7 +149,7 @@ void                EM_free_data_layer(struct EditMesh *em, struct CustomData *data, int type)
 extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs;
 
 void           EM_cache_x_mirror_vert(struct Object *ob, struct EditMesh *em);
-void           mouse_mesh(struct bContext *C, short mval[2], short extend);
+int                    mouse_mesh(struct bContext *C, short mval[2], short extend);
 int                    EM_check_backbuf(unsigned int index);
 int                    EM_mask_init_backbuf_border(struct ViewContext *vc, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax);
 void           EM_free_backbuf(void);
index e48a98a65f1e07af4744afdbc1430973cd78977a..1785b0303cb054c84c3d02218569de199120da8e 100644 (file)
@@ -102,7 +102,7 @@ void ED_object_constraint_update(struct Object *ob);
 void ED_object_constraint_dependency_update(struct Scene *scene, struct Object *ob);
 
 /* object_lattice.c */
-void mouse_lattice(struct bContext *C, short mval[2], int extend);
+int  mouse_lattice(struct bContext *C, short mval[2], int extend);
 void undo_push_lattice(struct bContext *C, char *name);
 
 /* object_shapekey.c */
index e14dedf6002f92f590c0c1cc5b11cabbbf707bfe..2d1452c8cb18fc7c498cefa33174ec8b124d01a9 100644 (file)
@@ -2222,7 +2222,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot)
 
 /* here actual select happens */
 /* gets called via generic mouse select operator */
-void mouse_mesh(bContext *C, short mval[2], short extend)
+int mouse_mesh(bContext *C, short mval[2], short extend)
 {
        ViewContext vc;
        EditVert *eve;
@@ -2281,10 +2281,13 @@ void mouse_mesh(bContext *C, short mval[2], short extend)
                        vc.em->mat_nr= efa->mat_nr;
 //                     BIF_preview_changed(ID_MA);
                }
-       }
 
-       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
+
+               return 1;
+       }
        
+       return 0;
 }
 
 /* *********** select linked ************* */
index 3751f8875f6743f51025a4b788351f50633e5922..09200514c0fdda62b7b584a178e212df075114b9 100644 (file)
@@ -517,7 +517,7 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
 
 /* Select MetaElement with mouse click (user can select radius circle or
  * stiffness circle) */
-void mouse_mball(bContext *C, short mval[2], int extend)
+int mouse_mball(bContext *C, short mval[2], int extend)
 {
        static MetaElem *startelem=NULL;
        Object *obedit= CTX_data_edit_object(C);
@@ -588,8 +588,12 @@ void mouse_mball(bContext *C, short mval[2], int extend)
                        mb->lastelem= act;
                        
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb);
+
+                       return 1;
                }
        }
+
+       return 0;
 }
 
 
index b49c1eb5902047609533d823f59ad1f0bbe284d0..3f27ea407a238e94f86dbbf9335531dc64ca7e05 100644 (file)
@@ -298,7 +298,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel)
        return data.bp;
 }
 
-void mouse_lattice(bContext *C, short mval[2], int extend)
+int mouse_lattice(bContext *C, short mval[2], int extend)
 {
        ViewContext vc;
        BPoint *bp= NULL;
@@ -315,7 +315,11 @@ void mouse_lattice(bContext *C, short mval[2], int extend)
                        bp->f1 ^= SELECT; /* swap */
 
                WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
+
+               return 1;
        }
+
+       return 0;
 }
 
 /******************************** Undo *************************/
index 508bf56cc718fb5407703b8f2163b56e29042e63..7f08a4b91e3abb67643624251736db58055f2d27 100644 (file)
@@ -999,7 +999,7 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff
 
 
 /* mval is region coords */
-static void mouse_select(bContext *C, short *mval, short extend, short obcenter, short enumerate)
+static int mouse_select(bContext *C, short *mval, short extend, short obcenter, short enumerate)
 {
        ViewContext vc;
        ARegion *ar= CTX_wm_region(C);
@@ -1007,6 +1007,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter,
        Scene *scene= CTX_data_scene(C);
        Base *base, *startbase=NULL, *basact=NULL, *oldbasact=NULL;
        int temp, a, dist=100;
+       int retval = 0;
        short hits;
        
        /* setup view context for argument to callbacks */
@@ -1153,6 +1154,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter,
                                        basact->flag|= SELECT;
                                        basact->object->flag= basact->flag;
                                        
+                                       retval = 1;
                                        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, basact->object);
                                        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object);
                                        
@@ -1172,6 +1174,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter,
        
        /* so, do we have something selected? */
        if(basact) {
+               retval = 1;
                
                if(vc.obedit) {
                        /* only do select */
@@ -1205,6 +1208,8 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter,
                        WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
                }
        }
+
+       return retval;
 }
 
 /* ********************  border and circle ************************************** */
@@ -1611,31 +1616,37 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
        short extend= RNA_boolean_get(op->ptr, "extend");
        short center= RNA_boolean_get(op->ptr, "center");
        short enumerate= RNA_boolean_get(op->ptr, "enumerate");
+       int     retval = 0;
 
        view3d_operator_needs_opengl(C);
        
        if(obedit) {
                if(obedit->type==OB_MESH)
-                       mouse_mesh(C, event->mval, extend);
+                       retval = mouse_mesh(C, event->mval, extend);
                else if(obedit->type==OB_ARMATURE)
-                       mouse_armature(C, event->mval, extend);
+                       retval = mouse_armature(C, event->mval, extend);
                else if(obedit->type==OB_LATTICE)
-                       mouse_lattice(C, event->mval, extend);
+                       retval = mouse_lattice(C, event->mval, extend);
                else if(ELEM(obedit->type, OB_CURVE, OB_SURF))
-                       mouse_nurb(C, event->mval, extend);
+                       retval = mouse_nurb(C, event->mval, extend);
                else if(obedit->type==OB_MBALL)
-                       mouse_mball(C, event->mval, extend);
+                       retval = mouse_mball(C, event->mval, extend);
                        
        }
        else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT)
-               PE_mouse_particles(C, event->mval, extend);
+               return PE_mouse_particles(C, event->mval, extend);
        else if(obact && paint_facesel_test(obact))
-               face_select(C, obact, event->mval, extend);
+               retval = face_select(C, obact, event->mval, extend);
        else
-               mouse_select(C, event->mval, extend, center, enumerate);
+               retval = mouse_select(C, event->mval, extend, center, enumerate);
 
-       /* allowing tweaks */
-       return OPERATOR_PASS_THROUGH|OPERATOR_FINISHED;
+       /* passthrough allows tweaks
+        * FINISHED to signal one operator worked
+        * */
+       if (retval)
+               return OPERATOR_PASS_THROUGH|OPERATOR_FINISHED;
+       else
+               return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */
 }
 
 void VIEW3D_OT_select(wmOperatorType *ot)