[Bf-blender-cvs] [219e2f976d0] master: Tool System: use set/add/subtract for all box select operators

Campbell Barton noreply at git.blender.org
Thu Mar 7 10:35:25 CET 2019


Commit: 219e2f976d077c16c28d72a2f6763c01230c5bf8
Author: Campbell Barton
Date:   Thu Mar 7 20:33:57 2019 +1100
Branches: master
https://developer.blender.org/rB219e2f976d077c16c28d72a2f6763c01230c5bf8

Tool System: use set/add/subtract for all box select operators

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/gpencil/gpencil_select.c
M	source/blender/editors/include/ED_markers.h
M	source/blender/editors/mask/mask_select.c
M	source/blender/editors/space_action/action_select.c
M	source/blender/editors/space_clip/tracking_select.c
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_graph/graph_select.c
M	source/blender/editors/space_info/info_report.c
M	source/blender/editors/space_nla/nla_select.c
M	source/blender/editors/space_node/node_select.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_sequencer/sequencer_select.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index a754f45f12f..146e57cebf8 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5180,9 +5180,11 @@ def km_node_editor_tool_select_box(params):
         {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
         {"items": [
             ("node.select_box", {"type": params.tool_tweak, "value": 'ANY'},
-              {"properties": [("tweak", True)]}),
+             {"properties": [("tweak", True)]}),
+            ("node.select_box", {"type": params.tool_tweak, "value": 'ANY', "shift": True},
+             {"properties": [("tweak", True), ("mode", 'ADD')]}),
             ("node.select_box", {"type": params.tool_tweak, "value": 'ANY', "ctrl": True},
-              {"properties": [("deselect", True), ("tweak", True)]}),
+             {"properties": [("tweak", True), ("mode", 'SUB')]}),
         ]},
     )
 
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 276339bfdf3..ce9a7361d7d 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1324,7 +1324,7 @@ class _defs_node_select:
     def box():
         def draw_settings(context, layout, tool):
             props = tool.operator_properties("node.select_box")
-            layout.prop(props, "deselect")
+            layout.prop(props, "mode", expand=True)
             pass
         return dict(
             text="Select Box",
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 5d85a78905b..81f555630eb 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -288,6 +288,28 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
 		add_marker_to_cfra_elem(lb, marker, only_sel);
 }
 
+void ED_markers_deselect_all(ListBase *markers, int action)
+{
+	if (action == SEL_TOGGLE) {
+		action = ED_markers_get_first_selected(markers) ? SEL_DESELECT : SEL_SELECT;
+	}
+
+	for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+		if (action == SEL_SELECT) {
+			marker->flag |= SELECT;
+		}
+		else if (action == SEL_DESELECT) {
+			marker->flag &= ~SELECT;
+		}
+		else if (action == SEL_INVERT) {
+			marker->flag ^= SELECT;
+		}
+		else {
+			BLI_assert(0);
+		}
+	}
+}
+
 /* --------------------------------- */
 
 /* Get the first selected marker */
@@ -1279,9 +1301,6 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
 {
 	View2D *v2d = UI_view2d_fromcontext(C);
 	ListBase *markers = ED_context_get_markers(C);
-	TimeMarker *marker;
-	bool select = !RNA_boolean_get(op->ptr, "deselect");
-	bool extend = RNA_boolean_get(op->ptr, "extend");
 	rctf rect;
 
 	WM_operator_properties_border_to_rctf(op, &rect);
@@ -1290,18 +1309,15 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
 	if (markers == NULL)
 		return 0;
 
-	/* XXX marker context */
-	for (marker = markers->first; marker; marker = marker->next) {
+	const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
+	const bool select = (sel_op != SEL_OP_SUB);
+	if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+		ED_markers_deselect_all(markers, SEL_DESELECT);
+	}
+
+	for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
 		if (BLI_rctf_isect_x(&rect, marker->frame)) {
-			if (select) {
-				marker->flag |= SELECT;
-			}
-			else {
-				marker->flag &= ~SELECT;
-			}
-		}
-		else if (!extend) {
-			marker->flag &= ~SELECT;
+			SET_FLAG_FROM_TEST(marker->flag, select, SELECT);
 		}
 	}
 
@@ -1334,8 +1350,9 @@ static void MARKER_OT_select_box(wmOperatorType *ot)
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-	/* rna */
-	WM_operator_properties_gesture_box_select(ot);
+	/* properties */
+	WM_operator_properties_gesture_box(ot);
+	WM_operator_properties_select_operation_simple(ot);
 }
 
 /* *********************** (de)select all ***************** */
