]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/clock.cpp
Add a dialog to control the clock
[r2c2.git] / source / libr2c2 / clock.cpp
index 93828cb90e5d87f728b4265a3bbed3f48ca03405..286ce966873af6b6735398ba1e5908f879460eda 100644 (file)
@@ -6,7 +6,8 @@ using namespace Msp;
 namespace R2C2 {
 
 Clock::Clock():
-       rate(1)
+       rate(1),
+       stopped(false)
 { }
 
 void Clock::set_rate(float s)
@@ -19,8 +20,16 @@ void Clock::set_current_time(const Time::TimeDelta &t)
        current_time = t;
 }
 
+void Clock::stop(bool s)
+{
+       stopped = s;
+}
+
 void Clock::tick(const Time::TimeDelta &dt)
 {
+       if(stopped)
+               return;
+
        unsigned prev_minute = current_time/Time::min;
        current_time += dt*rate;
        if(current_time>=Time::day)