summaryrefslogtreecommitdiff
path: root/src/ui/listwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-23 23:22:45 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-23 23:22:59 +0300
commitb0e0160ef5d8624d855d7226529e04c1b37ea05b (patch)
tree2e088790bf2509ef4aa493fb6795fd982d54ddea /src/ui/listwidget.c
parent480f3b7e9526d2219267d5426a7c997574846d59 (diff)
Cleanup
Diffstat (limited to 'src/ui/listwidget.c')
-rw-r--r--src/ui/listwidget.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c
index 0e2f9d7e..95be44a0 100644
--- a/src/ui/listwidget.c
+++ b/src/ui/listwidget.c
@@ -50,7 +50,6 @@ iDefineObjectConstruction(ListWidget)
50struct Impl_ListWidget { 50struct Impl_ListWidget {
51 iWidget widget; 51 iWidget widget;
52 iScrollWidget *scroll; 52 iScrollWidget *scroll;
53// int scrollY;
54 iSmoothScroll scrollY; 53 iSmoothScroll scrollY;
55 int itemHeight; 54 int itemHeight;
56 iPtrArray items; 55 iPtrArray items;
@@ -187,7 +186,6 @@ int scrollPos_ListWidget(const iListWidget *d) {
187} 186}
188 187
189void setScrollPos_ListWidget(iListWidget *d, int pos) { 188void setScrollPos_ListWidget(iListWidget *d, int pos) {
190// d->scrollY = pos;
191 setValue_Anim(&d->scrollY.pos, pos, 0); 189 setValue_Anim(&d->scrollY.pos, pos, 0);
192 d->hoverItem = iInvalidPos; 190 d->hoverItem = iInvalidPos;
193 refresh_Widget(as_Widget(d)); 191 refresh_Widget(as_Widget(d));
@@ -195,31 +193,12 @@ void setScrollPos_ListWidget(iListWidget *d, int pos) {
195 193
196void scrollOffset_ListWidget(iListWidget *d, int offset) { 194void scrollOffset_ListWidget(iListWidget *d, int offset) {
197 moveSpan_SmoothScroll(&d->scrollY, offset, 0); 195 moveSpan_SmoothScroll(&d->scrollY, offset, 0);
198 /*
199 d->scrollY += offset;
200 if (d->scrollY < 0) {
201 d->scrollY = 0;
202 stopWidgetMomentum_Touch(as_Widget(d));
203 }
204 const int scrollMax = scrollMax_ListWidget_(d);
205 if (d->scrollY >= scrollMax) {
206 d->scrollY = scrollMax;
207 stopWidgetMomentum_Touch(as_Widget(d));
208 }
209 d->noHoverWhileScrolling = iTrue;
210 if (oldScroll != d->scrollY) {
211 if (d->hoverItem != iInvalidPos) {
212 invalidateItem_ListWidget(d, d->hoverItem);
213 d->hoverItem = iInvalidPos;
214 }
215 updateVisible_ListWidget(d);
216 refresh_Widget(as_Widget(d));
217 return iTrue;
218 }*/
219// return iFalse;
220} 196}
221 197
222void scrollToItem_ListWidget(iListWidget *d, size_t index) { 198void scrollToItem_ListWidget(iListWidget *d, size_t index) {
199 if (index >= size_PtrArray(&d->items)) {
200 return;
201 }
223 stop_Anim(&d->scrollY.pos); 202 stop_Anim(&d->scrollY.pos);
224 const iRect rect = innerBounds_Widget(as_Widget(d)); 203 const iRect rect = innerBounds_Widget(as_Widget(d));
225 int yTop = d->itemHeight * index - pos_SmoothScroll(&d->scrollY); 204 int yTop = d->itemHeight * index - pos_SmoothScroll(&d->scrollY);
@@ -363,7 +342,6 @@ static iBool processEvent_ListWidget_(iListWidget *d, const SDL_Event *ev) {
363 else { 342 else {
364 /* Traditional mouse wheel. */ 343 /* Traditional mouse wheel. */
365 amount *= 3 * d->itemHeight; 344 amount *= 3 * d->itemHeight;
366 //if (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f ? 0.5f : 1.0f)
367 moveSpan_SmoothScroll(&d->scrollY, amount, 200); 345 moveSpan_SmoothScroll(&d->scrollY, amount, 200);
368 } 346 }
369 return iTrue; 347 return iTrue;