freemyipod r695 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r694‎ | r695 | r696 >
Date:13:48, 20 April 2011
Author:theseven
Status:new
Tags:
Comment:
libui: iconflow: fix hard jumps when moving by pressing a button while idle
Modified paths:
  • /libs/ui/chooser_renderer_iconflow.c (modified) (history)

Diff [purge]

Index: libs/ui/chooser_renderer_iconflow.c
@@ -37,7 +37,7 @@
3838 struct chooser_renderer_iconflow_data* rdata;
3939 rdata = (struct chooser_renderer_iconflow_data*)(data->rendererdata);
4040 rdata->viewposition = params->startposition * data->info->actionhandler->stepsperitem(data);
41 - rdata->accumulator = 0;
 41+ rdata->accumulator = 0;
4242 rdata->lastupdate = USEC_TIMER;
4343 return 0;
4444 }
@@ -60,14 +60,19 @@
6161 rdata = (struct chooser_renderer_iconflow_data*)(data->rendererdata);
6262 long time = USEC_TIMER;
6363 long timediff = time - rdata->lastupdate;
64 - int distance = data->position - rdata->viewposition;
65 - if (distance) rc = CHOOSER_RESULT_REDRAW;
66 - int factor = params->smoothness / timediff + 1;
 64+ if (!timediff) timediff = 1;
 65+ int distance;
 66+ if (!rdata->lastupdate) distance = 0;
 67+ else distance = data->position - rdata->viewposition;
 68+ int factor = params->smoothness / timediff;
 69+ if (!factor) factor = 1;
6770 rdata->accumulator += distance;
6871 distance = rdata->accumulator / factor;
6972 rdata->accumulator -= distance * factor;
7073 rdata->viewposition += distance;
7174 rdata->lastupdate = time;
 75+ if (data->position - rdata->viewposition) rc = CHOOSER_RESULT_REDRAW;
 76+ else rdata->lastupdate = 0;
7277 if (params->copy_dest.buf.addr == params->fill_dest.loc.buf.addr
7378 && params->copy_dest.buf.stride == params->fill_dest.loc.buf.stride
7479 && params->copy_dest.pos.x == params->fill_dest.loc.pos.x