Updated config.guess file
[ardour.git] / gtk2_ardour / taperegionview.cc
1 /*
2     Copyright (C) 2006 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 #include <cmath>
22 #include <algorithm>
23
24 #include <gtkmm.h>
25
26 #include <gtkmm2ext/gtk_ui.h>
27
28 #include <ardour/playlist.h>
29 #include <ardour/audioregion.h>
30 #include <ardour/audiosource.h>
31 #include <ardour/audio_diskstream.h>
32
33 #include "taperegionview.h"
34 #include "audio_time_axis.h"
35 #include "gui_thread.h"
36
37 #include "i18n.h"
38
39 using namespace sigc;
40 using namespace ARDOUR;
41 using namespace PBD;
42 using namespace Editing;
43 using namespace ArdourCanvas;
44
45 const TimeAxisViewItem::Visibility TapeAudioRegionView::default_tape_visibility = TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameHighlight|
46                                                                                                           TimeAxisViewItem::ShowFrame|
47                                                                                                           TimeAxisViewItem::HideFrameRight|
48                                                                                                           TimeAxisViewItem::FullWidthNameHighlight);
49
50 TapeAudioRegionView::TapeAudioRegionView (ArdourCanvas::Group *parent, AudioTimeAxisView &tv, 
51                                           AudioRegion& r, 
52                                           double spu, 
53                                           Gdk::Color& basic_color)
54
55         : AudioRegionView (parent, tv, r, spu, basic_color, 
56                            TimeAxisViewItem::Visibility ((r.position() != 0) ? default_tape_visibility : 
57                                                          TimeAxisViewItem::Visibility (default_tape_visibility|TimeAxisViewItem::HideFrameLeft)))
58 {
59 }
60
61 void
62 TapeAudioRegionView::init (double amplitude_above_axis, Gdk::Color& basic_color, bool wfw)
63 {
64         XMLNode *node;
65
66         editor = 0;
67         valid = true;
68         in_destructor = false;
69         _amplitude_above_axis = amplitude_above_axis;
70         zero_line = 0;
71         wait_for_waves = wfw;
72         _height = 0;
73
74         _flags = 0;
75
76         if ((node = region.extra_xml ("GUI")) != 0) {
77                 set_flags (node);
78         } else {
79                 _flags = WaveformVisible;
80                 store_flags ();
81         }
82
83         fade_in_handle = 0;
84         fade_out_handle = 0;
85         gain_line = 0;
86         sync_mark = 0;
87
88         compute_colors (basic_color);
89
90         create_waves ();
91
92         name_highlight->set_data ("regionview", this);
93
94         reset_width_dependent_items ((double) region.length() / samples_per_unit);
95
96         set_height (trackview.height);
97
98         region_muted ();
99         region_resized (BoundsChanged);
100         set_waveview_data_src();
101         region_locked ();
102
103         /* no events, no state changes */
104
105         set_colors ();
106
107         // ColorChanged.connect (mem_fun (*this, &AudioRegionView::color_handler));
108
109         /* every time the wave data changes and peaks are ready, redraw */
110
111         
112         for (uint32_t n = 0; n < region.n_channels(); ++n) {
113                 region.source(n).PeaksReady.connect (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
114         }
115         
116 }
117
118 TapeAudioRegionView::~TapeAudioRegionView()
119 {
120 }
121
122 void
123 TapeAudioRegionView::update (uint32_t n)
124 {
125         /* check that all waves are build and ready */
126
127         if (!tmp_waves.empty()) {
128                 return;
129         }
130
131         ENSURE_GUI_THREAD (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
132
133         /* this triggers a cache invalidation and redraw in the waveview */
134
135         waves[n]->property_data_src() = &region;
136 }
137
138 void
139 TapeAudioRegionView::set_frame_color ()
140 {
141         fill_opacity = 255;
142         TimeAxisViewItem::set_frame_color ();
143 }