13
0

change add new bbt marker from primary-click to context-click on BBT ruler

This commit is contained in:
Paul Davis 2022-10-03 14:16:27 -06:00
parent 374ff2b12d
commit 0938d21c30
4 changed files with 55 additions and 29 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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;
}

View File

@ -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)
{