clean up patch change/sysex headers.
[ardour.git] / gtk2_ardour / editor_markers.cc
index a4d990b1e3fa8ede3678929a137588ae7ec6d7b3..95c88b132f6371e99422ca3b0cbb901f68ccacf4 100644 (file)
@@ -646,7 +646,7 @@ Editor::mouse_add_new_marker (framepos_t where, bool is_cd)
                if (!choose_new_marker_name(markername)) {
                        return;
                }
-               Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags);
+               Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags, get_grid_music_divisions (0));
                begin_reversible_command (_("add marker"));
 
                XMLNode &before = _session->locations()->get_state();
@@ -838,9 +838,8 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
 
        if (loc == transport_loop_location() || loc == transport_punch_location() || loc->is_session_range ()) {
 
-               if (transport_marker_menu == 0) {
-                       build_range_marker_menu (loc == transport_loop_location() || loc == transport_punch_location(), loc->is_session_range());
-               }
+               delete transport_marker_menu;
+               build_range_marker_menu (loc, loc == transport_loop_location() || loc == transport_punch_location(), loc->is_session_range());
 
                marker_menu_item = item;
                transport_marker_menu->popup (1, ev->time);
@@ -868,9 +867,9 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
                        marker_menu->popup (1, ev->time);
 
        } else if (loc->is_range_marker()) {
-               if (range_marker_menu == 0) {
-                       build_range_marker_menu (false, false);
-               }
+               delete range_marker_menu;
+               build_range_marker_menu (loc, false, false);
+
                marker_menu_item = item;
                range_marker_menu->popup (1, ev->time);
        }
@@ -916,9 +915,8 @@ Editor::build_marker_menu (Location* loc)
 
        items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
        Gtk::CheckMenuItem* glue_item = static_cast<Gtk::CheckMenuItem*> (&items.back());
-       if (loc->position_lock_style() == MusicTime) {
-               glue_item->set_active ();
-       }
+       glue_item->set_active (loc->position_lock_style() == MusicTime);
+
        glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue));
 
        items.push_back (SeparatorElem());
@@ -927,11 +925,11 @@ Editor::build_marker_menu (Location* loc)
 }
 
 void
-Editor::build_range_marker_menu (bool loop_or_punch, bool session)
+Editor::build_range_marker_menu (Location* loc, bool loop_or_punch, bool session)
 {
        using namespace Menu_Helpers;
 
-       bool const loop_or_punch_or_session = loop_or_punch | session;
+       bool const loop_or_punch_or_session = loop_or_punch || session;
 
        Menu *markerMenu = new Menu;
        if (loop_or_punch_or_session) {
@@ -952,6 +950,13 @@ Editor::build_range_marker_menu (bool loop_or_punch, bool session)
 
        items.push_back (MenuElem (_("Zoom to Range"), sigc::mem_fun (*this, &Editor::marker_menu_zoom_to_range)));
 
+       items.push_back (SeparatorElem());
+       items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
+
+       Gtk::CheckMenuItem* glue_item = static_cast<Gtk::CheckMenuItem*> (&items.back());
+       glue_item->set_active (loc->position_lock_style() == MusicTime);
+       glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue));
+
        items.push_back (SeparatorElem());
        items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_range)));
        items.push_back (SeparatorElem());
@@ -1213,17 +1218,18 @@ Editor::marker_menu_set_from_playhead ()
 
        Location* l;
        bool is_start;
+       const int32_t divisions = get_grid_music_divisions (0);
 
        if ((l = find_location_from_marker (marker, is_start)) != 0) {
 
                if (l->is_mark()) {
-                       l->set_start (_session->audible_frame ());
+                       l->set_start (_session->audible_frame (), false, true, divisions);
                }
                else {
                        if (is_start) {
-                               l->set_start (_session->audible_frame ());
+                               l->set_start (_session->audible_frame (), false, true, divisions);
                        } else {
-                               l->set_end (_session->audible_frame ());
+                               l->set_end (_session->audible_frame (), false, true, divisions);
                        }
                }
        }
@@ -1687,12 +1693,18 @@ Editor::toggle_marker_menu_glue ()
                return;
        }
 
+       begin_reversible_command (_("change marker lock style"));
+       XMLNode &before = _session->locations()->get_state();
+
        if (loc->position_lock_style() == MusicTime) {
                loc->set_position_lock_style (AudioTime);
        } else {
                loc->set_position_lock_style (MusicTime);
        }
 
+       XMLNode &after = _session->locations()->get_state();
+       _session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
+       commit_reversible_command ();
 }
 
 void