summaryrefslogtreecommitdiff
path: root/Userland/Applications/Piano/KeysWidget.cpp
diff options
context:
space:
mode:
authorGrant Yap <grantivanyap@yahoo.com>2021-05-16 23:38:38 +0800
committerLinus Groh <mail@linusgroh.de>2021-05-17 00:16:49 +0100
commitca9101e5f0c804eee9cfb44ce770a98a249f75c6 (patch)
tree85d7b07fbcc12c5e29eeeddf8bf7aaea94989a74 /Userland/Applications/Piano/KeysWidget.cpp
parent186102dcc689cd38a8e88236088a0d33142936c7 (diff)
downloadserenity-ca9101e5f0c804eee9cfb44ce770a98a249f75c6.zip
Piano: Use the return key emoji in the key labels
The new way labels are stored unfortunately makes it *slightly* less convenient to update the lists of white key and black key labels.
Diffstat (limited to 'Userland/Applications/Piano/KeysWidget.cpp')
-rw-r--r--Userland/Applications/Piano/KeysWidget.cpp56
1 files changed, 29 insertions, 27 deletions
diff --git a/Userland/Applications/Piano/KeysWidget.cpp b/Userland/Applications/Piano/KeysWidget.cpp
index 35d621dd45..dfa72e1b1d 100644
--- a/Userland/Applications/Piano/KeysWidget.cpp
+++ b/Userland/Applications/Piano/KeysWidget.cpp
@@ -7,6 +7,8 @@
#include "KeysWidget.h"
#include "TrackManager.h"
+#include <AK/Array.h>
+#include <AK/StringView.h>
#include <LibGUI/Painter.h>
KeysWidget::KeysWidget(TrackManager& track_manager)
@@ -107,33 +109,33 @@ constexpr int black_key_width = 16;
constexpr int black_key_x_offset = black_key_width / 2;
constexpr int black_key_height = 60;
-constexpr char white_key_labels[] = {
- 'A',
- 'S',
- 'D',
- 'F',
- 'G',
- 'H',
- 'J',
- 'K',
- 'L',
- ';',
- '\'',
- 'r',
+constexpr int white_key_labels_count = 12;
+constexpr Array<StringView, white_key_labels_count> white_key_labels = {
+ "A",
+ "S",
+ "D",
+ "F",
+ "G",
+ "H",
+ "J",
+ "K",
+ "L",
+ ";",
+ "\'",
+ "\u23CE", // Return key symbol
};
-constexpr int white_key_labels_count = sizeof(white_key_labels) / sizeof(char);
-
-constexpr char black_key_labels[] = {
- 'W',
- 'E',
- 'T',
- 'Y',
- 'U',
- 'O',
- 'P',
- ']',
+
+constexpr int black_key_labels_count = 8;
+constexpr Array<StringView, black_key_labels_count> black_key_labels = {
+ "W",
+ "E",
+ "T",
+ "Y",
+ "U",
+ "O",
+ "P",
+ "]",
};
-constexpr int black_key_labels_count = sizeof(black_key_labels) / sizeof(char);
constexpr int black_key_offsets[] = {
white_key_width,
@@ -175,7 +177,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
painter.draw_rect(rect, Color::Black);
if (i < white_key_labels_count) {
rect.set_height(rect.height() * 1.5);
- painter.draw_text(rect, StringView(&white_key_labels[i], 1), Gfx::TextAlignment::Center, Color::Black);
+ painter.draw_text(rect, white_key_labels[i], Gfx::TextAlignment::Center, Color::Black);
}
note += white_key_note_accumulator[i % white_keys_per_octave];
@@ -197,7 +199,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
painter.draw_rect(rect, Color::Black);
if (i < black_key_labels_count) {
rect.set_height(rect.height() * 1.5);
- painter.draw_text(rect, StringView(&black_key_labels[i], 1), Gfx::TextAlignment::Center, Color::White);
+ painter.draw_text(rect, black_key_labels[i], Gfx::TextAlignment::Center, Color::White);
}
note += black_key_note_accumulator[i % black_keys_per_octave];