Selection of visible note range (full range vs fit contents, selectable from midi...
[ardour.git] / gtk2_ardour / midi_region_view.h
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 #ifndef __gtk_ardour_midi_region_view_h__
20 #define __gtk_ardour_midi_region_view_h__
21
22 #include <vector>
23
24 #include <libgnomecanvasmm.h>
25 #include <libgnomecanvasmm/polygon.h>
26 #include <sigc++/signal.h>
27 #include <ardour/midi_region.h>
28 #include <ardour/midi_model.h>
29 #include <ardour/types.h>
30
31 #include "region_view.h"
32 #include "route_time_axis.h"
33 #include "time_axis_view_item.h"
34 #include "automation_line.h"
35 #include "enums.h"
36 #include "canvas.h"
37
38 namespace ARDOUR {
39         class MidiRegion;
40 };
41
42 class MidiTimeAxisView;
43 class GhostRegion;
44 class AutomationTimeAxisView;
45
46 class MidiRegionView : public RegionView
47 {
48   public:
49         MidiRegionView (ArdourCanvas::Group *, 
50                         RouteTimeAxisView&,
51                         boost::shared_ptr<ARDOUR::MidiRegion>,
52                         double initial_samples_per_unit,
53                         Gdk::Color& basic_color);
54
55         ~MidiRegionView ();
56         
57         virtual void init (Gdk::Color& base_color, bool wait_for_data = false);
58         
59         boost::shared_ptr<ARDOUR::MidiRegion> midi_region() const;
60         
61         void set_y_position_and_height (double, double);
62     
63     void show_region_editor ();
64
65     GhostRegion* add_ghost (AutomationTimeAxisView&);
66
67         void add_event(const ARDOUR::MidiEvent& ev);
68         void add_note(const ARDOUR::MidiModel::Note& note);
69
70         void begin_write();
71         void end_write();
72         void extend_active_notes();
73
74   protected:
75
76     /* this constructor allows derived types
77        to specify their visibility requirements
78        to the TimeAxisViewItem parent class
79     */
80     
81     MidiRegionView (ArdourCanvas::Group *, 
82                         RouteTimeAxisView&,
83                         boost::shared_ptr<ARDOUR::MidiRegion>,
84                         double samples_per_unit,
85                         Gdk::Color& basic_color,
86                         TimeAxisViewItem::Visibility);
87     
88     void region_resized (ARDOUR::Change);
89
90     void set_flags (XMLNode *);
91     void store_flags ();
92     
93         void reset_width_dependent_items (double pixel_width);
94
95   private:
96
97         void display_events();
98         void clear_events();
99
100         bool canvas_event(GdkEvent* ev);
101
102         std::vector<ArdourCanvas::Item*> _events;
103         ArdourCanvas::SimpleRect**       _active_notes;
104 };
105
106 #endif /* __gtk_ardour_midi_region_view_h__ */