3D View boarder/lasso select tool options

Add tool options to control how select operates (add/sub/set/and/xor).

Note: edit mode armature select still needs to support all options,
this is complicated by how it handles partial end-point selection.
This commit is contained in:
Campbell Barton 2018-08-14 10:28:41 +10:00
parent d92d310b15
commit e88e80a6a0
Notes: blender-bot 2023-02-14 05:53:37 +01:00
Referenced by commit cd36d3f4d3, Fix lasso selection not working for lattices
Referenced by issue #56365, Border/Lasso Select Tool Option
Referenced by issue #55036, Tool System Todo
55 changed files with 718 additions and 387 deletions

View File

@ -373,18 +373,22 @@ class _defs_view3d_select:
@ToolDef.from_fn
def border():
def draw_settings(context, layout, tool):
props = tool.operator_properties("view3d.select_border")
layout.prop(props, "mode", expand=True)
return dict(
text="Select Border",
icon="ops.generic.select_border",
widget=None,
keymap=(
("view3d.select_border",
dict(deselect=False),
dict(mode='ADD'),
dict(type='EVT_TWEAK_A', value='ANY')),
("view3d.select_border",
dict(deselect=True),
dict(mode='SUB'),
dict(type='EVT_TWEAK_A', value='ANY', ctrl=True)),
),
draw_settings=draw_settings,
)
@ToolDef.from_fn
@ -405,18 +409,22 @@ class _defs_view3d_select:
@ToolDef.from_fn
def lasso():
def draw_settings(context, layout, tool):
props = tool.operator_properties("view3d.select_lasso")
layout.prop(props, "mode", expand=True)
return dict(
text="Select Lasso",
icon="ops.generic.select_lasso",
widget=None,
keymap=(
("view3d.select_lasso",
dict(deselect=False),
dict(mode='ADD'),
dict(type='EVT_TWEAK_A', value='ANY')),
("view3d.select_lasso",
dict(deselect=True),
dict(mode='SUB'),
dict(type='EVT_TWEAK_A', value='ANY', ctrl=True)),
),
draw_settings=draw_settings,
)
# -----------------------------------------------------------------------------
# Object Modes (named based on context.mode)

View File

@ -67,6 +67,7 @@
#include "ED_keyframes_edit.h" // XXX move the select modes out of there!
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "WM_api.h"
#include "WM_types.h"

View File

@ -71,6 +71,7 @@
#include "ED_anim_api.h"
#include "ED_markers.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_util.h"
#include "ED_numinput.h"
#include "ED_object.h"

View File

@ -35,6 +35,7 @@
#include "ED_armature.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "armature_intern.h"

View File

@ -55,6 +55,7 @@
#include "ED_armature.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"

View File

@ -60,6 +60,7 @@
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "armature_intern.h"

View File

@ -44,6 +44,7 @@
#include "ED_curve.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "curve_intern.h"

View File

@ -49,6 +49,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_types.h"
#include "ED_view3d.h"
#include "ED_curve.h"

View File

@ -50,6 +50,7 @@
#include "RNA_access.h"
#include "ED_gpencil.h"
#include "ED_select_utils.h"
#include "ED_object.h"
#include "ED_transform.h"

View File

@ -62,6 +62,7 @@
#include "UI_view2d.h"
#include "ED_gpencil.h"
#include "ED_select_utils.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"

View File

@ -204,7 +204,7 @@ void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
/* editface.c */
void paintface_flush_flags(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, struct rcti *rect, bool select, bool extend);
int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int sel_op);
void paintface_deselect_all_visible(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]);

View File

@ -62,9 +62,9 @@ void PE_update_object(
/* selection tools */
int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
int PE_border_select(struct bContext *C, const struct rcti *rect, bool select, bool extend);
int PE_border_select(struct bContext *C, const struct rcti *rect, const int sel_op);
int PE_circle_select(struct bContext *C, int selecting, const int mval[2], float rad);
int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, bool extend, bool select);
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);
/* particle_edit_undo.c */

View File

