/*
- Copyright (C) 2008 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
+ * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2009-2013 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
#include <iostream>
#include "evoral/midi_events.h"
#include "midi_time_axis.h"
#include "midi_streamview.h"
#include "public_editor.h"
-
-const int no_note = 0xff;
+#include "ui_config.h"
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.40f, 0.40f);
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.60f, 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);
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 |
void
PianoRollHeader::get_path(PianoRollHeader::ItemType note_type, int note, double x[], double y[])
{
- double y_pos = floor(_view.note_to_y(note)) - 0.5f;
+ double y_pos = floor(_view.note_to_y(note)) + 1.5f;
double note_height;
- double other_y1 = floor(_view.note_to_y(note+1)) + floor(_note_height / 2.0f) + 0.5f;
- double other_y2 = floor(_view.note_to_y(note-1)) + floor(_note_height / 2.0f) - 1.0f;
+ double other_y1 = floor(_view.note_to_y(note+1)) + floor(_note_height / 2.0f) + 2.5f;
+ double other_y2 = floor(_view.note_to_y(note-1)) + floor(_note_height / 2.0f) + 1.0f;
double width = get_width();
if (note == 0) {
- note_height = floor(_view.contents_height()) - y_pos;
+ note_height = floor(_view.contents_height()) - y_pos + 2.;
} else {
- note_height = floor(_view.note_to_y(note - 1)) - y_pos;
+ note_height = floor(_view.note_to_y(note - 1)) - y_pos + 2.;
}
switch (note_type) {
bool
PianoRollHeader::on_motion_notify_event (GdkEventMotion* ev)
{
+ int note = _view.y_to_note(ev->y);
+ set_note_highlight (note);
+
if (_dragging) {
- int note = _view.y_to_note(ev->y);
+ if ( false /*editor().current_mouse_mode() == Editing::MouseRange*/ ) { //ToDo: fix this. this mode is buggy, and of questionable utility anyway
- if (editor().current_mouse_mode() == Editing::MouseRange) {
-
/* select note range */
if (Keyboard::no_modifiers_active (ev->state)) {
}
} 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);
-
+
_clicked_note = note;
-
+
if (!_active_notes[note]) {
_active_notes[note] = true;
send_note_on(note);
PianoRollHeader::on_button_press_event (GdkEventButton* ev)
{
int note = _view.y_to_note(ev->y);
-
- if (ev->button == 2 && ev->type == GDK_BUTTON_PRESS) {
- if (Keyboard::no_modifiers_active (ev->state)) {
- SetNoteSelection (note); // EMIT SIGNAL
- return true;
- }
- return false;
- }
-
- if (ev->button == 1 && ev->type == GDK_BUTTON_PRESS && note >= 0 && note < 128) {
-
+ bool tertiary = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
+
+ if (ev->button == 2 && Keyboard::no_modifiers_active (ev->state)) {
+ SetNoteSelection (note); // EMIT SIGNAL
+ return true;
+ } else if (tertiary && (ev->button == 1 || ev->button == 2)) {
+ ExtendNoteSelection (note); // EMIT SIGNAL
+ return true;
+ } else if (ev->button == 1 && note >= 0 && note < 128) {
add_modal_grab();
_dragging = true;
-
+
if (!_active_notes[note]) {
_active_notes[note] = true;
_clicked_note = note;
send_note_on(note);
-
+
invalidate_note_range(note, note);
} else {
reset_clicked_note(note);
{
int note = _view.y_to_note(ev->y);
- if (editor().current_mouse_mode() == Editing::MouseRange) {
+ if (false /*editor().current_mouse_mode() == Editing::MouseRange*/ ) { //Todo: this mode is buggy, and of questionable utility anyway
if (Keyboard::no_modifiers_active (ev->state)) {
AddNoteSelection (note); // EMIT SIGNAL
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
ExtendNoteSelection (note); // EMIT SIGNAL
}
-
+
} else {
if (_dragging) {
return true;
}
+void
+PianoRollHeader::set_note_highlight (uint8_t note) {
+ if (_highlighted_note == note) {
+ return;
+ }
+
+ 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;
}
{
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;
}
void
PianoRollHeader::on_size_request(Gtk::Requisition* r)
{
- r->width = 20;
+ r->width = std::max (20.f, rintf (20.f * UIConfiguration::instance().get_ui_scale()));
}
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);