Add "Marker Toggle" #5193
authorNathan Stewart <therealnathanstewart@gmail.com>
Sat, 13 Aug 2016 14:02:43 +0000 (16:02 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 13 Aug 2016 14:07:16 +0000 (16:07 +0200)
gtk2_ardour/ardour.menus.in
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc

index d8ea6eb669502c61015c8c6a1187402dbe7b1f3a..f0c8dfe1f719695cadf65a734b063593e056737e 100644 (file)
       <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'/>
index d45545b4a703495835b8744e0053aa44c4a771e9..7d754ed1b01abb05651c659d075d705ed7ac98b8 100644 (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;
 
index 79900b35174c3db546564b035700bc9c7a596b1f..44c66e36c8d5a4f26b1413c88c4fd518e00b6dbb 100644 (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));
 
index 2741f66d4d2c2809fa298ef5271c0a5cd02f631f..2022216934589743fb2abe463f11b9db8763c667 100644 (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 */