Fix session range location by hooking into the undo system. Fixes #3654.
[ardour.git] / libs / ardour / ardour / session.h
index 7abeabd647c5591f383013429b3144128eedd4a4..ba39ee47f99fc85af21f521f587ffaf241397d3b 100644 (file)
@@ -23,7 +23,6 @@
 #include <list>
 #include <map>
 #include <set>
-#include <stack>
 #include <string>
 #include <vector>
 #include <stdint.h>
@@ -315,7 +314,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        int wipe ();
 
-       std::pair<framepos_t, framepos_t> get_extent () const;
        framepos_t current_end_frame () const;
        framepos_t current_start_frame () const;
        /** "actual" sample rate of session, set by current audioengine rate, pullup/down etc. */
@@ -409,13 +407,17 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
                }
        }
 
+       std::list<RouteGroup*> const & route_groups () const {
+               return _route_groups;
+       }
+
        /* fundamental operations. duh. */
 
        std::list<boost::shared_ptr<AudioTrack> > new_audio_track (
                int input_channels, int output_channels, TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1
                );
 
-       RouteList new_audio_route (bool aux, int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many);
+       RouteList new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many);
 
        std::list<boost::shared_ptr<MidiTrack> > new_midi_track (
                TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1
@@ -662,14 +664,17 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        std::string next_redo() const { return _history.next_redo(); }
 
        void begin_reversible_command (const std::string& cmd_name);
+       void begin_reversible_command (GQuark);
        void commit_reversible_command (Command* cmd = 0);
 
-       UndoTransaction* start_reversible_command (const std::string& cmd_name);
-       void finish_reversible_command (UndoTransaction&);
-
        void add_command (Command *const cmd) {
-               assert(!_current_trans.empty ());
-               _current_trans.top()->add_command (cmd);
+               assert (_current_trans);
+               _current_trans->add_command (cmd);
+       }
+
+       /** @return The list of operations that are currently in progress */
+       std::list<GQuark> const & current_operations () {
+               return _current_trans_quarks;
        }
 
        void add_commands (std::vector<Command*> const & cmds);
@@ -840,6 +845,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        Location*               _session_range_location; ///< session range, or 0 if there is nothing in the session yet
        Slave*                  _slave;
        bool                    _silent;
+
+       void maybe_update_session_range (framepos_t, framepos_t);
        
        // varispeed playback
        double                  _transport_speed;
@@ -959,7 +966,11 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        std::string             _path;
        std::string             _name;
        bool                    _is_new;
-       bool                     session_send_mtc;
+       bool                    _send_qf_mtc;
+       /** Number of process frames since the last MTC output (when sending MTC); used to
+        *  know when to send full MTC messages every so often.
+        */
+       pframes_t               _pframes_since_last_mtc;
        bool                     session_midi_feedback;
        bool                     play_loop;
        bool                     loop_changing;
@@ -1054,7 +1065,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        void first_stage_init (std::string path, std::string snapshot_name);
        int  second_stage_init ();
-       void update_session_range_location_marker ();
        void remove_empty_sounds ();
 
        void setup_midi_control ();
@@ -1137,7 +1147,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        bool _send_timecode_update; ///< Flag to send a full frame (Timecode) MTC message this cycle
 
-       int send_midi_time_code_for_cycle (pframes_t nframes);
+       int send_midi_time_code_for_cycle (framepos_t, framepos_t, pframes_t nframes);
 
        void reset_record_status ();
 
@@ -1253,6 +1263,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        void remove_playlist (boost::weak_ptr<Playlist>);
        void track_playlist_changed (boost::weak_ptr<Track>);
+       void playlist_region_added (boost::weak_ptr<Region>);
+       void playlist_ranges_moved (std::list<Evoral::RangeMove<framepos_t> > const &);
 
        /* NAMED SELECTIONS */
 
@@ -1331,8 +1343,14 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        void reverse_track_buffers ();
 
-       UndoHistory                  _history;
-       std::stack<UndoTransaction*> _current_trans;
+       UndoHistory      _history;
+       /** current undo transaction, or 0 */
+       UndoTransaction* _current_trans;
+       /** GQuarks to describe the reversible commands that are currently in progress.
+        *  These may be nested, in which case more recently-started commands are toward
+        *  the front of the list.
+        */
+       std::list<GQuark> _current_trans_quarks;
 
        void jack_timebase_callback (jack_transport_state_t, pframes_t, jack_position_t*, int);
        int  jack_sync_callback (jack_transport_state_t, jack_position_t*);