diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-11-30 16:43:11 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-11-30 16:43:11 +0000 |
commit | 9f2164b4f3b030177a229ddc3e87eb431af1bd54 (patch) | |
tree | 70a456e369c106be91a5d6dcb86cbb2eb4c8d0ad /gtk2_ardour/audio_clock.cc | |
parent | 9cca1464a8b031cfb26e541b6ca2d242e3df7c81 (diff) |
timecode clock info patch from oofus, big clock mods from oofus, rec-sensitive color in big clock, update all transport clocks when changing playhead, bounds check for automation bug
git-svn-id: svn://localhost/ardour2/trunk@1173 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/audio_clock.cc')
-rw-r--r-- | gtk2_ardour/audio_clock.cc | 227 |
1 files changed, 140 insertions, 87 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 270da7ab11..87a6257fee 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -58,7 +58,7 @@ const uint32_t AudioClock::field_length[(int) AudioClock::AudioFrames+1] = { 10 /* Audio Frame */ }; -AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool with_extras) +AudioClock::AudioClock (std::string name, bool allow_edit, bool duration, bool with_info) : is_duration (duration), editable (allow_edit), colon1 (":"), @@ -75,9 +75,48 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool ops_menu = 0; dragging = false; + if (with_info) { + frames_upper_info_label = manage (new Label); + frames_lower_info_label = manage (new Label); + smpte_upper_info_label = manage (new Label); + smpte_lower_info_label = manage (new Label); + bbt_upper_info_label = manage (new Label); + bbt_lower_info_label = manage (new Label); + + frames_upper_info_label->set_name ("AudioClockFramesUpperInfo"); + frames_lower_info_label->set_name ("AudioClockFramesLowerInfo"); + smpte_upper_info_label->set_name ("AudioClockSMPTEUpperInfo"); + smpte_lower_info_label->set_name ("AudioClockSMPTELowerInfo"); + bbt_upper_info_label->set_name ("AudioClockBBTUpperInfo"); + bbt_lower_info_label->set_name ("AudioClockBBTLowerInfo"); + + frames_info_box.pack_start (*frames_upper_info_label, true, true); + frames_info_box.pack_start (*frames_lower_info_label, true, true); + smpte_info_box.pack_start (*smpte_upper_info_label, true, true); + smpte_info_box.pack_start (*smpte_lower_info_label, true, true); + bbt_info_box.pack_start (*bbt_upper_info_label, true, true); + bbt_info_box.pack_start (*bbt_lower_info_label, true, true); + + } else { + frames_upper_info_label = 0; + frames_lower_info_label = 0; + smpte_upper_info_label = 0; + smpte_lower_info_label = 0; + bbt_upper_info_label = 0; + bbt_lower_info_label = 0; + } + audio_frames_ebox.add (audio_frames_label); - frames_packer_hbox.set_border_width (2); - frames_packer_hbox.pack_start (audio_frames_ebox, false, false); + + frames_packer.set_homogeneous (false); + frames_packer.set_border_width (2); + frames_packer.pack_start (audio_frames_ebox, false, false); + + if (with_info) { + frames_packer.pack_start (frames_info_box, false, false, 5); + } + + frames_packer_hbox.pack_start (frames_packer, true, false); hours_ebox.add (hours_label); minutes_ebox.add (minutes_label); @@ -100,6 +139,10 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool smpte_packer.pack_start (colon3, false, false); smpte_packer.pack_start (frames_ebox, false, false); + if (with_info) { + smpte_packer.pack_start (smpte_info_box, false, false, 5); + } + smpte_packer_hbox.pack_start (smpte_packer, true, false); bbt_packer.set_homogeneous (false); @@ -110,34 +153,8 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool bbt_packer.pack_start (b2, false, false); bbt_packer.pack_start (ticks_ebox, false, false); - if (with_extras) { - - framerate_label = manage (new Label); - pullup_label = manage (new Label); - - framerate_label->set_name ("BBTMeterLabel"); - pullup_label->set_name ("BBTTempoLabel"); - - rate_pullup_box.pack_start (*framerate_label, true, true); - rate_pullup_box.pack_start (*pullup_label, true, true); - - smpte_packer.pack_start (rate_pullup_box, false,false, 5); - - meter_label = manage (new Label); - tempo_label = manage (new Label); - - meter_label->set_name ("BBTMeterLabel"); - tempo_label->set_name ("BBTTempoLabel"); - - tempo_meter_box.pack_start (*meter_label, true, true); - tempo_meter_box.pack_start (*tempo_label, true, true); - - bbt_packer.pack_start (tempo_meter_box, false, false, 5); - } else { - framerate_label = 0; - pullup_label = 0; - meter_label = 0; - tempo_label = 0; + if (with_info) { + bbt_packer.pack_start (bbt_info_box, false, false, 5); } bbt_packer_hbox.pack_start (bbt_packer, true, false); @@ -152,7 +169,46 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool minsec_packer_hbox.pack_start (minsec_packer, true, false); + clock_frame.set_shadow_type (Gtk::SHADOW_IN); + clock_frame.set_name ("BaseFrame"); + + clock_frame.add (clock_base); + set_name (name); + + _mode = BBT; /* lie to force mode switch */ + set_mode (SMPTE); + + pack_start (clock_frame, true, true); + + /* the clock base handles button releases for menu popup regardless of + editable status. if the clock is editable, the clock base is where + we pass focus to after leaving the last editable "field", which + will then shutdown editing till the user starts it up again. + + it does this because the focus out event on the field disables + keyboard event handling, and we don't connect anything up to + notice focus in on the clock base. hence, keyboard event handling + stays disabled. + */ + + 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 (); + } + + set (last_when, true); +} + +void +AudioClock::set_name (string name) +{ + Widget::set_name (name); + clock_base.set_name (name); audio_frames_label.set_name (name); @@ -186,37 +242,7 @@ AudioClock::AudioClock (const string& name, bool allow_edit, bool duration, bool b1.set_name (name); b2.set_name (name); - clock_frame.set_shadow_type (Gtk::SHADOW_IN); - clock_frame.set_name ("BaseFrame"); - - clock_frame.add (clock_base); - - _mode = BBT; /* lie to force mode switch */ - set_mode (SMPTE); - - pack_start (clock_frame, true, true); - - /* the clock base handles button releases for menu popup regardless of - editable status. if the clock is editable, the clock base is where - we pass focus to after leaving the last editable "field", which - will then shutdown editing till the user starts it up again. - - it does this because the focus out event on the field disables - keyboard event handling, and we don't connect anything up to - notice focus in on the clock base. hence, keyboard event handling - stays disabled. - */ - - 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 (); - } - - set (last_when, true); + queue_draw (); } void @@ -404,6 +430,27 @@ AudioClock::set_frames (nframes_t when, bool force) char buf[32]; snprintf (buf, sizeof (buf), "%u", when); audio_frames_label.set_text (buf); + + if (frames_upper_info_label) { + nframes_t rate = session->frame_rate(); + + if (fmod (rate, 1000.0) == 0.000) { + sprintf (buf, "%uK", rate/1000); + } else { + sprintf (buf, "%.3fK", rate/1000.0f); + } + + frames_upper_info_label->set_text (buf); + + float vid_pullup = Config->get_video_pullup(); + + if (vid_pullup == 0.0) { + frames_lower_info_label->set_text(_("none")); + } else { + sprintf (buf, "%-6.4f", vid_pullup); + frames_lower_info_label->set_text (buf); + } + } } void @@ -481,19 +528,25 @@ AudioClock::set_smpte (nframes_t when, bool force) frames_label.set_text (buf); last_frames = smpte.frames; } - - if (framerate_label) { - sprintf (buf, "%-5.2f", Config->get_smpte_frames_per_second()); - framerate_label->set_text (buf); - - float x = Config->get_video_pullup(); - - if (x == 0.0) { - pullup_label->set_text (_("none")); + + if (smpte_upper_info_label) { + float smpte_frames = Config->get_smpte_frames_per_second(); + + if ( fmod(smpte_frames, 1.0) == 0.0) { + sprintf (buf, "%u", int (smpte_frames)); + } else { + sprintf (buf, "%.2f", smpte_frames); + } + + smpte_upper_info_label->set_text (buf); + + if (Config->get_smpte_drop_frames()) { + sprintf (buf, "DF"); } else { - sprintf (buf, "%-6.4f", x); - pullup_label->set_text (buf); + sprintf (buf, "NDF"); } + + smpte_lower_info_label->set_text (buf); } } @@ -511,12 +564,12 @@ AudioClock::set_bbt (nframes_t when, bool force) sprintf (buf, "%04" PRIu32, bbt.ticks); ticks_label.set_text (buf); - if (meter_label) { + if (bbt_upper_info_label) { TempoMap::Metric m (session->tempo_map().metric_at (when)); sprintf (buf, "%-5.2f", m.tempo().beats_per_minute()); - tempo_label->set_text (buf); + bbt_lower_info_label->set_text (buf); sprintf (buf, "%g|%g", m.meter().beats_per_bar(), m.meter().note_divisor()); - meter_label->set_text (buf); + bbt_upper_info_label->set_text (buf); } } @@ -1812,26 +1865,26 @@ AudioClock::set_size_requests () switch (_mode) { case SMPTE: - Gtkmm2ext::set_size_request_to_display_given_text (hours_label, "-88", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (minutes_label, "88", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (seconds_label, "88", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (frames_label, "88", 2, 2); + 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); break; case BBT: - Gtkmm2ext::set_size_request_to_display_given_text (bars_label, "-888", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (beats_label, "88", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (ticks_label, "8888", 2, 2); + 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); break; case MinSec: - Gtkmm2ext::set_size_request_to_display_given_text (ms_hours_label, "99", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (ms_minutes_label, "99", 2, 2); - Gtkmm2ext::set_size_request_to_display_given_text (ms_seconds_label, "99.999", 2, 2); + 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); break; case Frames: - Gtkmm2ext::set_size_request_to_display_given_text (audio_frames_label, "4294967296", 2, 2); + Gtkmm2ext::set_size_request_to_display_given_text (audio_frames_label, "0000000000", 5, 5); break; case Off: |