Merged with trunk revision 600
[ardour.git] / gtk2_ardour / audio_clock.cc
index 2aa9387379a4f505870a408d1eda3e52d926d38c..25985c4a3b956ae1f7adc8c59e6679baac6e2211 100644 (file)
@@ -195,6 +195,8 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool
        clock_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::SCROLL_MASK);
        clock_base.signal_button_release_event().connect (bind (mem_fun (*this, &AudioClock::field_button_release_event), SMPTE_Hours));
 
+       Session::SMPTEOffsetChanged.connect (mem_fun (*this, &AudioClock::smpte_offset_changed));
+
        if (editable) {
                setup_events ();
        }
@@ -389,6 +391,25 @@ AudioClock::set (jack_nframes_t when, bool force)
        last_when = when;
 }
 
+void
+AudioClock::smpte_offset_changed ()
+{
+       jack_nframes_t current;
+
+       switch (_mode) {
+       case SMPTE:
+               if (is_duration) {
+                       current = current_duration();
+               } else {
+                       current = current_time ();
+               }
+               set (current, true);
+               break;
+       default:
+               break;
+       }
+}
+
 void
 AudioClock::set_frames (jack_nframes_t when, bool force)
 {
@@ -446,9 +467,9 @@ AudioClock::set_smpte (jack_nframes_t when, bool force)
 
        if (force || smpte.hours != last_hrs || smpte.negative != last_negative) {
                if (smpte.negative) {
-                       sprintf (buf, "-%02ld", smpte.hours);
+                       sprintf (buf, "-%02" PRIu32, smpte.hours);
                } else {
-                       sprintf (buf, " %02ld", smpte.hours);
+                       sprintf (buf, " %02" PRIu32, smpte.hours);
                }
                hours_label.set_text (buf);
                last_hrs = smpte.hours;
@@ -456,19 +477,19 @@ AudioClock::set_smpte (jack_nframes_t when, bool force)
        }
 
        if (force || smpte.minutes != last_mins) {
-               sprintf (buf, "%02ld", smpte.minutes);
+               sprintf (buf, "%02" PRIu32, smpte.minutes);
                minutes_label.set_text (buf);
                last_mins = smpte.minutes;
        }
 
        if (force || smpte.seconds != last_secs) {
-               sprintf (buf, "%02ld", smpte.seconds);
+               sprintf (buf, "%02" PRIu32, smpte.seconds);
                seconds_label.set_text (buf);
                last_secs = smpte.seconds;
        }
 
        if (force || smpte.frames != last_frames) {
-               sprintf (buf, "%02ld", smpte.frames);
+               sprintf (buf, "%02" PRIu32, smpte.frames);
                frames_label.set_text (buf);
                last_frames = smpte.frames;
        }
@@ -1267,7 +1288,7 @@ AudioClock::smpte_frame_from_display () const
        smpte.minutes = atoi (minutes_label.get_text());
        smpte.seconds = atoi (seconds_label.get_text());
        smpte.frames = atoi (frames_label.get_text());
-       
+
        session->smpte_to_sample( smpte, sample, false /* use_offset */, false /* use_subframes */ );