fix: resolve 6 cppcheck low-style warnings in keyboard code
This commit is contained in:
@@ -15,7 +15,7 @@ void KeyboardEntryActivity::onEnter() {
|
|||||||
|
|
||||||
void KeyboardEntryActivity::onExit() { Activity::onExit(); }
|
void KeyboardEntryActivity::onExit() { Activity::onExit(); }
|
||||||
|
|
||||||
int KeyboardEntryActivity::getContentRowCount() const { return symMode ? SYM_ROWS : ABC_ROWS; }
|
int KeyboardEntryActivity::getContentRowCount() const { return ABC_ROWS; }
|
||||||
|
|
||||||
int KeyboardEntryActivity::getTotalRowCount() const { return getContentRowCount() + 1; }
|
int KeyboardEntryActivity::getTotalRowCount() const { return getContentRowCount() + 1; }
|
||||||
|
|
||||||
@@ -240,8 +240,8 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
|||||||
secondaryChar = key.primary;
|
secondaryChar = key.primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
char primaryBuf[2] = {primaryChar, '\0'};
|
const char primaryBuf[2] = {primaryChar, '\0'};
|
||||||
char secondaryBuf[2] = {secondaryChar, '\0'};
|
const char secondaryBuf[2] = {secondaryChar, '\0'};
|
||||||
|
|
||||||
const bool showSecondary = !symMode && row == 0 && secondaryChar != '\0';
|
const bool showSecondary = !symMode && row == 0 && secondaryChar != '\0';
|
||||||
GUI.drawKeyboardKey(renderer, Rect{keyX, rowY, keyWidth, keyHeight}, primaryBuf, isSelected,
|
GUI.drawKeyboardKey(renderer, Rect{keyX, rowY, keyWidth, keyHeight}, primaryBuf, isSelected,
|
||||||
@@ -257,16 +257,15 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
|||||||
const int bottomSelectedRow = isBottomRow(selectedRow);
|
const int bottomSelectedRow = isBottomRow(selectedRow);
|
||||||
|
|
||||||
struct BottomKeyInfo {
|
struct BottomKeyInfo {
|
||||||
SpecialKeyType type;
|
|
||||||
KeyboardKeyType themeType;
|
KeyboardKeyType themeType;
|
||||||
const char* label;
|
const char* label;
|
||||||
};
|
};
|
||||||
const BottomKeyInfo bottomKeys[BOTTOM_KEY_COUNT] = {
|
const BottomKeyInfo bottomKeys[BOTTOM_KEY_COUNT] = {
|
||||||
{SpecShift, KeyboardKeyType::Shift, symMode ? shiftString[0] : shiftString[shiftState]},
|
{KeyboardKeyType::Shift, symMode ? shiftString[0] : shiftString[shiftState]},
|
||||||
{SpecMode, KeyboardKeyType::Mode, symMode ? "abc" : "#@!"},
|
{KeyboardKeyType::Mode, symMode ? "abc" : "#@!"},
|
||||||
{SpecSpace, KeyboardKeyType::Space, nullptr},
|
{KeyboardKeyType::Space, nullptr},
|
||||||
{SpecDel, KeyboardKeyType::Del, nullptr},
|
{KeyboardKeyType::Del, nullptr},
|
||||||
{SpecOk, KeyboardKeyType::Ok, tr(STR_OK_BUTTON)},
|
{KeyboardKeyType::Ok, tr(STR_OK_BUTTON)},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < BOTTOM_KEY_COUNT; i++) {
|
for (int i = 0; i < BOTTOM_KEY_COUNT; i++) {
|
||||||
|
|||||||
@@ -910,7 +910,7 @@ void BaseTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0';
|
const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0';
|
||||||
const int primaryOffset = hasSecondary ? 0 : 0;
|
const int primaryOffset = 0;
|
||||||
const int itemWidth = renderer.getTextWidth(UI_12_FONT_ID, label);
|
const int itemWidth = renderer.getTextWidth(UI_12_FONT_ID, 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(UI_12_FONT_ID)) / 2 + primaryOffset;
|
const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset;
|
||||||
|
|||||||
@@ -829,7 +829,7 @@ void LyraTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0';
|
const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0';
|
||||||
const int primaryOffset = hasSecondary ? 0 : 0;
|
const int primaryOffset = 0;
|
||||||
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, label);
|
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, label);
|
||||||
const int textX = rect.x + (rect.width - textWidth) / 2;
|
const int textX = rect.x + (rect.width - textWidth) / 2;
|
||||||
const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset;
|
const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user