1
0
Fork 0
forked from len0rd/rockbox

Refactor the panning code into separate functions, and correct a comment

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18865 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2008-10-23 08:05:25 +00:00
parent 106b68e3a7
commit 188e898e3c

View file

@ -463,54 +463,13 @@ int show_menu(void) /* return 1 to quit */
menu_exit(m);
return 0;
}
/* interactively scroll around the image */
int scroll_bmp(struct t_disp* pdisp)
{
int lastbutton = 0;
while (true)
{
int button;
/* Pan the viewing window right - move image to the left and fill in
the right-hand side */
static void pan_view_right(struct t_disp* pdisp)
{
int move;
if (slideshow_enabled)
button = rb->button_get_w_tmo(jpeg_settings.ss_timeout * HZ);
else button = rb->button_get(true);
running_slideshow = false;
switch(button)
{
case JPEG_LEFT:
if (!(ds < ds_max) && entries > 0 && jpg.x_size <= MAX_X_SIZE)
return change_filename(DIR_PREV);
case JPEG_LEFT | BUTTON_REPEAT:
move = MIN(HSCROLL, pdisp->x);
if (move > 0)
{
MYXLCD(scroll_right)(move); /* scroll right */
pdisp->x -= move;
#ifdef HAVE_LCD_COLOR
yuv_bitmap_part(
pdisp->bitmap, pdisp->csub_x, pdisp->csub_y,
pdisp->x, pdisp->y, pdisp->stride,
0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */
move, MIN(LCD_HEIGHT, pdisp->height), /* w, h */
jpeg_settings.colour_mode, jpeg_settings.dither_mode);
#else
MYXLCD(gray_bitmap_part)(
pdisp->bitmap[0], pdisp->x, pdisp->y, pdisp->stride,
0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */
move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */
#endif
MYLCD_UPDATE();
}
break;
case JPEG_RIGHT:
if (!(ds < ds_max) && entries > 0 && jpg.x_size <= MAX_X_SIZE)
return change_filename(DIR_NEXT);
case JPEG_RIGHT | BUTTON_REPEAT:
move = MIN(HSCROLL, pdisp->width - pdisp->x - LCD_WIDTH);
if (move > 0)
{
@ -532,10 +491,43 @@ int scroll_bmp(struct t_disp* pdisp)
#endif
MYLCD_UPDATE();
}
break;
}
/* Pan the viewing window left - move image to the right and fill in
the left-hand side */
static void pan_view_left(struct t_disp* pdisp)
{
int move;
move = MIN(HSCROLL, pdisp->x);
if (move > 0)
{
MYXLCD(scroll_right)(move); /* scroll right */
pdisp->x -= move;
#ifdef HAVE_LCD_COLOR
yuv_bitmap_part(
pdisp->bitmap, pdisp->csub_x, pdisp->csub_y,
pdisp->x, pdisp->y, pdisp->stride,
0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */
move, MIN(LCD_HEIGHT, pdisp->height), /* w, h */
jpeg_settings.colour_mode, jpeg_settings.dither_mode);
#else
MYXLCD(gray_bitmap_part)(
pdisp->bitmap[0], pdisp->x, pdisp->y, pdisp->stride,
0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */
move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */
#endif
MYLCD_UPDATE();
}
}
/* Pan the viewing window up - move image down and fill in
the top */
static void pan_view_up(struct t_disp* pdisp)
{
int move;
case JPEG_UP:
case JPEG_UP | BUTTON_REPEAT:
move = MIN(VSCROLL, pdisp->y);
if (move > 0)
{
@ -563,10 +555,14 @@ int scroll_bmp(struct t_disp* pdisp)
#endif
MYLCD_UPDATE();
}
break;
}
/* Pan the viewing window down - move image up and fill in
the bottom */
static void pan_view_down(struct t_disp* pdisp)
{
int move;
case JPEG_DOWN:
case JPEG_DOWN | BUTTON_REPEAT:
move = MIN(VSCROLL, pdisp->height - pdisp->y - LCD_HEIGHT);
if (move > 0)
{
@ -609,7 +605,48 @@ int scroll_bmp(struct t_disp* pdisp)
#endif
MYLCD_UPDATE();
}
}
/* interactively scroll around the image */
int scroll_bmp(struct t_disp* pdisp)
{
int button;
int lastbutton = 0;
while (true)
{
if (slideshow_enabled)
button = rb->button_get_w_tmo(jpeg_settings.ss_timeout * HZ);
else button = rb->button_get(true);
running_slideshow = false;
switch(button)
{
case JPEG_LEFT:
if (!(ds < ds_max) && entries > 0 && jpg.x_size <= MAX_X_SIZE)
return change_filename(DIR_PREV);
case JPEG_LEFT | BUTTON_REPEAT:
pan_view_left(pdisp);
break;
case JPEG_RIGHT:
if (!(ds < ds_max) && entries > 0 && jpg.x_size <= MAX_X_SIZE)
return change_filename(DIR_NEXT);
case JPEG_RIGHT | BUTTON_REPEAT:
pan_view_right(pdisp);
break;
case JPEG_UP:
case JPEG_UP | BUTTON_REPEAT:
pan_view_up(pdisp);
break;
case JPEG_DOWN:
case JPEG_DOWN | BUTTON_REPEAT:
pan_view_down(pdisp);
break;
case BUTTON_NONE:
if (!slideshow_enabled)
break;
@ -1194,8 +1231,8 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
xlcd_init(rb);
#endif
/* should be ok to just load settings since a parameter is present
here and the drive should be spinning */
/* should be ok to just load settings since the plugin itself has
just been loaded from disk and the drive should be spinning */
configfile_init(rb);
configfile_load(JPEG_CONFIGFILE, jpeg_config,
ARRAYLEN(jpeg_config), JPEG_SETTINGS_MINVERSION);