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