2005-11-18 09:03:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-05-05 09:40:22 +00:00
|
|
|
* Copyright (C) 2002-2007 Björn Stenberg
|
|
|
|
* Copyright (C) 2007-2008 Nicolas Pennequin
|
2005-11-18 09:03:25 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-11-18 09:03:25 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-11-01 13:08:57 +00:00
|
|
|
#include "config.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include <stdio.h>
|
2010-05-06 21:04:40 +00:00
|
|
|
#include "string-extra.h"
|
2009-11-01 13:08:57 +00:00
|
|
|
#include "misc.h"
|
|
|
|
#include "font.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "system.h"
|
2007-04-01 17:32:12 +00:00
|
|
|
#include "rbunicode.h"
|
2010-04-11 11:18:45 +00:00
|
|
|
#include "sound.h"
|
2010-04-25 11:32:51 +00:00
|
|
|
#include "powermgmt.h"
|
2009-11-01 13:08:57 +00:00
|
|
|
#ifdef DEBUG
|
2006-02-02 20:42:56 +00:00
|
|
|
#include "debug.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2010-05-12 10:38:00 +00:00
|
|
|
#include "action.h"
|
2006-01-21 23:43:57 +00:00
|
|
|
#include "abrepeat.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "lang.h"
|
2010-01-07 07:34:15 +00:00
|
|
|
#include "language.h"
|
2009-11-01 13:36:57 +00:00
|
|
|
#include "statusbar.h"
|
2010-04-11 11:40:47 +00:00
|
|
|
#include "settings.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#include "scrollbar.h"
|
2009-11-01 13:08:57 +00:00
|
|
|
#include "screen_access.h"
|
2010-01-13 06:02:38 +00:00
|
|
|
#include "playlist.h"
|
2010-01-13 06:24:21 +00:00
|
|
|
#include "audio.h"
|
2010-05-06 09:22:55 +00:00
|
|
|
#include "tagcache.h"
|
2009-11-01 13:08:57 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "peakmeter.h"
|
|
|
|
/* Image stuff */
|
|
|
|
#include "bmp.h"
|
2009-11-01 13:08:57 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
2007-11-11 12:29:37 +00:00
|
|
|
#include "albumart.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2009-11-01 13:08:57 +00:00
|
|
|
#endif
|
|
|
|
|
2007-02-14 14:40:24 +00:00
|
|
|
#include "cuesheet.h"
|
2008-03-28 11:24:24 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#include "playback.h"
|
|
|
|
#endif
|
2007-04-25 22:08:00 +00:00
|
|
|
#include "backdrop.h"
|
2008-12-31 05:59:26 +00:00
|
|
|
#include "viewport.h"
|
2010-05-12 11:44:09 +00:00
|
|
|
#if CONFIG_TUNER
|
2010-05-12 10:38:00 +00:00
|
|
|
#include "radio.h"
|
|
|
|
#include "tuner.h"
|
2010-05-12 11:44:09 +00:00
|
|
|
#endif
|
2010-05-12 10:38:00 +00:00
|
|
|
#include "root_menu.h"
|
2007-04-25 22:08:00 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
#include "wps_internals.h"
|
2009-08-03 04:43:34 +00:00
|
|
|
#include "skin_engine.h"
|
2009-10-19 15:28:15 +00:00
|
|
|
#include "statusbar-skinned.h"
|
2010-07-30 23:47:49 +00:00
|
|
|
#include "skin_display.h"
|
2009-08-03 04:43:34 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
void skin_render(struct gui_wps *gwps, unsigned refresh_mode);
|
2009-08-03 04:43:34 +00:00
|
|
|
|
|
|
|
/* update a skinned screen, update_type is WPS_REFRESH_* values.
|
|
|
|
* Usually it should only be WPS_REFRESH_NON_STATIC
|
2010-09-14 11:56:50 +00:00
|
|
|
* A full update will be done if required (skin_do_full_update() == true)
|
2009-08-03 04:43:34 +00:00
|
|
|
*/
|
2010-09-14 11:56:50 +00:00
|
|
|
void skin_update(enum skinnable_screens skin, enum screen_type screen,
|
|
|
|
unsigned int update_type)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
2010-09-14 11:56:50 +00:00
|
|
|
struct gui_wps *gwps = skin_get_gwps(skin, screen);
|
2010-07-29 12:37:48 +00:00
|
|
|
/* This maybe shouldnt be here,
|
|
|
|
* This is also safe for skined screen which dont use the id3 */
|
2010-09-14 11:56:50 +00:00
|
|
|
struct mp3entry *id3 = skin_get_global_state()->id3;
|
2009-07-23 15:20:18 +00:00
|
|
|
bool cuesheet_update = (id3 != NULL ? cuesheet_subtrack_changed(id3) : false);
|
2010-09-14 11:56:50 +00:00
|
|
|
if (cuesheet_update)
|
|
|
|
skin_request_full_update(skin);
|
2010-05-12 10:38:00 +00:00
|
|
|
|
2010-09-14 11:56:50 +00:00
|
|
|
skin_render(gwps, skin_do_full_update(skin, screen) ?
|
|
|
|
SKIN_REFRESH_ALL : update_type);
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2009-08-27 17:55:05 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
2009-08-26 00:06:27 +00:00
|
|
|
void skin_statusbar_changed(struct gui_wps *skin)
|
|
|
|
{
|
|
|
|
if (!skin)
|
|
|
|
return;
|
|
|
|
struct wps_data *data = skin->data;
|
|
|
|
const struct screen *display = skin->display;
|
2009-10-19 15:28:15 +00:00
|
|
|
const int screen = display->screen_type;
|
2009-08-26 00:06:27 +00:00
|
|
|
|
2010-08-02 12:50:23 +00:00
|
|
|
struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, false, data)->vp;
|
2009-11-04 05:10:53 +00:00
|
|
|
viewport_set_defaults(vp, screen);
|
2009-08-26 00:06:27 +00:00
|
|
|
|
|
|
|
if (data->wps_sb_tag)
|
|
|
|
{ /* fix up the default viewport */
|
|
|
|
if (data->show_sb_on_wps)
|
|
|
|
{
|
2009-10-19 15:28:15 +00:00
|
|
|
if (statusbar_position(screen) != STATUSBAR_OFF)
|
|
|
|
return; /* vp is fixed already */
|
2009-08-26 00:06:27 +00:00
|
|
|
|
2009-10-19 15:28:15 +00:00
|
|
|
vp->y = STATUSBAR_HEIGHT;
|
2009-08-26 00:06:27 +00:00
|
|
|
vp->height = display->lcdheight - STATUSBAR_HEIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-19 15:28:15 +00:00
|
|
|
if (statusbar_position(screen) == STATUSBAR_OFF)
|
|
|
|
return; /* vp is fixed already */
|
|
|
|
vp->y = vp->x = 0;
|
2009-08-26 00:06:27 +00:00
|
|
|
vp->height = display->lcdheight;
|
2009-10-19 15:28:15 +00:00
|
|
|
vp->width = display->lcdwidth;
|
2009-08-26 00:06:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
|
2010-03-06 14:14:44 +00:00
|
|
|
{
|
2007-04-04 14:41:40 +00:00
|
|
|
struct screen *display = gwps->display;
|
2010-04-11 11:18:45 +00:00
|
|
|
struct viewport *vp = pb->vp;
|
2010-09-14 11:56:50 +00:00
|
|
|
struct wps_state *state = skin_get_global_state();
|
2009-10-16 19:14:37 +00:00
|
|
|
struct mp3entry *id3 = state->id3;
|
2010-10-12 12:17:39 +00:00
|
|
|
int x = pb->x, y = pb->y, width = pb->width, height = pb->height;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
unsigned long length, end;
|
|
|
|
int flags = HORIZONTAL;
|
|
|
|
|
2010-03-07 12:51:23 +00:00
|
|
|
if (height < 0)
|
2010-04-11 11:18:45 +00:00
|
|
|
height = font_get(vp->font)->height;
|
2009-02-16 08:28:51 +00:00
|
|
|
|
2009-02-16 08:34:56 +00:00
|
|
|
if (y < 0)
|
|
|
|
{
|
2010-04-11 11:18:45 +00:00
|
|
|
int line_height = font_get(vp->font)->height;
|
2009-02-16 08:34:56 +00:00
|
|
|
/* center the pb in the line, but only if the line is higher than the pb */
|
2010-03-07 12:51:23 +00:00
|
|
|
int center = (line_height-height)/2;
|
2009-02-16 08:34:56 +00:00
|
|
|
/* if Y was not set calculate by font height,Y is -line_number-1 */
|
2010-07-29 12:37:48 +00:00
|
|
|
y = line*line_height + (0 > center ? 0 : center);
|
2009-02-16 08:34:56 +00:00
|
|
|
}
|
2009-02-16 08:28:51 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
if (pb->type == SKIN_TOKEN_VOLUMEBAR)
|
2010-04-11 11:18:45 +00:00
|
|
|
{
|
|
|
|
int minvol = sound_min(SOUND_VOLUME);
|
|
|
|
int maxvol = sound_max(SOUND_VOLUME);
|
|
|
|
length = maxvol-minvol;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
end = global_settings.volume-minvol;
|
2010-04-11 11:18:45 +00:00
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
else if (pb->type == SKIN_TOKEN_BATTERY_PERCENTBAR)
|
2010-04-25 11:32:51 +00:00
|
|
|
{
|
|
|
|
length = 100;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
end = battery_level();
|
2010-04-25 11:32:51 +00:00
|
|
|
}
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
2010-05-13 06:56:21 +00:00
|
|
|
else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
|
2010-05-12 10:38:00 +00:00
|
|
|
{
|
|
|
|
int min = fm_region_data[global_settings.fm_region].freq_min;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
end = radio_current_frequency() - min;
|
2010-05-12 10:38:00 +00:00
|
|
|
length = fm_region_data[global_settings.fm_region].freq_max - min;
|
|
|
|
}
|
|
|
|
#endif
|
2010-05-13 06:59:16 +00:00
|
|
|
else if (id3 && id3->length)
|
|
|
|
{
|
|
|
|
length = id3->length;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
end = id3->elapsed + state->ff_rewind_count;
|
2010-05-13 06:59:16 +00:00
|
|
|
}
|
2009-10-16 19:14:37 +00:00
|
|
|
else
|
|
|
|
{
|
2010-03-06 14:14:44 +00:00
|
|
|
length = 1;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
end = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pb->horizontal)
|
|
|
|
{
|
|
|
|
/* we want to fill upwards which is technically inverted. */
|
2010-10-04 13:20:37 +00:00
|
|
|
flags = INVERTFILL;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pb->invert_fill_direction)
|
|
|
|
{
|
|
|
|
flags ^= INVERTFILL;
|
2009-10-16 19:14:37 +00:00
|
|
|
}
|
2009-10-19 15:28:15 +00:00
|
|
|
|
2010-10-03 14:19:30 +00:00
|
|
|
if (pb->nofill)
|
|
|
|
{
|
|
|
|
flags |= INNER_NOFILL;
|
|
|
|
}
|
|
|
|
|
2010-10-12 12:17:39 +00:00
|
|
|
if (pb->slider)
|
|
|
|
{
|
|
|
|
struct gui_img *img = pb->slider;
|
|
|
|
/* clear the slider */
|
|
|
|
screen_clear_area(display, x, y, width, height);
|
|
|
|
|
|
|
|
/* shrink the bar so the slider is inside bounds */
|
|
|
|
if (flags&HORIZONTAL)
|
|
|
|
{
|
|
|
|
width -= img->bm.width;
|
|
|
|
x += img->bm.width / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
height -= img->bm.height;
|
|
|
|
y += img->bm.height / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pb->nobar)
|
|
|
|
{
|
skin bar tag: Load an image from a label or filename. i.e %xl(bar_image, pb.bmp,0,0) %pb(0,0,10,10,bar_image) or %pb(0,0,10,10, pb.bmp) both are acceptable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28249 a1c6a512-1295-4272-9138-f99709370657
2010-10-12 12:46:57 +00:00
|
|
|
if (pb->image)
|
|
|
|
gui_bitmap_scrollbar_draw(display, &pb->image->bm,
|
2010-10-12 12:17:39 +00:00
|
|
|
x, y, width, height,
|
|
|
|
length, 0, end, flags);
|
|
|
|
else
|
|
|
|
gui_scrollbar_draw(display, x, y, width, height,
|
|
|
|
length, 0, end, flags);
|
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
if (pb->slider)
|
|
|
|
{
|
2010-10-08 14:26:36 +00:00
|
|
|
int xoff = 0, yoff = 0;
|
2010-10-12 12:17:39 +00:00
|
|
|
int w = width, h = height;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
struct gui_img *img = pb->slider;
|
2010-10-08 14:26:36 +00:00
|
|
|
|
|
|
|
if (flags&HORIZONTAL)
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
{
|
2010-10-08 14:26:36 +00:00
|
|
|
w = img->bm.width;
|
2010-10-12 12:17:39 +00:00
|
|
|
xoff = width * end / length;
|
2010-10-04 13:20:37 +00:00
|
|
|
if (flags&INVERTFILL)
|
2010-10-12 12:17:39 +00:00
|
|
|
xoff = width - xoff;
|
2010-10-08 14:26:36 +00:00
|
|
|
xoff -= w / 2;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-08 14:26:36 +00:00
|
|
|
h = img->bm.height;
|
|
|
|
yoff = height * end / length;
|
2010-10-04 13:20:37 +00:00
|
|
|
if (flags&INVERTFILL)
|
2010-10-08 14:26:36 +00:00
|
|
|
yoff = height - yoff;
|
|
|
|
yoff -= h / 2;
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
}
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
if(img->bm.format == FORMAT_MONO) {
|
|
|
|
#endif
|
|
|
|
display->mono_bitmap_part(img->bm.data,
|
2010-10-08 14:26:36 +00:00
|
|
|
0, 0, img->bm.width,
|
2010-10-12 12:17:39 +00:00
|
|
|
x + xoff, y + yoff, w, h);
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
} else {
|
|
|
|
display->transparent_bitmap_part((fb_data *)img->bm.data,
|
|
|
|
0, 0,
|
|
|
|
STRIDE(display->screen_type,
|
|
|
|
img->bm.width, img->bm.height),
|
2010-10-12 12:17:39 +00:00
|
|
|
x + xoff, y + yoff, w, h);
|
A bunch of new features for the bar type tags (%pb, %pv, %bl, etc):
* the bar orientation (horiz/vert) is now chosen based on the width and heigt values (or can be forced).
* the fill direction can now be inverted (fill right to left, or top to bottom is considered inverted)
* It can now draw a slider type bar instead of a fill type (or indeed a slider with a fill type)
To configure the new bar, any (or all) of the following params can be used after the bmp filename (order makes no difference either):
invert - cause the bar to fill in the inverted direction
vertical - draw a vertical bar (not needed if the height > width)
horizontal - draw a horizontal bar (this is obviously the default)
nofill - dont draw the filling bar (this still draws the outline, obviously pointless without the slider param)
slider - draw an image for the slider. The next param MUST be the label of the image to draw. No option to use a subimage here, so the whole image needs to be the image you want on the slider.
example: %pb(0,0,-,-,-,nofill, slider, slider_image, invert) - draw a boring horizontal progressbar which doesnt fill and only draws the image "slider_image" which moves right to left.
the slider type might need some tweaking. let us know how it goes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27821 a1c6a512-1295-4272-9138-f99709370657
2010-08-15 14:13:36 +00:00
|
|
|
}
|
2010-10-03 14:19:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pb->type == SKIN_TOKEN_PROGRESSBAR)
|
|
|
|
{
|
|
|
|
if (id3 && id3->length)
|
|
|
|
{
|
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
if (ab_repeat_mode_enabled())
|
2010-10-12 12:17:39 +00:00
|
|
|
ab_draw_markers(display, id3->length, x, y, width, height);
|
2010-10-03 14:19:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (id3->cuesheet)
|
|
|
|
cue_draw_markers(display, id3->cuesheet, id3->length,
|
2010-10-12 12:17:39 +00:00
|
|
|
x, y+1, width, height-2);
|
2010-10-03 14:19:30 +00:00
|
|
|
}
|
|
|
|
#if 0 /* disable for now CONFIG_TUNER */
|
|
|
|
else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
|
|
|
|
{
|
2010-10-12 12:17:39 +00:00
|
|
|
presets_draw_markers(display, x, y, width, height);
|
2010-10-03 14:19:30 +00:00
|
|
|
}
|
2010-05-31 11:12:15 +00:00
|
|
|
#endif
|
2010-03-06 14:14:44 +00:00
|
|
|
}
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2010-03-06 14:14:44 +00:00
|
|
|
|
2007-04-04 14:41:40 +00:00
|
|
|
/* clears the area where the image was shown */
|
2010-07-29 12:37:48 +00:00
|
|
|
void clear_image_pos(struct gui_wps *gwps, struct gui_img *img)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
|
|
|
if(!gwps)
|
|
|
|
return;
|
|
|
|
gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
2009-08-16 18:23:00 +00:00
|
|
|
gwps->display->fillrect(img->x, img->y, img->bm.width, img->subimage_height);
|
2007-04-04 14:41:40 +00:00
|
|
|
gwps->display->set_drawmode(DRMODE_SOLID);
|
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
void wps_draw_image(struct gui_wps *gwps, struct gui_img *img, int subimage)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
|
|
|
struct screen *display = gwps->display;
|
2009-08-16 18:23:00 +00:00
|
|
|
if(img->always_display)
|
2007-04-04 14:41:40 +00:00
|
|
|
display->set_drawmode(DRMODE_FG);
|
|
|
|
else
|
|
|
|
display->set_drawmode(DRMODE_SOLID);
|
|
|
|
|
|
|
|
#if LCD_DEPTH > 1
|
2009-08-16 18:23:00 +00:00
|
|
|
if(img->bm.format == FORMAT_MONO) {
|
2007-04-04 14:41:40 +00:00
|
|
|
#endif
|
2009-09-13 12:24:14 +00:00
|
|
|
display->mono_bitmap_part(img->bm.data,
|
2009-08-16 18:23:00 +00:00
|
|
|
0, img->subimage_height * subimage,
|
|
|
|
img->bm.width, img->x,
|
|
|
|
img->y, img->bm.width,
|
|
|
|
img->subimage_height);
|
2007-04-04 14:41:40 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
} else {
|
2009-08-16 18:23:00 +00:00
|
|
|
display->transparent_bitmap_part((fb_data *)img->bm.data,
|
|
|
|
0, img->subimage_height * subimage,
|
2009-09-13 12:24:14 +00:00
|
|
|
STRIDE(display->screen_type,
|
|
|
|
img->bm.width, img->bm.height),
|
2009-08-29 19:31:29 +00:00
|
|
|
img->x, img->y, img->bm.width,
|
2009-08-16 18:23:00 +00:00
|
|
|
img->subimage_height);
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
2005-11-21 23:55:39 +00:00
|
|
|
#endif
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2005-11-21 23:55:39 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
|
|
|
|
void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
|
|
|
if(!gwps || !gwps->data || !gwps->display)
|
|
|
|
return;
|
2005-11-21 23:55:39 +00:00
|
|
|
|
2007-04-04 14:41:40 +00:00
|
|
|
struct wps_data *data = gwps->data;
|
|
|
|
struct screen *display = gwps->display;
|
2009-08-16 18:23:00 +00:00
|
|
|
struct skin_token_list *list = data->images;
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2009-08-16 18:23:00 +00:00
|
|
|
while (list)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
2009-08-16 18:23:00 +00:00
|
|
|
struct gui_img *img = (struct gui_img*)list->token->value.data;
|
2010-08-12 13:27:10 +00:00
|
|
|
if (img->using_preloaded_icons && img->display >= 0)
|
|
|
|
{
|
|
|
|
screen_put_icon(display, img->x, img->y, img->display);
|
|
|
|
}
|
|
|
|
else if (img->loaded)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
2009-08-16 18:23:00 +00:00
|
|
|
if (img->display >= 0)
|
2008-03-23 20:31:00 +00:00
|
|
|
{
|
2009-08-16 18:23:00 +00:00
|
|
|
wps_draw_image(gwps, img, img->display);
|
|
|
|
}
|
|
|
|
else if (img->always_display && img->vp == vp)
|
2008-03-23 20:31:00 +00:00
|
|
|
{
|
2009-08-16 18:23:00 +00:00
|
|
|
wps_draw_image(gwps, img, 0);
|
2008-03-23 20:31:00 +00:00
|
|
|
}
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2009-08-16 18:23:00 +00:00
|
|
|
list = list->next;
|
2005-11-21 23:55:39 +00:00
|
|
|
}
|
2009-09-13 12:24:14 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
2009-09-07 02:36:56 +00:00
|
|
|
/* now draw the AA */
|
2009-10-19 15:28:15 +00:00
|
|
|
if (data->albumart && data->albumart->vp == vp
|
2010-09-14 12:21:56 +00:00
|
|
|
&& data->albumart->draw_handle >= 0)
|
2009-09-07 02:36:56 +00:00
|
|
|
{
|
2010-07-29 12:37:48 +00:00
|
|
|
draw_album_art(gwps, data->albumart->draw_handle, false);
|
2010-09-14 12:21:56 +00:00
|
|
|
data->albumart->draw_handle = -1;
|
2009-09-07 02:36:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-09-13 12:24:14 +00:00
|
|
|
|
2007-04-04 14:41:40 +00:00
|
|
|
display->set_drawmode(DRMODE_SOLID);
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
|
2010-10-10 23:46:15 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2008-09-06 14:56:02 +00:00
|
|
|
/* Evaluate the conditional that is at *token_index and return whether a skip
|
|
|
|
has ocurred. *token_index is updated with the new position.
|
2007-04-04 14:41:40 +00:00
|
|
|
*/
|
2010-08-14 15:17:59 +00:00
|
|
|
int evaluate_conditional(struct gui_wps *gwps, int offset,
|
|
|
|
struct conditional *conditional, int num_options)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
|
|
|
if (!gwps)
|
2007-11-18 13:24:39 +00:00
|
|
|
return false;
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2008-09-24 20:03:53 +00:00
|
|
|
char result[128];
|
|
|
|
const char *value;
|
2007-04-15 02:59:34 +00:00
|
|
|
|
2010-09-02 11:43:33 +00:00
|
|
|
int intval = num_options < 2 ? 2 : num_options;
|
2007-04-08 14:00:00 +00:00
|
|
|
/* get_token_value needs to know the number of options in the enum */
|
2010-08-14 15:17:59 +00:00
|
|
|
value = get_token_value(gwps, conditional->token, offset,
|
2007-04-08 14:00:00 +00:00
|
|
|
result, sizeof(result), &intval);
|
|
|
|
|
|
|
|
/* intval is now the number of the enum option we want to read,
|
2007-05-02 16:28:24 +00:00
|
|
|
starting from 1. If intval is -1, we check if value is empty. */
|
2007-04-08 14:00:00 +00:00
|
|
|
if (intval == -1)
|
2010-09-02 11:43:33 +00:00
|
|
|
{
|
|
|
|
if (num_options == 1) /* so %?AA<true> */
|
|
|
|
intval = (value && *value) ? 1 : 0; /* returned as 0 for true, -1 for false */
|
|
|
|
else
|
|
|
|
intval = (value && *value) ? 1 : num_options;
|
|
|
|
}
|
2007-04-08 14:00:00 +00:00
|
|
|
else if (intval > num_options || intval < 1)
|
|
|
|
intval = num_options;
|
2010-09-02 11:43:33 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
return intval -1;
|
2007-04-06 16:43:07 +00:00
|
|
|
}
|
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2007-04-04 14:41:40 +00:00
|
|
|
/* Display a line appropriately according to its alignment format.
|
|
|
|
format_align contains the text, separated between left, center and right.
|
|
|
|
line is the index of the line on the screen.
|
|
|
|
scroll indicates whether the line is a scrolling one or not.
|
|
|
|
*/
|
2010-07-29 12:37:48 +00:00
|
|
|
void write_line(struct screen *display,
|
2007-04-04 14:41:40 +00:00
|
|
|
struct align_pos *format_align,
|
|
|
|
int line,
|
|
|
|
bool scroll)
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2007-11-12 21:34:01 +00:00
|
|
|
int left_width = 0, left_xpos;
|
2007-09-13 20:53:23 +00:00
|
|
|
int center_width = 0, center_xpos;
|
|
|
|
int right_width = 0, right_xpos;
|
2007-04-04 14:41:40 +00:00
|
|
|
int ypos;
|
|
|
|
int space_width;
|
|
|
|
int string_height;
|
2007-11-12 21:34:01 +00:00
|
|
|
int scroll_width;
|
2007-04-04 14:41:40 +00:00
|
|
|
|
|
|
|
/* calculate different string sizes and positions */
|
|
|
|
display->getstringsize((unsigned char *)" ", &space_width, &string_height);
|
|
|
|
if (format_align->left != 0) {
|
|
|
|
display->getstringsize((unsigned char *)format_align->left,
|
|
|
|
&left_width, &string_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format_align->right != 0) {
|
|
|
|
display->getstringsize((unsigned char *)format_align->right,
|
|
|
|
&right_width, &string_height);
|
|
|
|
}
|
2007-09-13 20:53:23 +00:00
|
|
|
|
2007-11-12 21:34:01 +00:00
|
|
|
if (format_align->center != 0) {
|
|
|
|
display->getstringsize((unsigned char *)format_align->center,
|
|
|
|
¢er_width, &string_height);
|
|
|
|
}
|
|
|
|
|
2008-06-23 13:20:35 +00:00
|
|
|
left_xpos = 0;
|
2008-03-21 19:38:00 +00:00
|
|
|
right_xpos = (display->getwidth() - right_width);
|
|
|
|
center_xpos = (display->getwidth() + left_xpos - center_width) / 2;
|
2007-11-12 21:34:01 +00:00
|
|
|
|
2008-03-21 19:38:00 +00:00
|
|
|
scroll_width = display->getwidth() - left_xpos;
|
2007-04-04 14:41:40 +00:00
|
|
|
|
|
|
|
/* Checks for overlapping strings.
|
|
|
|
If needed the overlapping strings will be merged, separated by a
|
|
|
|
space */
|
|
|
|
|
|
|
|
/* CASE 1: left and centered string overlap */
|
|
|
|
/* there is a left string, need to merge left and center */
|
|
|
|
if ((left_width != 0 && center_width != 0) &&
|
2007-11-12 21:34:01 +00:00
|
|
|
(left_xpos + left_width + space_width > center_xpos)) {
|
2007-04-04 14:41:40 +00:00
|
|
|
/* replace the former separator '\0' of left and
|
|
|
|
center string with a space */
|
|
|
|
*(--format_align->center) = ' ';
|
|
|
|
/* calculate the new width and position of the merged string */
|
|
|
|
left_width = left_width + space_width + center_width;
|
|
|
|
/* there is no centered string anymore */
|
|
|
|
center_width = 0;
|
|
|
|
}
|
|
|
|
/* there is no left string, move center to left */
|
|
|
|
if ((left_width == 0 && center_width != 0) &&
|
2007-11-12 21:34:01 +00:00
|
|
|
(left_xpos + left_width > center_xpos)) {
|
2007-04-04 14:41:40 +00:00
|
|
|
/* move the center string to the left string */
|
|
|
|
format_align->left = format_align->center;
|
|
|
|
/* calculate the new width and position of the string */
|
|
|
|
left_width = center_width;
|
|
|
|
/* there is no centered string anymore */
|
|
|
|
center_width = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CASE 2: centered and right string overlap */
|
|
|
|
/* there is a right string, need to merge center and right */
|
|
|
|
if ((center_width != 0 && right_width != 0) &&
|
|
|
|
(center_xpos + center_width + space_width > right_xpos)) {
|
|
|
|
/* replace the former separator '\0' of center and
|
|
|
|
right string with a space */
|
|
|
|
*(--format_align->right) = ' ';
|
|
|
|
/* move the center string to the right after merge */
|
|
|
|
format_align->right = format_align->center;
|
|
|
|
/* calculate the new width and position of the merged string */
|
|
|
|
right_width = center_width + space_width + right_width;
|
2008-03-21 19:38:00 +00:00
|
|
|
right_xpos = (display->getwidth() - right_width);
|
2007-04-04 14:41:40 +00:00
|
|
|
/* there is no centered string anymore */
|
|
|
|
center_width = 0;
|
|
|
|
}
|
|
|
|
/* there is no right string, move center to right */
|
|
|
|
if ((center_width != 0 && right_width == 0) &&
|
|
|
|
(center_xpos + center_width > right_xpos)) {
|
|
|
|
/* move the center string to the right string */
|
|
|
|
format_align->right = format_align->center;
|
|
|
|
/* calculate the new width and position of the string */
|
|
|
|
right_width = center_width;
|
2008-03-21 19:38:00 +00:00
|
|
|
right_xpos = (display->getwidth() - right_width);
|
2007-04-04 14:41:40 +00:00
|
|
|
/* there is no centered string anymore */
|
|
|
|
center_width = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CASE 3: left and right overlap
|
|
|
|
There is no center string anymore, either there never
|
|
|
|
was one or it has been merged in case 1 or 2 */
|
|
|
|
/* there is a left string, need to merge left and right */
|
|
|
|
if ((left_width != 0 && center_width == 0 && right_width != 0) &&
|
2007-11-12 21:34:01 +00:00
|
|
|
(left_xpos + left_width + space_width > right_xpos)) {
|
2007-04-04 14:41:40 +00:00
|
|
|
/* replace the former separator '\0' of left and
|
|
|
|
right string with a space */
|
|
|
|
*(--format_align->right) = ' ';
|
|
|
|
/* calculate the new width and position of the string */
|
|
|
|
left_width = left_width + space_width + right_width;
|
|
|
|
/* there is no right string anymore */
|
|
|
|
right_width = 0;
|
|
|
|
}
|
|
|
|
/* there is no left string, move right to left */
|
|
|
|
if ((left_width == 0 && center_width == 0 && right_width != 0) &&
|
2007-09-13 20:53:23 +00:00
|
|
|
(left_width > right_xpos)) {
|
2007-04-04 14:41:40 +00:00
|
|
|
/* move the right string to the left string */
|
|
|
|
format_align->left = format_align->right;
|
|
|
|
/* calculate the new width and position of the string */
|
|
|
|
left_width = right_width;
|
|
|
|
/* there is no right string anymore */
|
|
|
|
right_width = 0;
|
|
|
|
}
|
|
|
|
|
2008-06-23 13:20:35 +00:00
|
|
|
ypos = (line * string_height);
|
2007-04-04 14:41:40 +00:00
|
|
|
|
|
|
|
|
2009-09-13 12:24:14 +00:00
|
|
|
if (scroll && ((left_width > scroll_width) ||
|
2007-11-12 21:34:01 +00:00
|
|
|
(center_width > scroll_width) ||
|
|
|
|
(right_width > scroll_width)))
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2007-04-04 14:41:40 +00:00
|
|
|
display->puts_scroll(0, line,
|
|
|
|
(unsigned char *)format_align->left);
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-04-04 14:41:40 +00:00
|
|
|
/* clear the line first */
|
|
|
|
display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
2008-03-21 19:38:00 +00:00
|
|
|
display->fillrect(left_xpos, ypos, display->getwidth(), string_height);
|
2007-04-04 14:41:40 +00:00
|
|
|
display->set_drawmode(DRMODE_SOLID);
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2007-04-04 14:41:40 +00:00
|
|
|
|
|
|
|
/* Nasty hack: we output an empty scrolling string,
|
|
|
|
which will reset the scroller for that line */
|
|
|
|
display->puts_scroll(0, line, (unsigned char *)"");
|
|
|
|
|
|
|
|
/* print aligned strings */
|
|
|
|
if (left_width != 0)
|
|
|
|
{
|
2007-11-12 21:34:01 +00:00
|
|
|
display->putsxy(left_xpos, ypos,
|
2007-04-04 14:41:40 +00:00
|
|
|
(unsigned char *)format_align->left);
|
|
|
|
}
|
|
|
|
if (center_width != 0)
|
|
|
|
{
|
|
|
|
display->putsxy(center_xpos, ypos,
|
|
|
|
(unsigned char *)format_align->center);
|
|
|
|
}
|
|
|
|
if (right_width != 0)
|
|
|
|
{
|
|
|
|
display->putsxy(right_xpos, ypos,
|
|
|
|
(unsigned char *)format_align->right);
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
void draw_peakmeters(struct gui_wps *gwps, int line_number,
|
|
|
|
struct viewport *viewport)
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2007-04-04 14:41:40 +00:00
|
|
|
struct wps_data *data = gwps->data;
|
2010-07-29 12:37:48 +00:00
|
|
|
if (!data->peak_meter_enabled)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
2010-07-29 12:37:48 +00:00
|
|
|
peak_meter_enable(false);
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
else
|
2008-06-23 06:04:17 +00:00
|
|
|
{
|
2010-07-29 12:37:48 +00:00
|
|
|
int h = font_get(viewport->font)->height;
|
|
|
|
int peak_meter_y = line_number * h;
|
2010-03-23 02:19:48 +00:00
|
|
|
|
2010-07-29 12:37:48 +00:00
|
|
|
/* The user might decide to have the peak meter in the last
|
|
|
|
line so that it is only displayed if no status bar is
|
|
|
|
visible. If so we neither want do draw nor enable the
|
|
|
|
peak meter. */
|
|
|
|
if (peak_meter_y + h <= viewport->y+viewport->height) {
|
|
|
|
peak_meter_enable(true);
|
|
|
|
peak_meter_screen(gwps->display, 0, peak_meter_y,
|
|
|
|
MIN(h, viewport->y+viewport->height - peak_meter_y));
|
2008-06-23 06:04:17 +00:00
|
|
|
}
|
2007-02-14 14:40:24 +00:00
|
|
|
}
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2010-05-12 10:38:00 +00:00
|
|
|
|
|
|
|
bool skin_has_sbs(enum screen_type screen, struct wps_data *data)
|
|
|
|
{
|
|
|
|
(void)screen;
|
2010-05-12 11:44:09 +00:00
|
|
|
(void)data;
|
2010-05-12 10:38:00 +00:00
|
|
|
bool draw = false;
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
if (data->wps_sb_tag)
|
|
|
|
draw = data->show_sb_on_wps;
|
|
|
|
else if (statusbar_position(screen) != STATUSBAR_OFF)
|
|
|
|
draw = true;
|
|
|
|
#endif
|
|
|
|
return draw;
|
|
|
|
}
|
2010-07-29 12:37:48 +00:00
|
|
|
#endif
|
2010-05-12 10:38:00 +00:00
|
|
|
|
|
|
|
/* do the button loop as often as required for the peak meters to update
|
|
|
|
* with a good refresh rate.
|
|
|
|
*/
|
2010-09-14 11:56:50 +00:00
|
|
|
int skin_wait_for_action(enum skinnable_screens skin, int context, int timeout)
|
2010-05-12 10:38:00 +00:00
|
|
|
{
|
2010-09-14 11:56:50 +00:00
|
|
|
(void)skin; /* silence charcell warning */
|
2010-05-12 11:44:09 +00:00
|
|
|
int button = ACTION_NONE;
|
2010-05-12 10:38:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int i;
|
|
|
|
/* when the peak meter is enabled we want to have a
|
|
|
|
few extra updates to make it look smooth. On the
|
|
|
|
other hand we don't want to waste energy if it
|
|
|
|
isn't displayed */
|
|
|
|
bool pm=false;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2010-09-14 11:56:50 +00:00
|
|
|
if(skin_get_gwps(skin, i)->data->peak_meter_enabled)
|
2010-05-12 10:38:00 +00:00
|
|
|
pm = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pm) {
|
|
|
|
long next_refresh = current_tick;
|
|
|
|
long next_big_refresh = current_tick + timeout;
|
|
|
|
button = BUTTON_NONE;
|
|
|
|
while (TIME_BEFORE(current_tick, next_big_refresh)) {
|
|
|
|
button = get_action(context,TIMEOUT_NOBLOCK);
|
|
|
|
if (button != ACTION_NONE) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
peak_meter_peek();
|
|
|
|
sleep(0); /* Sleep until end of current tick. */
|
|
|
|
|
|
|
|
if (TIME_AFTER(current_tick, next_refresh)) {
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2010-09-14 11:56:50 +00:00
|
|
|
if(skin_get_gwps(skin, i)->data->peak_meter_enabled)
|
|
|
|
skin_update(skin, i, SKIN_REFRESH_PEAK_METER);
|
2010-05-12 10:38:00 +00:00
|
|
|
next_refresh += HZ / PEAK_METER_FPS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The peak meter is disabled
|
|
|
|
-> no additional screen updates needed */
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
button = get_action(context, timeout);
|
|
|
|
}
|
|
|
|
return button;
|
|
|
|
}
|