Update GPL boilerplate and (C)
[ardour.git] / gtk2_ardour / streamview.h
1 /*
2  * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Nick Mainsbridge <mainsbridge@gmail.com>
4  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
5  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
6  * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2007 Doug McLain <doug@nostar.net>
8  * Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __ardour_streamview_h__
26 #define __ardour_streamview_h__
27
28 #include <list>
29 #include <cmath>
30
31 #include "pbd/signals.h"
32
33 #include "ardour/location.h"
34 #include "enums.h"
35
36 namespace Gdk {
37         class Color;
38 }
39
40 namespace ARDOUR {
41         class Crossfade;
42         class Region;
43         class Route;
44         class Source;
45         class Track;
46         struct PeakData;
47 }
48
49 namespace ArdourCanvas {
50         class Rectangle;
51         class Container;
52 }
53
54 struct RecBoxInfo {
55         ArdourCanvas::Rectangle* rectangle;
56         samplepos_t              start;
57         ARDOUR::samplecnt_t      length;
58 };
59
60 class Selectable;
61 class RouteTimeAxisView;
62 class RegionView;
63 class RegionSelection;
64 class CrossfadeView;
65 class Selection;
66
67 class StreamView : public sigc::trackable, public PBD::ScopedConnectionList
68 {
69 public:
70         virtual ~StreamView ();
71
72         RouteTimeAxisView&       trackview()       { return _trackview; }
73         const RouteTimeAxisView& trackview() const { return _trackview; }
74
75         void attach ();
76
77         void set_zoom_all();
78
79         int set_position (gdouble x, gdouble y);
80         virtual int set_height (double);
81
82         virtual int set_samples_per_pixel (double);
83         gdouble     get_samples_per_pixel () const { return _samples_per_pixel; }
84
85         virtual void set_layer_display (LayerDisplay);
86         virtual bool can_change_layer_display() const { return true; }
87         LayerDisplay layer_display () const { return _layer_display; }
88
89         ArdourCanvas::Container* canvas_item() { return _canvas_group; }
90
91         enum ColorTarget {
92                 RegionColor,
93                 StreamBaseColor
94         };
95
96         uint32_t get_region_color () const { return region_color; }
97         void     apply_color (uint32_t, ColorTarget t);
98         void     apply_color (Gdk::Color const &, ColorTarget t);
99
100         uint32_t     num_selected_regionviews () const;
101
102         RegionView*  find_view (boost::shared_ptr<const ARDOUR::Region>);
103         void         foreach_regionview (sigc::slot<void,RegionView*> slot);
104         void         foreach_selected_regionview (sigc::slot<void,RegionView*> slot);
105
106         void set_selected_regionviews (RegionSelection&);
107         void get_selectables (ARDOUR::samplepos_t, ARDOUR::samplepos_t, double, double, std::list<Selectable* >&, bool within = false);
108         void get_inverted_selectables (Selection&, std::list<Selectable* >& results);
109
110         virtual void update_contents_metrics(boost::shared_ptr<ARDOUR::Region>) {}
111
112         void add_region_view (boost::weak_ptr<ARDOUR::Region>);
113
114         void region_layered (RegionView*);
115         virtual void update_contents_height ();
116
117         virtual void redisplay_track () = 0;
118         double child_height () const;
119         ARDOUR::layer_t layers () const { return _layers; }
120
121         virtual RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool) {
122                 return 0;
123         }
124
125         void check_record_layers (boost::shared_ptr<ARDOUR::Region>, ARDOUR::samplepos_t);
126
127         virtual void playlist_layered (boost::weak_ptr<ARDOUR::Track>);
128
129         sigc::signal<void, RegionView*> RegionViewAdded;
130         sigc::signal<void> RegionViewRemoved;
131         /** Emitted when the height of regions has changed */
132         sigc::signal<void> ContentsHeightChanged;
133
134         virtual void parameter_changed (std::string const &);
135
136 protected:
137         StreamView (RouteTimeAxisView&, ArdourCanvas::Container* canvas_group = 0);
138
139         void         transport_changed();
140         void         transport_looped();
141         void         rec_enable_changed();
142         void         sess_rec_enable_changed();
143         void         create_rec_box(samplepos_t sample_pos, double width);
144         virtual void setup_rec_box () = 0;
145         virtual void update_rec_box ();
146
147         virtual RegionView* add_region_view_internal (boost::shared_ptr<ARDOUR::Region>,
148                       bool wait_for_waves, bool recording = false) = 0;
149         virtual void remove_region_view (boost::weak_ptr<ARDOUR::Region> );
150
151         void         display_track (boost::shared_ptr<ARDOUR::Track>);
152         virtual void undisplay_track ();
153         void         diskstream_changed ();
154         void         layer_regions ();
155
156         void playlist_switched (boost::weak_ptr<ARDOUR::Track>);
157
158         virtual void color_handler () = 0;
159
160         RouteTimeAxisView&       _trackview;
161         ArdourCanvas::Container* _canvas_group;
162         ArdourCanvas::Rectangle*  canvas_rect; /* frame around the whole thing */
163
164         typedef std::list<RegionView* > RegionViewList;
165         RegionViewList region_views;
166
167         double _samples_per_pixel;
168
169         sigc::connection        screen_update_connection;
170         std::vector<RecBoxInfo> rec_rects;
171         std::list< std::pair<boost::shared_ptr<ARDOUR::Region>,RegionView* > > rec_regions;
172         bool                    rec_updating;
173         bool                    rec_active;
174
175         uint32_t region_color;      ///< Contained region color
176         uint32_t stream_base_color; ///< Background color
177
178         PBD::ScopedConnectionList playlist_connections;
179         PBD::ScopedConnection playlist_switched_connection;
180
181         ARDOUR::layer_t _layers;
182         LayerDisplay    _layer_display;
183
184         double height;
185
186         PBD::ScopedConnectionList rec_data_ready_connections;
187         samplepos_t               last_rec_data_sample;
188
189         /* When recording, the session time at which a new layer must be created for the region
190            being recorded, or max_samplepos if not applicable.
191         */
192         samplepos_t _new_rec_layer_time;
193         void setup_new_rec_layer_time (boost::shared_ptr<ARDOUR::Region>);
194
195 private:
196         void update_coverage_frame ();
197 };
198
199 #endif /* __ardour_streamview_h__ */
200