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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-05 14:26:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-05 14:26:45 +0300
commit8d8d113b7379b96d8cd9440f4e1f87524a418fef (patch)
treeecc4ac8f59c846918fd280db82ee87dc15c92e4d /source/blender/editors
parent0ae6747300a74daf14482f9ca89caffa9e503454 (diff)
Tool System: use set/add/subtract for all circle select operators
This applies changes from the 3D view circle select to other operators.
Diffstat (limited to 'source/blender/editors')
-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
10 files changed, 85 insertions, 25 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);
}
/** \} */