mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:17:35 +00:00
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.
This commit is contained in:
parent
186102dcc6
commit
ca9101e5f0
1 changed files with 28 additions and 26 deletions
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "KeysWidget.h"
|
#include "KeysWidget.h"
|
||||||
#include "TrackManager.h"
|
#include "TrackManager.h"
|
||||||
|
#include <AK/Array.h>
|
||||||
|
#include <AK/StringView.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
|
|
||||||
KeysWidget::KeysWidget(TrackManager& track_manager)
|
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_x_offset = black_key_width / 2;
|
||||||
constexpr int black_key_height = 60;
|
constexpr int black_key_height = 60;
|
||||||
|
|
||||||
constexpr char white_key_labels[] = {
|
constexpr int white_key_labels_count = 12;
|
||||||
'A',
|
constexpr Array<StringView, white_key_labels_count> white_key_labels = {
|
||||||
'S',
|
"A",
|
||||||
'D',
|
"S",
|
||||||
'F',
|
"D",
|
||||||
'G',
|
"F",
|
||||||
'H',
|
"G",
|
||||||
'J',
|
"H",
|
||||||
'K',
|
"J",
|
||||||
'L',
|
"K",
|
||||||
';',
|
"L",
|
||||||
'\'',
|
";",
|
||||||
'r',
|
"\'",
|
||||||
|
"\u23CE", // Return key symbol
|
||||||
};
|
};
|
||||||
constexpr int white_key_labels_count = sizeof(white_key_labels) / sizeof(char);
|
|
||||||
|
|
||||||
constexpr char black_key_labels[] = {
|
constexpr int black_key_labels_count = 8;
|
||||||
'W',
|
constexpr Array<StringView, black_key_labels_count> black_key_labels = {
|
||||||
'E',
|
"W",
|
||||||
'T',
|
"E",
|
||||||
'Y',
|
"T",
|
||||||
'U',
|
"Y",
|
||||||
'O',
|
"U",
|
||||||
'P',
|
"O",
|
||||||
']',
|
"P",
|
||||||
|
"]",
|
||||||
};
|
};
|
||||||
constexpr int black_key_labels_count = sizeof(black_key_labels) / sizeof(char);
|
|
||||||
|
|
||||||
constexpr int black_key_offsets[] = {
|
constexpr int black_key_offsets[] = {
|
||||||
white_key_width,
|
white_key_width,
|
||||||
|
@ -175,7 +177,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
|
||||||
painter.draw_rect(rect, Color::Black);
|
painter.draw_rect(rect, Color::Black);
|
||||||
if (i < white_key_labels_count) {
|
if (i < white_key_labels_count) {
|
||||||
rect.set_height(rect.height() * 1.5);
|
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];
|
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);
|
painter.draw_rect(rect, Color::Black);
|
||||||
if (i < black_key_labels_count) {
|
if (i < black_key_labels_count) {
|
||||||
rect.set_height(rect.height() * 1.5);
|
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];
|
note += black_key_note_accumulator[i % black_keys_per_octave];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue