Re-expose timecode offset in the session option editor.
authorCarl Hetherington <carl@carlh.net>
Wed, 1 Dec 2010 20:49:22 +0000 (20:49 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 1 Dec 2010 20:49:22 +0000 (20:49 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8146 d708f5d6-7413-0410-9779-e7cbd77b26cf

12 files changed:
gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_clock.h
gtk2_ardour/editor.cc
gtk2_ardour/editor_actions.cc
gtk2_ardour/option_editor.cc
gtk2_ardour/option_editor.h
gtk2_ardour/session_option_editor.cc
libs/ardour/ardour/session.h
libs/ardour/ardour/session_configuration_vars.h
libs/ardour/session.cc
libs/ardour/session_state.cc
libs/ardour/session_time.cc

index d80e7e5b306a273fab2adb99df22ff93b62d3cc1..1c36391bb69b369c9066c9766b7810f9b306433c 100644 (file)
@@ -216,8 +216,6 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
        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, invalidator (*this), boost::bind (&AudioClock::timecode_offset_changed, this), gui_context());
-
        if (editable) {
                setup_events ();
        }
@@ -475,8 +473,12 @@ AudioClock::set (nframes_t when, bool force, nframes_t offset, char which)
 }
 
 void
-AudioClock::timecode_offset_changed ()
+AudioClock::session_configuration_changed (std::string p)
 {
+       if (p != "timecode-offset" && p != "timecode-offset-negative") {
+               return;
+       }
+       
        nframes_t current;
 
        switch (_mode) {
@@ -697,6 +699,8 @@ AudioClock::set_session (Session *s)
 
        if (_session) {
 
+               _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
+
                XMLProperty* prop;
                XMLNode* node = _session->extra_xml (X_("ClockModes"));
                AudioClock::Mode amode;
index 915dbd79de598b1d409efb692aa2bdecaddd35c7..faab980bcc7854215249a244366dc798e04b271e 100644 (file)
@@ -212,7 +212,7 @@ class AudioClock : public Gtk::HBox, public ARDOUR::SessionHandlePtr
        void build_ops_menu ();
        void setup_events ();
 
-       void timecode_offset_changed ();
+       void session_configuration_changed (std::string);
        void set_size_requests ();
 
        static const uint32_t field_length[(int)AudioFrames+1];
index 63d580c054004c26b94f81fb333e2337b9d81d40..b41282d0df81908a8b95ed7d85c9b6973f98bf4f 100644 (file)
@@ -1090,7 +1090,6 @@ Editor::set_session (Session *t)
        _session->PositionChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::map_position_change, this, _1), gui_context());
        _session->RouteAdded.connect (_session_connections, invalidator (*this), ui_bind (&Editor::handle_new_route, this, _1), gui_context());
        _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_title, this), gui_context());
-       _session->TimecodeOffsetChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_just_timecode, this), gui_context());
        _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::tempo_map_changed, this, _1), gui_context());
        _session->Located.connect (_session_connections, invalidator (*this), boost::bind (&Editor::located, this), gui_context());
        _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::parameter_changed, this, _1), gui_context());
@@ -2429,11 +2428,10 @@ Editor::timecode_snap_to_internal (framepos_t& start, int32_t direction, bool /*
                break;
 
        case SnapToTimecodeSeconds:
-               if (_session->timecode_offset_negative())
-               {
-                       start += _session->timecode_offset ();
+               if (_session->config.get_timecode_offset_negative()) {
+                       start += _session->config.get_timecode_offset ();
                } else {
-                       start -= _session->timecode_offset ();
+                       start -= _session->config.get_timecode_offset ();
                }
                if (((direction == 0) && (start % one_timecode_second > one_timecode_second / 2)) || direction > 0) {
                        start = (framepos_t) ceil ((double) start / one_timecode_second) * one_timecode_second;
@@ -2441,31 +2439,28 @@ Editor::timecode_snap_to_internal (framepos_t& start, int32_t direction, bool /*
                        start = (framepos_t) floor ((double) start / one_timecode_second) * one_timecode_second;
                }
 
-               if (_session->timecode_offset_negative())
-               {
-                       start -= _session->timecode_offset ();
+               if (_session->config.get_timecode_offset_negative()) {
+                       start -= _session->config.get_timecode_offset ();
                } else {
-                       start += _session->timecode_offset ();
+                       start += _session->config.get_timecode_offset ();
                }
                break;
 
        case SnapToTimecodeMinutes:
-               if (_session->timecode_offset_negative())
-               {
-                       start += _session->timecode_offset ();
+               if (_session->config.get_timecode_offset_negative()) {
+                       start += _session->config.get_timecode_offset ();
                } else {
-                       start -= _session->timecode_offset ();
+                       start -= _session->config.get_timecode_offset ();
                }
                if (((direction == 0) && (start % one_timecode_minute > one_timecode_minute / 2)) || direction > 0) {
                        start = (framepos_t) ceil ((double) start / one_timecode_minute) * one_timecode_minute;
                } else {
                        start = (framepos_t) floor ((double) start / one_timecode_minute) * one_timecode_minute;
                }
-               if (_session->timecode_offset_negative())
-               {
-                       start -= _session->timecode_offset ();
+               if (_session->config.get_timecode_offset_negative()) {
+                       start -= _session->config.get_timecode_offset ();
                } else {
-                       start += _session->timecode_offset ();
+                       start += _session->config.get_timecode_offset ();
                }
                break;
        default:
index d92f44be863cb87e0dde7d2ebc6cf4f1a9cc603e..2458e0234eb501de0e701df1276f79b9288b0c4d 100644 (file)
@@ -1241,6 +1241,8 @@ Editor::parameter_changed (std::string p)
                                tact->set_active (s);
                        }
                }
+       } else if (p == "timecode-offset" || p == "timecode-offset-negative") {
+               update_just_timecode ();
        }
 }
 
index af85d879cc7c2a0c8bc85a5f9aaaa1b486c9a3f3..46e10d00b2a72373186ca3b7a90eb8fd90b4dfb4 100644 (file)
@@ -191,6 +191,35 @@ FaderOption::add_to_page (OptionEditorPage* p)
        add_widgets_to_page (p, &_label, &_box);
 }
 
+ClockOption::ClockOption (string const & i, string const & n, sigc::slot<framecnt_t> g, sigc::slot<bool, framecnt_t> s)
+       : Option (i, n)
+       , _clock (X_("timecode-offset"), false, X_("TimecodeOffset"), true, false, true, false)
+       , _get (g)
+       , _set (s)
+{
+       _label.set_text (n + ":");
+       _label.set_alignment (0, 0.5);
+       _label.set_name (X_("OptionsLabel"));
+}
+
+void
+ClockOption::set_state_from_config ()
+{
+       _clock.set (_get ());
+}
+
+void
+ClockOption::add_to_page (OptionEditorPage* p)
+{
+       add_widgets_to_page (p, &_label, &_clock);
+}
+
+void
+ClockOption::set_session (Session* s)
+{
+       _clock.set_session (s);
+}
+          
 OptionEditorPage::OptionEditorPage (Gtk::Notebook& n, std::string const & t)
        : table (1, 3)
 {
index 0258f955aa9b2fe90b54e21b5683fea8a9d265a1..89a69dfe6719498f7f7e126f7f06823984aed9ad 100644 (file)
@@ -27,6 +27,7 @@
 #include <gtkmm/table.h>
 #include "gtkmm2ext/slider_controller.h"
 #include "ardour_dialog.h"
+#include "audio_clock.h"
 #include "ardour/types.h"
 
 /** @file option_editor.h
@@ -357,6 +358,21 @@ private:
        sigc::slot<bool, ARDOUR::gain_t> _set;
 };
 
+class ClockOption : public Option
+{
+public:
+       ClockOption (std::string const &, std::string const &, sigc::slot<ARDOUR::framecnt_t>, sigc::slot<bool, ARDOUR::framecnt_t>);
+       void set_state_from_config ();
+       void add_to_page (OptionEditorPage *);
+       void set_session (ARDOUR::Session *);
+
+private:
+       Gtk::Label _label;
+       AudioClock _clock;
+       sigc::slot<ARDOUR::framecnt_t> _get;
+       sigc::slot<bool, ARDOUR::framecnt_t> _set;
+};
+
 /** Class to represent a single page in an OptionEditor's notebook.
  *  Pages are laid out using a 3-column table; the 1st column is used
  *  to indent non-headings, and the 2nd and 3rd for actual content.
index 2558729c54e0a151d5db00e590634c163d67dae3..36eb87b07e13ca2e114ab26b374d99eee14f4e4a 100644 (file)
@@ -35,6 +35,8 @@ SessionOptionEditor::SessionOptionEditor (Session* s)
        : OptionEditor (&(s->config), _("Session Properties"))
        , _session_config (&(s->config))
 {
+       set_session (s);
+       
         set_name ("SessionProperties");
 
        /* SYNC */
@@ -111,6 +113,24 @@ SessionOptionEditor::SessionOptionEditor (Session* s)
 
        add_option (_("Sync"), vpu);
 
+       ClockOption* co = new ClockOption (
+               "timecode-offset",
+               _("Timecode Offset"),
+               sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_offset),
+               sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_offset)
+               );
+
+       co->set_session (_session);
+       
+       add_option (_("Sync"), co);
+
+       add_option (_("Sync"), new BoolOption (
+                           "timecode-offset-negative",
+                           _("Timecode Offset Negative"),
+                           sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_offset_negative),
+                           sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_offset_negative)
+                           ));
+
        /* FADES */
 
        ComboOption<CrossfadeModel>* cfm = new ComboOption<CrossfadeModel> (
index acdeee8cd443b25ef218fbaad3a302b0c84ecc5e..5e3176d59b93b519fb9accda948bd06f18919a43 100644 (file)
@@ -459,16 +459,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void timecode_duration (framecnt_t, Timecode::Time&) const;
        void timecode_duration_string (char *, framecnt_t) const;
 
-       void           set_timecode_offset (nframes_t);
-       nframes_t      timecode_offset () const { return _timecode_offset; }
-       void           set_timecode_offset_negative (bool);
-       bool           timecode_offset_negative () const { return _timecode_offset_negative; }
-
        nframes_t convert_to_frames_at (nframes_t position, AnyTime const &);
 
        static PBD::Signal1<void, framepos_t> StartTimeChanged;
        static PBD::Signal1<void, framepos_t> EndTimeChanged;
-       static PBD::Signal0<void> TimecodeOffsetChanged;
 
        std::vector<SyncSource> get_available_sync_options() const;
        void   request_sync_source (Slave*);
@@ -1142,8 +1136,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        double _frames_per_timecode_frame; /* has to be floating point because of drop frame */
        nframes_t _frames_per_hour;
        nframes_t _timecode_frames_per_hour;
-       nframes_t _timecode_offset;
-       bool _timecode_offset_negative;
 
        /* cache the most-recently requested time conversions. This helps when we
         * have multiple clocks showing the same time (e.g. the transport frame) */
index 057cff01fe08f492dabda9fea8bd2a5de0805cc6..687932da73de8cad0f11f446518573a86dcf094a 100644 (file)
@@ -51,3 +51,5 @@ CONFIG_VARIABLE (bool, show_group_tabs, "show-group-tabs", true)
 CONFIG_VARIABLE (bool, external_sync, "external-sync", false)
 CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", JACK)
 CONFIG_VARIABLE (InsertMergePolicy, insert_merge_policy, "insert-merge-policy", InsertMergeReject)
+CONFIG_VARIABLE (framecnt_t, timecode_offset, "timecode-offset", 0)
+CONFIG_VARIABLE (bool, timecode_offset_negative, "timecode-offset-negative", true)
index 325820b601493905d58905fcca76005fdc293f7a..5abaaf3508a3df6ec1becd981da22073b34b1bca 100644 (file)
@@ -119,7 +119,6 @@ PBD::Signal2<int,nframes_t,nframes_t> Session::AskAboutSampleRateMismatch;
 PBD::Signal0<void> Session::SendFeedback;
 PBD::Signal3<int,Session*,std::string,DataType> Session::MissingFile;
 
-PBD::Signal0<void> Session::TimecodeOffsetChanged;
 PBD::Signal1<void, framepos_t> Session::StartTimeChanged;
 PBD::Signal1<void, framepos_t> Session::EndTimeChanged;
 PBD::Signal0<void> Session::AutoBindingOn;
index f810e3fa121866d9657580c4ef000e2c45ad3f30..dea341bf15b31f4f86af2d276b155028658333ba 100644 (file)
@@ -249,8 +249,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        }
 
        last_timecode_when = 0;
