From fdaf120f17860bbfa27eae121510db1242a8c7b8 Mon Sep 17 00:00:00 2001
From: Mark Knoop <mark@markknoop.com>
Date: Tue, 2 Jun 2020 11:16:38 +0100
Subject: [PATCH] Add configuration option for new split action behaviour

---
 gtk2_ardour/editor_ops.cc                  |  2 +-
 gtk2_ardour/rc_option_editor.cc            | 10 ++++++++++
 libs/ardour/ardour/rc_configuration_vars.h |  1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 08dd4b4220..32140e3a2a 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -6587,7 +6587,7 @@ Editor::split_region ()
 		//  * nothing happens OR
 		//  * some other region (maybe off-screen) is split.
 		//NOTE:  if the entered_regionview is /part of the selection/ then we should operate on the selection as usual
-		if (_edit_point == EditAtMouse && entered_regionview && !entered_regionview->selected()) {
+		if (Config->get_split_region_ignores_selection() && _edit_point == EditAtMouse && entered_regionview && !entered_regionview->selected()) {
 			rs.add (entered_regionview);
 		} else {
 			rs = selection->regions;   //might be empty
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc
index d7d8854ae7..14bee8c710 100644
--- a/gtk2_ardour/rc_option_editor.cc
+++ b/gtk2_ardour/rc_option_editor.cc
@@ -2636,6 +2636,16 @@ RCOptionEditor::RCOptionEditor ()
 
 	add_option (_("Editor"), new OptionEditorHeading (_("Split/Separate")));
 
+  bo = new BoolOption (
+				"split-region-ignores-selection",
+				_("Ignore region selection when requesting split in Object mode"),
+				sigc::mem_fun (*_rc_config, &RCConfiguration::get_split_region_ignores_selection),
+				sigc::mem_fun (*_rc_config, &RCConfiguration::set_split_region_ignores_selection)
+				);
+  add_option (_("Editor"), bo);
+  Gtkmm2ext::UI::instance()->set_tip (bo->tip_widget(),
+			_("<b>When enabled</b> split affects the region under the mouse pointer, not the selected regions."));
+
 	ComboOption<RangeSelectionAfterSplit> *rras = new ComboOption<RangeSelectionAfterSplit> (
 		    "range-selection-after-separate",
 		    _("After a Separate operation, in Range mode"),
diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h
index 87dd884f2f..167e83c585 100644
--- a/libs/ardour/ardour/rc_configuration_vars.h
+++ b/libs/ardour/ardour/rc_configuration_vars.h
@@ -111,6 +111,7 @@ CONFIG_VARIABLE (bool, automation_follows_regions, "automation-follows-regions",
 CONFIG_VARIABLE (bool, region_boundaries_from_selected_tracks, "region-boundaries-from-selected-tracks", true)
 CONFIG_VARIABLE (bool, region_boundaries_from_onscreen_tracks, "region-boundaries-from-onscreen_tracks", true)
 CONFIG_VARIABLE (FadeShape, default_fade_shape, "default-fade-shape", FadeConstantPower)
+CONFIG_VARIABLE (bool, split_region_ignores_selection, "split-region-ignores-selection", false)
 CONFIG_VARIABLE (RangeSelectionAfterSplit, range_selection_after_split, "range-selection-after-split", PreserveSel)
 CONFIG_VARIABLE (RegionSelectionAfterSplit, region_selection_after_split, "region-selection-after-split", None)
 
-- 
2.26.2

