add note onset detection to the ferret, c/o the aubio-based Onset VAMP plugin (REQUIR...
[ardour.git] / gtk2_ardour / editor_markers.cc
index ab6cd4f939a022103c2c929954a298a04974bff7..daad9383e5b4e26519592df321f80f60a5105a48 100644 (file)
@@ -26,6 +26,7 @@
 #include <gtkmm2ext/window_title.h>
 
 #include <ardour/location.h>
+#include <ardour/profile.h>
 #include <pbd/memento_command.h>
 
 #include "editor.h"
@@ -78,7 +79,7 @@ Editor::add_new_location (Location *location)
 
        if (location->is_mark()) {
 
-               if (location->is_cd_marker() && ruler_shown[ruler_time_cd_marker]) {
+               if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
                        lam->start = new Marker (*this, *cd_marker_group, color, location->name(), Marker::Mark, location->start());
                }
                else {
@@ -102,7 +103,7 @@ Editor::add_new_location (Location *location)
                
        } else {
                // range marker
-               if (location->is_cd_marker() && ruler_shown[ruler_time_cd_marker]) {
+               if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
                        lam->start = new Marker (*this, *cd_marker_group, color, 
                                                 location->name(), Marker::Start, location->start());
                        lam->end   = new Marker (*this, *cd_marker_group, color, 
@@ -211,7 +212,7 @@ void Editor::update_cd_marker_display ()
 void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * location)
 {
        if (location->is_cd_marker()
-           && (ruler_shown[ruler_time_cd_marker] &&  lam->start->get_parent() != cd_marker_group))
+           && (ruler_cd_marker_action->get_active() &&  lam->start->get_parent() != cd_marker_group))
        {
                //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
                if (lam->start) {
@@ -221,7 +222,7 @@ void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * locatio
                        lam->end->reparent (*cd_marker_group);
                }
        }
-       else if ( (!location->is_cd_marker() || !ruler_shown[ruler_time_cd_marker]
+       else if ( (!location->is_cd_marker() || !ruler_cd_marker_action->get_active()
                  && (lam->start->get_parent() == cd_marker_group))  
        {
                //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
@@ -327,7 +328,9 @@ Editor::refresh_location_display_internal (Locations::LocationList& locations)
 
                i = tmp;
        }
-       
+
+       update_punch_range_view (false);
+       update_loop_range_view (false);
 }
 
 void
@@ -387,13 +390,23 @@ Editor::LocationMarkers::set_color_rgba (uint32_t rgba)
 }
 
 void
-Editor::mouse_add_new_marker (nframes_t where, bool is_cd)
+Editor::mouse_add_new_marker (nframes_t where, bool is_cd, bool is_xrun)
 {
-       string markername;
+       string markername, markerprefix;
        int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
-       
+
+       if (is_xrun) {
+               markerprefix = "xrun";
+               flags = Location::IsMark;
+       } else {
+               markerprefix = "mark";
+       }
+
        if (session) {
-               session->locations()->next_available_name(markername,"mark");
+               session->locations()->next_available_name(markername, markerprefix);
+               if (!is_xrun && !choose_new_marker_name(markername)) {
+                       return;
+               }               
                Location *location = new Location (where, where, markername, (Location::Flags) flags);
                session->begin_reversible_command (_("add marker"));
                 XMLNode &before = session->locations()->get_state();
@@ -423,6 +436,10 @@ Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent* event)
                /*NOTREACHED*/
        }
 
+       if (entered_marker == marker) {
+               entered_marker = NULL;
+       }
+
        Location* loc = find_location_from_marker (marker, is_start);
 
        if (session && loc) {
@@ -606,19 +623,21 @@ Editor::build_range_marker_menu (bool loop_or_punch)
        MenuList& items = markerMenu->items();
        markerMenu->set_name ("ArdourContextMenu");
 
+       items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range)));
        items.push_back (MenuElem (_("Locate to Range Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead)));
        items.push_back (MenuElem (_("Play from Range Mark"), mem_fun(*this, &Editor::marker_menu_play_from)));
        if (!loop_or_punch) {
-               items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range)));
                items.push_back (MenuElem (_("Loop Range"), mem_fun(*this, &Editor::marker_menu_loop_range)));
        }
        items.push_back (MenuElem (_("Set Range Mark from Playhead"), mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
-       items.push_back (MenuElem (_("Set Range from Range Selection"), mem_fun(*this, &Editor::marker_menu_set_from_selection)));
+       if (!Profile->get_sae()) {
+               items.push_back (MenuElem (_("Set Range from Range Selection"), mem_fun(*this, &Editor::marker_menu_set_from_selection)));
+       }
 
        items.push_back (SeparatorElem());
 
-       items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide)));
        if (!loop_or_punch) {
+               items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide)));
                items.push_back (MenuElem (_("Rename Range"), mem_fun(*this, &Editor::marker_menu_rename)));
                items.push_back (MenuElem (_("Remove Range"), mem_fun(*this, &Editor::marker_menu_remove)));
        }
@@ -627,8 +646,9 @@ Editor::build_range_marker_menu (bool loop_or_punch)
 
        items.push_back (MenuElem (_("Separate Regions in Range"), mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
        items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
-       items.push_back (MenuElem (_("Select Range"), mem_fun(*this, &Editor::marker_menu_select_using_range)));
-
+       if (!Profile->get_sae()) {
+               items.push_back (MenuElem (_("Select Range"), mem_fun(*this, &Editor::marker_menu_select_using_range)));
+       }
 }
 
 void
@@ -807,13 +827,13 @@ Editor::marker_menu_set_from_playhead ()
        if ((l = find_location_from_marker (marker, is_start)) != 0) {
 
                if (l->is_mark()) {
-                       l->set_start (session->transport_frame ());
+                       l->set_start (session->audible_frame ());
                }
                else {
                        if (is_start) {
-                               l->set_start (session->transport_frame ());
+                               l->set_start (session->audible_frame ());
                        } else {
-                               l->set_end (session->transport_frame ());
+                               l->set_end (session->audible_frame ());
                        }
                }
        }
@@ -1097,9 +1117,15 @@ Editor::update_punch_range_view (bool visibility)
                double x1 = frame_to_pixel (tpl->start());
                double x2 = frame_to_pixel (tpl->end());
                
+               guint track_canvas_width,track_canvas_height;
+               track_canvas->get_size(track_canvas_width,track_canvas_height);
+               
                transport_punch_range_rect->property_x1() = x1;
                transport_punch_range_rect->property_x2() = x2;
                
+               transport_punch_range_rect->property_x1() = (Config->get_punch_in() ? x1 : 0);
+               transport_punch_range_rect->property_x2() = (Config->get_punch_out() ? x2 : track_canvas_width);
+               
                if (visibility) {
                        transport_punch_range_rect->show();
                }
@@ -1137,6 +1163,10 @@ Editor::update_punch_range_view (bool visibility)
 void
 Editor::marker_selection_changed ()
 {
+       if (session && session->deletion_in_progress()) {
+               return;
+       }
+
        for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
                LocationMarkers* lam = i->second;
 
@@ -1158,7 +1188,7 @@ Editor::marker_selection_changed ()
        }
 
        for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
-               (*x)->add_line (cursor_group, canvas_height);
+               (*x)->add_line (cursor_group, vertical_adjustment.get_value(), canvas_height);
                (*x)->show_line ();
        }