Remove all use of nframes_t.
[ardour.git] / gtk2_ardour / streamview.h
index 00ec2d93f2a8a13b52a52fd10f935b805caaf87f..769255408a04da844f6cb3d82e9395f3a6274ee5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2001 Paul Davis 
+    Copyright (C) 2001, 2006 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
 */
 
 #ifndef __ardour_streamview_h__
 #define __ardour_streamview_h__
 
 #include <list>
-#include <map>
 #include <cmath>
 
-#include <ardour/location.h>
+#include "pbd/signals.h"
+
+#include "ardour/location.h"
 #include "enums.h"
 #include "simplerect.h"
 #include "canvas.h"
-#include "color.h"
 
 namespace Gdk {
        class Color;
@@ -37,141 +35,153 @@ namespace Gdk {
 
 namespace ARDOUR {
        class Route;
-       class AudioDiskstream;
        class Crossfade;
        class PeakData;
-       class AudioRegion;
+       class Region;
        class Source;
+       class Track;
 }
 
 struct RecBoxInfo {
-        ArdourCanvas::SimpleRect* rectangle;
-       jack_nframes_t start;
-       jack_nframes_t length;
+       ArdourCanvas::SimpleRect*  rectangle;
+       framepos_t                 start;
+       ARDOUR::framecnt_t         length;
 };
 
-class PublicEditor;
 class Selectable;
-class AudioTimeAxisView;
-class AudioRegionView;
-class AudioRegionSelection;
+class RouteTimeAxisView;
+class RegionView;
+class RegionSelection;
 class CrossfadeView;
 class Selection;
 
-class StreamView : public sigc::trackable
+class StreamView : public sigc::trackable, public PBD::ScopedConnectionList
 {
-  public:
-       StreamView (AudioTimeAxisView&);
-       ~StreamView ();
+public:
+       virtual ~StreamView ();
 
-       void set_waveform_shape (WaveformShape);
+       RouteTimeAxisView&       trackview()       { return _trackview; }
+       const RouteTimeAxisView& trackview() const { return _trackview; }
 
-       AudioTimeAxisView& trackview() { return _trackview; }
+       void attach ();
 
        void set_zoom_all();
 
-       int set_height (gdouble);
        int set_position (gdouble x, gdouble y);
+       virtual int set_height (double);
 
-       int set_samples_per_unit (gdouble spp);
-       gdouble get_samples_per_unit () { return _samples_per_unit; }
-
-       int set_amplitude_above_axis (gdouble app);
-       gdouble get_amplitude_above_axis () { return _amplitude_above_axis; }
+       virtual int set_samples_per_unit (gdouble spp);
+       gdouble     get_samples_per_unit () { return _samples_per_unit; }
+       virtual void horizontal_position_changed () {}
 
-       void set_show_waveforms (bool yn);
-       void set_show_waveforms_recording (bool yn) { use_rec_regions = yn; }
+       void set_layer_display (LayerDisplay);
+       LayerDisplay layer_display () const { return _layer_display; }
 
-       ArdourCanvas::Item* canvas_item() { return canvas_group; }
-
-       sigc::signal<void,AudioRegionView*> AudioRegionViewAdded;
+       ArdourCanvas::Group* background_group() { return _background_group; }
+       ArdourCanvas::Group* canvas_item() { return _canvas_group; }
 
        enum ColorTarget {
                RegionColor,
                StreamBaseColor
        };
 
-       void apply_color (Gdk::Color&, ColorTarget t);
-       void set_selected_regionviews (AudioRegionSelection&);
-       void get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable* >&);
-       void get_inverted_selectables (Selection&, list<Selectable* >& results);
        Gdk::Color get_region_color () const { return region_color; }
+       void       apply_color (Gdk::Color&, ColorTarget t);
 
-       void foreach_regionview (sigc::slot<void,AudioRegionView*> slot);
-       void foreach_crossfadeview (void (CrossfadeView::*pmf)(void));
+       uint32_t     num_selected_regionviews () const;
 
-       void attach ();
-       
-       void region_layered (AudioRegionView*);
+       RegionView*  find_view (boost::shared_ptr<const ARDOUR::Region>);
+       void         foreach_regionview (sigc::slot<void,RegionView*> slot);
+       void         foreach_selected_regionview (sigc::slot<void,RegionView*> slot);
+
+       void set_selected_regionviews (RegionSelection&);
+       void get_selectables (ARDOUR::framepos_t, ARDOUR::framepos_t, double, double, std::list<Selectable* >&);
+       void get_inverted_selectables (Selection&, std::list<Selectable* >& results);
+
+       virtual void update_contents_metrics(boost::shared_ptr<ARDOUR::Region>) {}
+
+       void add_region_view (boost::weak_ptr<ARDOUR::Region>);
+
+       void region_layered (RegionView*);
+       virtual void update_contents_height ();
+
+       virtual void redisplay_track () = 0;
+       double child_height () const;
+       ARDOUR::layer_t layers () const { return _layers; }
+
+       virtual RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool) {
+               return 0;
+       }
+
+       void check_record_layers (boost::shared_ptr<ARDOUR::Region>, ARDOUR::framepos_t);
        
-       AudioRegionView* find_view (const ARDOUR::AudioRegion&);
+       sigc::signal<void,RegionView*> RegionViewAdded;
 
-       void show_all_xfades ();
-       void hide_all_xfades ();
-       void hide_xfades_involving (AudioRegionView&);
-       void reveal_xfades_involving (AudioRegionView&);
+protected:
+       StreamView (RouteTimeAxisView&, ArdourCanvas::Group* background_group = 0, ArdourCanvas::Group* canvas_group = 0);
 
-  private:
-       AudioTimeAxisView& _trackview;
+       void         transport_changed();
+       void         transport_looped();
+       void         rec_enable_changed();
+       void         sess_rec_enable_changed();
+       virtual void setup_rec_box () = 0;
+       virtual void update_rec_box ();
 
-       ArdourCanvas::Group* canvas_group;
-       ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */
+       virtual RegionView* add_region_view_internal (boost::shared_ptr<ARDOUR::Region>,
+                     bool wait_for_waves, bool recording = false) = 0;
+       virtual void remove_region_view (boost::weak_ptr<ARDOUR::Region> );
 
-       typedef list<AudioRegionView* > AudioRegionViewList;
-       AudioRegionViewList region_views;
+       void         display_track (boost::shared_ptr<ARDOUR::Track>);
+       virtual void undisplay_track ();
+       void         diskstream_changed ();
+       void         layer_regions ();
 
-       typedef list<CrossfadeView*> CrossfadeViewList;
-       CrossfadeViewList crossfade_views;
+       virtual void playlist_switched (boost::weak_ptr<ARDOUR::Track>);
+       virtual void playlist_layered (boost::weak_ptr<ARDOUR::Track>);
+
+       virtual void color_handler () = 0;
+
+       RouteTimeAxisView&        _trackview;
+       bool                      owns_background_group;
+       bool                      owns_canvas_group;
+       ArdourCanvas::Group*      _background_group;
+       ArdourCanvas::Group*      _canvas_group;
+       ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */
+
+       typedef std::list<RegionView* > RegionViewList;
+       RegionViewList  region_views;
 
        double _samples_per_unit;
-       double _amplitude_above_axis;
-
-       sigc::connection screen_update_connection;
-       vector<RecBoxInfo> rec_rects;
-       list<ARDOUR::AudioRegion* > rec_regions;
-       bool rec_updating;
-       bool rec_active;
-       bool use_rec_regions;
-       list<sigc::connection> peak_ready_connections;
-       jack_nframes_t last_rec_peak_frame;
-       map<ARDOUR::Source*, bool> rec_peak_ready_map;
-       
-       void update_rec_box ();
-       void transport_changed();
-       void rec_enable_changed(void*  src = 0);
-       void sess_rec_enable_changed();
-       void setup_rec_box ();
-       void rec_peak_range_ready (jack_nframes_t start, jack_nframes_t cnt, ARDOUR::Source* src); 
-       void update_rec_regions ();
-       
-       void add_region_view (ARDOUR::Region*);
-       void add_region_view_internal (ARDOUR::Region*, bool wait_for_waves);
-       void remove_region_view (ARDOUR::Region* );
-       void remove_rec_region (ARDOUR::Region*);
-       void remove_audio_region_view (ARDOUR::AudioRegion* );
-       void remove_audio_rec_region (ARDOUR::AudioRegion*);
-
-       void display_diskstream (ARDOUR::AudioDiskstream* );
-       void undisplay_diskstream ();
-       void redisplay_diskstream ();
-       void diskstream_changed (void* );
-       void playlist_state_changed (ARDOUR::Change);
-       void playlist_changed (ARDOUR::AudioDiskstream* );
-       void playlist_modified ();
-
-       bool crossfades_visible;
-       void add_crossfade (ARDOUR::Crossfade*);
-       void remove_crossfade (ARDOUR::Crossfade*);
-
-       /* XXX why are these different? */
-       
-       Gdk::Color region_color;
-       uint32_t stream_base_color;
 
-       void color_handler (ColorID, uint32_t);
+       sigc::connection       screen_update_connection;
+       std::vector<RecBoxInfo>     rec_rects;
+       std::list< std::pair<boost::shared_ptr<ARDOUR::Region>,RegionView* > > rec_regions;
+       bool                   rec_updating;
+       bool                   rec_active;
 
-       vector<sigc::connection> playlist_connections;
-       sigc::connection playlist_change_connection;
+       Gdk::Color region_color;      ///< Contained region color
+       uint32_t   stream_base_color; ///< Background color
+
+       PBD::ScopedConnectionList playlist_connections;
+       PBD::ScopedConnection playlist_switched_connection;
+
+       ARDOUR::layer_t _layers;
+       LayerDisplay    _layer_display;
+
+       double height;
+
+       PBD::ScopedConnectionList rec_data_ready_connections;
+       framepos_t                last_rec_data_frame;
+
+       /* When recording, the session time at which a new layer must be created for the region
+          being recorded, or max_framepos if not applicable.
+       */
+       framepos_t _new_rec_layer_time;
+       void setup_new_rec_layer_time (boost::shared_ptr<ARDOUR::Region>);
+       
+private:
+       void update_coverage_frames ();
 };
 
 #endif /* __ardour_streamview_h__ */
+