use new syntax for connecting to backend signals that enforces explicit connection...
[ardour.git] / gtk2_ardour / streamview.h
1 /*
2     Copyright (C) 2001, 2006 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_streamview_h__
20 #define __ardour_streamview_h__
21
22 #include <list>
23 #include <cmath>
24
25 #include "pbd/signals.h"
26
27 #include "ardour/location.h"
28 #include "enums.h"
29 #include "simplerect.h"
30 #include "canvas.h"
31
32 namespace Gdk {
33         class Color;
34 }
35
36 namespace ARDOUR {
37         class Route;
38         class Diskstream;
39         class Crossfade;
40         class PeakData;
41         class Region;
42         class Source;
43 }
44
45 struct RecBoxInfo {
46         ArdourCanvas::SimpleRect* rectangle;
47         nframes_t                 start;
48         nframes_t                 length;
49 };
50
51 class Selectable;
52 class RouteTimeAxisView;
53 class RegionView;
54 class RegionSelection;
55 class CrossfadeView;
56 class Selection;
57
58 class StreamView : public sigc::trackable, public PBD::ScopedConnectionList
59 {
60 public:
61         virtual ~StreamView ();
62
63         RouteTimeAxisView&       trackview()       { return _trackview; }
64         const RouteTimeAxisView& trackview() const { return _trackview; }
65
66         void attach ();
67
68         void set_zoom_all();
69
70         int set_position (gdouble x, gdouble y);
71         virtual int set_height (double);
72
73         virtual int set_samples_per_unit (gdouble spp);
74         gdouble     get_samples_per_unit () { return _samples_per_unit; }
75
76         void set_layer_display (LayerDisplay);
77         LayerDisplay layer_display () const { return _layer_display; }
78
79         ArdourCanvas::Group* background_group() { return _background_group; }
80         ArdourCanvas::Group* canvas_item() { return canvas_group; }
81
82         enum ColorTarget {
83                 RegionColor,
84                 StreamBaseColor
85         };
86
87         Gdk::Color get_region_color () const { return region_color; }
88         void       apply_color (Gdk::Color&, ColorTarget t);
89
90         RegionView*  find_view (boost::shared_ptr<const ARDOUR::Region>);
91         void         foreach_regionview (sigc::slot<void,RegionView*> slot);
92
93         void set_selected_regionviews (RegionSelection&);
94         void get_selectables (nframes_t, nframes_t, double, double, std::list<Selectable* >&);
95         void get_inverted_selectables (Selection&, std::list<Selectable* >& results);
96
97         virtual void update_contents_metrics(boost::shared_ptr<ARDOUR::Region>) {}
98
99         void add_region_view_weak (boost::weak_ptr<ARDOUR::Region> r);
100         void add_region_view (boost::shared_ptr<ARDOUR::Region>);
101
102         void region_layered (RegionView*);
103         virtual void update_contents_height ();
104
105         virtual void redisplay_diskstream () = 0;
106         double child_height () const;
107         ARDOUR::layer_t layers () const { return _layers; }
108
109         virtual RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool) {
110                 return 0;
111         }
112
113         sigc::signal<void,RegionView*> RegionViewAdded;
114         sigc::signal<void> HeightChanged;
115
116 protected:
117         StreamView (RouteTimeAxisView&, ArdourCanvas::Group* group = NULL);
118
119         void         transport_changed();
120         void         transport_looped();
121         void         rec_enable_changed();
122         void         sess_rec_enable_changed();
123         virtual void setup_rec_box () = 0;
124         void         update_rec_box ();
125
126         virtual RegionView* add_region_view_internal (boost::shared_ptr<ARDOUR::Region>,
127                       bool wait_for_waves, bool recording = false) = 0;
128         virtual void remove_region_view (boost::weak_ptr<ARDOUR::Region> );
129
130         void         display_diskstream (boost::shared_ptr<ARDOUR::Diskstream>);
131         virtual void undisplay_diskstream ();
132         void         diskstream_changed ();
133         void         layer_regions ();
134
135         virtual void playlist_changed_weak (boost::weak_ptr<ARDOUR::Diskstream>);
136         virtual void playlist_changed (boost::shared_ptr<ARDOUR::Diskstream>);
137         virtual void playlist_modified_weak (boost::weak_ptr<ARDOUR::Diskstream>);
138         virtual void playlist_modified (boost::shared_ptr<ARDOUR::Diskstream>);
139
140         virtual void color_handler () = 0;
141
142         RouteTimeAxisView&        _trackview;
143         bool                      owns_canvas_group;
144         ArdourCanvas::Group*      _background_group;
145         ArdourCanvas::Group*      canvas_group;
146         ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */
147
148         typedef std::list<RegionView* > RegionViewList;
149         RegionViewList  region_views;
150
151         double _samples_per_unit;
152
153         sigc::connection       screen_update_connection;
154         std::vector<RecBoxInfo>     rec_rects;
155         std::list< std::pair<boost::shared_ptr<ARDOUR::Region>,RegionView* > > rec_regions;
156         bool                   rec_updating;
157         bool                   rec_active;
158         bool                   use_rec_regions;
159
160         Gdk::Color region_color;      ///< Contained region color
161         uint32_t   stream_base_color; ///< Background color
162
163         PBD::ScopedConnectionList playlist_connections;
164         boost::signals2::scoped_connection playlist_change_connection;
165
166         ARDOUR::layer_t _layers;
167         LayerDisplay    _layer_display;
168
169         double height;
170
171         PBD::ScopedConnectionList rec_data_ready_connections;
172         nframes_t                 last_rec_data_frame;
173
174 private:
175         void update_coverage_frames ();
176 };
177
178 #endif /* __ardour_streamview_h__ */
179