feat(keyboard): unify keyboard metrics across Base, Lyra and Lyra3Covers themes
This commit is contained in:
@@ -261,13 +261,16 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
|||||||
GUI.drawTextField(renderer, Rect{contentRect.x, inputStartY, contentRect.width, inputHeight}, textWidth);
|
GUI.drawTextField(renderer, Rect{contentRect.x, inputStartY, contentRect.width, inputHeight}, textWidth);
|
||||||
|
|
||||||
const int keyHeight = metrics.keyboardKeyHeight;
|
const int keyHeight = metrics.keyboardKeyHeight;
|
||||||
|
const int bottomKeyHeight = metrics.keyboardBottomKeyHeight;
|
||||||
const int keySpacing = metrics.keyboardKeySpacing;
|
const int keySpacing = metrics.keyboardKeySpacing;
|
||||||
const int keyWidth = (pageWidth * 95 / 100 - (COLS - 1) * keySpacing) / COLS;
|
const int keyWidth = (pageWidth * 95 / 100 - (COLS - 1) * keySpacing) / COLS;
|
||||||
const int leftMargin = (pageWidth - (COLS * keyWidth + (COLS - 1) * keySpacing)) / 2;
|
const int leftMargin = (pageWidth - (COLS * keyWidth + (COLS - 1) * keySpacing)) / 2;
|
||||||
|
|
||||||
|
const int bottomRowGap = metrics.keyboardBottomKeySpacing > 0 ? 4 : 0;
|
||||||
const int keyboardStartY = metrics.keyboardBottomAligned
|
const int keyboardStartY = metrics.keyboardBottomAligned
|
||||||
? pageHeight - metrics.buttonHintsHeight - metrics.verticalSpacing -
|
? pageHeight - metrics.buttonHintsHeight - metrics.verticalSpacing -
|
||||||
(keyHeight + keySpacing) * getTotalRowCount() + metrics.keyboardVerticalOffset
|
(keyHeight + keySpacing) * getContentRowCount() - bottomKeyHeight -
|
||||||
|
bottomRowGap + metrics.keyboardVerticalOffset
|
||||||
: inputStartY + inputHeight + lineHeight + metrics.verticalSpacing;
|
: inputStartY + inputHeight + lineHeight + metrics.verticalSpacing;
|
||||||
const KeyDef(*layout)[COLS] = symMode ? symLayout : abcLayout;
|
const KeyDef(*layout)[COLS] = symMode ? symLayout : abcLayout;
|
||||||
const int contentRows = getContentRowCount();
|
const int contentRows = getContentRowCount();
|
||||||
@@ -297,7 +300,6 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int bottomRowGap = metrics.keyboardBottomKeySpacing > 0 ? 4 : 0;
|
|
||||||
const int bottomRowY = keyboardStartY + contentRows * (keyHeight + keySpacing) + bottomRowGap;
|
const int bottomRowY = keyboardStartY + contentRows * (keyHeight + keySpacing) + bottomRowGap;
|
||||||
const int bkSpacing = metrics.keyboardBottomKeySpacing;
|
const int bkSpacing = metrics.keyboardBottomKeySpacing;
|
||||||
const int contentTotalWidth = COLS * keyWidth + (COLS - 1) * keySpacing;
|
const int contentTotalWidth = COLS * keyWidth + (COLS - 1) * keySpacing;
|
||||||
@@ -325,8 +327,8 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
|||||||
const int keyX = leftMargin + i * (bottomKeyWidth + bkSpacing);
|
const int keyX = leftMargin + i * (bottomKeyWidth + bkSpacing);
|
||||||
const bool isSelected = bottomSelected && i == selectedCol;
|
const bool isSelected = bottomSelected && i == selectedCol;
|
||||||
|
|
||||||
GUI.drawKeyboardKey(renderer, Rect{keyX, bottomRowY, bottomKeyWidth, keyHeight}, bottomKeys[i].label, isSelected,
|
GUI.drawKeyboardKey(renderer, Rect{keyX, bottomRowY, bottomKeyWidth, bottomKeyHeight}, bottomKeys[i].label,
|
||||||
nullptr, bottomKeys[i].themeType);
|
isSelected, nullptr, bottomKeys[i].themeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto labels = mappedInput.mapLabels(tr(STR_BACK), tr(STR_SELECT), tr(STR_DIR_LEFT), tr(STR_DIR_RIGHT));
|
const auto labels = mappedInput.mapLabels(tr(STR_BACK), tr(STR_SELECT), tr(STR_DIR_LEFT), tr(STR_DIR_RIGHT));
|
||||||
|
|||||||
@@ -884,8 +884,8 @@ void BaseTheme::drawTextField(const GfxRenderer& renderer, Rect rect, const int
|
|||||||
const int bracketHeight = lineHeight;
|
const int bracketHeight = lineHeight;
|
||||||
const int fieldLeft = rect.x + 10;
|
const int fieldLeft = rect.x + 10;
|
||||||
const int fieldRight = rect.x + rect.width - 15;
|
const int fieldRight = rect.x + rect.width - 15;
|
||||||
const int topY = rect.y;
|
const int topY = rect.y - 5;
|
||||||
const int bottomY = rect.y + rect.height + lineHeight;
|
const int bottomY = rect.y + rect.height + lineHeight + 5;
|
||||||
const int tickLen = bracketHeight / 2;
|
const int tickLen = bracketHeight / 2;
|
||||||
|
|
||||||
renderer.drawLine(fieldLeft, topY, fieldLeft, bottomY);
|
renderer.drawLine(fieldLeft, topY, fieldLeft, bottomY);
|
||||||
@@ -937,10 +937,11 @@ void BaseTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch
|
|||||||
const int itemWidth = renderer.getTextWidth(fontId, label);
|
const int itemWidth = renderer.getTextWidth(fontId, label);
|
||||||
const int textX = rect.x + (rect.width - itemWidth) / 2;
|
const int textX = rect.x + (rect.width - itemWidth) / 2;
|
||||||
const int textY = rect.y + (rect.height - renderer.getLineHeight(fontId)) / 2 + primaryOffset;
|
const int textY = rect.y + (rect.height - renderer.getLineHeight(fontId)) / 2 + primaryOffset;
|
||||||
renderer.drawText(fontId, textX, textY, label, !isSelected);
|
|
||||||
|
|
||||||
if (hasSecondary) {
|
if (hasSecondary) {
|
||||||
const int secWidth = renderer.getTextWidth(SMALL_FONT_ID, secondaryLabel);
|
const int secWidth = renderer.getTextWidth(SMALL_FONT_ID, secondaryLabel);
|
||||||
renderer.drawText(SMALL_FONT_ID, rect.x + rect.width - secWidth - 1, rect.y - 3, secondaryLabel, !isSelected);
|
renderer.drawText(SMALL_FONT_ID, rect.x + rect.width - secWidth - 1, rect.y, secondaryLabel, !isSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer.drawText(fontId, textX, textY, label, !isSelected);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ struct ThemeMetrics {
|
|||||||
int keyboardKeyWidth;
|
int keyboardKeyWidth;
|
||||||
int keyboardKeyHeight;
|
int keyboardKeyHeight;
|
||||||
int keyboardKeySpacing;
|
int keyboardKeySpacing;
|
||||||
|
int keyboardBottomKeyHeight;
|
||||||
int keyboardBottomKeySpacing;
|
int keyboardBottomKeySpacing;
|
||||||
bool keyboardBottomAligned;
|
bool keyboardBottomAligned;
|
||||||
bool keyboardCenteredText;
|
bool keyboardCenteredText;
|
||||||
@@ -100,12 +101,13 @@ constexpr ThemeMetrics values = {.batteryWidth = 15,
|
|||||||
.statusBarHorizontalMargin = 5,
|
.statusBarHorizontalMargin = 5,
|
||||||
.statusBarVerticalMargin = 19,
|
.statusBarVerticalMargin = 19,
|
||||||
.keyboardKeyWidth = 22,
|
.keyboardKeyWidth = 22,
|
||||||
.keyboardKeyHeight = 30,
|
.keyboardKeyHeight = 40,
|
||||||
.keyboardKeySpacing = 10,
|
.keyboardKeySpacing = 0,
|
||||||
.keyboardBottomKeySpacing = 0,
|
.keyboardBottomKeyHeight = 35,
|
||||||
|
.keyboardBottomKeySpacing = 5,
|
||||||
.keyboardBottomAligned = true,
|
.keyboardBottomAligned = true,
|
||||||
.keyboardCenteredText = false,
|
.keyboardCenteredText = false,
|
||||||
.keyboardVerticalOffset = -10};
|
.keyboardVerticalOffset = -13};
|
||||||
}
|
}
|
||||||
|
|
||||||
class BaseTheme {
|
class BaseTheme {
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ constexpr ThemeMetrics values = {.batteryWidth = 16,
|
|||||||
.statusBarHorizontalMargin = 5,
|
.statusBarHorizontalMargin = 5,
|
||||||
.statusBarVerticalMargin = 19,
|
.statusBarVerticalMargin = 19,
|
||||||
.keyboardKeyWidth = 31,
|
.keyboardKeyWidth = 31,
|
||||||
.keyboardKeyHeight = 50,
|
.keyboardKeyHeight = 40,
|
||||||
.keyboardKeySpacing = 0,
|
.keyboardKeySpacing = 0,
|
||||||
|
.keyboardBottomKeyHeight = 35,
|
||||||
.keyboardBottomKeySpacing = 5,
|
.keyboardBottomKeySpacing = 5,
|
||||||
.keyboardBottomAligned = true,
|
.keyboardBottomAligned = true,
|
||||||
.keyboardCenteredText = true,
|
.keyboardCenteredText = true,
|
||||||
.keyboardVerticalOffset = 0};
|
.keyboardVerticalOffset = -7};
|
||||||
}
|
}
|
||||||
|
|
||||||
class Lyra3CoversTheme : public LyraTheme {
|
class Lyra3CoversTheme : public LyraTheme {
|
||||||
|
|||||||
@@ -34,10 +34,11 @@ constexpr ThemeMetrics values = {.batteryWidth = 16,
|
|||||||
.keyboardKeyWidth = 31,
|
.keyboardKeyWidth = 31,
|
||||||
.keyboardKeyHeight = 40,
|
.keyboardKeyHeight = 40,
|
||||||
.keyboardKeySpacing = 0,
|
.keyboardKeySpacing = 0,
|
||||||
|
.keyboardBottomKeyHeight = 35,
|
||||||
.keyboardBottomKeySpacing = 5,
|
.keyboardBottomKeySpacing = 5,
|
||||||
.keyboardBottomAligned = true,
|
.keyboardBottomAligned = true,
|
||||||
.keyboardCenteredText = true,
|
.keyboardCenteredText = true,
|
||||||
.keyboardVerticalOffset = -12};
|
.keyboardVerticalOffset = -7};
|
||||||
}
|
}
|
||||||
|
|
||||||
class LyraTheme : public BaseTheme {
|
class LyraTheme : public BaseTheme {
|
||||||
|
|||||||
Reference in New Issue
Block a user