summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-06-19 13:54:28 +0000
committerCarl Hetherington <carl@carlh.net>2012-06-19 13:54:28 +0000
commitd54fb5f54ec4e3cfb88887a6a0ab5ee9407af0b5 (patch)
tree74428ce58b1fa597cb34115070b5416bb9640bda /gtk2_ardour
parent3dd8fbdefa5ad5a818d1bc7d5952f9aaa97485bc (diff)
Add option to add new range marker from the context menu without needing the keyboard (#4378).
git-svn-id: svn://localhost/ardour2/branches/3.0@12781 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.h1
-rw-r--r--gtk2_ardour/editor_markers.cc25
-rw-r--r--gtk2_ardour/editor_rulers.cc2
3 files changed, 27 insertions, 1 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index a2d7c93fd3..3fd38ec609 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -632,6 +632,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void hide_marker (ArdourCanvas::Item*, GdkEvent*);
void clear_marker_display ();
void mouse_add_new_marker (framepos_t where, bool is_cd=false, bool is_xrun=false);
+ void mouse_add_new_range (framepos_t);
bool choose_new_marker_name(std::string &name);
void update_cd_marker_display ();
void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index 46f4a0ddd5..28706ac7bc 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -662,6 +662,31 @@ Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun)
}
void
+Editor::mouse_add_new_range (framepos_t where)
+{
+ if (!_session) {
+ return;
+ }
+
+ /* Make this marker 1/8th of the visible area of the session so that
+ it's reasonably easy to manipulate after creation.
+ */
+
+ framepos_t const end = where + current_page_frames() / 8;
+
+ string name;
+ _session->locations()->next_available_name (name, _("range"));
+ Location* loc = new Location (*_session, where, end, name, Location::IsRangeMarker);
+
+ begin_reversible_command (_("new range marker"));
+ XMLNode& before = _session->locations()->get_state ();
+ _session->locations()->add (loc, true);
+ XMLNode& after = _session->locations()->get_state ();
+ _session->add_command (new MementoCommand<Locations> (*_session->locations(), &before, &after));
+ commit_reversible_command ();
+}
+
+void
Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
{
Marker* marker;
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index ea5622e4c9..ac771c42f0 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -342,7 +342,7 @@ Editor::popup_ruler_menu (framepos_t where, ItemType t)
ruler_items.push_back (SeparatorElem ());
break;
case RangeMarkerBarItem:
- //ruler_items.push_back (MenuElem (_("New Range")));
+ ruler_items.push_back (MenuElem (_("New range"), sigc::bind (sigc::mem_fun (*this, &Editor::mouse_add_new_range), where)));
ruler_items.push_back (MenuElem (_("Clear all ranges"), sigc::mem_fun(*this, &Editor::clear_ranges)));
ruler_items.push_back (MenuElem (_("Unhide ranges"), sigc::mem_fun(*this, &Editor::unhide_ranges)));
ruler_items.push_back (SeparatorElem ());