1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-23 21:14:04 +02:00

ubb-la/gui.c: add horizontal panning (WIP)

This commit is contained in:
Werner Almesberger 2013-01-30 20:49:39 -03:00
parent 12a1808e09
commit c702fc0e90

View File

@ -159,13 +159,14 @@ static void show_buffer(const uint8_t *buf, int skip, int nibbles,
int x0, int x1, int zoom, int pos)
{
int xm, w, p0, p1;
int d;
int d, dp;
xm = (x0+x1) >> 1;
dp = pos-((nibbles+skip) >> 1);
if (zoom < 0) {
w = (nibbles-skip) >> -zoom;
p0 = xm-(w >> 1);
p1 = xm+((w+1) >> 1);
p0 = xm-(w >> 1)-(dp >> -zoom);
p1 = xm+((w+1) >> 1)-(dp >> -zoom);
if (p0 < x0) {
skip += (x0-p0) << -zoom;
p0 = x0;
@ -177,8 +178,8 @@ static void show_buffer(const uint8_t *buf, int skip, int nibbles,
show_buffer_zoom_out(buf, skip, nibbles, p0, p1);
} else {
w = (nibbles-skip) << zoom;
p0 = xm-(w >> 1);
p1 = xm+((w+1) >> 1);
p0 = xm-(w >> 1)-(dp << zoom);
p1 = xm+((w+1) >> 1)-(dp << zoom);
if (p0 < x0) {
d = ((x0-p0)+(1 << zoom)-1) >> zoom;
skip += d;
@ -229,6 +230,14 @@ void gui(const uint8_t *buf, int skip, int nibbles)
if (zoom > min_zoom)
zoom--;
break;
case SDLK_LEFT:
if (pos)
pos--;
break;
case SDLK_RIGHT:
if (pos < nibbles-1)
pos++;
break;
case SDLK_RETURN:
case SDLK_q:
return;