Fix LV2UI_Request_Parameter Feature URI
[ardour.git] / gtk2_ardour / midi_region_view.cc
index 4a19a6697ac18189f5b1ad1a1d502173511efc6b..bf0595de75485dc18878bf9f44f390609933f0e1 100644 (file)
@@ -133,6 +133,8 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container*      parent,
        PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
 
        Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&MidiRegionView::parameter_changed, this, _1), gui_context());
+       UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &MidiRegionView::parameter_changed));
+
        connect_to_diskstream ();
 }
 
@@ -191,6 +193,8 @@ MidiRegionView::parameter_changed (std::string const & p)
                }
        } else if (p == "color-regions-using-track-color") {
                set_colors ();
+       } else if (p == "use-note-color-for-velocity") {
+               color_handler ();
        }
 }
 
@@ -347,6 +351,9 @@ MidiRegionView::canvas_group_event(GdkEvent* ev)
                return RegionView::canvas_group_event (ev);
        }
 
+       //For now, move the snapped cursor aside so it doesn't bother you during internal editing
+       //trackview.editor().set_snapped_cursor_position(_region->position());
+
        bool r;
 
        switch (ev->type) {
@@ -680,16 +687,17 @@ MidiRegionView::motion (GdkEventMotion* ev)
 
        }
 
-       /* we may be dragging some non-note object (eg. patch-change, sysex)
-        */
-
-       return editor.drags()->motion_handler ((GdkEvent *) ev, false);
+       //let RegionView do it's thing.  drags are handled in here
+       return RegionView::canvas_group_event ((GdkEvent *) ev);
 }
 
 
 bool
 MidiRegionView::scroll (GdkEventScroll* ev)
 {
+       if (trackview.editor().drags()->active()) {
+               return false;
+       }
        if (_selection.empty()) {
                return false;
        }
@@ -1053,14 +1061,15 @@ MidiRegionView::note_diff_add_change (NoteBase* ev,
 void
 MidiRegionView::apply_diff (bool as_subcommand, bool was_copy)
 {
-       bool add_or_remove;
        bool commit = false;
 
        if (!_note_diff_command) {
                return;
        }
 
-       if (!was_copy && (add_or_remove = _note_diff_command->adds_or_removes())) {
+       bool add_or_remove = _note_diff_command->adds_or_removes();
+
+       if (!was_copy && add_or_remove) {
                // Mark all selected notes for selection when model reloads
                for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
                        _marked_for_selection.insert((*i)->note());
@@ -1763,6 +1772,7 @@ MidiRegionView::update_sustained (Note* ev, bool update_ghost_regions)
        y1 = y0 + std::max(1., floor(note_height()) - 1);
 
        ev->set (ArdourCanvas::Rect (x0, y0, x1, y1));
+       ev->set_velocity (note->velocity()/127.0);
 
        if (!note->length()) {
                if (_active_notes && note->note() < 128) {
@@ -2928,9 +2938,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/)
                                                                                            ArdourCanvas::Rect (note->x0(), note->y0(), note->x0(), note->y1()));
 
                        // calculate the colors: get the color settings
-                       uint32_t fill_color = UINT_RGBA_CHANGE_A(
-                               UIConfiguration::instance().color ("midi note selected"),
-                               128);
+                       uint32_t fill_color = NoteBase::meter_style_fill_color (note->note()->velocity(), true);
 
                        // make the resize preview notes more transparent and bright
                        fill_color = UINT_INTERPOLATE(fill_color, 0xFFFFFF40, 0.5);
@@ -2942,7 +2950,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/)
                                0.85));
 
                        resize_rect->set_outline_color (NoteBase::calculate_outline (
-                                                               UIConfiguration::instance().color ("midi note selected")));
+                                                               UIConfiguration::instance().color ("midi note selected outline")));
 
                        resize_data->resize_rect = resize_rect;
                        _resize_data.push_back(resize_data);
@@ -3035,6 +3043,7 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
                        } else {
                                snapped_x = trackview.editor ().pixel_to_sample (current_x);
                        }
+
                        const Temporal::Beats beats = Temporal::Beats (tmap.exact_beat_at_sample (snapped_x + midi_region()->position(), divisions)
                                                                     - midi_region()->beat()) + midi_region()->start_beats();
 
@@ -3058,6 +3067,8 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
                        show_verbose_cursor (buf, 0, 0);
 
                        cursor_set = true;
+
+                       trackview.editor().set_snapped_cursor_position ( snapped_x + midi_region()->position() );
                }
 
        }
@@ -3507,7 +3518,7 @@ MidiRegionView::nudge_notes (bool forward, bool fine)
                        next_pos.sample -= 1;
                }
 
-               trackview.editor().snap_to (next_pos, (forward ? RoundUpAlways : RoundDownAlways), false);
+               trackview.editor().snap_to (next_pos, (forward ? RoundUpAlways : RoundDownAlways), SnapToGrid_Unscaled, false);
                const samplecnt_t distance = ref_point - next_pos.sample;
                delta = region_samples_to_region_beats (fabs ((double)distance));
        }