return;
}
- begin_reversible_command (_("normalize"));
-
set_canvas_cursor (wait_cursor);
gdk_flush ();
if (arv) {
dialog.descend (1.0 / regions);
double const a = arv->audio_region()->maximum_amplitude (&dialog);
+
+ if (a == -1) {
+ /* the user cancelled the operation */
+ set_canvas_cursor (current_canvas_cursor);
+ return;
+ }
+
max_amps.push_back (a);
max_amp = max (max_amp, a);
dialog.ascend ();
}
}
+ begin_reversible_command (_("normalize"));
+
list<double>::const_iterator a = max_amps.begin ();
for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) {
add_button (Stock::CANCEL, RESPONSE_CANCEL);
add_button (_("Normalize"), RESPONSE_ACCEPT);
+
+ signal_response().connect (sigc::mem_fun (*this, &NormalizeDialog::button_clicked));
}
bool
_last_normalization_value = target ();
return r;
}
+
+void
+NormalizeDialog::button_clicked (int r)
+{
+ if (r == RESPONSE_CANCEL) {
+ cancel ();
+ }
+}
private:
void update_progress_gui (float);
+ void button_clicked (int);
Gtk::RadioButton* _normalize_individually;
Gtk::SpinButton* _spin;
void ascend ();
void descend (float);
+ bool cancelled () const;
+
+protected:
+ void cancel ();
+
private:
/** Report overall progress.
* @param p Current progress (from 0 to 1)
};
std::list<Level> _stack;
+ bool _cancelled;
};
}
send_change (PropertyChange (Properties::scale_amplitude));
}
-/** @return the maximum (linear) amplitude of the region */
+/** @return the maximum (linear) amplitude of the region, or a -ve
+ * number if the Progress object reports that the process was cancelled.
+ */
double
AudioRegion::maximum_amplitude (Progress* p) const
{
fpos += to_read;
p->set_progress (float (fpos - _start) / _length);
+ if (p->cancelled ()) {
+ return -1;
+ }
}
return maxamp;
using namespace std;
ARDOUR::Progress::Progress ()
+ : _cancelled (false)
{
descend (1);
}
set_overall_progress (overall);
}
+
+void
+ARDOUR::Progress::cancel ()
+{
+ _cancelled = true;
+}
+
+bool
+ARDOUR::Progress::cancelled () const
+{
+ return _cancelled;
+}