#include "prompter.h"
#include "editor_drag.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
if (mm) {
can_remove = mm->meter().movable ();
+ delete meter_marker_menu;
+ build_meter_marker_menu (mm, can_remove);
+ meter_marker_menu->popup (1, ev->time);
} else if (tm) {
- can_remove = tm->tempo().movable ();
+ if (!tm->tempo().active()) {
+ return;
+ }
+ 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);
} else {
return;
}
-
- delete tempo_or_meter_marker_menu;
- build_tempo_or_meter_marker_menu (can_remove);
- tempo_or_meter_marker_menu->popup (1, ev->time);
}
void
items.push_back (MenuElem (_("Loop Range"), sigc::mem_fun(*this, &Editor::marker_menu_loop_range)));
items.push_back (MenuElem (_("Set Marker from Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
- if (!Profile->get_sae()) {
- items.push_back (MenuElem (_("Set Range from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection), false)));
- }
+ items.push_back (MenuElem (_("Set Range from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection), false)));
items.push_back (MenuElem (_("Zoom to Range"), sigc::mem_fun (*this, &Editor::marker_menu_zoom_to_range)));
items.push_back (MenuElem (_("Separate Regions in Range"), sigc::mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
- if (!Profile->get_sae()) {
- items.push_back (MenuElem (_("Select Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_using_range)));
+ items.push_back (MenuElem (_("Select Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_using_range)));
+}
+
+void
+Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove)
+{
+ using namespace Menu_Helpers;
+
+ 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 (_("Make Ramped"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
+ } else {
+ items.push_back (MenuElem (_("Make Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
+ }
+
+ 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 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);
}
void
-Editor::build_tempo_or_meter_marker_menu (bool can_remove)
+Editor::build_meter_marker_menu (MeterMarker* loc, bool can_remove)
{
using namespace Menu_Helpers;
- tempo_or_meter_marker_menu = new Menu;
- MenuList& items = tempo_or_meter_marker_menu->items();
- tempo_or_meter_marker_menu->set_name ("ArdourContextMenu");
+ meter_marker_menu = new Menu;
+ MenuList& items = meter_marker_menu->items();
+ meter_marker_menu->set_name ("ArdourContextMenu");
+
+ 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 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)));
}
}
+void
+Editor::toggle_marker_lock_style ()
+{
+ MeterMarker* mm;
+ TempoMarker* tm;
+ dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
+
+ if (mm) {
+ 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) {
+ 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 ();
+ }
+}
+
+void
+Editor::toggle_tempo_type ()
+{
+ TempoMarker* tm;
+ MeterMarker* mm;
+ dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
+
+ if (tm) {
+ 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 ();
+ }
+}
+
void
Editor::toggle_marker_menu_lock ()
{