new color management design starts to take shape (canvas color only for now)
[ardour.git] / gtk2_ardour / streamview.h
1 /*
2     Copyright (C) 2001 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     $Id$
19 */
20
21 #ifndef __ardour_streamview_h__
22 #define __ardour_streamview_h__
23
24 #include <list>
25 #include <map>
26 #include <cmath>
27
28 #include <ardour/location.h>
29 #include "enums.h"
30 #include "simplerect.h"
31 #include "canvas.h"
32 #include "color.h"
33
34 namespace Gdk {
35         class Color;
36 }
37
38 namespace ARDOUR {
39         class Route;
40         class DiskStream;
41         class Crossfade;
42         class PeakData;
43         class AudioRegion;
44         class Source;
45 }
46
47 struct RecBoxInfo {
48         ArdourCanvas::SimpleRect* rectangle;
49         jack_nframes_t start;
50         jack_nframes_t length;
51 };
52
53 class PublicEditor;
54 class Selectable;
55 class AudioTimeAxisView;
56 class AudioRegionView;
57 class AudioRegionSelection;
58 class CrossfadeView;
59 class Selection;
60
61 class StreamView : public sigc::trackable
62 {
63   public:
64         StreamView (AudioTimeAxisView&);
65         ~StreamView ();
66
67         void set_waveform_shape (WaveformShape);
68
69         AudioTimeAxisView& trackview() { return _trackview; }
70
71         void set_zoom_all();
72
73         int set_height (gdouble);
74         int set_position (gdouble x, gdouble y);
75
76         int set_samples_per_unit (gdouble spp);
77         gdouble get_samples_per_unit () { return _samples_per_unit; }
78
79         int set_amplitude_above_axis (gdouble app);
80         gdouble get_amplitude_above_axis () { return _amplitude_above_axis; }
81
82         void set_show_waveforms (bool yn);
83         void set_show_waveforms_recording (bool yn) { use_rec_regions = yn; }
84
85         ArdourCanvas::Item* canvas_item() { return canvas_group; }
86
87         sigc::signal<void,AudioRegionView*> AudioRegionViewAdded;
88
89         enum ColorTarget {
90                 RegionColor,
91                 StreamBaseColor
92         };
93
94         void apply_color (Gdk::Color&, ColorTarget t);
95         void set_selected_regionviews (AudioRegionSelection&);
96         void get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable* >&);
97         void get_inverted_selectables (Selection&, list<Selectable* >& results);
98         Gdk::Color get_region_color () const { return region_color; }
99
100         void foreach_regionview (sigc::slot<void,AudioRegionView*> slot);
101         void foreach_crossfadeview (void (CrossfadeView::*pmf)(void));
102
103         void attach ();
104         
105         void region_layered (AudioRegionView*);
106         
107         AudioRegionView* find_view (const ARDOUR::AudioRegion&);
108
109         void show_all_xfades ();
110         void hide_all_xfades ();
111         void hide_xfades_involving (AudioRegionView&);
112         void reveal_xfades_involving (AudioRegionView&);
113
114   private:
115         AudioTimeAxisView& _trackview;
116
117         ArdourCanvas::Group* canvas_group;
118         ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */
119
120         typedef list<AudioRegionView* > AudioRegionViewList;
121         AudioRegionViewList region_views;
122
123         typedef list<CrossfadeView*> CrossfadeViewList;
124         CrossfadeViewList crossfade_views;
125
126         double _samples_per_unit;
127         double _amplitude_above_axis;
128
129         sigc::connection screen_update_connection;
130         vector<RecBoxInfo> rec_rects;
131         list<ARDOUR::AudioRegion* > rec_regions;
132         bool rec_updating;
133         bool rec_active;
134         bool use_rec_regions;
135         list<sigc::connection> peak_ready_connections;
136         jack_nframes_t last_rec_peak_frame;
137         map<ARDOUR::Source*, bool> rec_peak_ready_map;
138         
139         void update_rec_box ();
140         void transport_changed();
141         void rec_enable_changed(void*  src = 0);
142         void sess_rec_enable_changed();
143         void setup_rec_box ();
144         void rec_peak_range_ready (jack_nframes_t start, jack_nframes_t cnt, ARDOUR::Source* src); 
145         void update_rec_regions ();
146         
147         void add_region_view (ARDOUR::Region*);
148         void add_region_view_internal (ARDOUR::Region*, bool wait_for_waves);
149         void remove_region_view (ARDOUR::Region* );
150         void remove_rec_region (ARDOUR::Region*);
151         void remove_audio_region_view (ARDOUR::AudioRegion* );
152         void remove_audio_rec_region (ARDOUR::AudioRegion*);
153
154         void display_diskstream (ARDOUR::DiskStream* );
155         void undisplay_diskstream ();
156         void redisplay_diskstream ();
157         void diskstream_changed (void* );
158         void playlist_state_changed (ARDOUR::Change);
159         void playlist_changed (ARDOUR::DiskStream* );
160         void playlist_modified ();
161
162         bool crossfades_visible;
163         void add_crossfade (ARDOUR::Crossfade*);
164         void remove_crossfade (ARDOUR::Crossfade*);
165
166         /* XXX why are these different? */
167         
168         Gdk::Color region_color;
169         uint32_t stream_base_color;
170
171         void color_handler (ColorID, uint32_t);
172
173         vector<sigc::connection> playlist_connections;
174         sigc::connection playlist_change_connection;
175 };
176
177 #endif /* __ardour_streamview_h__ */