From f1fbb81af9bc79d2ac09c0a6954ef64fbdf9dd40 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 17 Jun 2021 11:22:03 -0400 Subject: [PATCH] Factor away Editor::do_remove_location_at_playhead_cursor() --- gtk2_ardour/editor.h | 1 - gtk2_ardour/editor_ops.cc | 34 ++-------------------------------- gtk2_ardour/public_editor.h | 4 ++-- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 9281c2378b..ae82c000a1 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1526,7 +1526,6 @@ private: void toggle_location_at_playhead_cursor (); void add_location_from_playhead_cursor (); - bool do_remove_location_at_playhead_cursor (); void remove_location_at_playhead_cursor (); bool select_new_marker; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index cf2d08c386..887d68ad46 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -2323,8 +2323,7 @@ Editor::set_session_end_from_playhead () void Editor::toggle_location_at_playhead_cursor () { - if (!do_remove_location_at_playhead_cursor()) - { + if (!_controller.remove_marker_at_playhead()) { add_location_from_playhead_cursor(); } } @@ -2335,39 +2334,10 @@ Editor::add_location_from_playhead_cursor () add_location_mark (_session->audible_sample()); } -bool -Editor::do_remove_location_at_playhead_cursor () -{ - bool removed = false; - if (_session) { - //set up for undo - XMLNode &before = _session->locations()->get_state(); - - //find location(s) at this time - Locations::LocationList locs; - _session->locations()->find_all_between (_session->audible_sample(), _session->audible_sample()+1, locs, Location::Flags(0)); - for (Locations::LocationList::iterator i = locs.begin(); i != locs.end(); ++i) { - if ((*i)->is_mark()) { - _session->locations()->remove (*i); - removed = true; - } - } - - //store undo - if (removed) { - begin_reversible_command (_("remove marker")); - XMLNode &after = _session->locations()->get_state(); - _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); - commit_reversible_command (); - } - } - return removed; -} - void Editor::remove_location_at_playhead_cursor () { - do_remove_location_at_playhead_cursor (); + _controller.remove_marker_at_playhead(); } /** Add a range marker around each selected region */ diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 095dbafa75..e3da129195 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -50,7 +50,7 @@ #include "evoral/Note.h" -#include "ardour/session_handle.h" +#include "ardour/session_controller_handle.h" #include "canvas/fwd.h" @@ -116,7 +116,7 @@ using ARDOUR::samplecnt_t; * of PublicEditor need not be recompiled if private methods or member variables * change. */ -class PublicEditor : public ArdourWidgets::Tabbable, public ARDOUR::SessionHandlePtr, public AxisViewProvider +class PublicEditor : public ArdourWidgets::Tabbable, public ARDOUR::SessionControllerHandlePtr, public AxisViewProvider { public: PublicEditor (Gtk::Widget& content);