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