f2906d40c4724e8177d78adf20c047f37041048b
[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 <map>
24 #include <cmath>
25
26 #include <ardour/location.h>
27 #include "enums.h"
28 #include "simplerect.h"
29 #include "canvas.h"
30 #include "color.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         jack_nframes_t            start;
48         jack_nframes_t            length;
49 };
50
51 class PublicEditor;
52 class Selectable;
53 class RouteTimeAxisView;
54 class RegionView;
55 class RegionSelection;
56 class CrossfadeView;
57 class Selection;
58
59 class StreamView : public sigc::trackable
60 {
61 public:
62         virtual ~StreamView ();
63
64         RouteTimeAxisView& trackview() { 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 (gdouble);
72
73         virtual int set_samples_per_unit (gdouble spp);
74         gdouble     get_samples_per_unit () { return _samples_per_unit; }
75
76         ArdourCanvas::Item* canvas_item() { return canvas_group; }
77
78         enum ColorTarget {
79                 RegionColor,
80                 StreamBaseColor
81         };
82
83         Gdk::Color get_region_color () const { return region_color; }
84         void       apply_color (Gdk::Color&, ColorTarget t);
85
86         RegionView*  find_view (const ARDOUR::Region&);
87         void         foreach_regionview (sigc::slot<void,RegionView*> slot);
88
89         void set_selected_regionviews (RegionSelection&);
90         void get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable* >&);
91         void get_inverted_selectables (Selection&, list<Selectable* >& results);
92
93         void add_region_view (ARDOUR::Region*);
94         void region_layered (RegionView*);
95         
96         sigc::signal<void,RegionView*> RegionViewAdded;
97
98 protected:
99         StreamView (RouteTimeAxisView&);
100         
101 //private:
102         void update_rec_box ();
103         void transport_changed();
104         void rec_enable_changed(void*  src = 0);
105         void sess_rec_enable_changed();
106         virtual void setup_rec_box () = 0;
107         void rec_peak_range_ready (jack_nframes_t start, jack_nframes_t cnt, ARDOUR::Source* src); 
108         virtual void update_rec_regions () = 0;
109         
110         virtual void add_region_view_internal (ARDOUR::Region*, bool wait_for_waves) = 0;
111         virtual void remove_region_view (ARDOUR::Region* );
112         void remove_rec_region (ARDOUR::Region*);
113
114         void display_diskstream (ARDOUR::Diskstream* );
115         virtual void undisplay_diskstream ();
116         virtual void redisplay_diskstream () = 0;
117         void diskstream_changed (void* );
118         void playlist_state_changed (ARDOUR::Change);
119         virtual void playlist_changed (ARDOUR::Diskstream* );
120         virtual void playlist_modified ();
121
122
123         RouteTimeAxisView& _trackview;
124
125         ArdourCanvas::Group*      canvas_group;
126         ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */
127
128         typedef list<RegionView* > RegionViewList;
129         RegionViewList region_views;
130
131         double _samples_per_unit;
132
133         sigc::connection       screen_update_connection;
134         vector<RecBoxInfo>     rec_rects;
135         list<ARDOUR::Region* > rec_regions;
136         bool                   rec_updating;
137         bool                   rec_active;
138         bool                   use_rec_regions;
139         
140         /* XXX why are these different? */
141         Gdk::Color region_color;
142         uint32_t   stream_base_color;
143
144         virtual void color_handler (ColorID, uint32_t) = 0;
145
146         vector<sigc::connection> playlist_connections;
147         sigc::connection         playlist_change_connection;
148 };
149
150 #endif /* __ardour_streamview_h__ */
151