Add touch-down visual feedback to settings menus

Handle touch-down events separately from tap events in settings activities to provide immediate visual feedback when menu items are touched, before the tap is completed. This improves UI responsiveness by updating the selected index on touch-down.
This commit is contained in:
Justin Mitchell
2026-06-19 14:41:21 -04:00
parent 06ff5aa44a
commit 57c389c0b6
25 changed files with 351 additions and 52 deletions
@@ -25,6 +25,20 @@ void IntervalSelectionActivity::adjustValue(const int delta) {
requestUpdate();
}
bool IntervalSelectionActivity::setValueFromTouch(const int x, const int y) {
const int screenWidth = renderer.getScreenWidth();
const int barWidth = std::min(360, std::max(0, screenWidth - 40));
constexpr int barHeight = 16;
const int barX = std::max(0, (screenWidth - barWidth) / 2);
const int barY = 140;
if (y < barY - 28 || y > barY + barHeight + 36 || x < barX - 20 || x > barX + barWidth + 20) return false;
const int clampedX = std::max(barX, std::min(x, barX + barWidth));
const int range = std::max(1, maxValue - minValue);
value = clampedValue(minValue + (clampedX - barX) * range / std::max(1, barWidth));
return true;
}
void IntervalSelectionActivity::loop() {
if (ignoreConfirmRelease) {
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
@@ -50,6 +64,31 @@ void IntervalSelectionActivity::loop() {
return;
}
switch (mappedInput.wasSwipe()) {
case MappedInputManager::SwipeDir::Left:
adjustValue(-smallStep);
return;
case MappedInputManager::SwipeDir::Right:
adjustValue(smallStep);
return;
case MappedInputManager::SwipeDir::Up:
adjustValue(largeStep);
return;
case MappedInputManager::SwipeDir::Down:
adjustValue(-largeStep);
return;
case MappedInputManager::SwipeDir::None:
break;
}
int tapX = 0;
int tapY = 0;
if (mappedInput.wasScreenTapped(tapX, tapY) && setValueFromTouch(tapX, tapY)) {
setResult(IntervalResult{static_cast<uint32_t>(value)});
finish();
return;
}
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Left}, [this] { adjustValue(-smallStep); });
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Right}, [this] { adjustValue(smallStep); });
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Up}, [this] { adjustValue(largeStep); });