2 Copyright (C) 2001-2007 Paul Davis
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.
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.
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.
25 #include <gtkmm2ext/gtk_ui.h>
27 #include <ardour/midi_playlist.h>
28 #include <ardour/midi_region.h>
29 #include <ardour/midi_source.h>
30 #include <ardour/midi_diskstream.h>
31 #include <ardour/midi_track.h>
32 #include <ardour/smf_source.h>
33 #include <ardour/region_factory.h>
35 #include "automation_streamview.h"
36 #include "region_view.h"
37 #include "automation_region_view.h"
38 #include "automation_time_axis.h"
39 #include "canvas-simplerect.h"
40 #include "region_selection.h"
41 #include "selection.h"
42 #include "public_editor.h"
43 #include "ardour_ui.h"
44 #include "rgb_macros.h"
45 #include "gui_thread.h"
47 #include "simplerect.h"
48 #include "simpleline.h"
51 using namespace ARDOUR;
53 using namespace Editing;
55 AutomationStreamView::AutomationStreamView (AutomationTimeAxisView& tv)
56 : StreamView (*dynamic_cast<RouteTimeAxisView*>(tv.get_parent()),
57 new ArdourCanvas::Group(*tv.canvas_display))
58 , _controller(tv.controller())
59 , _automation_view(tv)
61 //canvas_rect->property_fill_color_rgba() = stream_base_color;
62 canvas_rect->property_outline_color_rgba() = RGBA_BLACK;
64 use_rec_regions = tv.editor.show_waveforms_recording ();
67 AutomationStreamView::~AutomationStreamView ()
73 AutomationStreamView::add_region_view_internal (boost::shared_ptr<Region> region, bool wfd, bool recording)
76 cerr << "No region" << endl;
81 boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(region);
83 mr->midi_source()->load_model();
86 const boost::shared_ptr<AutomationControl> control
87 = boost::dynamic_pointer_cast<AutomationControl>(
88 region->control(_controller->controllable()->parameter()));
90 boost::shared_ptr<AutomationList> list;
92 list = boost::dynamic_pointer_cast<AutomationList>(control->list());
93 assert(!control->list() || list);
96 AutomationRegionView *region_view;
97 std::list<RegionView *>::iterator i;
99 for (i = region_views.begin(); i != region_views.end(); ++i) {
100 if ((*i)->region() == region) {
102 /* great. we already have a MidiRegionView for this Region. use it again. */
104 (*i)->set_valid (true);
105 (*i)->enable_display(wfd);
106 display_region(dynamic_cast<AutomationRegionView*>(*i));
112 region_view = new AutomationRegionView (canvas_group, _automation_view, region,
113 _controller->controllable()->parameter(), list,
114 _samples_per_unit, region_color);
116 region_view->init (region_color, false);
117 region_views.push_front (region_view);
119 /* follow global waveform setting */
122 region_view->enable_display(true);
123 //region_view->midi_region()->midi_source(0)->load_model();
126 display_region(region_view);
128 /* catch regionview going away */
129 region->GoingAway.connect (bind (mem_fun (*this, &AutomationStreamView::remove_region_view), region));
131 RegionViewAdded (region_view);
137 AutomationStreamView::display_region(AutomationRegionView* region_view)
139 region_view->line().reset();
143 AutomationStreamView::redisplay_diskstream ()
145 list<RegionView *>::iterator i, tmp;
147 for (i = region_views.begin(); i != region_views.end(); ++i)
148 (*i)->set_valid (false);
150 if (_trackview.is_track()) {
151 _trackview.get_diskstream()->playlist()->foreach_region (static_cast<StreamView*>(this), &StreamView::add_region_view);
154 for (i = region_views.begin(); i != region_views.end(); ) {
158 if (!(*i)->is_valid()) {
160 region_views.erase (i);
162 (*i)->enable_display(true);
163 (*i)->set_y_position_and_height(0, height);
169 /* now fix layering */
171 for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
178 AutomationStreamView::setup_rec_box ()
183 AutomationStreamView::update_rec_regions (nframes_t start, nframes_t dur)
188 AutomationStreamView::rec_data_range_ready (jack_nframes_t start, jack_nframes_t dur)
190 // this is called from the butler thread for now
192 ENSURE_GUI_THREAD(bind (mem_fun (*this, &AutomationStreamView::rec_data_range_ready), start, dur));
194 this->update_rec_regions (start, dur);
198 AutomationStreamView::color_handler ()
200 /*if (_trackview.is_midi_track()) {
201 canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiTrackBase.get();
204 if (!_trackview.is_midi_track()) {
205 canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiBusBase.get();;