Highlight note in piano roll - #6510
This commit is contained in:
parent
041b31d7c6
commit
f2495d9808
@ -485,6 +485,11 @@ MidiRegionView::leave_internal()
|
||||
if (frame_handle_end) {
|
||||
frame_handle_end->raise_to_top();
|
||||
}
|
||||
|
||||
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
||||
if (mtv) {
|
||||
mtv->set_note_highlight (NO_MIDI_NOTE);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -4006,7 +4011,7 @@ MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
|
||||
|
||||
std::string name;
|
||||
|
||||
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
||||
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
||||
if (mtv) {
|
||||
boost::shared_ptr<MasterDeviceNames> device_names(mtv->get_device_names());
|
||||
if (device_names) {
|
||||
@ -4018,6 +4023,7 @@ MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
|
||||
patch_key.program(),
|
||||
n->note());
|
||||
}
|
||||
mtv->set_note_highlight (n->note());
|
||||
}
|
||||
|
||||
char buf[128];
|
||||
|
@ -123,6 +123,11 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanva
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MidiTimeAxisView::set_note_highlight (uint8_t note) {
|
||||
_piano_roll_header->set_note_highlight (note);
|
||||
}
|
||||
|
||||
void
|
||||
MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
|
||||
{
|
||||
|
@ -68,6 +68,8 @@ class StepEntry;
|
||||
class StepEditor;
|
||||
class MidiChannelSelectorWindow;
|
||||
|
||||
#define NO_MIDI_NOTE 0xff
|
||||
|
||||
class MidiTimeAxisView : public RouteTimeAxisView
|
||||
{
|
||||
public:
|
||||
@ -102,6 +104,7 @@ public:
|
||||
void check_step_edit ();
|
||||
|
||||
void first_idle ();
|
||||
void set_note_highlight (uint8_t note);
|
||||
|
||||
uint8_t get_channel_for_add () const;
|
||||
|
||||
|
@ -28,18 +28,16 @@
|
||||
#include "midi_streamview.h"
|
||||
#include "public_editor.h"
|
||||
|
||||
const int no_note = 0xff;
|
||||
|
||||
using namespace std;
|
||||
using namespace Gtkmm2ext;
|
||||
|
||||
PianoRollHeader::Color PianoRollHeader::white = PianoRollHeader::Color(0.77f, 0.78f, 0.76f);
|
||||
PianoRollHeader::Color PianoRollHeader::white_highlight = PianoRollHeader::Color(0.87f, 0.88f, 0.86f);
|
||||
PianoRollHeader::Color PianoRollHeader::white_highlight = PianoRollHeader::Color(1.00f, 0.50f, 0.50f);
|
||||
PianoRollHeader::Color PianoRollHeader::white_shade_light = PianoRollHeader::Color(0.95f, 0.95f, 0.95f);
|
||||
PianoRollHeader::Color PianoRollHeader::white_shade_dark = PianoRollHeader::Color(0.56f, 0.56f, 0.56f);
|
||||
|
||||
PianoRollHeader::Color PianoRollHeader::black = PianoRollHeader::Color(0.24f, 0.24f, 0.24f);
|
||||
PianoRollHeader::Color PianoRollHeader::black_highlight = PianoRollHeader::Color(0.30f, 0.30f, 0.30f);
|
||||
PianoRollHeader::Color PianoRollHeader::black_highlight = PianoRollHeader::Color(0.50f, 0.10f, 0.10f);
|
||||
PianoRollHeader::Color PianoRollHeader::black_shade_light = PianoRollHeader::Color(0.46f, 0.46f, 0.46f);
|
||||
PianoRollHeader::Color PianoRollHeader::black_shade_dark = PianoRollHeader::Color(0.1f, 0.1f, 0.1f);
|
||||
|
||||
@ -67,8 +65,8 @@ PianoRollHeader::Color::set(const PianoRollHeader::Color& c)
|
||||
|
||||
PianoRollHeader::PianoRollHeader(MidiStreamView& v)
|
||||
: _view(v)
|
||||
, _highlighted_note(no_note)
|
||||
, _clicked_note(no_note)
|
||||
, _highlighted_note(NO_MIDI_NOTE)
|
||||
, _clicked_note(NO_MIDI_NOTE)
|
||||
, _dragging(false)
|
||||
{
|
||||
add_events (Gdk::BUTTON_PRESS_MASK |
|
||||
@ -463,9 +461,10 @@ PianoRollHeader::on_expose_event (GdkEventExpose* ev)
|
||||
bool
|
||||
PianoRollHeader::on_motion_notify_event (GdkEventMotion* ev)
|
||||
{
|
||||
if (_dragging) {
|
||||
int note = _view.y_to_note(ev->y);
|
||||
set_note_highlight (note);
|
||||
|
||||
int note = _view.y_to_note(ev->y);
|
||||
if (_dragging) {
|
||||
|
||||
if ( false /*editor().current_mouse_mode() == Editing::MouseRange*/ ) { //ToDo: fix this. this mode is buggy, and of questionable utility anyway
|
||||
|
||||
@ -476,21 +475,9 @@ PianoRollHeader::on_motion_notify_event (GdkEventMotion* ev)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* play notes */
|
||||
|
||||
if (_highlighted_note != no_note) {
|
||||
if (note > _highlighted_note) {
|
||||
invalidate_note_range(_highlighted_note, note);
|
||||
} else {
|
||||
invalidate_note_range(note, _highlighted_note);
|
||||
}
|
||||
|
||||
_highlighted_note = note;
|
||||
}
|
||||
|
||||
/* redraw already taken care of above */
|
||||
if (_clicked_note != no_note && _clicked_note != note) {
|
||||
/* redraw already taken care of above in set_note_highlight */
|
||||
if (_clicked_note != NO_MIDI_NOTE && _clicked_note != note) {
|
||||
_active_notes[_clicked_note] = false;
|
||||
send_note_off(_clicked_note);
|
||||
|
||||
@ -569,12 +556,27 @@ PianoRollHeader::on_button_release_event (GdkEventButton* ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
PianoRollHeader::set_note_highlight (uint8_t note) {
|
||||
if (_highlighted_note != NO_MIDI_NOTE) {
|
||||
if (note > _highlighted_note) {
|
||||
invalidate_note_range (_highlighted_note, note);
|
||||
} else {
|
||||
invalidate_note_range (note, _highlighted_note);
|
||||
}
|
||||
}
|
||||
|
||||
_highlighted_note = note;
|
||||
|
||||
if (_highlighted_note != NO_MIDI_NOTE) {
|
||||
invalidate_note_range (_highlighted_note, _highlighted_note);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
PianoRollHeader::on_enter_notify_event (GdkEventCrossing* ev)
|
||||
{
|
||||
_highlighted_note = _view.y_to_note(ev->y);
|
||||
|
||||
invalidate_note_range(_highlighted_note, _highlighted_note);
|
||||
set_note_highlight (_view.y_to_note(ev->y));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -583,11 +585,11 @@ PianoRollHeader::on_leave_notify_event (GdkEventCrossing*)
|
||||
{
|
||||
invalidate_note_range(_highlighted_note, _highlighted_note);
|
||||
|
||||
if (_clicked_note != no_note) {
|
||||
if (_clicked_note != NO_MIDI_NOTE) {
|
||||
reset_clicked_note(_clicked_note, _clicked_note != _highlighted_note);
|
||||
}
|
||||
|
||||
_highlighted_note = no_note;
|
||||
_highlighted_note = NO_MIDI_NOTE;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -702,7 +704,7 @@ void
|
||||
PianoRollHeader::reset_clicked_note (uint8_t note, bool invalidate)
|
||||
{
|
||||
_active_notes[note] = false;
|
||||
_clicked_note = no_note;
|
||||
_clicked_note = NO_MIDI_NOTE;
|
||||
send_note_off (note);
|
||||
if (invalidate) {
|
||||
invalidate_note_range (note, note);
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void on_size_allocate(Gtk::Allocation& a);
|
||||
|
||||
void note_range_changed();
|
||||
void set_note_highlight (uint8_t note);
|
||||
|
||||
struct Color {
|
||||
Color();
|
||||
|
Loading…
Reference in New Issue
Block a user