From 40f8ddf8297a062968fc6a1523aa210d69c22626 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Mar 2019 18:47:55 +1100 Subject: 3D View: move deselect all logic into an option This removes `VIEW3D_OT_select_or_deselect_all`, adding a deselect_all option to the `VIEW3D_OT_select` operator. - Add utility functions to simplify de-selecting all. - Return true from selection functions when they change the selection to avoid redundant updates. - Use arrays of bases when passing objects between selection utility functions since some users require bases. - Fix logical error in box selection that updated all objects after the first hit. --- source/blender/editors/include/ED_armature.h | 12 +++++++----- source/blender/editors/include/ED_curve.h | 14 ++++++++------ source/blender/editors/include/ED_lattice.h | 6 +++++- source/blender/editors/include/ED_mball.h | 4 ++++ source/blender/editors/include/ED_mesh.h | 9 ++++++--- source/blender/editors/include/ED_particle.h | 7 ++++--- source/blender/editors/include/ED_sculpt.h | 2 +- 7 files changed, 35 insertions(+), 19 deletions(-) (limited to 'source/blender/editors/include') diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 3d4ca7bf3be..d469c0ea8a0 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -154,11 +154,12 @@ void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm); void ED_armature_to_edit(struct bArmature *arm); void ED_armature_edit_free(struct bArmature *arm); -void ED_armature_edit_deselect_all(struct Object *obedit); -void ED_armature_edit_deselect_all_visible(struct Object *obedit); +bool ED_armature_edit_deselect_all(struct Object *obedit); +bool ED_armature_edit_deselect_all_visible(struct Object *obedit); -void ED_armature_edit_deselect_all_multi(struct Object **objects, uint objects_len); -void ED_armature_edit_deselect_all_visible_multi(struct Object **objects, uint objects_len); +bool ED_armature_edit_deselect_all_multi_ex(struct Base **bases, uint bases_len); +bool ED_armature_edit_deselect_all_visible_multi_ex(struct Base **bases, uint bases_len); +bool ED_armature_edit_deselect_all_visible_multi(struct bContext *C); bool ED_armature_pose_select_pick_with_buffer( struct ViewLayer *view_layer, struct View3D *v3d, struct Base *base, const unsigned int *buffer, short hits, @@ -239,8 +240,9 @@ bool ED_object_posemode_exit_ex(struct Main *bmain, struct Object *ob); bool ED_object_posemode_exit(struct bContext *C, struct Object *ob); bool ED_object_posemode_enter_ex(struct Main *bmain, struct Object *ob); bool ED_object_posemode_enter(struct bContext *C, struct Object *ob); +bool ED_pose_deselect_all_multi_ex(struct Base **bases, uint bases_len, int select_mode, const bool ignore_visibility); +bool ED_pose_deselect_all_multi(struct bContext *C, int select_mode, const bool ignore_visibility); bool ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility); -void ED_pose_deselect_all_multi(struct Object **objects, uint objects_len, int select_mode, const bool ignore_visibility); void ED_pose_bone_select_tag_update(struct Object *ob); void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select); void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob, bool current_frame_only); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index b585dc766d7..3e8821efbd0 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -25,6 +25,7 @@ #define __ED_CURVE_H__ struct BPoint; +struct Base; struct BezTriple; struct Curve; struct EditNurb; @@ -56,17 +57,18 @@ struct Nurb *ED_curve_add_nurbs_primitive(struct bContext *C, struct Object *obe bool ED_curve_nurb_select_check(struct View3D *v3d, struct Nurb *nu); int ED_curve_nurb_select_count(struct View3D *v3d, struct Nurb *nu); -void ED_curve_nurb_select_all(struct Nurb *nu); -void ED_curve_nurb_deselect_all(struct Nurb *nu); +bool ED_curve_nurb_select_all(const struct Nurb *nu); +bool ED_curve_nurb_deselect_all(const struct Nurb *nu); int join_curve_exec(struct bContext *C, struct wmOperator *op); /* editcurve_select.c */ bool ED_curve_select_check(struct View3D *v3d, struct EditNurb *editnurb); -void ED_curve_deselect_all(struct EditNurb *editnurb); -void ED_curve_deselect_all_multi(struct Object **objects, int objects_len); -void ED_curve_select_all(struct EditNurb *editnurb); -void ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles); +bool ED_curve_deselect_all(struct EditNurb *editnurb); +bool ED_curve_deselect_all_multi_ex(struct Base **bases, int bases_len); +bool ED_curve_deselect_all_multi(struct bContext *C); +bool ED_curve_select_all(struct EditNurb *editnurb); +bool ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles); int ED_curve_select_count(struct View3D *v3d, struct EditNurb *editnurb); /* editcurve_undo.c */ diff --git a/source/blender/editors/include/ED_lattice.h b/source/blender/editors/include/ED_lattice.h index 98a091861d1..f65f47c40ad 100644 --- a/source/blender/editors/include/ED_lattice.h +++ b/source/blender/editors/include/ED_lattice.h @@ -24,6 +24,7 @@ #ifndef __ED_LATTICE_H__ #define __ED_LATTICE_H__ +struct Base; struct Object; struct UndoType; struct wmKeyConfig; @@ -33,9 +34,12 @@ void ED_operatortypes_lattice(void); void ED_keymap_lattice(struct wmKeyConfig *keyconf); /* editlattice_select.c */ -void ED_lattice_flags_set(struct Object *obedit, int flag); +bool ED_lattice_flags_set(struct Object *obedit, int flag); bool ED_lattice_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +bool ED_lattice_deselect_all_multi_ex(struct Base **bases, const uint bases_len); +bool ED_lattice_deselect_all_multi(struct bContext *C); + /* editlattice_undo.c */ void ED_lattice_undosys_type(struct UndoType *ut); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index e1033866193..2683631e85f 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -24,6 +24,7 @@ #ifndef __ED_MBALL_H__ #define __ED_MBALL_H__ +struct Base; struct Object; struct UndoType; struct bContext; @@ -37,6 +38,9 @@ struct MetaElem *ED_mball_add_primitive(struct bContext *C, struct Object *obedi bool ED_mball_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +bool ED_mball_deselect_all_multi_ex(struct Base **bases, uint bases_len); +bool ED_mball_deselect_all_multi(struct bContext *C); + void ED_mball_editmball_free(struct Object *obedit); void ED_mball_editmball_make(struct Object *obedit); void ED_mball_editmball_load(struct Object *obedit); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index b912cf88102..9e68c4a03ae 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -203,6 +203,9 @@ void EDBM_select_swap(struct BMEditMesh *em); /* exported for UV */ bool EDBM_select_interior_faces(struct BMEditMesh *em); void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc); /* rename? */ +bool EDBM_mesh_deselect_all_multi_ex(struct Base **bases, const uint bases_len); +bool EDBM_mesh_deselect_all_multi(struct bContext *C); + extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs; /* editmesh_preselect_edgering.c */ @@ -237,15 +240,15 @@ void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd /* editface.c */ void paintface_flush_flags(struct bContext *C, struct Object *ob, short flag); bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle); -int do_paintface_box_select(struct ViewContext *vc, const struct rcti *rect, int sel_op); -void paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags); +bool do_paintface_box_select(struct ViewContext *vc, const struct rcti *rect, int sel_op); +bool paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags); void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select); bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]); void paintface_hide(struct bContext *C, struct Object *ob, const bool unselected); void paintface_reveal(struct bContext *C, struct Object *ob, const bool select); -void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags); +bool paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags); void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags); void paintvert_flush_flags(struct Object *ob); void paintvert_tag_select_update(struct bContext *C, struct Object *ob); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index bbecffee9c0..6731d878dc6 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -53,11 +53,12 @@ void PE_update_object( struct Object *ob, int useflag); /* selection tools */ -int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); -int PE_box_select(struct bContext *C, const struct rcti *rect, const int sel_op); +bool PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +bool PE_box_select(struct bContext *C, const struct rcti *rect, const int sel_op); bool PE_circle_select(struct bContext *C, int sel_op, const int mval[2], float rad); int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, const int sel_op); -void PE_deselect_all_visible(struct PTCacheEdit *edit); +bool PE_deselect_all_visible_ex(struct PTCacheEdit *edit); +bool PE_deselect_all_visible(struct bContext *C); /* particle_edit_undo.c */ void ED_particle_undosys_type(struct UndoType *ut); diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index ce234b5fb12..31b642165cd 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -37,7 +37,7 @@ struct rcti; /* sculpt.c */ void ED_operatortypes_sculpt(void); void ED_sculpt_redraw_planes_get(float planes[4][4], struct ARegion *ar, struct Object *ob); -int ED_sculpt_mask_box_select(struct bContext *C, struct ViewContext *vc, const struct rcti *rect, bool select); +bool ED_sculpt_mask_box_select(struct bContext *C, struct ViewContext *vc, const struct rcti *rect, bool select); /* sculpt_undo.c */ void ED_sculpt_undosys_type(struct UndoType *ut); -- cgit v1.2.3