From 19d1132afb8d1877f7b3e7c1ff27a11503f1b56d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 19 Jan 2011 20:54:51 +0000 Subject: [PATCH] Terminate RapidScreenUpdate clock updates earlier when they are not necessary. Fix set from playhead when used on the position clock in the region properties dialogue. Make clocks sample-accurate when they are set in frames and then queried in frames without an edit in-between. git-svn-id: svn://localhost/ardour2/branches/3.0@8547 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.h | 3 +++ gtk2_ardour/audio_clock.cc | 40 +++++++++++++++++++++++++++----------- gtk2_ardour/audio_clock.h | 7 +++++++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 81cbd65308..a0ea33a354 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -174,6 +174,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr static sigc::signal Blink; static sigc::signal RapidScreenUpdate; static sigc::signal SuperRapidScreenUpdate; + /** Emitted frequently with the audible frame, false, and the edit point as + * parameters respectively. + */ static sigc::signal Clock; XMLNode* editor_settings() const; diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 4e29cc3c8b..6e65e512b2 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -80,7 +80,9 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string& colon5 (":"), b1 ("|"), b2 ("|"), - last_when(0) + last_when(0), + _canonical_time_is_displayed (true), + _canonical_time (0) { last_when = 0; last_pdelta = 0; @@ -416,17 +418,12 @@ AudioClock::on_realize () void AudioClock::set (framepos_t when, bool force, framecnt_t offset, char which) { - if ((!force && !is_visible()) || _session == 0) { return; } - if (when == last_when && !offset && !force) { - return; - } - - bool pdelta = Config->get_primary_clock_delta_edit_cursor(); - bool sdelta = Config->get_secondary_clock_delta_edit_cursor(); + bool const pdelta = Config->get_primary_clock_delta_edit_cursor (); + bool const sdelta = Config->get_secondary_clock_delta_edit_cursor (); if (offset && which == 'p' && pdelta) { when = (when > offset) ? when - offset : offset - when; @@ -434,13 +431,17 @@ AudioClock::set (framepos_t when, bool force, framecnt_t offset, char which) when = (when > offset) ? when - offset : offset - when; } + if (when == last_when && !force) { + return; + } + if (which == 'p' && pdelta && !last_pdelta) { set_widget_name("TransportClockDisplayDelta"); last_pdelta = true; } else if (which == 'p' && !pdelta && last_pdelta) { set_widget_name("TransportClockDisplay"); last_pdelta = false; - } else if (which == 's' && sdelta && !last_sdelta) { + } else if (which == 's' && sdelta && !last_sdelta) { set_widget_name("SecondaryClockDisplayDelta"); last_sdelta = true; } else if (which == 's' && !sdelta && last_sdelta) { @@ -470,6 +471,10 @@ AudioClock::set (framepos_t when, bool force, framecnt_t offset, char which) } last_when = when; + + /* we're setting the time from a frames value, so keep it as the canonical value */ + _canonical_time = when; + _canonical_time_is_displayed = false; } void @@ -891,6 +896,7 @@ AudioClock::field_key_release_event (GdkEventKey *ev, Field field) new_text += new_char; label->set_text (new_text); + _canonical_time_is_displayed = true; key_entry_state++; } @@ -916,10 +922,12 @@ AudioClock::field_key_release_event (GdkEventKey *ev, Field field) // Bars should never be, unless this clock is for a duration if (atoi(bars_label.get_text()) == 0 && !is_duration) { bars_label.set_text("001"); + _canonical_time_is_displayed = true; } // beats should never be 0, unless this clock is for a duration if (atoi(beats_label.get_text()) == 0 && !is_duration) { beats_label.set_text("01"); + _canonical_time_is_displayed = true; } break; default: @@ -1134,7 +1142,6 @@ AudioClock::field_button_release_event (GdkEventButton *ev, Field field) } if (Keyboard::is_context_menu_event (ev)) { - cerr << "Context menu event on clock\n"; if (ops_menu == 0) { build_ops_menu (); } @@ -1397,6 +1404,10 @@ AudioClock::get_frames (Field field, framepos_t pos, int dir) framepos_t AudioClock::current_time (framepos_t pos) const { + if (!_canonical_time_is_displayed) { + return _canonical_time; + } + framepos_t ret = 0; switch (_mode) { @@ -1456,26 +1467,31 @@ AudioClock::timecode_sanitize_display() // Check Timecode fields for sanity, possibly adjusting values if (atoi(minutes_label.get_text()) > 59) { minutes_label.set_text("59"); + _canonical_time_is_displayed = true; } if (atoi(seconds_label.get_text()) > 59) { seconds_label.set_text("59"); + _canonical_time_is_displayed = true; } switch ((long)rint(_session->timecode_frames_per_second())) { case 24: if (atoi(frames_label.get_text()) > 23) { frames_label.set_text("23"); + _canonical_time_is_displayed = true; } break; case 25: if (atoi(frames_label.get_text()) > 24) { frames_label.set_text("24"); + _canonical_time_is_displayed = true; } break; case 30: if (atoi(frames_label.get_text()) > 29) { frames_label.set_text("29"); + _canonical_time_is_displayed = true; } break; default: @@ -1485,6 +1501,7 @@ AudioClock::timecode_sanitize_display() if (_session->timecode_drop_frames()) { if ((atoi(minutes_label.get_text()) % 10) && (atoi(seconds_label.get_text()) == 0) && (atoi(frames_label.get_text()) < 2)) { frames_label.set_text("02"); + _canonical_time_is_displayed = true; } } } @@ -1976,8 +1993,9 @@ AudioClock::set_from_playhead () if (!_session) { return; } - + set (_session->transport_frame()); + ValueChanged (); } void diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index f07b12d4c5..25eab1a3ba 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -183,6 +183,13 @@ class AudioClock : public Gtk::HBox, public ARDOUR::SessionHandlePtr double drag_y; double drag_accum; + /** true if the time of this clock is the one displayed in its widgets. + * if false, the time in the widgets is an approximation of _canonical_time, + * and _canonical_time should be returned as the `current' time of the clock. + */ + bool _canonical_time_is_displayed; + framepos_t _canonical_time; + void on_realize (); bool field_motion_notify_event (GdkEventMotion *ev, Field);