Factor away Editor::do_remove_location_at_playhead_cursor()

This commit is contained in:
David Robillard 2021-06-17 11:22:03 -04:00
parent e7454a896b
commit f1fbb81af9
3 changed files with 4 additions and 35 deletions

View file

@ -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;

View file

@ -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<Locations>(*(_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 */

View file

@ -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);