2 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2007 Doug McLain <doug@nostar.net>
4 * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __ardour_midi_streamview_h__
24 #define __ardour_midi_streamview_h__
29 #include "ardour/location.h"
31 #include "streamview.h"
32 #include "time_axis_view_item.h"
33 #include "route_time_axis.h"
48 namespace ArdourCanvas {
54 class MidiTimeAxisView;
56 class RegionSelection;
60 class MidiStreamView : public StreamView
63 MidiStreamView (MidiTimeAxisView&);
66 void set_selected_regionviews (RegionSelection&);
67 void get_inverted_selectables (Selection&, std::list<Selectable* >& results);
69 enum VisibleNoteRange {
74 Gtk::Adjustment note_range_adjustment;
75 ArdourCanvas::Container* midi_underlay_group;
77 void set_note_range(VisibleNoteRange r);
79 inline uint8_t lowest_note() const { return _lowest_note; }
80 inline uint8_t highest_note() const { return _highest_note; }
82 void update_note_range(uint8_t note_num);
84 void set_layer_display (LayerDisplay);
85 //bool can_change_layer_display() const { return false; } // revert this change for now. Although stacked view is weirdly implemented wrt the "scroomer", it is still necessary to be able to manage layered regions.
86 void redisplay_track ();
88 inline double contents_height() const {
89 return (child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2);
92 inline double note_to_y(uint8_t note) const {
93 return contents_height() - (note + 1 - lowest_note()) * note_height() + 1;
96 uint8_t y_to_note(double y) const;
98 inline double note_height() const {
99 return contents_height() / (double)contents_note_range();
102 inline uint8_t contents_note_range() const {
103 return highest_note() - lowest_note() + 1;
106 sigc::signal<void> NoteRangeChanged;
108 RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool);
110 bool paste (ARDOUR::samplepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t sub_num);
112 void apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views);
114 void suspend_updates ();
115 void resume_updates ();
118 void setup_rec_box ();
119 void update_rec_box ();
123 RegionView* add_region_view_internal (
124 boost::shared_ptr<ARDOUR::Region>,
126 bool recording = false);
128 void display_region(MidiRegionView* region_view, bool load_model);
129 void display_track (boost::shared_ptr<ARDOUR::Track> tr);
131 void update_contents_height ();
133 void draw_note_lines();
134 bool update_data_note_range(uint8_t min, uint8_t max);
135 void update_contents_metrics(boost::shared_ptr<ARDOUR::Region> r);
137 void color_handler ();
139 void note_range_adjustment_changed();
140 void apply_note_range_to_regions ();
143 double _range_sum_cache;
144 uint8_t _lowest_note; ///< currently visible
145 uint8_t _highest_note; ///< currently visible
146 uint8_t _data_note_min; ///< in data
147 uint8_t _data_note_max; ///< in data
148 ArdourCanvas::LineSet* _note_lines;
149 /** true if updates to the note lines and regions are currently suspended */
150 bool _updates_suspended;
153 #endif /* __ardour_midi_streamview_h__ */