Prevent multiple tempo / meter changes being inserted at the same point
on the timeline; adding a new change at the same time as an existing one will replace the existing one. Should prevent #769 from happening. Some cleanups and tweaks to tempo / meter dialogues. Desensitize Remove menu option for those changes that can't be removed. git-svn-id: svn://localhost/ardour2/branches/3.0@7045 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ceb1025c2c
commit
c2da4ec8f9
|
@ -346,7 +346,7 @@ Editor::Editor ()
|
|||
session_range_marker_menu = 0;
|
||||
range_marker_menu = 0;
|
||||
marker_menu_item = 0;
|
||||
tm_marker_menu = 0;
|
||||
tempo_or_meter_marker_menu = 0;
|
||||
transport_marker_menu = 0;
|
||||
new_transport_marker_menu = 0;
|
||||
editor_mixer_strip_width = Wide;
|
||||
|
|
|
@ -1454,15 +1454,16 @@ public:
|
|||
void update_punch_range_view (bool visibility=false);
|
||||
void new_transport_marker_menu_popdown ();
|
||||
void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
|
||||
void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
|
||||
void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
|
||||
void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
|
||||
void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
|
||||
void build_range_marker_menu (bool loop_or_punch);
|
||||
void build_marker_menu (bool);
|
||||
void build_tm_marker_menu ();
|
||||
void build_tempo_or_meter_marker_menu (bool);
|
||||
void build_new_transport_marker_menu ();
|
||||
void dynamic_cast_marker_object (void*, MeterMarker**, TempoMarker**) const;
|
||||
|
||||
Gtk::Menu* tm_marker_menu;
|
||||
Gtk::Menu* tempo_or_meter_marker_menu;
|
||||
Gtk::Menu* marker_menu;
|
||||
Gtk::Menu* session_range_marker_menu;
|
||||
Gtk::Menu* range_marker_menu;
|
||||
|
|
|
@ -490,15 +490,25 @@ Editor::location_gone (Location *location)
|
|||
}
|
||||
|
||||
void
|
||||
Editor::tm_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
|
||||
Editor::tempo_or_meter_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
|
||||
{
|
||||
if (tm_marker_menu == 0) {
|
||||
build_tm_marker_menu ();
|
||||
marker_menu_item = item;
|
||||
|
||||
MeterMarker* mm;
|
||||
TempoMarker* tm;
|
||||
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
||||
|
||||
bool can_remove = false;
|
||||
|
||||
if (mm) {
|
||||
can_remove = mm->meter().movable ();
|
||||
} else if (tm) {
|
||||
can_remove = tm->tempo().movable ();
|
||||
}
|
||||
|
||||
marker_menu_item = item;
|
||||
tm_marker_menu->popup (1, ev->time);
|
||||
|
||||
delete tempo_or_meter_marker_menu;
|
||||
build_tempo_or_meter_marker_menu (can_remove);
|
||||
tempo_or_meter_marker_menu->popup (1, ev->time);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -662,16 +672,18 @@ Editor::build_range_marker_menu (bool loop_or_punch)
|
|||
}
|
||||
|
||||
void
|
||||
Editor::build_tm_marker_menu ()
|
||||
Editor::build_tempo_or_meter_marker_menu (bool can_remove)
|
||||
{
|
||||
using namespace Menu_Helpers;
|
||||
|
||||
tm_marker_menu = new Menu;
|
||||
MenuList& items = tm_marker_menu->items();
|
||||
tm_marker_menu->set_name ("ArdourContextMenu");
|
||||
tempo_or_meter_marker_menu = new Menu;
|
||||
MenuList& items = tempo_or_meter_marker_menu->items();
|
||||
tempo_or_meter_marker_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
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
|
||||
|
@ -972,43 +984,48 @@ Editor::marker_menu_loop_range ()
|
|||
}
|
||||
|
||||
void
|
||||
Editor::marker_menu_edit ()
|
||||
Editor::dynamic_cast_marker_object (void* p, MeterMarker** m, TempoMarker** t) const
|
||||
{
|
||||
MeterMarker* mm;
|
||||
TempoMarker* tm;
|
||||
Marker* marker;
|
||||
|
||||
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
||||
Marker* marker = reinterpret_cast<Marker*> (p);
|
||||
if (!marker) {
|
||||
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if ((mm = dynamic_cast<MeterMarker*> (marker)) != 0) {
|
||||
edit_meter_section (&mm->meter());
|
||||
} else if ((tm = dynamic_cast<TempoMarker*> (marker)) != 0) {
|
||||
edit_tempo_section (&tm->tempo());
|
||||
} else {
|
||||
fatal << X_("programming erorr: unhandled marker type in Editor::marker_menu_edit")
|
||||
*m = dynamic_cast<MeterMarker*> (marker);
|
||||
*t = dynamic_cast<TempoMarker*> (marker);
|
||||
|
||||
if (*m == 0 && *t == 0) {
|
||||
fatal << X_("programming erorr: unhandled marker type in Editor::dynamic_cast_marker_object")
|
||||
<< endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::marker_menu_edit ()
|
||||
{
|
||||
MeterMarker* mm;
|
||||
TempoMarker* tm;
|
||||
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
||||
|
||||
if (mm) {
|
||||
edit_meter_section (&mm->meter());
|
||||
} else if (tm) {
|
||||
edit_tempo_section (&tm->tempo());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::marker_menu_remove ()
|
||||
{
|
||||
MeterMarker* mm;
|
||||
TempoMarker* tm;
|
||||
Marker* marker;
|
||||
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
||||
|
||||
if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
|
||||
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if ((mm = dynamic_cast<MeterMarker*> (marker)) != 0) {
|
||||
if (mm) {
|
||||
remove_meter_marker (marker_menu_item);
|
||||
} else if ((tm = dynamic_cast<TempoMarker*> (marker)) != 0) {
|
||||
} else if (tm) {
|
||||
remove_tempo_marker (marker_menu_item);
|
||||
} else {
|
||||
remove_marker (*marker_menu_item, (GdkEvent*) 0);
|
||||
|
|
|
@ -1152,11 +1152,11 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
break;
|
||||
|
||||
case TempoMarkerItem:
|
||||
tm_marker_context_menu (&event->button, item);
|
||||
tempo_or_meter_marker_context_menu (&event->button, item);
|
||||
break;
|
||||
|
||||
case MeterMarkerItem:
|
||||
tm_marker_context_menu (&event->button, item);
|
||||
tempo_or_meter_marker_context_menu (&event->button, item);
|
||||
break;
|
||||
|
||||
case CrossfadeViewItem:
|
||||
|
|
|
@ -34,8 +34,8 @@ using namespace ARDOUR;
|
|||
using namespace PBD;
|
||||
|
||||
TempoDialog::TempoDialog (TempoMap& map, nframes_t frame, const string & action)
|
||||
: ArdourDialog (_("edit tempo")),
|
||||
bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0, 1.0),
|
||||
: ArdourDialog (_("New Tempo")),
|
||||
bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0),
|
||||
bpm_spinner (bpm_adjustment),
|
||||
ok_button (action),
|
||||
cancel_button (_("Cancel")),
|
||||
|
@ -50,8 +50,8 @@ TempoDialog::TempoDialog (TempoMap& map, nframes_t frame, const string & action)
|
|||
}
|
||||
|
||||
TempoDialog::TempoDialog (TempoSection& section, const string & action)
|
||||
: ArdourDialog ("tempo dialog"),
|
||||
bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0, 1.0),
|
||||
: ArdourDialog ("Edit Tempo"),
|
||||
bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0),
|
||||
bpm_spinner (bpm_adjustment),
|
||||
ok_button (action),
|
||||
cancel_button (_("Cancel")),
|
||||
|
@ -142,6 +142,7 @@ TempoDialog::init (const BBT_Time& when, double bpm, double note_type, bool mova
|
|||
bpm_spinner.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
|
||||
bpm_spinner.signal_button_press_event().connect (sigc::mem_fun (*this, &TempoDialog::bpm_button_press), false);
|
||||
bpm_spinner.signal_button_release_event().connect (sigc::mem_fun (*this, &TempoDialog::bpm_button_release), false);
|
||||
bpm_spinner.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::bpm_changed));
|
||||
when_bar_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
|
||||
when_bar_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TempoDialog::entry_key_release), false);
|
||||
when_beat_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
|
||||
|
@ -149,6 +150,12 @@ TempoDialog::init (const BBT_Time& when, double bpm, double note_type, bool mova
|
|||
note_types.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::note_types_change));
|
||||
}
|
||||
|
||||
void
|
||||
TempoDialog::bpm_changed ()
|
||||
{
|
||||
set_response_sensitive (RESPONSE_ACCEPT, true);
|
||||
}
|
||||
|
||||
bool
|
||||
TempoDialog::bpm_button_press (GdkEventButton*)
|
||||
{
|
||||
|
@ -233,7 +240,7 @@ TempoDialog::note_types_change ()
|
|||
|
||||
|
||||
MeterDialog::MeterDialog (TempoMap& map, nframes_t frame, const string & action)
|
||||
: ArdourDialog ("meter dialog"),
|
||||
: ArdourDialog ("New Meter"),
|
||||
ok_button (action),
|
||||
cancel_button (_("Cancel"))
|
||||
{
|
||||
|
@ -246,7 +253,7 @@ MeterDialog::MeterDialog (TempoMap& map, nframes_t frame, const string & action)
|
|||
}
|
||||
|
||||
MeterDialog::MeterDialog (MeterSection& section, const string & action)
|
||||
: ArdourDialog ("meter dialog"),
|
||||
: ArdourDialog ("Edit Meter"),
|
||||
ok_button (action),
|
||||
cancel_button (_("Cancel"))
|
||||
{
|
||||
|
|
|
@ -35,20 +35,9 @@
|
|||
|
||||
#include "ardour_dialog.h"
|
||||
|
||||
struct TempoDialog : public ArdourDialog
|
||||
class TempoDialog : public ArdourDialog
|
||||
{
|
||||
Gtk::ComboBoxText note_types;
|
||||
std::vector<std::string> strings;
|
||||
Gtk::Adjustment bpm_adjustment;
|
||||
Gtk::SpinButton bpm_spinner;
|
||||
Gtk::Button ok_button;
|
||||
Gtk::Button cancel_button;
|
||||
Gtk::Entry when_bar_entry;
|
||||
Gtk::Entry when_beat_entry;
|
||||
Gtk::Label when_bar_label;
|
||||
Gtk::Label when_beat_label;
|
||||
char buf[64];
|
||||
|
||||
public:
|
||||
TempoDialog (ARDOUR::TempoMap&, nframes_t, const std::string & action);
|
||||
TempoDialog (ARDOUR::TempoSection&, const std::string & action);
|
||||
|
||||
|
@ -63,17 +52,23 @@ private:
|
|||
bool bpm_button_release (GdkEventButton* );
|
||||
bool entry_key_release (GdkEventKey* );
|
||||
void note_types_change ();
|
||||
};
|
||||
|
||||
struct MeterDialog : public ArdourDialog
|
||||
{
|
||||
Gtk::Entry bpb_entry;
|
||||
Gtk::ComboBoxText note_types;
|
||||
std::vector<std::string> strings;
|
||||
Gtk::Adjustment bpm_adjustment;
|
||||
Gtk::SpinButton bpm_spinner;
|
||||
Gtk::Button ok_button;
|
||||
Gtk::Button cancel_button;
|
||||
Gtk::Entry when_bar_entry;
|
||||
Gtk::Entry when_beat_entry;
|
||||
Gtk::Label when_bar_label;
|
||||
Gtk::Label when_beat_label;
|
||||
char buf[64];
|
||||
};
|
||||
|
||||
class MeterDialog : public ArdourDialog
|
||||
{
|
||||
public:
|
||||
|
||||
MeterDialog (ARDOUR::TempoMap&, nframes_t, const std::string & action);
|
||||
MeterDialog (ARDOUR::MeterSection&, const std::string & action);
|
||||
|
@ -87,6 +82,14 @@ private:
|
|||
bool entry_key_press (GdkEventKey* );
|
||||
bool entry_key_release (GdkEventKey* );
|
||||
void note_types_change ();
|
||||
|
||||
Gtk::Entry bpb_entry;
|
||||
Gtk::ComboBoxText note_types;
|
||||
std::vector<std::string> strings;
|
||||
Gtk::Button ok_button;
|
||||
Gtk::Button cancel_button;
|
||||
Gtk::Entry when_bar_entry;
|
||||
char buf[64];
|
||||
};
|
||||
|
||||
#endif /* __ardour_gtk_tempo_dialog_h__ */
|
||||
|
|
|
@ -105,6 +105,8 @@ class MetricSection {
|
|||
*/
|
||||
virtual XMLNode& get_state() const = 0;
|
||||
|
||||
int compare (MetricSection *, bool) const;
|
||||
|
||||
private:
|
||||
BBT_Time _start;
|
||||
nframes64_t _frame;
|
||||
|
|
|
@ -370,17 +370,47 @@ TempoMap::do_insert (MetricSection* section, bool with_bbt)
|
|||
{
|
||||
Metrics::iterator i;
|
||||
|
||||
/* Look for any existing MetricSection that is of the same type and
|
||||
at the same time as the new one, and remove it before adding
|
||||
the new one.
|
||||
*/
|
||||
|
||||
Metrics::iterator to_remove = metrics->end ();
|
||||
|
||||
for (i = metrics->begin(); i != metrics->end(); ++i) {
|
||||
|
||||
if (with_bbt) {
|
||||
if ((*i)->start() < section->start()) {
|
||||
int const c = (*i)->compare (section, with_bbt);
|
||||
|
||||
if (c < 0) {
|
||||
/* this section is before the one to be added; go back round */
|
||||
continue;
|
||||
} else if (c > 0) {
|
||||
/* this section is after the one to be added; there can't be any at the same time */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((*i)->frame() < section->frame()) {
|
||||
|
||||
/* hacky comparison of type */
|
||||
bool const a = dynamic_cast<TempoSection*> (*i) != 0;
|
||||
bool const b = dynamic_cast<TempoSection*> (section) != 0;
|
||||
|
||||
if (a == b) {
|
||||
to_remove = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_remove != metrics->end()) {
|
||||
/* remove the MetricSection at the same time as the one we are about to add */
|
||||
metrics->erase (to_remove);
|
||||
}
|
||||
|
||||
/* Add the given MetricSection */
|
||||
|
||||
for (i = metrics->begin(); i != metrics->end(); ++i) {
|
||||
|
||||
if ((*i)->compare (section, with_bbt) < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
metrics->insert (i, section);
|
||||
break;
|
||||
|
@ -400,7 +430,6 @@ TempoMap::add_tempo (const Tempo& tempo, BBT_Time where)
|
|||
Glib::RWLock::WriterLock lm (lock);
|
||||
|
||||
/* new tempos always start on a beat */
|
||||
|
||||
where.ticks = 0;
|
||||
|
||||
do_insert (new TempoSection (where, tempo.beats_per_minute(), tempo.note_type()), true);
|
||||
|
@ -468,7 +497,6 @@ TempoMap::add_meter (const Meter& meter, BBT_Time where)
|
|||
}
|
||||
|
||||
/* new meters *always* start on a beat. */
|
||||
|
||||
where.ticks = 0;
|
||||
|
||||
do_insert (new MeterSection (where, meter.beats_per_bar(), meter.note_divisor()), true);
|
||||
|
@ -1892,3 +1920,33 @@ TempoMap::bbt_subtract (const BBT_Time& start, const BBT_Time& decrement) const
|
|||
result.bars -= op.bars;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Compare the time of this with that of another MetricSection.
|
||||
* @param with_bbt True to compare using ::start(), false to use ::frame().
|
||||
* @return -1 for less than, 0 for equal, 1 for greater than.
|
||||
*/
|
||||
|
||||
int
|
||||
MetricSection::compare (MetricSection* other, bool with_bbt) const
|
||||
{
|
||||
if (with_bbt) {
|
||||
if (start() == other->start()) {
|
||||
return 0;
|
||||
} else if (start() < other->start()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (frame() == other->frame()) {
|
||||
return 0;
|
||||
} else if (frame() < other->frame()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user