- Changed IO's vector<Port*>'s to PortList
[ardour.git] / gtk2_ardour / midi_region_view.cc
1 /*
2     Copyright (C) 2001-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
19 #include <cmath>
20 #include <cassert>
21 #include <algorithm>
22
23 #include <gtkmm.h>
24
25 #include <gtkmm2ext/gtk_ui.h>
26
27 #include <ardour/playlist.h>
28 #include <ardour/midi_region.h>
29 #include <ardour/midi_source.h>
30 #include <ardour/midi_diskstream.h>
31
32 #include "streamview.h"
33 #include "midi_region_view.h"
34 #include "midi_time_axis.h"
35 #include "simplerect.h"
36 #include "simpleline.h"
37 #include "public_editor.h"
38 //#include "midi_region_editor.h"
39 #include "ghostregion.h"
40 #include "midi_time_axis.h"
41 #include "utils.h"
42 #include "rgb_macros.h"
43 #include "gui_thread.h"
44
45 #include "i18n.h"
46
47 using namespace sigc;
48 using namespace ARDOUR;
49 using namespace PBD;
50 using namespace Editing;
51 using namespace ArdourCanvas;
52
53 MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, MidiRegion& r, double spu,
54                                   Gdk::Color& basic_color)
55         : RegionView (parent, tv, r, spu, basic_color)
56 {
57 }
58
59 MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, MidiRegion& r, double spu, 
60                                   Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
61         : RegionView (parent, tv, r, spu, basic_color, visibility)
62 {
63 }
64
65 void
66 MidiRegionView::init (Gdk::Color& basic_color, bool wfd)
67 {
68         // FIXME: Some redundancy here with RegionView::init.  Need to figure out
69         // where order is important and where it isn't...
70         
71         RegionView::init(basic_color, wfd);
72
73         compute_colors (basic_color);
74
75         reset_width_dependent_items ((double) _region.length() / samples_per_unit);
76
77         set_height (trackview.height);
78
79         region_muted ();
80         region_resized (BoundsChanged);
81         region_locked ();
82
83         _region.StateChanged.connect (mem_fun(*this, &MidiRegionView::region_changed));
84
85         set_colors ();
86 }
87
88 MidiRegionView::~MidiRegionView ()
89 {
90         in_destructor = true;
91
92         RegionViewGoingAway (this); /* EMIT_SIGNAL */
93 }
94
95 ARDOUR::MidiRegion&
96 MidiRegionView::midi_region() const
97 {
98         // "Guaranteed" to succeed...
99         return dynamic_cast<MidiRegion&>(_region);
100 }
101
102 void
103 MidiRegionView::show_region_editor ()
104 {
105         cerr << "No MIDI region editor." << endl;
106 }
107
108 GhostRegion*
109 MidiRegionView::add_ghost (AutomationTimeAxisView& atv)
110 {
111         return NULL;
112 }
113