Add "Marker Toggle" #5193

This commit is contained in:
Nathan Stewart 2016-08-13 16:02:43 +02:00 committed by Robin Gareus
parent 613ae0c110
commit 5b4584ad94
4 changed files with 24 additions and 3 deletions

View File

@ -130,6 +130,7 @@
<menu action="MarkerMenu">
<menuitem action='add-location-from-playhead'/>
<menuitem action='remove-location-from-playhead'/>
<menuitem action='toggle-location-at-playhead'/>
<separator/>
<menuitem action='goto-mark-1'/>
<menuitem action='goto-mark-2'/>

View File

@ -1461,7 +1461,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void set_loop_range (framepos_t start, framepos_t end, std::string cmd);
void set_punch_range (framepos_t start, framepos_t end, std::string cmd);
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

@ -254,6 +254,7 @@ Editor::register_actions ()
reg_sens (editor_actions, "set-session-start-from-playhead", _("Set Session Start from Playhead"), sigc::mem_fun(*this, &Editor::set_session_start_from_playhead));
reg_sens (editor_actions, "set-session-end-from-playhead", _("Set Session End from Playhead"), sigc::mem_fun(*this, &Editor::set_session_end_from_playhead));
reg_sens (editor_actions, "toggle-location-at-playhead", _("Toggle Mark at Playhead"), sigc::mem_fun(*this, &Editor::toggle_location_at_playhead_cursor));
reg_sens (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(*this, &Editor::add_location_from_playhead_cursor));
reg_sens (editor_actions, "alternate-add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(*this, &Editor::add_location_from_playhead_cursor));

View File

@ -2243,19 +2243,29 @@ Editor::set_session_end_from_playhead ()
_session->set_end_is_free (false);
}
void
Editor::toggle_location_at_playhead_cursor ()
{
if (!do_remove_location_at_playhead_cursor())
{
add_location_from_playhead_cursor();
}
}
void
Editor::add_location_from_playhead_cursor ()
{
add_location_mark (_session->audible_frame());
}
void
Editor::remove_location_at_playhead_cursor ()
bool
Editor::do_remove_location_at_playhead_cursor ()
{
bool removed = false;
if (_session) {
//set up for undo
XMLNode &before = _session->locations()->get_state();
bool removed = false;
//find location(s) at this time
Locations::LocationList locs;
@ -2275,6 +2285,13 @@ Editor::remove_location_at_playhead_cursor ()
commit_reversible_command ();
}
}
return removed;
}
void
Editor::remove_location_at_playhead_cursor ()
{
do_remove_location_at_playhead_cursor ();
}
/** Add a range marker around each selected region */