This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/editors/include/ED_select_utils.h
Campbell Barton 5e5285baf6 View 3D: move picking arguments into a struct & minor refactor
- Add SelectPick_Params struct to make picking logic more
  straightforward and easier to extend.

- Use `eSelectOp` instead of booleans (extend, deselect, toggle)
  which were used to represent 4 states (which wasn't obvious).

- Handle deselect_all when pocking instead of view3d_select_exec,
  de-duplicate de-selection which was already needed in when replacing
  the selection in picking functions.

- Handle outliner update & notifiers in the picking functions
  instead of view3d_select_exec.

- Fix particle select deselect_all option which did nothing.
2022-03-16 14:48:25 +11:00

95 lines
2.4 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup editors
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct KDTree_1d;
enum {
SEL_TOGGLE = 0,
SEL_SELECT = 1,
SEL_DESELECT = 2,
SEL_INVERT = 3,
};
typedef enum WalkSelectDirection {
UI_SELECT_WALK_UP,
UI_SELECT_WALK_DOWN,
UI_SELECT_WALK_LEFT,
UI_SELECT_WALK_RIGHT,
} WalkSelectDirections;
/** 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;
/* Select Similar */
enum {
SIM_CMP_EQ = 0,
SIM_CMP_GT,
SIM_CMP_LT,
};
#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'.
* 1: select, 0: deselect, -1: pass.
*/
int ED_select_op_action(eSelectOp sel_op, bool is_select, bool is_inside);
/**
* 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(eSelectOp sel_op, bool is_select, bool is_inside);
int ED_select_similar_compare_float(float delta, float thresh, int compare);
bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree,
float length,
float thresh,
int compare);
/**
* Utility to use for selection operations that run multiple times (circle select).
*/
eSelectOp ED_select_op_modal(eSelectOp sel_op, bool is_first);
/** Argument passed to picking functions. */
struct SelectPick_Params {
/**
* - #SEL_OP_ADD named "extend" from operators.
* - #SEL_OP_SUB named "deselect" from operators.
* - #SEL_OP_XOR named "toggle" from operators.
* - #SEL_OP_AND (never used for picking).
* - #SEL_OP_SET use when "extend", "deselect" and "toggle" are all disabled.
*/
eSelectOp sel_op;
/** Deselect all, even when there is nothing found at the cursor location. */
bool deselect_all;
};
/**
* Utility to get #eSelectPickMode from booleans for convenience.
*/
eSelectOp ED_select_op_from_booleans(bool extend, bool deselect, bool toggle);
#ifdef __cplusplus
}
#endif