X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_streamview.cc;h=d3a316194df53ddec4c8522b63ac0deabc1a8990;hb=9bfe404b4e9f5bc1bbe11b4ef6fd9778a362d04c;hp=9c54c2912e03bfc5aee7b644e60ac65e2c598dea;hpb=fc1e7dbb55939c708ce572d3a5c2518ea926a682;p=ardour.git diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 9c54c2912e..d3a316194d 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -33,8 +33,8 @@ #include "ardour/region_factory.h" #include "ardour/session.h" #include "ardour/smf_source.h" +#include "ardour/evoral_types_convert.h" -#include "ardour_ui.h" #include "gui_thread.h" #include "midi_region_view.h" #include "midi_streamview.h" @@ -45,9 +45,10 @@ #include "region_view.h" #include "rgb_macros.h" #include "selection.h" +#include "ui_config.h" #include "utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -75,7 +76,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), @@ -85,7 +86,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv) color_handler (); - UIConfiguration::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); @@ -242,6 +243,18 @@ MidiStreamView::update_data_note_range(uint8_t min, uint8_t max) return dirty; } +void +MidiStreamView::set_layer_display (LayerDisplay d) +{ + +//revert this change for now. Although stacked view is weirdly implemented wrt the "scroomer", it is still necessary to manage layered midi regions. +// if (d != Overlaid) { +// return; +// } + + StreamView::set_layer_display (d); +} + void MidiStreamView::redisplay_track () { @@ -323,7 +336,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 @@ -336,17 +349,17 @@ 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 ? + + if (mid >= 0 && h > 1.0) { _note_lines->add (mid, h, color); } @@ -436,13 +449,13 @@ MidiStreamView::setup_rec_box () { // cerr << _trackview.name() << " streamview SRB\n"; - if (_trackview.session()->transport_rolling()) { + if (!_trackview.session()->transport_stopped()) { if (!rec_active && _trackview.session()->record_status() == Session::Recording && - _trackview.track()->record_enabled()) { + _trackview.track()->rec_enable_control()->get_value()) { - 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 */ @@ -512,7 +525,7 @@ MidiStreamView::setup_rec_box () } else if (rec_active && (_trackview.session()->record_status() != Session::Recording || - !_trackview.track()->record_enabled())) { + !_trackview.track()->rec_enable_control()->get_value())) { screen_update_connection.disconnect(); rec_active = false; rec_updating = false; @@ -565,9 +578,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")); } } @@ -610,7 +623,7 @@ MidiStreamView::update_rec_box () /* Update the region being recorded to reflect where we currently are */ boost::shared_ptr region = rec_regions.back().first; - region->set_length (_trackview.track()->current_capture_end () - _trackview.track()->current_capture_start()); + region->set_length (_trackview.track()->current_capture_end () - _trackview.track()->current_capture_start(), 0); MidiRegionView* mrv = dynamic_cast (rec_regions.back().second); mrv->extend_active_notes (); @@ -619,7 +632,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) { @@ -628,7 +641,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 @@ -647,7 +661,7 @@ void MidiStreamView::resume_updates () { _updates_suspended = false; - + draw_note_lines (); apply_note_range_to_regions (); @@ -661,7 +675,7 @@ struct RegionPositionSorter { }; bool -MidiStreamView::paste (ARDOUR::framepos_t pos, const Selection& selection, PasteContext& ctx) +MidiStreamView::paste (ARDOUR::framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t sub_num) { /* Paste into the first region which starts on or before pos. Only called when using an internal editing tool. */ @@ -689,5 +703,5 @@ MidiStreamView::paste (ARDOUR::framepos_t pos, const Selection& selection, Paste } MidiRegionView* mrv = dynamic_cast (*prev); - return mrv ? mrv->paste(pos, selection, ctx) : false; + return mrv ? mrv->paste(pos, selection, ctx, sub_num) : false; }