Add some touch padding to the right of the inventory scrollbar

This way if you touch your finger a little bit to the right of the scrollbar, it still activates it instead of closing the inventory. (this was quite easy to do on accident)
This commit is contained in:
UnknownShadow200 2020-10-01 23:07:48 +10:00
parent cad713e6fe
commit 73a68dca39
2 changed files with 9 additions and 2 deletions

View File

@ -304,7 +304,7 @@ static int ScrollbarWidget_PointerDown(void* widget, int id, int x, int y) {
int posY, height;
if (w->draggingId == id) return true;
if (x < w->x || x >= w->x + w->width) return false;
if (x < w->x || x >= w->x + w->width + w->padding) return false;
/* only intercept pointer that's dragging scrollbar */
if (w->draggingId) return false;
@ -378,6 +378,13 @@ void ScrollbarWidget_Create(struct ScrollbarWidget* w) {
w->scrollingAcc = 0.0f;
w->draggingId = 0;
w->dragOffset = 0;
#ifdef CC_BUILD_TOUCH
/* It's easy to accidentally touch a bit to the right of the */
/* scrollbar with your finger, so just add some padding */
if (!Input_TouchMode) return;
w->padding = Display_ScaleX(15);
#endif
}

View File

@ -54,7 +54,7 @@ struct ScrollbarWidget {
int topRow, rowsTotal, rowsVisible;
float scrollingAcc;
int dragOffset;
int draggingId;
int draggingId, padding;
int borderX, borderY;
int nubsWidth, offsets[3];
};