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"
|
2011-09-08 12:38:21 +00:00
|
|
|
#include "core_alloc.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"
|
2013-12-20 22:34:28 +00:00
|
|
|
#include "line.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"
|
Lists can now be completly draw using the skin engine!
due to lack of user feedback the actual tags may change, hopefully not though.
The way it works is the skin specifies a rectangle and a viewport label. For each item in the list that is being displayed all viewports with the specified label are drawn. However, instead of the viewport x/y position being offset from the top left corner like normal they are offset from the rectangle position in the list (so think of them as child-viewports of the rectangle which moves).
Normally the rectangle will move down the screen to show a normal list, this can be changed to move across the screen in a grid pattern.
The UI viewport is used to bound the items (i.e %Vi() )
Scrolling is completly disabled in all items except the currently selected item.
This works well in combination with the %cs tag to show differently styled lists based on the current screen :)
New tags:
%LT - Get the current items text
%LI - Get the current items icon number
%Lc - Use as a conditional to determine if the current item is the selected item
%LB - BAR TAG to show the scroll bar, params/options like other bar types. It still needs a bit of work though. Use as a conditional to find out if the bar is actually needed
%Lb(viewport, width, height [,tile]) - specify the viewport label to draw for each item and the size of each item. if the last param is 'tile' it will form a grid instead of a list
example.sbs:
%?cs<%Lb(a,100,20)|>
%V(0,0,10,-,1)%Vf(aabbcc)
%?LB<%LB(0,0,10,185, invert)>
%Vi(-,10,0,-,-35,1)
%Vl(a,5,5,160,12,1)
%s%?Lc<%Vg(00ffaa, ff0000, 000000)%Vs(gradient)%>%>%>%ac>zzzzzzz %LT zzzzz%s%?Lc<%ar%<%<%<>
%V(0,185,-,-,1)
%s%LT
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30461 a1c6a512-1295-4272-9138-f99709370657
2011-09-06 13:49:41 +00:00
|
|
|
#include "list.h"
|
2012-07-05 12:44:13 +00:00
|
|
|
#include "option_select.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
|
|
|
|
|
2013-12-13 09:24:15 +00:00
|
|
|
|
|
|
|
#ifdef AB_REPEAT_ENABLE
|
|
|
|
|
|
|
|
#define DIRECTION_RIGHT 1
|
|
|
|
#define DIRECTION_LEFT -1
|
|
|
|
|
|
|
|
static int ab_calc_mark_x_pos(int mark, int capacity,
|
|
|
|
int offset, int size)
|
|
|
|
{
|
|
|
|
return offset + ( (size * mark) / capacity );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ab_draw_vertical_line_mark(struct screen * screen,
|
|
|
|
int x, int y, int h)
|
|
|
|
{
|
|
|
|
screen->set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
screen->vline(x, y, y+h-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ab_draw_arrow_mark(struct screen * screen,
|
|
|
|
int x, int y, int h, int direction)
|
|
|
|
{
|
|
|
|
/* draw lines in decreasing size until a height of zero is reached */
|
|
|
|
screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
|
|
|
while( h > 0 )
|
|
|
|
{
|
|
|
|
screen->vline(x, y, y+h-1);
|
|
|
|
h -= 2;
|
|
|
|
y++;
|
|
|
|
x += direction;
|
|
|
|
screen->set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ab_draw_markers(struct screen * screen, int capacity,
|
|
|
|
int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
bool a_set, b_set;
|
|
|
|
unsigned int a, b;
|
|
|
|
int xa, xb;
|
|
|
|
|
|
|
|
a_set = ab_get_A_marker(&a);
|
|
|
|
b_set = ab_get_B_marker(&b);
|
|
|
|
xa = ab_calc_mark_x_pos(a, capacity, x, w);
|
|
|
|
xb = ab_calc_mark_x_pos(b, capacity, x, w);
|
|
|
|
/* if both markers are set, determine if they're far enough apart
|
|
|
|
to draw arrows */
|
|
|
|
if ( a_set && b_set )
|
|
|
|
{
|
|
|
|
int arrow_width = (h+1) / 2;
|
|
|
|
if ( (xb-xa) < (arrow_width*2) )
|
|
|
|
{
|
|
|
|
ab_draw_vertical_line_mark(screen, xa, y, h);
|
|
|
|
ab_draw_vertical_line_mark(screen, xb, y, h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a_set)
|
|
|
|
ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT);
|
|
|
|
|
|
|
|
if (b_set)
|
|
|
|
ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
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;
|
2011-11-15 14:11:08 +00:00
|
|
|
struct viewport *vp = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), 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
|
|
|
}
|
2011-01-13 06:48:39 +00:00
|
|
|
else if (pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ||
|
|
|
|
pb->type == SKIN_TOKEN_PEAKMETER_RIGHTBAR)
|
|
|
|
{
|
|
|
|
int left, right, val;
|
|
|
|
peak_meter_current_vals(&left, &right);
|
|
|
|
val = pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ? left : right;
|
|
|
|
length = MAX_PEAK;
|
|
|
|
end = peak_meter_scale_value(val, length);
|
|
|
|
}
|
Lists can now be completly draw using the skin engine!
due to lack of user feedback the actual tags may change, hopefully not though.
The way it works is the skin specifies a rectangle and a viewport label. For each item in the list that is being displayed all viewports with the specified label are drawn. However, instead of the viewport x/y position being offset from the top left corner like normal they are offset from the rectangle position in the list (so think of them as child-viewports of the rectangle which moves).
Normally the rectangle will move down the screen to show a normal list, this can be changed to move across the screen in a grid pattern.
The UI viewport is used to bound the items (i.e %Vi() )
Scrolling is completly disabled in all items except the currently selected item.
This works well in combination with the %cs tag to show differently styled lists based on the current screen :)
New tags:
%LT - Get the current items text
%LI - Get the current items icon number
%Lc - Use as a conditional to determine if the current item is the selected item
%LB - BAR TAG to show the scroll bar, params/options like other bar types. It still needs a bit of work though. Use as a conditional to find out if the bar is actually needed
%Lb(viewport, width, height [,tile]) - specify the viewport label to draw for each item and the size of each item. if the last param is 'tile' it will form a grid instead of a list
example.sbs:
%?cs<%Lb(a,100,20)|>
%V(0,0,10,-,1)%Vf(aabbcc)
%?LB<%LB(0,0,10,185, invert)>
%Vi(-,10,0,-,-35,1)
%Vl(a,5,5,160,12,1)
%s%?Lc<%Vg(00ffaa, ff0000, 000000)%Vs(gradient)%>%>%>%ac>zzzzzzz %LT zzzzz%s%?Lc<%ar%<%<%<>
%V(0,185,-,-,1)
%s%LT
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30461 a1c6a512-1295-4272-9138-f99709370657
2011-09-06 13:49:41 +00:00
|
|
|
else if (pb->type == SKIN_TOKEN_LIST_SCROLLBAR)
|
|
|
|
{
|
|
|
|
int val, min, max;
|
|
|
|
skinlist_get_scrollbar(&val, &min, &max);
|
|
|
|
end = val - min;
|
|
|
|
length = max - min;
|
|
|
|
}
|
2012-07-05 12:44:13 +00:00
|
|
|
else if (pb->type == SKIN_TOKEN_SETTINGBAR)
|
|
|
|
{
|
|
|
|
int val, count;
|
|
|
|
get_setting_info_for_bar(pb->setting_id, &count, &val);
|
|
|
|
length = count - 1;
|
|
|
|
end = val;
|
|
|
|
}
|
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
|
|
|
{
|
2010-11-18 11:47:42 +00:00
|
|
|
#ifdef HAVE_RADIO_RSSI
|
|
|
|
if (pb->type == SKIN_TOKEN_TUNER_RSSI_BAR)
|
|
|
|
{
|
|
|
|
int val = tuner_get(RADIO_RSSI);
|
|
|
|
int min = tuner_get(RADIO_RSSI_MIN);
|
|
|
|
int max = tuner_get(RADIO_RSSI_MAX);
|
|
|
|
end = val - min;
|
|
|
|
length = max - min;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int min = fm_region_data[global_settings.fm_region].freq_min;
|
|
|
|
end = radio_current_frequency() - min;
|
|
|
|
length = fm_region_data[global_settings.fm_region].freq_max - min;
|
|
|
|
}
|
2010-05-12 10:38:00 +00:00
|
|
|
}
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2014-01-12 14:11:46 +00:00
|
|
|
if (pb->noborder)
|
|
|
|
{
|
|
|
|
flags |= BORDER_NOFILL;
|
|
|
|
}
|
|
|
|
|
2011-11-15 14:11:08 +00:00
|
|
|
if (SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider))
|
2010-10-12 12:17:39 +00:00
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider);
|
2010-10-12 12:17:39 +00:00
|
|
|
/* clear the slider */
|
|
|
|
screen_clear_area(display, x, y, width, height);
|
|
|
|
|
2013-01-23 01:44:18 +00:00
|
|
|
/* account for the sliders width in the progressbar */
|
2010-10-12 12:17:39 +00:00
|
|
|
if (flags&HORIZONTAL)
|
|
|
|
{
|
|
|
|
width -= img->bm.width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
height -= img->bm.height;
|
|
|
|
}
|
|
|
|
}
|
2013-01-23 01:44:18 +00:00
|
|
|
|
2011-11-15 14:11:08 +00:00
|
|
|
if (SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->backdrop))
|
New option for the bar tags: 'backdrop, <label>' will draw another image under the progressbar (only works with image and slider bars)
example:
%V(22,253,198,14,-)
%xl(a,PLAY_BAR_BACKDROP-240x320x16.bmp,0,0)
%pb(0,0,198,14,PLAY_BAR-240x320x16.bmp, backdrop, a)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29127 a1c6a512-1295-4272-9138-f99709370657
2011-01-24 09:04:28 +00:00
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->backdrop);
|
2011-11-08 21:34:46 +00:00
|
|
|
img->bm.data = core_get_data(img->buflib_handle);
|
2013-01-23 01:44:18 +00:00
|
|
|
display->bmp_part(&img->bm, 0, 0, x, y, pb->width, height);
|
New option for the bar tags: 'backdrop, <label>' will draw another image under the progressbar (only works with image and slider bars)
example:
%V(22,253,198,14,-)
%xl(a,PLAY_BAR_BACKDROP-240x320x16.bmp,0,0)
%pb(0,0,198,14,PLAY_BAR-240x320x16.bmp, backdrop, a)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29127 a1c6a512-1295-4272-9138-f99709370657
2011-01-24 09:04:28 +00:00
|
|
|
flags |= DONT_CLEAR_EXCESS;
|
2011-05-08 20:35:29 +00:00
|
|
|
}
|
2013-01-23 01:44:18 +00:00
|
|
|
|
2010-10-12 12:17:39 +00:00
|
|
|
if (!pb->nobar)
|
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->image);
|
|
|
|
if (img)
|
2011-09-08 12:38:21 +00:00
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
char *img_data = core_get_data(img->buflib_handle);
|
|
|
|
img->bm.data = img_data;
|
|
|
|
gui_bitmap_scrollbar_draw(display, &img->bm,
|
2010-10-12 12:17:39 +00:00
|
|
|
x, y, width, height,
|
|
|
|
length, 0, end, flags);
|
2011-09-08 12:38:21 +00:00
|
|
|
}
|
2010-10-12 12:17:39 +00:00
|
|
|
else
|
|
|
|
gui_scrollbar_draw(display, x, y, width, height,
|
|
|
|
length, 0, end, flags);
|
|
|
|
}
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2011-11-15 14:11:08 +00:00
|
|
|
if (SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider))
|
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
|
|
|
int xoff = 0, yoff = 0;
|
2010-10-12 12:17:39 +00:00
|
|
|
int w = width, h = height;
|
2011-11-15 14:11:08 +00:00
|
|
|
struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider);
|
2011-11-08 21:34:46 +00:00
|
|
|
img->bm.data = core_get_data(img->buflib_handle);
|
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;
|
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;
|
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
|
|
|
}
|
2011-11-08 21:34:46 +00:00
|
|
|
display->bmp_part(&img->bm, 0, 0, x + xoff, y + yoff, w, h);
|
2010-10-03 14:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2012-12-03 09:43:58 +00:00
|
|
|
void wps_draw_image(struct gui_wps *gwps, struct gui_img *img,
|
|
|
|
int subimage, struct viewport* vp)
|
2007-04-04 14:41:40 +00:00
|
|
|
{
|
|
|
|
struct screen *display = gwps->display;
|
2011-11-08 21:34:46 +00:00
|
|
|
img->bm.data = core_get_data(img->buflib_handle);
|
2012-02-28 11:05:28 +00:00
|
|
|
display->set_drawmode(DRMODE_SOLID);
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2012-12-03 09:43:58 +00:00
|
|
|
if (img->is_9_segment)
|
|
|
|
display->nine_segment_bmp(&img->bm, 0, 0, vp->width, vp->height);
|
|
|
|
else
|
|
|
|
display->bmp_part(&img->bm, 0, img->subimage_height * subimage,
|
|
|
|
img->x, img->y, img->bm.width, img->subimage_height);
|
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;
|
2012-02-28 13:18:56 +00:00
|
|
|
(void)vp;
|
2007-04-04 14:41:40 +00:00
|
|
|
struct wps_data *data = gwps->data;
|
|
|
|
struct screen *display = gwps->display;
|
2011-11-15 14:11:08 +00:00
|
|
|
struct skin_token_list *list = SKINOFFSETTOPTR(get_skin_buffer(data), 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
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
struct wps_token *token = SKINOFFSETTOPTR(get_skin_buffer(data), list->token);
|
|
|
|
struct gui_img *img = (struct gui_img*)SKINOFFSETTOPTR(get_skin_buffer(data), 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
|
|
|
{
|
2012-12-03 09:43:58 +00:00
|
|
|
wps_draw_image(gwps, img, img->display, vp);
|
2009-08-16 18:23:00 +00:00
|
|
|
}
|
2007-04-04 14:41:40 +00:00
|
|
|
}
|
2011-11-15 14:11:08 +00:00
|
|
|
list = SKINOFFSETTOPTR(get_skin_buffer(data), 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 */
|
2011-11-15 14:11:08 +00:00
|
|
|
struct skin_albumart *aa = SKINOFFSETTOPTR(get_skin_buffer(data), data->albumart);
|
|
|
|
if (aa && SKINOFFSETTOPTR(get_skin_buffer(data), aa->vp) == vp
|
|
|
|
&& aa->draw_handle >= 0)
|
2009-09-07 02:36:56 +00:00
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
draw_album_art(gwps, aa->draw_handle, false);
|
|
|
|
aa->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 */
|
2011-11-15 14:11:08 +00:00
|
|
|
value = get_token_value(gwps, SKINOFFSETTOPTR(get_skin_buffer(gwps->data), conditional->token),
|
|
|
|
offset, result, sizeof(result), &intval);
|
2007-04-08 14:00:00 +00:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2011-08-14 13:50:07 +00:00
|
|
|
void write_line(struct screen *display, struct align_pos *format_align,
|
2013-12-20 22:34:28 +00:00
|
|
|
int line, bool scroll, struct line_desc *linedes)
|
2005-11-17 20:20:01 +00:00
|
|
|
{
|
2011-12-14 09:48:52 +00:00
|
|
|
int left_width = 0;
|
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 space_width;
|
|
|
|
int string_height;
|
2007-11-12 21:34:01 +00:00
|
|
|
int scroll_width;
|
2011-12-14 09:48:52 +00:00
|
|
|
int viewport_width = display->getwidth();
|
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);
|
|
|
|
}
|
|
|
|
|
2011-12-14 09:48:52 +00:00
|
|
|
right_xpos = (viewport_width - right_width);
|
|
|
|
center_xpos = (viewport_width - center_width) / 2;
|
2007-11-12 21:34:01 +00:00
|
|
|
|
2011-12-14 09:48:52 +00:00
|
|
|
scroll_width = viewport_width;
|
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) &&
|
2011-12-14 09:48:52 +00:00
|
|
|
(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) &&
|
2011-12-14 09:48:52 +00:00
|
|
|
(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;
|
2011-12-14 09:48:52 +00:00
|
|
|
right_xpos = (viewport_width - 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;
|
2011-12-14 09:48:52 +00:00
|
|
|
right_xpos = (viewport_width - 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) &&
|
2011-12-14 09:48:52 +00:00
|
|
|
(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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-01-09 22:21:33 +00:00
|
|
|
/* strings can be as large as MAX_LINE which exceeds put_lines()
|
|
|
|
* limit for inline strings. Use $t to avoid truncation */
|
2013-12-20 22:34:28 +00:00
|
|
|
linedes->scroll = true;
|
2014-01-09 22:21:33 +00:00
|
|
|
display->put_line(0, line * string_height, linedes, "$t", format_align->left);
|
2005-11-17 20:20:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-20 22:34:28 +00:00
|
|
|
linedes->scroll = false;
|
2005-11-17 20:20:01 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-04-04 14:41:40 +00:00
|
|
|
/* clear the line first */
|
|
|
|
display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
2011-12-14 09:48:52 +00:00
|
|
|
display->fillrect(0, line*string_height, viewport_width, 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 *)"");
|
2011-08-14 14:04:46 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2011-12-14 09:48:52 +00:00
|
|
|
line *= string_height;
|
2013-12-20 22:34:28 +00:00
|
|
|
center_xpos = (viewport_width-center_width)/2;
|
|
|
|
right_xpos = viewport_width-right_width;
|
|
|
|
#endif
|
2014-04-18 11:27:25 +00:00
|
|
|
/* print aligned strings. print whole line at once so that %Vs works
|
|
|
|
* across the full viewport width */
|
|
|
|
char *left = format_align->left ?: "";
|
|
|
|
char *center = format_align->center ?: "";
|
|
|
|
char *right = format_align->right ?: "";
|
|
|
|
|
|
|
|
display->put_line(0, line, linedes, "$t$*s$t$*s$t", left,
|
|
|
|
center_xpos - left_width, center,
|
|
|
|
right_xpos - (center_xpos + center_width), 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
|
|
|
|
/* 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;
|
|
|
|
}
|