diff options
author | Carl Hetherington <carl@carlh.net> | 2010-09-20 00:58:25 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-09-20 00:58:25 +0000 |
commit | a2885a430bbb69a72f901d227cacce979f121020 (patch) | |
tree | 191ae276dbbd2e456a0d8edabccd19fee486572c /gtk2_ardour | |
parent | a212e7eec999e696dde6d4747b783fb6098bdb47 (diff) |
Add progress bar to strip silence dialogue. Fixes #3103.
git-svn-id: svn://localhost/ardour2/branches/3.0@7809 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 21 | ||||
-rw-r--r-- | gtk2_ardour/strip_silence_dialog.cc | 9 | ||||
-rw-r--r-- | gtk2_ardour/strip_silence_dialog.h | 5 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 1 |
5 files changed, 33 insertions, 6 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 9063599e23..9e5e065ecd 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -127,6 +127,7 @@ class EditorLocations; class EditorSnapshots; class EditorSummary; class RegionLayeringOrderEditor; +class ProgressReporter; /* <CMT Additions> */ class ImageFrameView; @@ -1910,7 +1911,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* audio filters */ - void apply_filter (ARDOUR::Filter&, std::string cmd); + void apply_filter (ARDOUR::Filter&, std::string cmd, ProgressReporter* progress = 0); Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv); void apply_midi_note_edit_op (ARDOUR::MidiOperator& op); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 10d8410dad..426e42ced2 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4740,7 +4740,7 @@ Editor::strip_region_silence () if (r == Gtk::RESPONSE_OK) { StripSilence s (*_session, d.threshold (), d.minimum_length (), d.fade_length ()); - apply_filter (s, _("strip silence")); + apply_filter (s, _("strip silence"), &d); } } @@ -4855,7 +4855,7 @@ Editor::quantize_region () } void -Editor::apply_filter (Filter& filter, string command) +Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress) { RegionSelection rs; @@ -4870,6 +4870,9 @@ Editor::apply_filter (Filter& filter, string command) track_canvas->get_window()->set_cursor (*wait_cursor); gdk_flush (); + int n = 0; + int const N = rs.size (); + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ) { RegionSelection::iterator tmp = r; ++tmp; @@ -4878,10 +4881,14 @@ Editor::apply_filter (Filter& filter, string command) if (arv) { boost::shared_ptr<Playlist> playlist = arv->region()->playlist(); - if (arv->audio_region()->apply (filter) == 0) { + if (progress) { + progress->descend (1.0 / N); + } + + if (arv->audio_region()->apply (filter, progress) == 0) { playlist->clear_changes (); - + if (filter.results.empty ()) { /* no regions returned; remove the old one */ @@ -4907,9 +4914,15 @@ Editor::apply_filter (Filter& filter, string command) } else { goto out; } + + if (progress) { + progress->ascend (); + progress->set_progress (float (n + 1) / N); + } } r = tmp; + ++n; } commit_reversible_command (); diff --git a/gtk2_ardour/strip_silence_dialog.cc b/gtk2_ardour/strip_silence_dialog.cc index 936c071290..d0f806e71a 100644 --- a/gtk2_ardour/strip_silence_dialog.cc +++ b/gtk2_ardour/strip_silence_dialog.cc @@ -53,6 +53,7 @@ StripSilenceDialog* StripSilenceDialog::current = 0; /** Construct Strip silence dialog box */ StripSilenceDialog::StripSilenceDialog (Session* s, list<boost::shared_ptr<ARDOUR::AudioRegion> > const & regions) : ArdourDialog (_("Strip Silence")) + , ProgressReporter () , _minimum_length (X_("silence duration"), true, "SilenceDurationClock", true, false, true, false) , _fade_length (X_("silence duration"), true, "SilenceDurationClock", true, false, true, false) , _wave_width (640) @@ -143,6 +144,8 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list<boost::shared_ptr<ARDOU get_vbox()->pack_start (*_canvas, true, true); + get_vbox()->pack_start (_progress_bar, true, true); + show_all (); _threshold.get_adjustment()->signal_value_changed().connect (sigc::mem_fun (*this, &StripSilenceDialog::threshold_changed)); @@ -560,3 +563,9 @@ StripSilenceDialog::Wave::~Wave () delete *i; } } + +void +StripSilenceDialog::update_progress_gui (float p) +{ + _progress_bar.set_fraction (p); +} diff --git a/gtk2_ardour/strip_silence_dialog.h b/gtk2_ardour/strip_silence_dialog.h index 1e8b140358..3b800eb115 100644 --- a/gtk2_ardour/strip_silence_dialog.h +++ b/gtk2_ardour/strip_silence_dialog.h @@ -23,6 +23,7 @@ #include "ardour/types.h" #include "ardour_dialog.h" #include "canvas.h" +#include "progress_reporter.h" namespace ARDOUR { class AudioRegion; @@ -30,7 +31,7 @@ namespace ARDOUR { } /// Dialog box to set options for the `strip silence' filter -class StripSilenceDialog : public ArdourDialog +class StripSilenceDialog : public ArdourDialog, public ProgressReporter { public: StripSilenceDialog (ARDOUR::Session*, std::list<boost::shared_ptr<ARDOUR::AudioRegion> > const &); @@ -52,6 +53,7 @@ private: void resize_silence_rects (); void update_threshold_line (); void threshold_changed (); + void update_progress_gui (float); Gtk::SpinButton _threshold; AudioClock _minimum_length; @@ -59,6 +61,7 @@ private: Gtk::Label _segment_count_label; Gtk::Label _shortest_silence_label; Gtk::Label _shortest_audible_label; + Gtk::ProgressBar _progress_bar; typedef std::list<std::pair<ARDOUR::frameoffset_t,ARDOUR::framecnt_t> > SilenceResult; struct Wave { diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index bd5ef56690..2f003a615c 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -167,6 +167,7 @@ gtk2_ardour_sources = [ 'port_matrix_labels.cc', 'port_matrix_row_labels.cc', 'processor_box.cc', + 'progress_reporter.cc', 'prompter.cc', 'public_editor.cc', 'quantize_dialog.cc', |