@ -43,7 +43,7 @@ struct ListBase;
/* 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 extend);
int 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);

View File

@ -0,0 +1,52 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ED_select_utils.h
* \ingroup editors
*/
#ifndef __ED_SELECT_UTILS_H__
#define __ED_SELECT_UTILS_H__
enum {
SEL_TOGGLE = 0,
SEL_SELECT = 1,
SEL_DESELECT = 2,
SEL_INVERT = 3,
};
/** See #WM_operator_properties_select_operation */
typedef enum {
SEL_OP_ADD = 1,
SEL_OP_SUB,
SEL_OP_SET,
SEL_OP_AND,
SEL_OP_XOR,
} eSelectOp;
#define SEL_OP_USE_OUTSIDE(sel_op) (ELEM(sel_op, SEL_OP_AND))
#define SEL_OP_USE_PRE_DESELECT(sel_op) (ELEM(sel_op, SEL_OP_SET))
#define SEL_OP_CAN_DESELECT(sel_op) (!ELEM(sel_op, SEL_OP_ADD))
/* Use when we've de-selected all first for 'SEL_OP_SET' */
int ED_select_op_action(const eSelectOp sel_op, const bool is_select, const bool is_inside);
int ED_select_op_action_deselected(const eSelectOp sel_op, const bool is_select, const bool is_inside);
#endif /* __ED_SELECT_UTILS_H__ */

View File

@ -53,6 +53,7 @@
#include "BKE_layer.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_lattice.h"
#include "ED_view3d.h"

View File

@ -36,6 +36,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_object.h"
#include "ED_lattice.h"

View File

@ -45,6 +45,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "ED_select_utils.h"
#include "ED_mask.h" /* own include */
#include "ED_screen.h"

View File

@ -42,6 +42,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_mask.h" /* own include */
#include "ED_image.h"
#include "ED_object.h" /* ED_keymap_proportional_maskmode only */

View File

@ -52,6 +52,7 @@
#include "ED_keyframing.h"
#include "ED_mask.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "RNA_access.h"
#include "RNA_define.h"

View File

@ -45,6 +45,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_mask.h" /* own include */
#include "RNA_access.h"

View File

