a few more header files fixes, plus cleanup from nick_m, and the start of Action...
[ardour.git] / gtk2_ardour / regionview.h
1 /*
2     Copyright (C) 2001-2004 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 __gtk_ardour_region_view_h__
22 #define __gtk_ardour_region_view_h__
23
24 #include <vector>
25 #include <gtkmm.h>
26 #include <libgnomecanvas/libgnomecanvas.h>
27 #include <sigc++/signal.h>
28 #include <ardour/region.h>
29
30 #include "time_axis_view_item.h"
31 #include "automation_line.h"
32 #include "enums.h"
33 #include "canvas-waveview.h"
34
35 namespace ARDOUR {
36         class AudioRegion;
37         class PeakData;
38 };
39
40 class AudioTimeAxisView;
41 class AudioRegionGainLine;
42 class AudioRegionEditor;
43 class GhostRegion;
44 class AutomationTimeAxisView;
45
46 class AudioRegionView : public TimeAxisViewItem
47 {
48   public:
49     AudioRegionView (GnomeCanvasGroup *, 
50                      AudioTimeAxisView&,
51                      ARDOUR::AudioRegion&,
52                      double initial_samples_per_unit,
53                      double amplitude_above_axis,
54                      Gdk::Color& base_color,
55                      bool wait_for_waves);
56     ~AudioRegionView ();
57
58     ARDOUR::AudioRegion& region;  // ok, let 'em have it
59     bool is_valid() const { return valid; }
60     void set_valid (bool yn) { valid = yn; }
61
62     std::string get_item_name();
63     void set_height (double);
64     void set_samples_per_unit (double);
65     bool set_duration (jack_nframes_t, void*);
66
67     void set_amplitude_above_axis (gdouble spp);
68
69     void move (double xdelta, double ydelta);
70
71     void raise ();
72     void raise_to_top ();
73     void lower ();
74     void lower_to_bottom ();
75
76     bool set_position(jack_nframes_t pos, void* src, double* delta = 0);
77     
78     void temporarily_hide_envelope (); // dangerous
79     void unhide_envelope (); // dangerous
80
81     void set_envelope_visible (bool);
82     void set_waveform_visible (bool yn);
83     void set_waveform_shape (WaveformShape);
84
85     bool waveform_rectified() const { return _flags & WaveformRectified; }
86     bool waveform_visible() const { return _flags & WaveformVisible; }
87     bool envelope_visible() const { return _flags & EnvelopeVisible; }
88     
89     void show_region_editor ();
90     void hide_region_editor();
91
92     void add_gain_point_event (GnomeCanvasItem *item, GdkEvent *event);
93     void remove_gain_point_event (GnomeCanvasItem *item, GdkEvent *event);
94
95     AudioRegionGainLine* get_gain_line() const { return gain_line; }
96
97     void region_changed (ARDOUR::Change);
98     void envelope_active_changed ();
99
100     static sigc::signal<void,AudioRegionView*> AudioRegionViewGoingAway;
101     sigc::signal<void> GoingAway;
102
103     GhostRegion* add_ghost (AutomationTimeAxisView&);
104     void remove_ghost (GhostRegion*);
105
106     void reset_fade_in_shape_width (jack_nframes_t);
107     void reset_fade_out_shape_width (jack_nframes_t);
108     void set_fade_in_active (bool);
109     void set_fade_out_active (bool);
110
111     uint32_t get_fill_color ();
112
113     virtual void entered ();
114     virtual void exited ();
115
116   private:
117     enum Flags {
118             EnvelopeVisible = 0x1,
119             WaveformVisible = 0x4,
120             WaveformRectified = 0x8
121     };
122
123     vector<GnomeCanvasItem *> waves; /* waveviews */
124     vector<GnomeCanvasItem *> tmp_waves; /* see ::create_waves()*/
125     GnomeCanvasItem* sync_mark; /* polgyon for sync position */
126     GnomeCanvasItem* no_wave_msg; /* text */
127     GnomeCanvasItem* zero_line; /* simpleline */
128     GnomeCanvasItem* fade_in_shape; /* polygon */
129     GnomeCanvasItem* fade_out_shape; /* polygon */
130     GnomeCanvasItem* fade_in_handle; /* simplerect */
131     GnomeCanvasItem* fade_out_handle; /* simplerect */
132
133     AudioRegionGainLine* gain_line;
134     AudioRegionEditor *editor;
135
136     vector<ControlPoint *> control_points;
137     double _amplitude_above_axis;
138     double current_visible_sync_position;
139
140     uint32_t _flags;
141     uint32_t fade_color;
142     bool     valid; /* see StreamView::redisplay_diskstream() */
143     double _pixel_width;
144     double _height;
145     bool    in_destructor;
146     bool    wait_for_waves;
147
148     void reset_fade_shapes ();
149     void reset_fade_in_shape ();
150     void reset_fade_out_shape ();
151     void fade_in_changed ();
152     void fade_out_changed ();
153     void fade_in_active_changed ();
154     void fade_out_active_changed ();
155
156     void region_resized (ARDOUR::Change);
157     void region_moved (void *);
158     void region_muted ();
159     void region_locked ();
160     void region_opacity ();
161     void region_layered ();
162     void region_renamed ();
163     void region_sync_changed ();
164     void region_scale_amplitude_changed ();
165
166     static gint _lock_toggle (GnomeCanvasItem*, GdkEvent*, void*);
167     void lock_toggle ();
168
169     void create_waves ();
170     void create_one_wave (uint32_t, bool);
171     void manage_zero_line ();
172     void peaks_ready_handler (uint32_t);
173     void reset_name (gdouble width);
174     void set_flags (XMLNode *);
175     void store_flags ();
176
177     void set_colors ();
178     void compute_colors (Gdk::Color&);
179     void set_frame_color ();
180     void reset_width_dependent_items (double pixel_width);
181     void set_waveview_data_src();
182
183     vector<GnomeCanvasWaveViewCache*> wave_caches;
184     vector<GhostRegion*> ghosts;
185 };
186
187 #endif /* __gtk_ardour_region_view_h__ */