1#include "ListElement.hpp"
13 ret |= this->handleInertiaScroll(event);
26 if (event->isKeyDown())
29 event->wheelScroll += (SPEED *
event->held(UP_BUTTON) - SPEED *
event->held(DOWN_BUTTON));
31 ret |=
event->held(UP_BUTTON) ||
event->held(DOWN_BUTTON);
37bool ListElement::handleInertiaScroll(InputEvents* event)
40 ListElement* elem =
this;
42 if (event->isTouchDown())
45 if (event->xPos < elem->xAbs)
49 elem->dragging =
true;
50 elem->lastMouseY =
event->yPos;
51 elem->initialTouchDown =
event->yPos;
56 else if (event->isTouchDrag())
61 if (this->initialTouchDown >= 0 && (abs(event->yPos - this->initialTouchDown) < 10 * getEffectiveScale()))
64 this->initialTouchDown = -1;
66 int distance =
event->yPos - elem->lastMouseY;
68 elem->lastMouseY =
event->yPos;
71 elem->elasticCounter = distance;
76 else if (event->isTouchUp())
79 elem->dragging =
false;
84 if (elem->y > minYScroll)
91 if (!elem->dragging && elem->elasticCounter != 0)
93 elem->y += elem->elasticCounter;
96 elem->elasticCounter *= 0.95;
99 if (abs(elem->elasticCounter) < 10)
100 elem->elasticCounter = 0;
103 if (elem->y > minYScroll)
104 elem->y = minYScroll;
109 if (ret)
event->isScrolling =
true;
111 if (event->wheelScroll != 0)
114 elem->y +=
event->wheelScroll * 10;
115 if (elem->y > minYScroll)
116 elem->y = minYScroll;
117 event->wheelScroll *= 0.95;
119 if (abs(event->wheelScroll) < 0.1)
120 event->wheelScroll = 0;
bool hidden
whether this element should skip rendering or not
virtual bool process(InputEvents *event)
process any input that is received for this element
bool process(InputEvents *event)
process any input that is received for this element