@ -46,6 +46,7 @@
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "WM_api.h"
@ -391,7 +392,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
return true;
}
int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op)
{
Object *ob = vc->obact;
Mesh *me;
@ -412,7 +413,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
selar = MEM_callocN(me->totpoly + 1, "selar");
if (extend == false && select) {
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
paintface_deselect_all_visible(vc->obact, SEL_DESELECT, false);
}
@ -439,13 +440,12 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
mpoly = me->mpoly;
for (a = 1; a <= me->totpoly; a++, mpoly++) {
if (selar[a]) {
if (mpoly->flag & ME_HIDE) {
/* pass */
}
else {
if (select) mpoly->flag |= ME_FACE_SEL;
else mpoly->flag &= ~ME_FACE_SEL;
if ((mpoly->flag & ME_HIDE) == 0) {
const bool is_select = mpoly->flag & ME_FACE_SEL;
const bool is_inside = (selar[a] != 0);
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(mpoly->flag, sel_op_result, ME_FACE_SEL);
}
}
}

View File

@ -59,6 +59,7 @@
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "DNA_mesh_types.h"

View File

@ -40,6 +40,7 @@
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "mesh_intern.h" /* own include */

View File

@ -55,6 +55,7 @@
#include "ED_mball.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "WM_api.h"

View File

@ -37,6 +37,7 @@
#include "ED_mball.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_object.h"
#include "mball_intern.h"

View File

@ -46,6 +46,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_object.h"
#include "DEG_depsgraph.h"

View File

@ -72,6 +72,7 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_keyframing.h"
#include "UI_interface.h"

View File

@ -75,6 +75,7 @@
#include "ED_mesh.h"
#include "ED_particle.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "GPU_immediate.h"
@ -418,6 +419,7 @@ typedef struct PEData {
float dist;
float dval;
int select;
eSelectOp sel_op;
float *dvec;
float combfac;
@ -610,10 +612,15 @@ static bool point_is_selected(PTCacheEditPoint *point)
/*************************** iterators *******************************/
typedef void (*ForPointFunc)(PEData *data, int point_index);
typedef void (*ForKeyFunc)(PEData *data, int point_index, int key_index);
typedef void (*ForKeyFunc)(PEData *data, int point_index, int key_index, bool is_inside);
typedef void (*ForKeyMatFunc)(PEData *data, float mat[4][4], float imat[4][4], int point_index, int key_index, PTCacheEditKey *key);
static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, bool nearest)
enum eParticleSelectFlag {
PSEL_NEAREST = (1 << 0),
PSEL_ALL_KEYS = (1 << 1),
};
static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum eParticleSelectFlag flag)
{
ParticleEditSettings *pset = PE_settings(data->scene);
PTCacheEdit *edit = data->edit;
@ -634,34 +641,45 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, bool nearest)
/* only do end keys */
key = point->keys + point->totkey - 1;
if (nearest) {
if (flag & PSEL_NEAREST) {
if (key_inside_circle(data, dist, KEY_WCO, &dist)) {
nearest_point = p;
nearest_key = point->totkey - 1;
}
}
else if (key_inside_test(data, KEY_WCO))
func(data, p, point->totkey - 1);
else {
const bool is_inside = key_inside_test(data, KEY_WCO);
if (is_inside || (flag & PSEL_ALL_KEYS)) {
func(data, p, point->totkey - 1, is_inside);
}
}
}
}
else {
/* do all keys */
LOOP_VISIBLE_KEYS {
if (nearest) {
if (flag & PSEL_NEAREST) {
if (key_inside_circle(data, dist, KEY_WCO, &dist)) {
nearest_point = p;
nearest_key = k;
}
}
else if (key_inside_test(data, KEY_WCO))
func(data, p, k);
else {
const bool is_inside = key_inside_test(data, KEY_WCO);
if (is_inside || (flag & PSEL_ALL_KEYS)) {
func(data, p, k, is_inside);
}
}
}
}
}
/* do nearest only */
if (nearest && nearest_point > -1)
func(data, nearest_point, nearest_key);
if (flag & PSEL_NEAREST) {
if (nearest_point != -1) {
func(data, nearest_point, nearest_key, true);
}
}
}
static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selected)
@ -797,7 +815,7 @@ static void foreach_selected_key(PEData *data, ForKeyFunc func)
LOOP_VISIBLE_POINTS {
LOOP_SELECTED_KEYS {
func(data, p, k);
func(data, p, k, true);
}
}
}
@ -1496,7 +1514,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
/*-----selection callbacks-----*/
static void select_key(PEData *data, int point_index, int key_index)
static void select_key(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@ -1510,7 +1528,20 @@ static void select_key(PEData *data, int point_index, int key_index)
point->flag |= PEP_EDIT_RECALC;
}
static void select_keys(PEData *data, int point_index, int UNUSED(key_index))
static void select_key_op(PEData *data, int point_index, int key_index, bool is_inside)
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
const bool is_select = key->flag & PEK_SELECT;
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
}
}
static void select_keys(PEData *data, int point_index, int UNUSED(key_index), bool UNUSED(is_inside))
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@ -1526,7 +1557,7 @@ static void select_keys(PEData *data, int point_index, int UNUSED(key_index))
point->flag |= PEP_EDIT_RECALC;
}
static void extend_key_select(PEData *data, int point_index, int key_index)
static void extend_key_select(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@ -1536,7 +1567,7 @@ static void extend_key_select(PEData *data, int point_index, int key_index)
point->flag |= PEP_EDIT_RECALC;
}
static void deselect_key_select(PEData *data, int point_index, int key_index)
static void deselect_key_select(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@ -1546,7 +1577,7 @@ static void deselect_key_select(PEData *data, int point_index, int key_index)
point->flag |= PEP_EDIT_RECALC;
}
static void toggle_key_select(PEData *data, int point_index, int key_index)
static void toggle_key_select(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@ -1664,12 +1695,15 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
data.rad = ED_view3d_select_dist_px();
/* 1 = nearest only */
if (extend)
for_mouse_hit_keys(&data, extend_key_select, true);
else if (deselect)
for_mouse_hit_keys(&data, deselect_key_select, true);
else
for_mouse_hit_keys(&data, toggle_key_select, true);
if (extend) {
for_mouse_hit_keys(&data, extend_key_select, PSEL_NEAREST);
}
else if (deselect) {
for_mouse_hit_keys(&data, deselect_key_select, PSEL_NEAREST);
}
else {
for_mouse_hit_keys(&data, toggle_key_select, PSEL_NEAREST);
}
PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
@ -1900,7 +1934,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
data.rad = 75.0f;
data.select = !RNA_boolean_get(op->ptr, "deselect");
for_mouse_hit_keys(&data, select_keys, true);
for_mouse_hit_keys(&data, select_keys, PSEL_NEAREST);
PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
@ -1946,7 +1980,7 @@ void PE_deselect_all_visible(PTCacheEdit *edit)
}
}
int PE_border_select(bContext *C, const rcti *rect, bool select, bool extend)
int PE_border_select(bContext *C, const rcti *rect, const int sel_op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
@ -1956,14 +1990,15 @@ int PE_border_select(bContext *C, const rcti *rect, bool select, bool extend)
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
if (extend == 0 && select)
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
PE_deselect_all_visible(edit);
}
PE_set_view3d_data(C, &data);
data.rect = rect;
data.select = select;
data.sel_op = sel_op;
for_mouse_hit_keys(&data, select_key, false);
for_mouse_hit_keys(&data, select_key_op, PSEL_ALL_KEYS);
PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
@ -1988,7 +2023,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad)
data.rad = rad;
data.select = selecting;
for_mouse_hit_keys(&data, select_key, false);
for_mouse_hit_keys(&data, select_key, 0);
PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
@ -1998,7 +2033,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad)
/************************ lasso select operator ************************/
int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool extend, bool select)
int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const int sel_op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
@ -2018,8 +2053,9 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
if (extend == 0 && select)
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
PE_deselect_all_visible(edit);
}
/* only for depths */
PE_set_view3d_data(C, &data);
@ -2032,47 +2068,32 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
LOOP_KEYS {
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co))
{
if (select) {
if (!(key->flag & PEK_SELECT)) {
key->flag |= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
}
}
else {
if (key->flag & PEK_SELECT) {
key->flag &= ~PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
}
}
const bool is_select = key->flag & PEK_SELECT;
const bool is_inside = (
(ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co));
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
}
}
}
else if (pset->selectmode == SCE_SELECT_END) {
if (point->totkey) {
key = point->keys + point->totkey - 1;
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co))
{
if (select) {
if (!(key->flag & PEK_SELECT)) {
key->flag |= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
}
}
else {
if (key->flag & PEK_SELECT) {
key->flag &= ~PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
}
}
const bool is_select = key->flag & PEK_SELECT;
const bool is_inside = (
(ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co));
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
}
}
}
@ -2944,7 +2965,7 @@ static void set_delete_particle(PEData *data, int pa_index)
edit->points[pa_index].flag |= PEP_TAG;
}
static void set_delete_particle_key(PEData *data, int pa_index, int key_index)
static void set_delete_particle_key(PEData *data, int pa_index, int key_index, bool UNUSED(is_inside))
{
PTCacheEdit *edit = data->edit;

View File

@ -34,6 +34,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "ED_select_utils.h"
#include "ED_physics.h"
#include "ED_object.h"

View File

@ -258,7 +258,7 @@ static void mask_box_select_task_cb(
} BKE_pbvh_vertex_iter_end;
}
int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select, bool UNUSED(extend))
int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Sculpt *sd = vc->scene->toolsettings->sculpt;

