AudioUnit work.
[ardour.git] / gtk2_ardour / audio_clock.cc
index d7eb1e59369aaae3a0f34adbda657dc46791dd11..8c6f3a7d8277f7ffddafe4f9821a7b708b89ff2f 100644 (file)
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
 
 using PBD::atoi;
+using PBD::atof;
 
 const uint32_t AudioClock::field_length[(int) AudioClock::AudioFrames+1] = {
        2,   /* SMPTE_Hours */
@@ -194,6 +196,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 ();
        }
@@ -388,6 +392,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)
 {
@@ -435,7 +458,7 @@ void
 AudioClock::set_smpte (jack_nframes_t when, bool force)
 {
        char buf[32];
-       SMPTE_Time smpte;
+       SMPTE::Time smpte;
        
        if (is_duration) {
                session->smpte_duration (when, smpte);
@@ -445,9 +468,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;
@@ -455,19 +478,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;
        }
@@ -1259,14 +1282,14 @@ AudioClock::smpte_frame_from_display () const
                return 0;
        }
        
-       SMPTE_Time smpte;
+       SMPTE::Time smpte;
        jack_nframes_t sample;
        
        smpte.hours = atoi (hours_label.get_text());
        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 */ );
        
 
@@ -1280,10 +1303,10 @@ AudioClock::smpte_frame_from_display () const
 #define SMPTE_SAMPLE_TEST_7
 
        // Testcode for smpte<->sample conversions (P.S.)
-       SMPTE_Time smpte1;
+       SMPTE::Time smpte1;
        jack_nframes_t sample1;
        jack_nframes_t oldsample = 0;
-       SMPTE_Time smpte2;
+       SMPTE::Time smpte2;
        jack_nframes_t sample_increment;
 
        sample_increment = (long)rint(session->frame_rate() / session->smpte_frames_per_second);
@@ -1735,9 +1758,8 @@ AudioClock::set_mode (Mode m)
           started editing the clock and then we switch clock mode.
        */
 
-       // GTK2FIX might need an equivalent here for drop focus
-
-
+       clock_base.grab_focus ();
+               
        if (_mode == m) {
                return;
        }