Skip to content

Commit

Permalink
Add some touch padding to the right of the inventory scrollbar
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
UnknownShadow200 committed Oct 1, 2020
1 parent cad713e commit 73a68dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Widgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
}


Expand Down
2 changes: 1 addition & 1 deletion src/Widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand Down

0 comments on commit 73a68dc

Please sign in to comment.