Piano: Highlight pressed key in roll widget

This commit is contained in:
Peter Elliott 2020-10-05 20:31:01 -07:00 committed by Andreas Kling
commit 01bff0141e
Notes: sideshowbarker 2024-07-19 01:55:52 +09:00
6 changed files with 25 additions and 1 deletions

View file

@ -92,6 +92,8 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
for (int y = 0; y < notes_to_paint; ++y) {
int y_pos = y * note_height;
int note = (note_count - note_offset - 1) - y;
for (int x = 0; x < horizontal_notes_to_paint; ++x) {
// This is needed to avoid rounding errors. You can't just use
// m_note_width as the width.
@ -105,6 +107,9 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
else
painter.fill_rect(rect, Color::White);
if (keys_widget() && keys_widget()->note_is_set(note))
painter.fill_rect(rect, note_pressed_color.with_alpha(128));
painter.draw_line(rect.top_right(), rect.bottom_right(), Color::Black);
painter.draw_line(rect.bottom_left(), rect.bottom_right(), Color::Black);
}