extend strict-i/o to include route outputs.
[ardour.git] / gtk2_ardour / midi_streamview.cc
index 5175cb35a8152166e28dbbc9d19045faa19f1e7b..9258cf027d385973dd4080f64bcce0a4c881cc31 100644 (file)
@@ -34,8 +34,6 @@
 #include "ardour/session.h"
 #include "ardour/smf_source.h"
 
-#include "ardour_ui.h"
-#include "global_signals.h"
 #include "gui_thread.h"
 #include "midi_region_view.h"
 #include "midi_streamview.h"
@@ -46,6 +44,7 @@
 #include "region_view.h"
 #include "rgb_macros.h"
 #include "selection.h"
+#include "ui_config.h"
 #include "utils.h"
 
 #include "i18n.h"
@@ -76,7 +75,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
           can be put below ghost regions from MIDI underlays
        */
        _note_lines = new ArdourCanvas::LineSet (_canvas_group, ArdourCanvas::LineSet::Horizontal);
-       
+
        _note_lines->Event.connect(
                sigc::bind(sigc::mem_fun(_trackview.editor(),
                                         &PublicEditor::canvas_stream_view_event),
@@ -86,7 +85,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
 
        color_handler ();
 
-       ColorsChanged.connect(sigc::mem_fun(*this, &MidiStreamView::color_handler));
+       UIConfiguration::instance().ColorsChanged.connect(sigc::mem_fun(*this, &MidiStreamView::color_handler));
 
        note_range_adjustment.set_page_size(_highest_note - _lowest_note);
        note_range_adjustment.set_value(_lowest_note);
@@ -324,7 +323,7 @@ MidiStreamView::draw_note_lines()
                 */
 
                if (i <= highest_note()) {
-                       _note_lines->add (y, 1.0, ARDOUR_UI::config()->color ("piano roll black outline"));
+                       _note_lines->add (y, 1.0, UIConfiguration::instance().color ("piano roll black outline"));
                }
 
                /* now add a thicker line/bar which covers the entire vertical
@@ -337,16 +336,16 @@ MidiStreamView::draw_note_lines()
                case 6:
                case 8:
                case 10:
-                       color = ARDOUR_UI::config()->color_mod ("piano roll black", "piano roll black");
+                       color = UIConfiguration::instance().color_mod ("piano roll black", "piano roll black");
                        break;
                default:
-                       color = ARDOUR_UI::config()->color_mod ("piano roll white", "piano roll white");
+                       color = UIConfiguration::instance().color_mod ("piano roll white", "piano roll white");
                        break;
                }
 
                double h = y - prev_y;
                double mid = y + (h/2.0);
-                               
+
                if (height > 1.0) { // XXX ? should that not be h >= 1 ?
                        _note_lines->add (mid, h, color);
                }
@@ -443,7 +442,7 @@ MidiStreamView::setup_rec_box ()
                    _trackview.session()->record_status() == Session::Recording &&
                    _trackview.track()->record_enabled()) {
 
-                       if (ARDOUR_UI::config()->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) {
+                       if (UIConfiguration::instance().get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) {
 
                                /* add a new region, but don't bother if they set show-waveforms-while-recording mid-record */
 
@@ -566,9 +565,9 @@ MidiStreamView::color_handler ()
        draw_note_lines ();
 
        if (_trackview.is_midi_track()) {
-               canvas_rect->set_fill_color (ARDOUR_UI::config()->color_mod ("midi track base", "midi track base"));
+               canvas_rect->set_fill_color (UIConfiguration::instance().color_mod ("midi track base", "midi track base"));
        } else {
-               canvas_rect->set_fill_color (ARDOUR_UI::config()->color ("midi bus base"));
+               canvas_rect->set_fill_color (UIConfiguration::instance().color ("midi bus base"));
        }
 }
 
@@ -620,7 +619,7 @@ MidiStreamView::update_rec_box ()
 uint8_t
 MidiStreamView::y_to_note (double y) const
 {
-       int const n = ((contents_height() - y - 1) / contents_height() * (double)contents_note_range())
+       int const n = ((contents_height() - y) / contents_height() * (double)contents_note_range())
                + lowest_note();
 
        if (n < 0) {
@@ -629,7 +628,8 @@ MidiStreamView::y_to_note (double y) const
                return 127;
        }
 
-       return n;
+       /* min due to rounding and/or off-by-one errors */
+       return min ((uint8_t) n, highest_note());
 }
 
 /** Suspend updates to the regions' note ranges and our
@@ -648,7 +648,7 @@ void
 MidiStreamView::resume_updates ()
 {
        _updates_suspended = false;
-       
+
        draw_note_lines ();
        apply_note_range_to_regions ();