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>
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.
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.
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.
25 #ifndef __ardour_streamview_h__
26 #define __ardour_streamview_h__
31 #include "pbd/signals.h"
33 #include "ardour/location.h"
49 namespace ArdourCanvas {
55 ArdourCanvas::Rectangle* rectangle;
57 ARDOUR::samplecnt_t length;
61 class RouteTimeAxisView;
63 class RegionSelection;
67 class StreamView : public sigc::trackable, public PBD::ScopedConnectionList
70 virtual ~StreamView ();
72 RouteTimeAxisView& trackview() { return _trackview; }
73 const RouteTimeAxisView& trackview() const { return _trackview; }
79 int set_position (gdouble x, gdouble y);
80 virtual int set_height (double);
82 virtual int set_samples_per_pixel (double);
83 gdouble get_samples_per_pixel () const { return _samples_per_pixel; }
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; }
89 ArdourCanvas::Container* canvas_item() { return _canvas_group; }
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);
100 uint32_t num_selected_regionviews () const;
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);
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);
110 virtual void update_contents_metrics(boost::shared_ptr<ARDOUR::Region>) {}
112 void add_region_view (boost::weak_ptr<ARDOUR::Region>);
114 void region_layered (RegionView*);
115 virtual void update_contents_height ();
117 virtual void redisplay_track () = 0;
118 double child_height () const;
119 ARDOUR::layer_t layers () const { return _layers; }
121 virtual RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool) {
125 void check_record_layers (boost::shared_ptr<ARDOUR::Region>, ARDOUR::samplepos_t);
127 virtual void playlist_layered (boost::weak_ptr<ARDOUR::Track>);
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;
134 virtual void parameter_changed (std::string const &);
137 StreamView (RouteTimeAxisView&, ArdourCanvas::Container* canvas_group = 0);
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 ();
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> );
151 void display_track (boost::shared_ptr<ARDOUR::Track>);
152 virtual void undisplay_track ();
153 void diskstream_changed ();
154 void layer_regions ();
156 void playlist_switched (boost::weak_ptr<ARDOUR::Track>);
158 virtual void color_handler () = 0;
160 RouteTimeAxisView& _trackview;
161 ArdourCanvas::Container* _canvas_group;
162 ArdourCanvas::Rectangle* canvas_rect; /* frame around the whole thing */
164 typedef std::list<RegionView* > RegionViewList;
165 RegionViewList region_views;
167 double _samples_per_pixel;
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;
175 uint32_t region_color; ///< Contained region color
176 uint32_t stream_base_color; ///< Background color
178 PBD::ScopedConnectionList playlist_connections;
179 PBD::ScopedConnection playlist_switched_connection;
181 ARDOUR::layer_t _layers;
182 LayerDisplay _layer_display;
186 PBD::ScopedConnectionList rec_data_ready_connections;
187 samplepos_t last_rec_data_sample;
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.
192 samplepos_t _new_rec_layer_time;
193 void setup_new_rec_layer_time (boost::shared_ptr<ARDOUR::Region>);
196 void update_coverage_frame ();
199 #endif /* __ardour_streamview_h__ */