-       _timecode_offset = 0;
-       _timecode_offset_negative = true;
        last_timecode_valid = false;
 
        sync_time_vars ();
@@ -3402,9 +3400,10 @@ Session::config_changed (std::string p, bool ours)
                listen_position_changed ();
        } else if (p == "solo-control-is-listen-control") {
                solo_control_mode_changed ();
+       } else if (p == "timecode-offset" || p == "timecode-offset-negative") {
+               last_timecode_valid = false;
        }
 
-
        set_dirty ();
 }
 
index b39c9399b3253ed7b2b45ea56f0d99d4c17cdb68..e33fe3a9fba1e736eedbb5aeca3535178e75cbfe 100644 (file)
@@ -186,24 +186,6 @@ Session::sync_time_vars ()
        };
 }
 
-void
-Session::set_timecode_offset (nframes_t off)
-{
-       _timecode_offset = off;
-       last_timecode_valid = false;
-
-       TimecodeOffsetChanged (); /* EMIT SIGNAL */
-}
-
-void
-Session::set_timecode_offset_negative (bool neg)
-{
-       _timecode_offset_negative = neg;
-       last_timecode_valid = false;
-
-       TimecodeOffsetChanged (); /* EMIT SIGNAL */
-}
-
 void
 Session::timecode_to_sample( Timecode::Time& timecode, framepos_t& sample, bool use_offset, bool use_subframes ) const
 {
@@ -273,22 +255,22 @@ Session::timecode_to_sample( Timecode::Time& timecode, framepos_t& sample, bool
        }
 
        if (use_offset) {
-               if (timecode_offset_negative()) {
-                       if (sample >= timecode_offset()) {
-                               sample -= timecode_offset();
+               if (config.get_timecode_offset_negative()) {
+                       if (sample >= config.get_timecode_offset()) {
+                               sample -= config.get_timecode_offset();
                        } else {
                                /* Prevent song-time from becoming negative */
                                sample = 0;
                        }
                } else {
                        if (timecode.negative) {
-                               if (sample <= timecode_offset()) {
-                                       sample = timecode_offset() - sample;
+                               if (sample <= config.get_timecode_offset()) {
+                                       sample = config.get_timecode_offset() - sample;
                                } else {
                                        sample = 0;
                                }
                        } else {
-                               sample += timecode_offset();
+                               sample += config.get_timecode_offset();
                        }
                }
        }
@@ -305,15 +287,15 @@ Session::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool u
                offset_sample = sample;
                timecode.negative = false;
        } else {
-               if (_timecode_offset_negative) {
-                       offset_sample =  sample + _timecode_offset;
+               if (config.get_timecode_offset_negative()) {
+                       offset_sample = sample + config.get_timecode_offset ();
                        timecode.negative = false;
                } else {
-                       if (sample < _timecode_offset) {
-                               offset_sample = (_timecode_offset - sample);
+                       if (sample < config.get_timecode_offset()) {
+                               offset_sample = (config.get_timecode_offset() - sample);
                                timecode.negative = true;
                        } else {
-                               offset_sample =  sample - _timecode_offset;
+                               offset_sample =  sample - config.get_timecode_offset();
                                timecode.negative = false;
                        }
                }
@@ -527,7 +509,7 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/,
 #if 0
        /* Timecode info */
 
-       pos->timecode_offset = _timecode_offset;
+       pos->timecode_offset = config.get_timecode_offset();
        t.timecode_frame_rate = timecode_frames_per_second();
        pos->valid = jack_position_bits_t (pos->valid | JackPositionTimecode;
 
@@ -580,13 +562,10 @@ Session::convert_to_frames_at (nframes_t /*position*/, AnyTime const & any)
                secs += any.timecode.minutes * 60;
                secs += any.timecode.seconds;
                secs += any.timecode.frames / timecode_frames_per_second();
-               if (_timecode_offset_negative)
-               {
-                       return (nframes_t) floor (secs * frame_rate()) - _timecode_offset;
-               }
-               else
-               {
-                       return (nframes_t) floor (secs * frame_rate()) + _timecode_offset;
+               if (config.get_timecode_offset_negative()) {
+                       return (nframes_t) floor (secs * frame_rate()) - config.get_timecode_offset();
+               } else {
+                       return (nframes_t) floor (secs * frame_rate()) + config.get_timecode_offset();
                }
                break;