diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 794af66dd1..cfa11b0fdc 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -600,6 +600,8 @@ public: void mouse_add_new_meter_event (Temporal::timepos_t where); void edit_tempo_section (Temporal::TempoPoint&); void edit_meter_section (Temporal::MeterPoint&); + void mouse_add_bbt_marker_event (Temporal::timepos_t where); + void edit_bbt (Temporal::MusicTimePoint&); bool should_ripple () const; diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index b2ff58c2e1..48d3ca6fcd 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3552,41 +3552,16 @@ void BBTRulerDrag::finished (GdkEvent* event, bool movement_occurred) { if (!_drag_valid) { - TempoMap::abort_update (); + _editor->abort_tempo_map_edit (); return; } if (!movement_occurred) { - _editor->begin_reversible_command (_("add BBT marker")); - /* position markers must always be positioned using audio time */ + /* click, no drag */ - BBTMarkerDialog* marker_dialog = new BBTMarkerDialog (timepos_t (grab_sample())); - - /* run this modally since we are finishing a drag and the drag object - * will be destroyed when we return from here - */ - - int result = marker_dialog->run (); - BBT_Time bbt; - std::string name; - - switch (result) { - case RESPONSE_ACCEPT: - case RESPONSE_OK: - bbt = marker_dialog->bbt_value (); - name = marker_dialog->name(); - map->set_bartime (bbt, marker_dialog->position(), name); - delete marker_dialog; - break; - default: - delete marker_dialog; - TempoMap::abort_update (); - _editor->abort_reversible_command (); - return; - } - - /* the map change is committed below */ + _editor->abort_tempo_map_edit (); + return; } else { diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 6f29c3b806..c93614d9ca 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -301,6 +301,10 @@ Editor::popup_ruler_menu (timepos_t const & where, ItemType t) } break; + case BBTRulerItem: + ruler_items.push_back (MenuElem (_("Add BBT Marker"), sigc::bind (sigc::mem_fun (*this, &Editor::mouse_add_bbt_marker_event), where))); + break; + default: break; } diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 2d4ad9d58e..eaa9f2abb9 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -540,6 +540,51 @@ Editor::mouse_add_new_meter_event (timepos_t pos) //map.dump (cerr); } +void +Editor::mouse_add_bbt_marker_event (timepos_t pos) +{ + if (_session == 0) { + return; + } + + /* position markers must always be positioned using audio time */ + + BBTMarkerDialog marker_dialog (pos); + + /* run this modally since we are finishing a drag and the drag object + * will be destroyed when we return from here + */ + + int result = marker_dialog.run (); + + switch (result) { + case RESPONSE_ACCEPT: + case RESPONSE_OK: + break; + default: + return; + } + + BBT_Time bbt; + std::string name; + + bbt = marker_dialog.bbt_value (); + name = marker_dialog.name(); + + begin_reversible_command (_("add BBT marker")); + + TempoMap::WritableSharedPtr map (TempoMap::write_copy()); + XMLNode &before = map->get_state(); + + map->set_bartime (bbt, marker_dialog.position(), name); + + _session->add_command (new Temporal::TempoCommand (_("add BBT marker"), &before, &map->get_state())); + commit_reversible_command (); + + TempoMap::update (map); +} + + void Editor::remove_bbt_marker (ArdourCanvas::Item* item) {