@@ -1343,29 +1360,12 @@ static void MARKER_OT_select_box(wmOperatorType *ot)
 static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
 {
 	ListBase *markers = ED_context_get_markers(C);
-	TimeMarker *marker;
-	int action = RNA_enum_get(op->ptr, "action");
-
-	if (markers == NULL)
+	if (markers == NULL) {
 		return OPERATOR_CANCELLED;
-
-	if (action == SEL_TOGGLE) {
-		action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT;
 	}
 
-	for (marker = markers->first; marker; marker = marker->next) {
-		switch (action) {
-			case SEL_SELECT:
-				marker->flag |= SELECT;
-				break;
-			case SEL_DESELECT:
-				marker->flag &= ~SELECT;
-				break;
-			case SEL_INVERT:
-				marker->flag ^= SELECT;
-				break;
-		}
-	}
+	int action = RNA_enum_get(op->ptr, "action");
+	ED_markers_deselect_all(markers, action);
 
 	WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
 	WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 1e7a34eeecd..0862a8661a3 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1173,9 +1173,9 @@ void GPENCIL_OT_select_box(wmOperatorType *ot)
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
 
-	/* rna */
-	WM_operator_properties_select_operation(ot);
+	/* properties */
 	WM_operator_properties_gesture_box(ot);
+	WM_operator_properties_select_operation(ot);
 }
 
 /** \} */
diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h
index 3716708e994..f3ca7135e40 100644
--- a/source/blender/editors/include/ED_markers.h
+++ b/source/blender/editors/include/ED_markers.h
@@ -56,6 +56,8 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
 
 void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short sel);
 
+void ED_markers_deselect_all(ListBase *markers, int action);
+
 struct TimeMarker *ED_markers_get_first_selected(ListBase *markers);
 
 /* Operators ------------------------------ */
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 2cab5d673ed..9bda6f7a92d 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -402,8 +402,13 @@ static int box_select_exec(bContext *C, wmOperator *op)
 	rcti rect;
 	rctf rectf;
 	bool changed = false;
-	const bool select = !RNA_boolean_get(op->ptr, "deselect");
-	const bool extend = RNA_boolean_get(op->ptr, "extend");
+
+	const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
+	const bool select = (sel_op != SEL_OP_SUB);
+	if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+		ED_mask_select_toggle_all(mask, SEL_DESELECT);
+		changed = true;
+	}
 
 	/* get rectangle from operator */
 	WM_operator_properties_border_to_rcti(op, &rect);
@@ -428,17 +433,11 @@ static int box_select_exec(bContext *C, wmOperator *op)
 
 				/* TODO: handles? */
 				/* TODO: uw? */
-
 				if (BLI_rctf_isect_pt_v(&rectf, point_deform->bezt.vec[1])) {
 					BKE_mask_point_select_set(point, select);
 					BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select);
+					changed = true;
 				}
-				else if (!extend) {
-					BKE_mask_point_select_set(point, false);
-					BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, false);
-				}
-
-				changed = true;
 			}
 		}
 	}
@@ -471,7 +470,8 @@ void MASK_OT_select_box(wmOperatorType *ot)
 	ot->flag = OPTYPE_UNDO;
 
 	/* properties */
-	WM_operator_properties_gesture_box_select(ot);
+	WM_operator_properties_gesture_box(ot);
+	WM_operator_properties_select_operation_simple(ot);
 }
 
 static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, bool select, bool extend)
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 0d9c3808b55..ed63cb523de 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -333,29 +333,22 @@ static int actkeys_box_select_exec(bContext *C, wmOperator *op)
 {
 	bAnimContext ac;
 	rcti rect;
-	short mode = 0, selectmode = 0;
-	const bool select = !RNA_boolean_get(op->ptr, "deselect");
-	const bool extend = RNA_boolean_get(op->ptr, "extend");
+	short mode = 0;
 
 	/* get editor data */
-	if (ANIM_animdata_get_context(C, &ac) == 0)
+	if (ANIM_animdata_get_context(C, &ac) == 0) {
 		return OPERATOR_CANCELLED;
+	}
 
-	/* clear all selection if not extending selection */
-	if (!extend) {
+	const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
+	const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
+	if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
 		deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
 	}
 
 	/* get settings from operator */
 	WM_operator_properties_border_to_rcti(op, &rect);
 
-	if (select) {
-		selectmode = SELECT_ADD;
-	}
-	else {
-		selectmode = SELECT_SUBTRACT;
-	}
-
 	/* selection 'mode' depends on whether box_select region only matters on one axis */
 	if (RNA_boolean_get(op->ptr, "axis_range")) {
 		/* mode depends on which axis of the range is larger to determine which axis to use
@@ -399,9 +392,11 @@ void ACTION_OT_select_box(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
 	/* rna */
-	WM_operator_properties_gesture_box_select(ot);
-
 	ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
+
+	/* properties */
+	WM_operator_properties_gesture_box(ot);
+	WM_operator_properties_select_operation_simple(ot);
 }
 
 /* ******************** Region Select Operators ***************************** */
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index abf89e86cdb..e25bf22db91 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list