View File

@ -48,6 +48,7 @@
#include "ED_paint.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_image.h"
#include "ED_gpencil.h"
#include "UI_resources.h"
@ -1444,9 +1445,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
RNA_enum_set(kmi->ptr, "mode", SEL_OP_ADD);
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
RNA_enum_set(kmi->ptr, "mode", SEL_OP_SUB);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
/* Image/Texture Paint mode */

View File

@ -40,6 +40,7 @@
#include "ED_markers.h"
#include "ED_transform.h"
#include "ED_object.h"
#include "ED_select_utils.h"
#include "action_intern.h"

View File

@ -62,6 +62,7 @@
#include "ED_keyframes_edit.h"
#include "ED_markers.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "WM_api.h"
#include "WM_types.h"

View File

@ -44,6 +44,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_clip.h"
#include "RNA_access.h"

View File

@ -55,6 +55,7 @@
#include "ED_mask.h"
#include "ED_space_api.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_clip.h"
#include "ED_transform.h"
#include "ED_uvedit.h" /* just for ED_image_draw_cursor */

View File

@ -46,6 +46,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_clip.h"
#include "RNA_access.h"

View File

@ -48,6 +48,7 @@
#include "ED_anim_api.h"
#include "ED_markers.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "ED_object.h"

View File

@ -56,6 +56,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_markers.h"
#include "ED_select_utils.h"
#include "WM_api.h"
#include "WM_types.h"

