Made select operator return FINISHED only when it did something (only PASSTHROUGH otherwise)

This commit is contained in:
2009-11-24 04:59:52 +00:00
parent 1c4599522c
commit 4dd78dcbdf
11 changed files with 55 additions and 27 deletions

View 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)

View 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 ***********************/

View 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]);

View 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);

View 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);

View 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);

View 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 */

View 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 ************* */

View 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;
}

View 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 *************************/

View 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)