Piano: Draw note names on top of notes

This commit is contained in:
Musab Kılıç 2021-09-02 22:45:04 +03:00 committed by Andreas Kling
parent d7b6cc6421
commit 764d31b6c3
Notes: sideshowbarker 2024-07-18 04:49:30 +09:00

View File

@ -105,18 +105,6 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
background_painter.translate(-x_offset, -y_offset);
background_painter.translate(horizontal_note_offset_remainder, note_offset_remainder);
for (int note = note_count - (note_offset + notes_to_paint); note <= (note_count - 1) - note_offset; ++note) {
int y = ((note_count - 1) - note) * note_height;
Gfx::IntRect note_name_rect(3, y, 1, note_height);
const char* note_name = note_names[note % notes_per_octave];
background_painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft);
note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0);
if (note % notes_per_octave == 0)
background_painter.draw_text(note_name_rect, String::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft);
}
m_prev_zoom_level = m_zoom_level;
m_prev_scroll_x = horizontal_scrollbar().value();
m_prev_scroll_y = vertical_scrollbar().value();
@ -165,6 +153,14 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
painter.fill_rect(rect, note_pressed_color);
painter.draw_rect(rect, Color::Black);
}
Gfx::IntRect note_name_rect(3, y, 1, note_height);
const char* note_name = note_names[note % notes_per_octave];
painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft);
note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0);
if (note % notes_per_octave == 0)
painter.draw_text(note_name_rect, String::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft);
}
int x = m_roll_width * (static_cast<double>(m_track_manager.time()) / roll_length);