summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-10-28 17:09:32 +0000
committerCarl Hetherington <carl@carlh.net>2010-10-28 17:09:32 +0000
commit6f9e9ad23e98ac1b3f52065ad53641cbf4c38f22 (patch)
tree9db23782df87668152fbdf6f16a03651733ec511 /libs
parentd731e4dba1109ba641cea132c004dad71cbc4268 (diff)
Make normalize cancel button work.
git-svn-id: svn://localhost/ardour2/branches/3.0@7935 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/progress.h6
-rw-r--r--libs/ardour/audioregion.cc7
-rw-r--r--libs/ardour/progress.cc13
3 files changed, 25 insertions, 1 deletions
diff --git a/libs/ardour/ardour/progress.h b/libs/ardour/ardour/progress.h
index e252c63bd8..6cd66bdcbe 100644
--- a/libs/ardour/ardour/progress.h
+++ b/libs/ardour/ardour/progress.h
@@ -35,6 +35,11 @@ public:
void ascend ();
void descend (float);
+ bool cancelled () const;
+
+protected:
+ void cancel ();
+
private:
/** Report overall progress.
* @param p Current progress (from 0 to 1)
@@ -49,6 +54,7 @@ private:
};
std::list<Level> _stack;
+ bool _cancelled;
};
}
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 1461e1a3a4..be3b80de87 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -1143,7 +1143,9 @@ AudioRegion::set_scale_amplitude (gain_t g)
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
{
@@ -1173,6 +1175,9 @@ AudioRegion::maximum_amplitude (Progress* p) const
fpos += to_read;
p->set_progress (float (fpos - _start) / _length);
+ if (p->cancelled ()) {
+ return -1;
+ }
}
return maxamp;
diff --git a/libs/ardour/progress.cc b/libs/ardour/progress.cc
index d09309f793..0822b8e616 100644
--- a/libs/ardour/progress.cc
+++ b/libs/ardour/progress.cc
@@ -24,6 +24,7 @@
using namespace std;
ARDOUR::Progress::Progress ()
+ : _cancelled (false)
{
descend (1);
}
@@ -70,3 +71,15 @@ ARDOUR::Progress::set_progress (float p)
set_overall_progress (overall);
}
+
+void
+ARDOUR::Progress::cancel ()
+{
+ _cancelled = true;
+}
+
+bool
+ARDOUR::Progress::cancelled () const
+{
+ return _cancelled;
+}