Add Tab and Cover touch kinds to TouchRegistry
Extends the Kind enum with two new touch interaction types: Tab (2) and Cover (3), enabling support for additional UI element touch handling.
This commit is contained in:
@@ -189,7 +189,14 @@ void HomeActivity::loop() {
|
||||
selectorIndex = static_cast<int>(recentBooks.size()) + tappedId;
|
||||
}
|
||||
|
||||
if (tapped || mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
// A tap on the continue-reading cover selects that book (home selector index).
|
||||
int coverId = -1;
|
||||
const bool coverTapped = mappedInput.wasCoverTapped(coverId);
|
||||
if (coverTapped && coverId >= 0 && coverId < static_cast<int>(recentBooks.size())) {
|
||||
selectorIndex = coverId;
|
||||
}
|
||||
|
||||
if (tapped || coverTapped || mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
if (selectorIndex < recentBooks.size()) {
|
||||
onSelectBook(recentBooks[selectorIndex].path);
|
||||
} else {
|
||||
|
||||
@@ -126,6 +126,15 @@ void SettingsActivity::loop() {
|
||||
return;
|
||||
}
|
||||
|
||||
// A tap on a category tab switches to it (keeps focus on the tab row); the
|
||||
// hasChangedCategory block below swaps in that category's settings list.
|
||||
int tabId = -1;
|
||||
if (mappedInput.wasTabTapped(tabId) && tabId >= 0 && tabId < categoryCount) {
|
||||
selectedCategoryIndex = tabId;
|
||||
selectedSettingIndex = 0;
|
||||
hasChangedCategory = true;
|
||||
}
|
||||
|
||||
// Handle actions with early return
|
||||
if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) {
|
||||
if (selectedSettingIndex == 0) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "MappedInputManager.h"
|
||||
#include "components/TouchRegistry.h"
|
||||
#include "components/UITheme.h"
|
||||
#include "fontIds.h"
|
||||
|
||||
@@ -336,6 +337,18 @@ void KeyboardEntryActivity::loop() {
|
||||
}
|
||||
}
|
||||
|
||||
// A tap selects the key and presses it in one gesture. Encoded id = row*100+col
|
||||
// (bottom function row = getContentRowCount()). Skipped in cursor mode, where a
|
||||
// tap on a key would be ambiguous with cursor editing.
|
||||
int tappedKey = -1;
|
||||
if (!cursorMode && mappedInput.wasItemTapped(tappedKey)) {
|
||||
selectedRow = tappedKey / 100;
|
||||
selectedCol = tappedKey % 100;
|
||||
if (handleKeyPress()) {
|
||||
requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
if (confirmHeld && !confirmLongHandled && !cursorMode) {
|
||||
if (handleKeyPress()) {
|
||||
@@ -646,6 +659,8 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
||||
if (snippetIdx < URL_SNIPPET_COUNT) {
|
||||
GUI.drawKeyboardKey(renderer, Rect{keyX, rowY, keyWidth, keyHeight}, urlSnippets[snippetIdx],
|
||||
activeKeySelected, nullptr);
|
||||
TouchRegistry::getInstance().add(Rect{keyX, rowY, keyWidth, keyHeight}, row * 100 + col,
|
||||
TouchRegistry::Item);
|
||||
}
|
||||
} else {
|
||||
const KeyDef& key = layout[row][col];
|
||||
@@ -663,6 +678,7 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
||||
const bool showSecondary = !symMode && row == 0 && secondaryChar != '\0';
|
||||
GUI.drawKeyboardKey(renderer, Rect{keyX, rowY, keyWidth, keyHeight}, primaryBuf, activeKeySelected,
|
||||
showSecondary ? secondaryBuf : nullptr);
|
||||
TouchRegistry::getInstance().add(Rect{keyX, rowY, keyWidth, keyHeight}, row * 100 + col, TouchRegistry::Item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -691,6 +707,8 @@ void KeyboardEntryActivity::render(RenderLock&&) {
|
||||
const bool activeKeySelected = isSelected && !cursorMode;
|
||||
GUI.drawKeyboardKey(renderer, Rect{keyX, bottomRowY, bottomKeyWidth, bottomKeyHeight}, bottomKeys[i].label,
|
||||
activeKeySelected, nullptr, bottomKeys[i].themeType);
|
||||
TouchRegistry::getInstance().add(Rect{keyX, bottomRowY, bottomKeyWidth, bottomKeyHeight}, contentRows * 100 + i,
|
||||
TouchRegistry::Item);
|
||||
}
|
||||
|
||||
if (cursorMode) {
|
||||
|
||||
Reference in New Issue
Block a user