View Issue Details

IDProjectCategoryView StatusLast Update
0005193ardourfeaturespublic2016-08-15 17:11
Reporterlhm100 Assigned Tox42  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version3.0 beta5 
Summary0005193: Add "Marker Toggle"
DescriptionWhen mixing, working sections at a time is useful for me. Having a Marker Toggle (that I could bind to a button on my control surface) would be very helpful.

This would only make sense when the transport is stopped:
Basically: If there is no marker at the current location, create one (just like KP-Enter). If there IS a marker at the current location (because you used jump-back or jump-forward to get to it) then delete that marker. (use Ctrl-KP-Enter?)
TagsNo tags attached.

Activities

nstewart

2016-08-10 23:30

reporter  

toggle-marker.diff (3,236 bytes)   
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index d8ea6eb..f690ebe 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -128,6 +128,7 @@
       </menu>
 
       <menu action="MarkerMenu">
+        <menuitem action='toggle-location-at-playhead'/>
         <menuitem action='add-location-from-playhead'/>
         <menuitem action='remove-location-from-playhead'/>
         <separator/>
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index d45545b..7d754ed 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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;
 
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 79900b3..44c66e3 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -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));
 
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index c208e55..526d8bd 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -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 */
toggle-marker.diff (3,236 bytes)   

nstewart

2016-08-10 23:33

reporter   ~0018354

I'm not sure if this is the best way to implement this, but I was looking for similar functionality, and implemented it by moving the work for Editor::remove_location_at_playhead_cursor() into a do_remove_location_at_playhead_cursor(), returning true if it found one, and adding a Editor::toggle_location_at_playhead_cursor() command. If no marker found at the current location, it calls Editor::add_location_from_playhead().

x42

2016-08-13 14:10

administrator   ~0018358

merged as Ardour 5.0-9-g5b4584a -- thanks

nstewart

2016-08-15 17:11

reporter   ~0018374

Patch accepted, marking closed.

Issue History

Date Modified Username Field Change
2012-11-27 07:02 lhm100 New Issue
2016-08-10 23:30 nstewart File Added: toggle-marker.diff
2016-08-10 23:33 nstewart Note Added: 0018354
2016-08-13 14:10 x42 Note Added: 0018358
2016-08-13 14:10 x42 Status new => resolved
2016-08-13 14:10 x42 Resolution open => fixed
2016-08-13 14:10 x42 Assigned To => x42
2016-08-15 17:11 nstewart Note Added: 0018374
2016-08-15 17:11 nstewart Status resolved => closed