From 4dd78dcbdfdfdf1dd9acf028506ad65fb22c1de1 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 24 Nov 2009 04:59:52 +0000 Subject: Made select operator return FINISHED only when it did something (only PASSTHROUGH otherwise) --- source/blender/editors/armature/editarmature.c | 5 +++- source/blender/editors/curve/editcurve.c | 13 +++++---- source/blender/editors/include/ED_armature.h | 2 +- source/blender/editors/include/ED_curve.h | 2 +- source/blender/editors/include/ED_mball.h | 2 +- source/blender/editors/include/ED_mesh.h | 2 +- source/blender/editors/include/ED_object.h | 2 +- source/blender/editors/mesh/editmesh_mods.c | 9 ++++-- source/blender/editors/metaball/mball_edit.c | 6 +++- source/blender/editors/object/object_lattice.c | 6 +++- .../blender/editors/space_view3d/view3d_select.c | 33 ++++++++++++++-------- 11 files changed, 55 insertions(+), 27 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index db499c72908..78ba73ce5d5 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -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) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 7801168dd83..e53b419c6ea 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -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 ***********************/ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 1836729e419..2aa47311515 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -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]); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index fea684971b2..66a481ca5ac 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -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); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 6708a73e088..b21bcb0cc09 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -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); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index fa47426c70a..35e1f10b516 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -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); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index e48a98a65f1..1785b0303cb 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -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 */ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index e14dedf6002..2d1452c8cb1 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -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 ************* */ diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 3751f8875f6..09200514c0f 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -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; } diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index b49c1eb5902..3f27ea407a2 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -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 *************************/ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 508bf56cc71..7f08a4b91e3 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -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) -- cgit v1.2.3