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