Fix DSP load sorting with inactive plugins
[ardour.git] / gtk2_ardour / midi_streamview.h
1 /*
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>
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 #ifndef __ardour_midi_streamview_h__
24 #define __ardour_midi_streamview_h__
25
26 #include <list>
27 #include <cmath>
28
29 #include "ardour/location.h"
30 #include "enums.h"
31 #include "streamview.h"
32 #include "time_axis_view_item.h"
33 #include "route_time_axis.h"
34
35 namespace Gdk {
36         class Color;
37 }
38
39 namespace ARDOUR {
40         class Crossfade;
41         class MidiModel;
42         class MidiRegion;
43         class Route;
44         class Source;
45         struct PeakData;
46 }
47
48 namespace ArdourCanvas {
49         class LineSet;
50 }
51
52 class PublicEditor;
53 class Selectable;
54 class MidiTimeAxisView;
55 class MidiRegionView;
56 class RegionSelection;
57 class CrossfadeView;
58 class Selection;
59
60 class MidiStreamView : public StreamView
61 {
62 public:
63         MidiStreamView (MidiTimeAxisView&);
64         ~MidiStreamView ();
65
66         void set_selected_regionviews (RegionSelection&);
67         void get_inverted_selectables (Selection&, std::list<Selectable* >& results);
68
69         enum VisibleNoteRange {
70                 FullRange,
71                 ContentsRange
72         };
73
74         Gtk::Adjustment note_range_adjustment;
75         ArdourCanvas::Container* midi_underlay_group;
76
77         void set_note_range(VisibleNoteRange r);
78
79         inline uint8_t lowest_note()  const { return _lowest_note; }
80         inline uint8_t highest_note() const { return _highest_note; }
81
82         void update_note_range(uint8_t note_num);
83
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 ();
87
88         inline double contents_height() const {
89                 return (child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2);
90         }
91
92         inline double note_to_y(uint8_t note) const {
93                 return contents_height() - (note + 1 - lowest_note()) * note_height() + 1;
94         }
95
96         uint8_t y_to_note(double y) const;
97
98         inline double note_height() const {
99                 return contents_height() / (double)contents_note_range();
100         }
101
102         inline uint8_t contents_note_range() const {
103                 return highest_note() - lowest_note() + 1;
104         }
105
106         sigc::signal<void> NoteRangeChanged;
107
108         RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool);
109
110         bool paste (ARDOUR::samplepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t sub_num);
111
112         void apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views);
113
114         void suspend_updates ();
115         void resume_updates ();
116
117 protected:
118         void setup_rec_box ();
119         void update_rec_box ();
120
121 private:
122
123         RegionView* add_region_view_internal (
124                         boost::shared_ptr<ARDOUR::Region>,
125                         bool wait_for_waves,
126                         bool recording = false);
127
128         void display_region(MidiRegionView* region_view, bool load_model);
129         void display_track (boost::shared_ptr<ARDOUR::Track> tr);
130
131         void update_contents_height ();
132
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);
136
137         void color_handler ();
138
139         void note_range_adjustment_changed();
140         void apply_note_range_to_regions ();
141
142         bool                      _range_dirty;
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;
151 };
152
153 #endif /* __ardour_midi_streamview_h__ */