summaryrefslogtreecommitdiff
path: root/Userland/Applications/Piano
diff options
context:
space:
mode:
authorMusab Kılıç <musabkilic@protonmail.com>2021-09-02 22:45:04 +0300
committerAndreas Kling <kling@serenityos.org>2021-09-03 23:34:38 +0200
commit764d31b6c337313c404d514f8923c15685340ae3 (patch)
tree1985072f351ce2c9fb61f424d1e7d67c39f697f2 /Userland/Applications/Piano
parentd7b6cc6421c48185f4dfafb24d2b093b86305860 (diff)
downloadserenity-764d31b6c337313c404d514f8923c15685340ae3.zip
Piano: Draw note names on top of notes
Diffstat (limited to 'Userland/Applications/Piano')
-rw-r--r--Userland/Applications/Piano/RollWidget.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp
index d53e0ef64e..51bc56f27c 100644
--- a/Userland/Applications/Piano/RollWidget.cpp
+++ b/Userland/Applications/Piano/RollWidget.cpp
@@ -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);