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