1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-05 15:53:43 +02:00

ubb-la/gui.c (gui): make panning zoom-dependent (2 samples at maximum zoom)

This commit is contained in:
Werner Almesberger 2013-01-30 21:08:25 -03:00
parent 4fb2a8cbee
commit 435144223d

View File

@ -206,6 +206,12 @@ static void update(void)
} }
static int pos_step(int zoom)
{
return 1 << (MAX_ZOOM-zoom+1);
}
void gui(const uint8_t *buf, int skip, int nibbles) void gui(const uint8_t *buf, int skip, int nibbles)
{ {
SDL_Event event; SDL_Event event;
@ -235,12 +241,14 @@ void gui(const uint8_t *buf, int skip, int nibbles)
zoom--; zoom--;
break; break;
case SDLK_LEFT: case SDLK_LEFT:
if (pos) pos -= pos_step(zoom);
pos--; if (pos < 0)
pos = 0;
break; break;
case SDLK_RIGHT: case SDLK_RIGHT:
if (pos < nibbles-1) pos += pos_step(zoom);
pos++; if (pos > nibbles-1)
pos = nibbles-1;
break; break;
case SDLK_RETURN: case SDLK_RETURN:
case SDLK_q: case SDLK_q: