Fix bug #6762, MIDNAM note read outs don't work when dragging MIDI note
authorTim Mayberry <mojofunk@gmail.com>
Wed, 10 Feb 2016 12:55:37 +0000 (22:55 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Wed, 10 Feb 2016 22:17:18 +0000 (08:17 +1000)
Also fixes it so the key is selected in the piano roll header

gtk2_ardour/editor_drag.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h

index 0aac54ebc048b37796fb4d0cd267840818c39b51..21cd043304928851f78a593c6d72d7892acd16a0 100644 (file)
@@ -5506,13 +5506,9 @@ NoteDrag::motion (GdkEvent * event, bool)
                 * odd with them. so show the note value anyway, always.
                 */
 
-               char buf[12];
                uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127);
 
-               snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (new_note).c_str(),
-                         (int) floor ((double)new_note));
-
-               show_verbose_cursor_text (buf);
+               _region->show_verbose_cursor_for_new_note_value (_primary->note(), new_note);
        }
 }
 
index c62686170a9372aae83d8b03d1a032c17dbf2240..0b13c3ff4e9b6f5c51355bb586cf773c1486dd9a 100644 (file)
@@ -3997,11 +3997,10 @@ MidiRegionView::delete_sysex (SysEx* /*sysex*/)
        // display_sysexes();
 }
 
-void
-MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
+std::string
+MidiRegionView::get_note_name (boost::shared_ptr<NoteType> n, uint8_t note_value) const
 {
        using namespace MIDI::Name;
-
        std::string name;
 
        MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
@@ -4014,19 +4013,36 @@ MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
                                                       n->channel(),
                                                       patch_key.bank(),
                                                       patch_key.program(),
-                                                      n->note());
+                                                      note_value);
                }
-               mtv->set_note_highlight (n->note());
        }
 
        char buf[128];
        snprintf (buf, sizeof (buf), "%d %s\nCh %d Vel %d",
-                 (int) n->note (),
-                 name.empty() ? Evoral::midi_note_name (n->note()).c_str() : name.c_str(),
+                 (int) note_value,
+                 name.empty() ? Evoral::midi_note_name (note_value).c_str() : name.c_str(),
                  (int) n->channel() + 1,
                  (int) n->velocity());
 
-       show_verbose_cursor(buf, 10, 20);
+       return buf;
+}
+
+void
+MidiRegionView::show_verbose_cursor_for_new_note_value(boost::shared_ptr<NoteType> current_note,
+                                                       uint8_t new_value) const
+{
+       MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
+       if (mtv) {
+               mtv->set_note_highlight (new_value);
+       }
+
+       show_verbose_cursor(get_note_name(current_note, new_value), 10, 20);
+}
+
+void
+MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
+{
+       show_verbose_cursor_for_new_note_value(n, n->note());
 }
 
 void
index 5733861d87feec3b84e7c980911a817d525c099a..b24b76798126383ff7674753a1c405bb5ae82608 100644 (file)
@@ -337,6 +337,9 @@ public:
 
        void note_deleted (NoteBase*);
 
+       void show_verbose_cursor_for_new_note_value(boost::shared_ptr<NoteType> current_note,
+                                                   uint8_t new_note) const;
+
 protected:
        void region_resized (const PBD::PropertyChange&);
 
@@ -391,6 +394,8 @@ private:
        void add_to_selection (NoteBase*);
        void remove_from_selection (NoteBase*);
 
+       std::string get_note_name (boost::shared_ptr<NoteType> note, uint8_t note_value) const;
+
        void show_verbose_cursor (std::string const &, double, double) const;
        void show_verbose_cursor (boost::shared_ptr<NoteType>) const;