Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c13
-rw-r--r--source/blender/editors/include/ED_select_utils.h3
-rw-r--r--source/blender/editors/mask/mask_select.c14
-rw-r--r--source/blender/editors/space_action/action_select.c12
-rw-r--r--source/blender/editors/space_clip/tracking_select.c11
-rw-r--r--source/blender/editors/space_graph/graph_select.c12
-rw-r--r--source/blender/editors/space_node/node_select.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c9
-rw-r--r--source/blender/editors/util/select_utils.c13
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c13
-rw-r--r--source/blender/windowmanager/WM_api.h3
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c7
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c17
13 files changed, 94 insertions, 43 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index e3d4b42e359..1e7a34eeecd 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -906,8 +906,6 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
const int my = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
- bool select = !RNA_boolean_get(op->ptr, "deselect");
-
GP_SpaceConversion gsc = {NULL};
/* for bounding rect around circle (for quicky intersection testing) */
rcti rect = {0};
@@ -921,6 +919,14 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const bool select = (sel_op != SEL_OP_SUB);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_gpencil_select_toggle_all(C, SEL_DESELECT);
+ changed = true;
+ }
+
/* init space conversion stuff */
gp_point_conversion_init(C, &gsc);
@@ -973,7 +979,8 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/** \} */
diff --git a/source/blender/editors/include/ED_select_utils.h b/source/blender/editors/include/ED_select_utils.h
index 72cc7ef01cb..a7b9ac7e6c9 100644
--- a/source/blender/editors/include/ED_select_utils.h
+++ b/source/blender/editors/include/ED_select_utils.h
@@ -56,4 +56,7 @@ int ED_select_op_action_deselected(const eSelectOp sel_op, const bool is_select,
int ED_select_similar_compare_float(const float delta, const float thresh, const int compare);
bool ED_select_similar_compare_float_tree(const struct KDTree *tree, const float length, const float thresh, const int compare);
+
+eSelectOp ED_select_op_modal(const eSelectOp sel_op, const bool is_first);
+
#endif /* __ED_SELECT_UTILS_H__ */
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 3f0a3032cc1..2cab5d673ed 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -612,8 +612,6 @@ static int circle_select_exec(bContext *C, wmOperator *op)
const int y = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
- const bool select = !RNA_boolean_get(op->ptr, "deselect");
-
/* compute ellipse and position in unified coordinates */
ED_mask_get_size(sa, &width, &height);
ED_mask_zoom(sa, ar, &zoomx, &zoomy);
@@ -624,6 +622,15 @@ static int circle_select_exec(bContext *C, wmOperator *op)
ED_mask_point_pos(sa, ar, x, y, &offset[0], &offset[1]);
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const bool select = (sel_op != SEL_OP_SUB);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_mask_select_toggle_all(mask, SEL_DESELECT);
+ ED_mask_select_flush_all(mask);
+ changed = true;
+ }
+
/* do actual selection */
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
@@ -677,7 +684,8 @@ void MASK_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index c7b62af9d0b..0d9c3808b55 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -610,8 +610,6 @@ void ACTION_OT_select_lasso(wmOperatorType *ot)
static int action_circle_select_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
- const bool select = !RNA_boolean_get(op->ptr, "deselect");
- const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT;
KeyframeEdit_CircleData data = {0};
rctf rect_fl;
@@ -624,6 +622,13 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ deselect_action_keys(&ac, 0, SELECT_SUBTRACT);
+ }
+
data.mval[0] = x;
data.mval[1] = y;
data.radius_squared = radius * radius;
@@ -659,7 +664,8 @@ void ACTION_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/* ******************** Column Select Operator **************************** */
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index c9d24db7ba6..abf89e86cdb 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -698,7 +698,13 @@ static int circle_select_exec(bContext *C, wmOperator *op)
const int y = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
- const bool select = !RNA_boolean_get(op->ptr, "deselect");
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const bool select = (sel_op != SEL_OP_SUB);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_clip_select_all(sc, SEL_DESELECT, NULL);
+ changed = true;
+ }
/* compute ellipse and position in unified coordinates */
ED_space_clip_get_size(sc, &width, &height);
@@ -782,7 +788,8 @@ void CLIP_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/********************** select all operator *********************/
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 85afd70e083..3c3bd760a72 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -505,8 +505,6 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot)
static int graph_circle_select_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
- const bool select = !RNA_boolean_get(op->ptr, "deselect");
- const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT;
bool incl_handles = false;
KeyframeEdit_CircleData data = {0};
@@ -520,6 +518,13 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ deselect_graph_keys(&ac, 0, SELECT_SUBTRACT, true);
+ }
+
data.mval[0] = x;
data.mval[1] = y;
data.radius_squared = radius * radius;
@@ -566,7 +571,8 @@ void GRAPH_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/* ******************** Column Select Operator **************************** */
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 747af14499e..33e4134b6e7 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -619,7 +619,12 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
float zoom = (float)(BLI_rcti_size_x(&ar->winrct)) / (float)(BLI_rctf_size_x(&ar->v2d.cur));
- const bool select = !RNA_boolean_get(op->ptr, "deselect");
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const bool select = (sel_op != SEL_OP_SUB);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
+ }
/* get operator properties */
x = RNA_int_get(op->ptr, "x");
@@ -657,7 +662,8 @@ void NODE_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/* ****** Lasso Select ****** */
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index e14d0a5ff3f..161b4e67c77 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -3351,17 +3351,12 @@ static bool object_circle_select(ViewContext *vc, const eSelectOp sel_op, const
static int view3d_circle_select_exec(bContext *C, wmOperator *op)
{
ViewContext vc;
- const bool is_first = (op->customdata && (((wmGesture *)op->customdata)->is_active_prev == false));
const int radius = RNA_int_get(op->ptr, "radius");
- eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int mval[2] = {RNA_int_get(op->ptr, "x"),
RNA_int_get(op->ptr, "y")};
- if (is_first == false) {
- if (sel_op == SEL_OP_SET) {
- sel_op = SEL_OP_ADD;
- }
- }
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
ED_view3d_viewcontext_init(C, &vc);
diff --git a/source/blender/editors/util/select_utils.c b/source/blender/editors/util/select_utils.c
index b0b001ee238..80b103e0c4b 100644
--- a/source/blender/editors/util/select_utils.c
+++ b/source/blender/editors/util/select_utils.c
@@ -69,6 +69,19 @@ int ED_select_op_action_deselected(const eSelectOp sel_op, const bool is_select,
return -1;
}
+/**
+ * Utility to use for selection operations that run multiple times (circle select).
+ */
+eSelectOp ED_select_op_modal(const eSelectOp sel_op, const bool is_first)
+{
+ if (sel_op == SEL_OP_SET) {
+ if (is_first == false) {
+ return SEL_OP_ADD;
+ }
+ }
+ return sel_op;
+}
+
int ED_select_similar_compare_float(const float delta, const float thresh, const int compare)
{
switch (compare) {
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 11420aa32f0..ae532a8e5c7 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -3339,6 +3339,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
+ Image *ima = CTX_data_edit_image(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ToolSettings *ts = scene->toolsettings;
@@ -3349,7 +3350,6 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
MLoopUV *luv;
int x, y, radius, width, height;
float zoomx, zoomy, offset[2], ellipse[2];
- const bool select = !RNA_boolean_get(op->ptr, "deselect");
const bool use_face_center = (
(ts->uv_flag & UV_SYNC_SELECTION) ?
@@ -3376,6 +3376,14 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
+ const eSelectOp sel_op = ED_select_op_modal(
+ RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata));
+ const bool select = (sel_op != SEL_OP_SUB);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+ changed_multi = true;
+ }
+
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -3454,7 +3462,8 @@ static void UV_OT_select_circle(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
- WM_operator_properties_gesture_circle_select(ot);
+ WM_operator_properties_gesture_circle(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/** \} */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index f4b4d7cc50e..5b5904c6d73 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -375,9 +375,7 @@ void WM_operator_properties_gesture_lasso_ex(struct wmOperatorType *ot, b
void WM_operator_properties_gesture_lasso(struct wmOperatorType *ot);
void WM_operator_properties_gesture_lasso_select(struct wmOperatorType *ot);
void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
-void WM_operator_properties_gesture_circle_ex(struct wmOperatorType *ot, bool deselect);
void WM_operator_properties_gesture_circle(struct wmOperatorType *ot);
-void WM_operator_properties_gesture_circle_select(struct wmOperatorType *ot);
void WM_operator_properties_mouse_select(struct wmOperatorType *ot);
void WM_operator_properties_select_all(struct wmOperatorType *ot);
void WM_operator_properties_select_action(struct wmOperatorType *ot, int default_action);
@@ -483,6 +481,7 @@ void WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type);
void WM_gesture_end(struct bContext *C, struct wmGesture *gesture);
void WM_gestures_remove(struct bContext *C);
+bool WM_gesture_is_modal_first(const struct wmGesture *gesture);
/* fileselecting support */
void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op);
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 09fc143f71d..c9853776902 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -116,6 +116,13 @@ void WM_gestures_remove(bContext *C)
WM_gesture_end(C, win->gesture.first);
}
+bool WM_gesture_is_modal_first(const wmGesture *gesture)
+{
+ if (gesture == NULL) {
+ return true;
+ }
+ return (gesture->is_active_prev == false);
+}
/* tweak and line gestures */
int wm_gesture_evaluate(wmGesture *gesture)
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 330c66c3a6a..5700e4fc0bc 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -353,7 +353,7 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
/**
* Use with #WM_gesture_circle_invoke
*/
-void WM_operator_properties_gesture_circle_ex(wmOperatorType *ot, bool deselect)
+void WM_operator_properties_gesture_circle(wmOperatorType *ot)
{
PropertyRNA *prop;
const int radius_default = 25;
@@ -366,21 +366,6 @@ void WM_operator_properties_gesture_circle_ex(wmOperatorType *ot, bool deselect)
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
- if (deselect) {
- prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- }
-}
-
-void WM_operator_properties_gesture_circle(wmOperatorType *ot)
-{
- WM_operator_properties_gesture_circle_ex(ot, false);
-}
-
-void WM_operator_properties_gesture_circle_select(wmOperatorType *ot)
-{
- WM_operator_properties_gesture_circle_ex(ot, true);
}
void WM_operator_properties_mouse_select(wmOperatorType *ot)