View File

@ -39,6 +39,7 @@
#include "ED_anim_api.h"
#include "ED_markers.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "WM_api.h"

View File

@ -46,6 +46,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "RNA_access.h"
#include "RNA_define.h"

View File

@ -37,6 +37,7 @@
#include "ED_node.h" /* own include */
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "RNA_access.h"

View File

@ -45,6 +45,7 @@
#include "ED_node.h" /* own include */
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "RNA_access.h"
#include "RNA_define.h"

View File

@ -71,6 +71,7 @@
#include "ED_object.h"
#include "ED_outliner.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_keyframing.h"
#include "ED_armature.h"

View File

@ -52,6 +52,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "outliner_intern.h"

View File

@ -39,6 +39,7 @@
#include "ED_sequencer.h"
#include "ED_markers.h"
#include "ED_transform.h" /* transform keymap */
#include "ED_select_utils.h"
#include "BKE_sequencer.h"

View File

@ -50,6 +50,7 @@
#include "ED_screen.h"
#include "ED_sequencer.h"
#include "ED_select_utils.h"
#include "UI_view2d.h"

View File

@ -57,6 +57,7 @@
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "view3d_intern.h"
@ -487,9 +488,9 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", false);
RNA_enum_set(kmi->ptr, "mode", SEL_OP_ADD);
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", true);
RNA_enum_set(kmi->ptr, "mode", SEL_OP_SUB);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,7 @@ set(SRC
ed_transverts.c
ed_util.c
numinput.c
select_utils.c
# general includes
../include/BIF_gl.h
@ -54,6 +55,7 @@ set(SRC
../include/ED_curve.h
../include/ED_datafiles.h
../include/ED_fileselect.h
../include/ED_gizmo_library.h
../include/ED_gpencil.h
../include/ED_image.h
../include/ED_info.h
@ -63,7 +65,6 @@ set(SRC
../include/ED_lattice.h
../include/ED_logic.h
../include/ED_markers.h
../include/ED_gizmo_library.h
../include/ED_mask.h
../include/ED_mball.h
../include/ED_mesh.h
@ -79,6 +80,7 @@ set(SRC
../include/ED_screen.h
../include/ED_screen_types.h
../include/ED_sculpt.h
../include/ED_select_utils.h
../include/ED_sequencer.h
../include/ED_sound.h
../include/ED_space_api.h

View File

@ -0,0 +1,70 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file select_utils.c
* \ingroup editors
*/
#include "BLI_utildefines.h"
#include "ED_select_utils.h"
/** 1: select, 0: deselect, -1: pass. */
int ED_select_op_action(const eSelectOp sel_op, const bool is_select, const bool is_inside)
{
switch (sel_op) {
case SEL_OP_ADD:
return (!is_select && (is_inside)) ? 1 : -1;
case SEL_OP_SUB:
return (is_select && is_inside) ? 0 : -1;
case SEL_OP_SET:
return is_inside ? 1 : 0;
case SEL_OP_AND:
return (is_select && is_inside) ? -1 : (is_select ? 0 : -1);
case SEL_OP_XOR:
return (is_select && is_inside) ? 0 : ((!is_select && is_inside) ? 1 : -1);
}
BLI_assert(!"invalid sel_op");
return -1;
}
/**
* Use when we've de-selected all items first (for modes that need it).
*
* \note In some cases changing selection needs to perform other checks,
* so it's more straightforward to deselect all, then select.
*/
int ED_select_op_action_deselected(const eSelectOp sel_op, const bool is_select, const bool is_inside)
{
switch (sel_op) {
case SEL_OP_ADD:
return (!is_select && is_inside) ? 1 : -1;
case SEL_OP_SUB:
return (is_select && is_inside) ? 0 : -1;
case SEL_OP_SET:
/* Only difference w/ function above. */
return is_inside ? 1 : -1;
case SEL_OP_AND:
return (is_select && is_inside) ? -1 : (is_select ? 0 : -1);
case SEL_OP_XOR:
return (is_select && is_inside) ? 0 : ((!is_select && is_inside) ? 1 : -1);
}
BLI_assert(!"invalid sel_op");
return -1;
}

View File

@ -76,6 +76,7 @@
#include "ED_uvedit.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "RNA_access.h"

View File

@ -364,6 +364,7 @@ void WM_operator_properties_select_action(struct wmOperatorType *ot, int
void WM_operator_properties_select_action_simple(struct wmOperatorType *ot, int default_action);
void WM_operator_properties_select_random(struct wmOperatorType *ot);
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op);
void WM_operator_properties_select_operation(struct wmOperatorType *ot);
struct CheckerIntervalParams {
int nth; /* bypass when set to zero */
int skip;
@ -375,14 +376,6 @@ void WM_operator_properties_checker_interval_from_op(
bool WM_operator_properties_checker_interval_test(
const struct CheckerIntervalParams *op_params, int depth);
/* MOVE THIS SOMEWHERE ELSE */
#define SEL_TOGGLE 0
#define SEL_SELECT 1
#define SEL_DESELECT 2
#define SEL_INVERT 3
/* flags for WM_operator_properties_filesel */
#define WM_FILESEL_RELPATH (1 << 0)
@ -391,7 +384,6 @@ bool WM_operator_properties_checker_interval_test(
#define WM_FILESEL_FILEPATH (1 << 3)
#define WM_FILESEL_FILES (1 << 4)
/* operator as a python command (resultuing string must be freed) */
char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op,
const bool all_args, const bool macro_args,

View File

@ -39,6 +39,7 @@
#include "BKE_global.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "GPU_glew.h"

View File

@ -49,6 +49,7 @@
#include "wm_event_system.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "RNA_access.h"
#include "RNA_define.h"
@ -86,13 +87,22 @@ static void gesture_modal_state_to_operator(wmOperator *op, int modal_state)
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
if ((prop = RNA_struct_find_property(op->ptr, "deselect"))) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_DESELECT));
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_DESELECT));
}
}
if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_enum_set(op->ptr, prop, (modal_state == GESTURE_MODAL_DESELECT) ? SEL_OP_SUB : SEL_OP_ADD);
}
}
break;
case GESTURE_MODAL_IN:
case GESTURE_MODAL_OUT:
if ((prop = RNA_struct_find_property(op->ptr, "zoom_out"))) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_OUT));
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_OUT));
}
}
break;
}
@ -107,6 +117,11 @@ static int gesture_modal_state_from_operator(wmOperator *op)
return RNA_property_boolean_get(op->ptr, prop) ? GESTURE_MODAL_DESELECT : GESTURE_MODAL_SELECT;
}
}
if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
if (RNA_property_is_set(op->ptr, prop)) {
return RNA_property_enum_get(op->ptr, prop) == SEL_OP_SUB ? GESTURE_MODAL_DESELECT : GESTURE_MODAL_SELECT;
}
}
if ((prop = RNA_struct_find_property(op->ptr, "zoom_out"))) {
if (RNA_property_is_set(op->ptr, prop)) {
return RNA_property_boolean_get(op->ptr, prop) ? GESTURE_MODAL_OUT : GESTURE_MODAL_IN;

View File

@ -39,6 +39,8 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "ED_select_utils.h"
#include "WM_api.h"
#include "WM_types.h"
@ -250,6 +252,20 @@ void WM_operator_properties_gesture_border(wmOperatorType *ot)
WM_operator_properties_gesture_border_ex(ot, false, false);
}
void WM_operator_properties_select_operation(wmOperatorType *ot)
{
static const EnumPropertyItem select_mode_items[] = {
{SEL_OP_ADD, "ADD", 0, "Add", ""},
{SEL_OP_SUB, "SUB", 0, "Subtract", ""},
{SEL_OP_SET, "SET", 0, "Set", ""},
{SEL_OP_AND, "AND", 0, "And", ""},
{SEL_OP_XOR, "XOR", 0, "Xor", ""},
{0, NULL, 0, NULL, NULL}
};
PropertyRNA *prop = RNA_def_enum(ot->srna, "mode", select_mode_items, SEL_OP_ADD, "Mode", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
void WM_operator_properties_gesture_border_zoom(wmOperatorType *ot)
{
WM_operator_properties_border(ot);