Show a region's sources in its properties dialogue.
[ardour.git] / gtk2_ardour / audio_clock.cc
index 0847031df4afb84673d655679e4440c5095674b6..a7f57c6820c95a11c22afc10f679603220a838fd 100644 (file)
@@ -35,6 +35,7 @@
 #include "audio_clock.h"
 #include "utils.h"
 #include "keyboard.h"
+#include "gui_thread.h"
 #include "i18n.h"
 
 using namespace ARDOUR;
@@ -64,7 +65,7 @@ const uint32_t AudioClock::field_length[(int) AudioClock::AudioFrames+1] = {
        10   /* Audio Frame */
 };
 
-AudioClock::AudioClock (std::string clock_name, bool transient, std::string widget_name, 
+AudioClock::AudioClock (const string& clock_name, bool transient, const string& widget_name, 
                        bool allow_edit, bool follows_playhead, bool duration, bool with_info)
        : _name (clock_name),
          is_transient (transient),
@@ -214,7 +215,7 @@ AudioClock::AudioClock (std::string clock_name, bool transient, std::string widg
        clock_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::SCROLL_MASK);
        clock_base.signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &AudioClock::field_button_release_event), Timecode_Hours));
 
-       Session::TimecodeOffsetChanged.connect (_session_connections, sigc::mem_fun (*this, &AudioClock::timecode_offset_changed));
+       Session::TimecodeOffsetChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::timecode_offset_changed, this), gui_context());
 
        if (editable) {
                setup_events ();
@@ -667,7 +668,7 @@ AudioClock::set_bbt (nframes_t when, bool force)
        }
 
        if (bbt_upper_info_label) {
-               nframes64_t pos;
+               framepos_t pos;
 
                if (bbt_reference_time < 0) {
                        pos = when;
@@ -1492,7 +1493,7 @@ AudioClock::timecode_frame_from_display () const
        }
 
        Timecode::Time timecode;
-       nframes_t sample;
+       framepos_t sample;
 
        timecode.hours = atoi (hours_label.get_text());
        timecode.minutes = atoi (minutes_label.get_text());
@@ -1515,12 +1516,12 @@ AudioClock::timecode_frame_from_display () const
 
        // Testcode for timecode<->sample conversions (P.S.)
        Timecode::Time timecode1;
-       nframes_t sample1;
-       nframes_t oldsample = 0;
+       framepos_t sample1;
+       framepos_t oldsample = 0;
        Timecode::Time timecode2;
-       nframes_t sample_increment;
+       framecnt_t sample_increment;
 
-       sample_increment = (long)rint(_session->frame_rate() / _session->timecode_frames_per_second);
+       sample_increment = (framecnt_t)rint(_session->frame_rate() / _session->timecode_frames_per_second);
 
 #ifdef Timecode_SAMPLE_TEST_1
        // Test 1: use_offset = false, use_subframes = false
@@ -2043,30 +2044,30 @@ AudioClock::set_mode (Mode m)
 void
 AudioClock::set_size_requests ()
 {
-       /* note that in some fonts, "88" is narrower than "00", hence the 2 pixel padding */
+       /* note that in some fonts, "88" is narrower than "00" */
 
        switch (_mode) {
        case Timecode:
-               Gtkmm2ext::set_size_request_to_display_given_text (hours_label, "-00", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (minutes_label, "00", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (seconds_label, "00", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (frames_label, "00", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (hours_label, "-88", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (minutes_label, "88", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (seconds_label, "88", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (frames_label, "88", 5, 5);
                break;
 
        case BBT:
-               Gtkmm2ext::set_size_request_to_display_given_text (bars_label, "-000", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (beats_label, "00", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (ticks_label, "0000", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (bars_label, "-888", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (beats_label, "88", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (ticks_label, "8888", 5, 5);
                break;
 
        case MinSec:
-               Gtkmm2ext::set_size_request_to_display_given_text (ms_hours_label, "00", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (ms_minutes_label, "00", 5, 5);
-               Gtkmm2ext::set_size_request_to_display_given_text (ms_seconds_label, "00.000", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (ms_hours_label, "88", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (ms_minutes_label, "88", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (ms_seconds_label, "88.888", 5, 5);
                break;
 
        case Frames:
-               Gtkmm2ext::set_size_request_to_display_given_text (audio_frames_label, "0000000000", 5, 5);
+               Gtkmm2ext::set_size_request_to_display_given_text (audio_frames_label, "8888888888", 5, 5);
                break;
 
        case Off:
@@ -2077,7 +2078,62 @@ AudioClock::set_size_requests ()
 }
 
 void
-AudioClock::set_bbt_reference (nframes64_t pos)
+AudioClock::set_bbt_reference (framepos_t pos)
 {
        bbt_reference_time = pos;
 }
+
+void
+AudioClock::on_style_changed (const Glib::RefPtr<Style>& old_style)
+{
+       HBox::on_style_changed (old_style);
+
+       /* propagate style changes to all component widgets that should inherit the main one */
+
+       Glib::RefPtr<RcStyle> rcstyle = get_modifier_style();
+
+       clock_base.modify_style (rcstyle);
+       audio_frames_label.modify_style (rcstyle);
+       hours_label.modify_style (rcstyle);
+       minutes_label.modify_style (rcstyle);
+       seconds_label.modify_style (rcstyle);
+       frames_label.modify_style (rcstyle);
+       bars_label.modify_style (rcstyle);
+       beats_label.modify_style (rcstyle);
+       ticks_label.modify_style (rcstyle);
+       ms_hours_label.modify_style (rcstyle);
+       ms_minutes_label.modify_style (rcstyle);
+       ms_seconds_label.modify_style (rcstyle);
+       hours_ebox.modify_style (rcstyle);
+       minutes_ebox.modify_style (rcstyle);
+       seconds_ebox.modify_style (rcstyle);
+       frames_ebox.modify_style (rcstyle);
+       audio_frames_ebox.modify_style (rcstyle);
+       bars_ebox.modify_style (rcstyle);
+       beats_ebox.modify_style (rcstyle);
+       ticks_ebox.modify_style (rcstyle);
+       ms_hours_ebox.modify_style (rcstyle);
+       ms_minutes_ebox.modify_style (rcstyle);
+       ms_seconds_ebox.modify_style (rcstyle);
+
+       colon1.modify_style (rcstyle);
+       colon2.modify_style (rcstyle);
+       colon3.modify_style (rcstyle);
+       colon4.modify_style (rcstyle);
+       colon5.modify_style (rcstyle);
+       b1.modify_style (rcstyle);
+       b2.modify_style (rcstyle);
+
+       set_size_requests ();
+}
+
+void
+AudioClock::set_is_duration (bool yn)
+{
+        if (yn == is_duration) {
+                return;
+        }
+        
+        is_duration = yn;
+        set (last_when, true, 0, 's');
+}