summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-05-02 23:14:43 +0000
committerCarl Hetherington <carl@carlh.net>2010-05-02 23:14:43 +0000
commitc2da4ec8f988f6f8b9e426b03222a2c687c72edb (patch)
tree0223f8268e4462f0f1494c2795adb6367cee975a /gtk2_ardour
parentceb1025c2c8ab1246a51c3967ee5a79773a4e008 (diff)
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
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc2
-rw-r--r--gtk2_ardour/editor.h7
-rw-r--r--gtk2_ardour/editor_markers.cc75
-rw-r--r--gtk2_ardour/editor_mouse.cc4
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc2
-rw-r--r--gtk2_ardour/tempo_dialog.cc19
-rw-r--r--gtk2_ardour/tempo_dialog.h37
7 files changed, 87 insertions, 59 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 754b10f4da..98480743e0 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -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;
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index ca6ff920c8..7040bafa8a 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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;
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index 81ad022ce0..dad515671e 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -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;
- tm_marker_menu->popup (1, ev->time);
+
+ 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 ();
+ }
+
+ 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_remove ()
+Editor::marker_menu_edit ()
{
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) {
+ edit_meter_section (&mm->meter());
+ } else if (tm) {
+ edit_tempo_section (&tm->tempo());
}
+}
+
+void
+Editor::marker_menu_remove ()
+{
+ MeterMarker* mm;
+ TempoMarker* tm;
+ dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
- 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);
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 197121eb06..bd55c04b5e 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -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:
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index fd598b8c81..edfaee3694 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -296,7 +296,7 @@ Editor::remove_tempo_marker (ArdourCanvas::Item* item)
}
if (tempo_marker->tempo().movable()) {
- Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::real_remove_tempo_marker), &tempo_marker->tempo()));
+ Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::real_remove_tempo_marker), &tempo_marker->tempo()));
}
}
diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc
index 93cb5fcf01..71fd5b40b4 100644
--- a/gtk2_ardour/tempo_dialog.cc
+++ b/gtk2_ardour/tempo_dialog.cc
@@ -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"))
{
diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h
index c75f60ac23..c1a88367ca 100644
--- a/gtk2_ardour/tempo_dialog.h
+++ b/gtk2_ardour/tempo_dialog.h
@@ -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,18 +52,24 @@ 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__ */