diff options
author | Robin Gareus <robin@gareus.org> | 2014-01-17 00:20:58 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-01-17 00:20:58 +0100 |
commit | b4462b3d22f57f3fe7f4e933b2df0e2c89148e78 (patch) | |
tree | 114d4c04b6206b199c1c627900a2cbfe1d31007d /gtk2_ardour | |
parent | 10933e200369ecceb2c8b3a52be41b930955d269 (diff) |
add seeking to sfdb auditioner
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/sfdb_ui.cc | 49 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.h | 11 |
2 files changed, 58 insertions, 2 deletions
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 9b3d78e86d..54faae5654 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -120,7 +120,9 @@ SoundFileBox::SoundFileBox (bool persistent) length_clock ("sfboxLengthClock", !persistent, "", false, false, true, false), timecode_clock ("sfboxTimecodeClock", !persistent, "", false, false, false, false), main_box (false, 6), - autoplay_btn (_("Auto-play")) + autoplay_btn (_("Auto-play")), + seek_slider(0,1000,1), + _seeking(false) { set_name (X_("SoundFileBox")); @@ -198,9 +200,18 @@ SoundFileBox::SoundFileBox (bool persistent) bottom_box.pack_start(stop_btn, true, true); bottom_box.pack_start(autoplay_btn, false, false); + seek_slider.set_draw_value(false); + + seek_slider.add_events(Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); + seek_slider.signal_button_press_event().connect(sigc::mem_fun(*this, &SoundFileBox::seek_button_press), false); + seek_slider.signal_button_release_event().connect(sigc::mem_fun(*this, &SoundFileBox::seek_button_release), false); + main_box.pack_start (seek_slider, false, false); + play_btn.signal_clicked().connect (sigc::mem_fun (*this, &SoundFileBox::audition)); stop_btn.signal_clicked().connect (sigc::mem_fun (*this, &SoundFileBox::stop_audition)); + stop_btn.set_sensitive (false); + channels_value.set_alignment (0.0f, 0.5f); samplerate_value.set_alignment (0.0f, 0.5f); } @@ -216,10 +227,46 @@ SoundFileBox::set_session(Session* s) if (!_session) { play_btn.set_sensitive (false); stop_btn.set_sensitive (false); + auditioner_connections.drop_connections(); + } else { + auditioner_connections.drop_connections(); + _session->AuditionActive.connect(auditioner_connections, invalidator (*this), boost::bind (&SoundFileBox::audition_active, this, _1), gui_context()); + _session->the_auditioner()->AuditionProgress.connect(auditioner_connections, invalidator (*this), boost::bind (&SoundFileBox::audition_progress, this, _1, _2), gui_context()); + } +} + +void +SoundFileBox::audition_active(bool active) { + stop_btn.set_sensitive (active); + seek_slider.set_sensitive (active); + if (!active) { + seek_slider.set_value(0); + } +} + +void +SoundFileBox::audition_progress(ARDOUR::framecnt_t pos, ARDOUR::framecnt_t len) { + if (!_seeking) { + seek_slider.set_value( 1000.0 * pos / len); + seek_slider.set_sensitive (true); } } bool +SoundFileBox::seek_button_press(GdkEventButton*) { + _seeking = true; + return false; // pass on to slider +} + +bool +SoundFileBox::seek_button_release(GdkEventButton*) { + _seeking = false; + _session->the_auditioner()->seek_to_percent(seek_slider.get_value() / 10.0); + seek_slider.set_sensitive (false); + return false; // pass on to slider +} + +bool SoundFileBox::setup_labels (const string& filename) { if (!path.empty()) { diff --git a/gtk2_ardour/sfdb_ui.h b/gtk2_ardour/sfdb_ui.h index 5d8decddf4..ccfd3799be 100644 --- a/gtk2_ardour/sfdb_ui.h +++ b/gtk2_ardour/sfdb_ui.h @@ -36,6 +36,7 @@ #include <gtkmm/filechooserwidget.h> #include <gtkmm/frame.h> #include <gtkmm/label.h> +#include <gtkmm/scale.h> #include <gtkmm/textview.h> #include <gtkmm/table.h> #include <gtkmm/liststore.h> @@ -57,7 +58,7 @@ namespace ARDOUR { class GainMeter; class Mootcher; -class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr +class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList { public: SoundFileBox (bool persistent); @@ -103,11 +104,19 @@ class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr Gtk::Button stop_btn; Gtk::CheckButton autoplay_btn; Gtk::Button apply_btn; + Gtk::HScale seek_slider; + + PBD::ScopedConnectionList auditioner_connections; + void audition_active(bool); + void audition_progress(ARDOUR::framecnt_t, ARDOUR::framecnt_t); bool tags_entry_left (GdkEventFocus* event); void tags_changed (); void save_tags (const std::vector<std::string>&); void stop_audition (); + bool seek_button_press(GdkEventButton*); + bool seek_button_release(GdkEventButton*); + bool _seeking; }; class SoundFileBrowser : public ArdourWindow |