#include "prompter.h"
#include "editor_drag.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
if (!tm->tempo().active()) {
return;
}
- can_remove = tm->tempo().movable ();
+ can_remove = tm->tempo().movable() && !tm->tempo().locked_to_meter();
delete tempo_marker_menu;
build_tempo_marker_menu (tm, can_remove);
tempo_marker_menu->popup (1, ev->time);
tempo_marker_menu = new Menu;
MenuList& items = tempo_marker_menu->items();
tempo_marker_menu->set_name ("ArdourContextMenu");
+
if (loc->tempo().type() == TempoSection::Constant) {
- items.push_back (MenuElem (_("Ramped"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
+ items.push_back (MenuElem (_("Make Ramped"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
} else {
- items.push_back (MenuElem (_("Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
+ items.push_back (MenuElem (_("Make Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
}
- if (loc->tempo().position_lock_style() == AudioTime) {
+
+ if (loc->tempo().position_lock_style() == AudioTime && can_remove) {
items.push_back (MenuElem (_("Lock to Music"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
- } else {
+ } else if (can_remove) {
items.push_back (MenuElem (_("Lock to Audio"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
}
+
items.push_back (MenuElem (_("Edit..."), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
-
items.back().set_sensitive (can_remove);
}
meter_marker_menu = new Menu;
MenuList& items = meter_marker_menu->items();
meter_marker_menu->set_name ("ArdourContextMenu");
- if (loc->meter().position_lock_style() == AudioTime) {
+
+ if (loc->meter().position_lock_style() == AudioTime && can_remove) {
items.push_back (MenuElem (_("Lock to Music"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
- } else {
+ } else if (can_remove) {
items.push_back (MenuElem (_("Lock to Audio"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
}
+
items.push_back (MenuElem (_("Edit..."), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
if (mm) {
- if (mm->meter().position_lock_style() == AudioTime) {
- mm->meter().set_position_lock_style (MusicTime);
- } else {
- mm->meter().set_position_lock_style (AudioTime);
- }
+ begin_reversible_command (_("change meter lock style"));
+ XMLNode &before = _session->tempo_map().get_state();
+ MeterSection* msp = &mm->meter();
+
+ const Meter meter (msp->divisions_per_bar(), msp->note_divisor());
+ const Timecode::BBT_Time bbt (msp->bbt());
+ const PositionLockStyle pls = (msp->position_lock_style() == AudioTime) ? MusicTime : AudioTime;
+
+ _session->tempo_map().replace_meter (*msp, meter, bbt, pls);
+
+ XMLNode &after = _session->tempo_map().get_state();
+ _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
+ commit_reversible_command ();
} else if (tm) {
- if (tm->tempo().position_lock_style() == AudioTime) {
- tm->tempo().set_position_lock_style (MusicTime);
- } else {
- tm->tempo().set_position_lock_style (AudioTime);
- }
+ TempoSection* tsp = &tm->tempo();
+
+ const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type());
+ const double pulse = tsp->pulse();
+ const framepos_t frame = tsp->frame();
+ const TempoSection::Type type = tsp->type();
+ const PositionLockStyle pls = (tsp->position_lock_style() == AudioTime) ? MusicTime : AudioTime;
+
+ begin_reversible_command (_("change tempo lock style"));
+ XMLNode &before = _session->tempo_map().get_state();
+
+ _session->tempo_map().replace_tempo (*tsp, tempo, pulse, frame, type, pls);
+
+ XMLNode &after = _session->tempo_map().get_state();
+ _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
+ commit_reversible_command ();
}
}
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
if (tm) {
- if (tm->tempo().type() == TempoSection::Constant) {
- tm->tempo().set_type (TempoSection::Ramp);
- } else {
- tm->tempo().set_type (TempoSection::Constant);
- }
+ TempoSection* tsp = &tm->tempo();
+
+ const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type());
+ const double pulse = tsp->pulse();
+ const framepos_t frame = tsp->frame();
+ const TempoSection::Type type = (tsp->type() == TempoSection::Ramp) ? TempoSection::Constant : TempoSection::Ramp;
+ const PositionLockStyle pls = tsp->position_lock_style();
+
+ begin_reversible_command (_("change tempo type"));
+ XMLNode &before = _session->tempo_map().get_state();
+
+ _session->tempo_map().replace_tempo (*tsp, tempo, pulse, frame, type, pls);
+
+ XMLNode &after = _session->tempo_map().get_state();
+ _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
+ commit_reversible_command ();
}
}