2005-11-22 03:38:07 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-05-03 12:30:40 +00:00
|
|
|
* Copyright (C) 2008 by Jonathan Gordon
|
2005-11-22 03:38:07 +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-22 03:38:07 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
2006-03-12 23:45:40 +00:00
|
|
|
#include <stdio.h>
|
2008-05-03 12:30:40 +00:00
|
|
|
#include "config.h"
|
2006-01-21 23:43:57 +00:00
|
|
|
#include "system.h"
|
2005-11-22 03:38:07 +00:00
|
|
|
#include "icons.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "misc.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2008-05-03 12:30:40 +00:00
|
|
|
#include "settings_list.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "playlist.h"
|
|
|
|
#include "dsp.h"
|
|
|
|
#include "viewport.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "quickscreen.h"
|
2008-05-04 08:11:28 +00:00
|
|
|
#include "talk.h"
|
2008-11-03 11:11:07 +00:00
|
|
|
#include "list.h"
|
2009-03-08 18:37:32 +00:00
|
|
|
#include "option_select.h"
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT];
|
|
|
|
static struct viewport vp_icons[NB_SCREENS];
|
|
|
|
/* vp_icons will be used like this:
|
|
|
|
the side icons will be aligned to the top of this vp and to their sides
|
2009-03-28 09:09:58 +00:00
|
|
|
the bottom icon will be aligned center and at the bottom of this vp */
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
#define MIN_LINES 4
|
|
|
|
#define MAX_NEEDED_LINES 8
|
|
|
|
#define CENTER_MARGIN 10 /* pixels between the 2 center items minimum */
|
|
|
|
#define CENTER_ICONAREA_WIDTH (CENTER_MARGIN+8*2)
|
|
|
|
|
|
|
|
static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
|
|
|
|
struct screen *display,
|
|
|
|
struct viewport *parent)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2008-05-11 10:28:52 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
int screen = display->screen_type;
|
|
|
|
#else
|
|
|
|
const int screen = 0;
|
|
|
|
#endif
|
|
|
|
|
2008-10-31 04:58:33 +00:00
|
|
|
int char_height, i, width, pad = 0;
|
|
|
|
int left_width, right_width, bottom_lines = 2;
|
2008-05-03 12:30:40 +00:00
|
|
|
unsigned char *s;
|
|
|
|
int nb_lines = viewport_get_nb_lines(parent);
|
2009-05-06 02:17:04 +00:00
|
|
|
|
|
|
|
/* nb_lines only returns the number of fully visible lines, small screens
|
|
|
|
or really large fonts could cause problems with the calculation below.
|
|
|
|
*/
|
|
|
|
if(nb_lines==0)
|
|
|
|
nb_lines++;
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
char_height = parent->height/nb_lines;
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-10-31 04:58:33 +00:00
|
|
|
/* center the icons VP first */
|
2008-05-03 12:30:40 +00:00
|
|
|
vp_icons[screen] = *parent;
|
2009-03-28 09:09:58 +00:00
|
|
|
vp_icons[screen].width = CENTER_ICONAREA_WIDTH; /* absolute smallest allowed */
|
2009-02-05 00:14:52 +00:00
|
|
|
vp_icons[screen].x = parent->x + (parent->width / 2 - CENTER_ICONAREA_WIDTH / 2);
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
vps[screen][QUICKSCREEN_BOTTOM] = *parent;
|
|
|
|
if (nb_lines <= MIN_LINES) /* make the bottom item use 1 line */
|
|
|
|
bottom_lines = 1;
|
|
|
|
else
|
|
|
|
bottom_lines = 2;
|
|
|
|
vps[screen][QUICKSCREEN_BOTTOM].height = bottom_lines*char_height;
|
2008-05-11 10:28:52 +00:00
|
|
|
vps[screen][QUICKSCREEN_BOTTOM].y =
|
|
|
|
parent->y + parent->height - bottom_lines*char_height;
|
2008-05-03 12:30:40 +00:00
|
|
|
if (nb_lines >= MAX_NEEDED_LINES)
|
2006-04-02 10:41:16 +00:00
|
|
|
{
|
2008-05-03 12:30:40 +00:00
|
|
|
vps[screen][QUICKSCREEN_BOTTOM].y -= char_height;
|
2008-02-05 05:50:20 +00:00
|
|
|
}
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
/* adjust the left/right items widths to fit the screen nicely */
|
|
|
|
s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id));
|
|
|
|
left_width = display->getstringsize(s, NULL, NULL);
|
|
|
|
s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id));
|
|
|
|
right_width = display->getstringsize(s, NULL, NULL);
|
|
|
|
nb_lines -= bottom_lines;
|
2008-10-31 04:58:33 +00:00
|
|
|
|
|
|
|
width = MAX(left_width, right_width);
|
|
|
|
if (width*2 + vp_icons[screen].width > display->lcdwidth)
|
|
|
|
width = (display->lcdwidth - vp_icons[screen].width)/2;
|
|
|
|
else /* add more gap in icons vp */
|
|
|
|
{
|
|
|
|
int excess = display->lcdwidth - vp_icons[screen].width - width*2;
|
|
|
|
if (excess > CENTER_MARGIN*4)
|
|
|
|
{
|
|
|
|
pad = CENTER_MARGIN;
|
|
|
|
excess -= CENTER_MARGIN*2;
|
|
|
|
}
|
|
|
|
vp_icons[screen].x -= excess/2;
|
|
|
|
vp_icons[screen].width += excess;
|
|
|
|
}
|
2008-05-03 12:30:40 +00:00
|
|
|
vps[screen][QUICKSCREEN_LEFT] = *parent;
|
2008-10-31 04:58:33 +00:00
|
|
|
vps[screen][QUICKSCREEN_LEFT].x = parent->x + pad;
|
|
|
|
vps[screen][QUICKSCREEN_LEFT].width = width;
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
vps[screen][QUICKSCREEN_RIGHT] = *parent;
|
2008-10-31 04:58:33 +00:00
|
|
|
vps[screen][QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad;
|
|
|
|
vps[screen][QUICKSCREEN_RIGHT].width = width;
|
|
|
|
|
|
|
|
/* shrink the icons vp by a few pixels if there is room so the arrows
|
2008-11-03 11:11:07 +00:00
|
|
|
aren't drawn right next to the text */
|
2008-10-31 04:58:33 +00:00
|
|
|
if (vp_icons[screen].width > CENTER_ICONAREA_WIDTH+8)
|
|
|
|
{
|
|
|
|
vp_icons[screen].width -= 8;
|
|
|
|
vp_icons[screen].x += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
if (nb_lines <= MIN_LINES)
|
|
|
|
i = 0;
|
|
|
|
else
|
|
|
|
i = nb_lines/2;
|
|
|
|
vps[screen][QUICKSCREEN_LEFT].y = parent->y + (i*char_height);
|
|
|
|
vps[screen][QUICKSCREEN_RIGHT].y = parent->y + (i*char_height);
|
|
|
|
if (nb_lines >= 3)
|
|
|
|
i = 3*char_height;
|
|
|
|
else
|
|
|
|
i = nb_lines*char_height;
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
vps[screen][QUICKSCREEN_LEFT].height = i;
|
|
|
|
vps[screen][QUICKSCREEN_RIGHT].height = i;
|
|
|
|
vp_icons[screen].y = vps[screen][QUICKSCREEN_LEFT].y + (char_height/2);
|
2008-05-11 10:28:52 +00:00
|
|
|
vp_icons[screen].height =
|
|
|
|
vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y;
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
2008-02-05 09:09:38 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
static void quickscreen_draw_text(char *s, int item, bool title,
|
|
|
|
struct screen *display, struct viewport *vp)
|
|
|
|
{
|
|
|
|
int nb_lines = viewport_get_nb_lines(vp);
|
2008-05-11 10:28:52 +00:00
|
|
|
int w, h, line = 0, x = 0;
|
2008-05-03 12:30:40 +00:00
|
|
|
display->getstringsize(s, &w, &h);
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
if (nb_lines > 1 && !title)
|
|
|
|
line = 1;
|
|
|
|
switch (item)
|
|
|
|
{
|
|
|
|
case QUICKSCREEN_BOTTOM:
|
|
|
|
x = (vp->width - w)/2;
|
|
|
|
break;
|
|
|
|
case QUICKSCREEN_LEFT:
|
|
|
|
x = 0;
|
|
|
|
break;
|
|
|
|
case QUICKSCREEN_RIGHT:
|
|
|
|
x = vp->width - w;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (w>vp->width)
|
2008-05-11 10:28:52 +00:00
|
|
|
display->puts_scroll(0, line, s);
|
2006-04-02 10:41:16 +00:00
|
|
|
else
|
2008-05-03 12:30:40 +00:00
|
|
|
display->putsxy(x, line*h, s);
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
static void gui_quickscreen_draw(struct gui_quickscreen *qs,
|
|
|
|
struct screen *display,
|
|
|
|
struct viewport *parent)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2008-05-11 10:28:52 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
int screen = display->screen_type;
|
|
|
|
#else
|
|
|
|
const int screen = 0;
|
|
|
|
#endif
|
|
|
|
|
2005-11-22 03:38:07 +00:00
|
|
|
int i;
|
2008-05-03 12:30:40 +00:00
|
|
|
char buf[MAX_PATH];
|
|
|
|
unsigned char *title, *value;
|
|
|
|
void *setting;
|
|
|
|
int temp;
|
|
|
|
display->set_viewport(parent);
|
|
|
|
display->clear_viewport();
|
|
|
|
for (i=0; i<QUICKSCREEN_ITEM_COUNT; i++)
|
|
|
|
{
|
|
|
|
if (!qs->items[i])
|
|
|
|
continue;
|
2008-05-11 10:28:52 +00:00
|
|
|
display->set_viewport(&vps[screen][i]);
|
|
|
|
display->scroll_stop(&vps[screen][i]);
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
title = P2STR(ID2P(qs->items[i]->lang_id));
|
|
|
|
setting = qs->items[i]->setting;
|
2008-05-28 10:55:39 +00:00
|
|
|
temp = option_value_as_int(qs->items[i]);
|
2008-05-11 10:28:52 +00:00
|
|
|
value = option_get_valuestring((struct settings_list*)qs->items[i],
|
|
|
|
buf, MAX_PATH, temp);
|
|
|
|
|
2008-09-07 20:09:11 +00:00
|
|
|
if (vps[screen][i].height < display->getcharheight()*2)
|
2008-05-03 12:30:40 +00:00
|
|
|
{
|
|
|
|
char text[MAX_PATH];
|
|
|
|
snprintf(text, MAX_PATH, "%s: %s", title, value);
|
2008-05-11 10:28:52 +00:00
|
|
|
quickscreen_draw_text(text, i, true, display, &vps[screen][i]);
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-11 10:28:52 +00:00
|
|
|
quickscreen_draw_text(title, i, true, display, &vps[screen][i]);
|
|
|
|
quickscreen_draw_text(value, i, false, display, &vps[screen][i]);
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
|
|
|
display->update_viewport();
|
|
|
|
}
|
|
|
|
/* draw the icons */
|
2008-05-11 10:28:52 +00:00
|
|
|
display->set_viewport(&vp_icons[screen]);
|
2008-05-03 12:30:40 +00:00
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
|
2008-05-11 10:28:52 +00:00
|
|
|
vp_icons[screen].width - 8, 0, 7, 8);
|
2008-05-03 12:30:40 +00:00
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 0, 0, 7, 8);
|
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
2008-05-11 10:28:52 +00:00
|
|
|
(vp_icons[screen].width/2) - 4,
|
|
|
|
vp_icons[screen].height - 7, 7, 8);
|
2008-05-03 12:30:40 +00:00
|
|
|
display->update_viewport();
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
display->set_viewport(parent);
|
|
|
|
display->update_viewport();
|
|
|
|
display->set_viewport(NULL);
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
|
|
|
|
2008-05-08 20:37:26 +00:00
|
|
|
static void talk_qs_option(struct settings_list *opt, bool enqueue)
|
2008-05-04 15:02:46 +00:00
|
|
|
{
|
|
|
|
if (global_settings.talk_menu) {
|
|
|
|
if(!enqueue)
|
|
|
|
talk_shutup();
|
|
|
|
talk_id(opt->lang_id, true);
|
2008-05-28 10:55:39 +00:00
|
|
|
option_talk_value(opt, option_value_as_int(opt), true);
|
2008-05-04 15:02:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-11 21:48:20 +00:00
|
|
|
/*
|
|
|
|
* Does the actions associated to the given button if any
|
|
|
|
* - qs : the quickscreen
|
|
|
|
* - button : the key we are going to analyse
|
|
|
|
* returns : true if the button corresponded to an action, false otherwise
|
|
|
|
*/
|
|
|
|
static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2008-05-03 12:30:40 +00:00
|
|
|
int item;
|
2009-01-09 11:07:26 +00:00
|
|
|
bool invert = false;
|
2005-11-22 03:38:07 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_QS_LEFT:
|
2008-05-03 12:30:40 +00:00
|
|
|
item = QUICKSCREEN_LEFT;
|
|
|
|
break;
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
case ACTION_QS_DOWNINV:
|
2009-01-09 11:07:26 +00:00
|
|
|
invert = true; /* fallthrough */
|
|
|
|
case ACTION_QS_DOWN:
|
2008-05-03 12:30:40 +00:00
|
|
|
item = QUICKSCREEN_BOTTOM;
|
|
|
|
break;
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_QS_RIGHT:
|
2008-05-03 12:30:40 +00:00
|
|
|
item = QUICKSCREEN_RIGHT;
|
|
|
|
break;
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
2009-01-09 11:07:26 +00:00
|
|
|
option_select_next_val((struct settings_list *)qs->items[item], invert, true);
|
2008-05-04 15:02:46 +00:00
|
|
|
talk_qs_option((struct settings_list *)qs->items[item], false);
|
2008-05-03 12:30:40 +00:00
|
|
|
return true;
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
2009-05-15 05:08:28 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
/* figure out which button was pressed...
|
|
|
|
* top is exit, left/right/botton are the respective actions
|
|
|
|
*/
|
|
|
|
static int quickscreen_touchscreen_button(void)
|
|
|
|
{
|
|
|
|
short x,y;
|
|
|
|
if (action_get_touchscreen_press(&x, &y) != BUTTON_REL)
|
|
|
|
return ACTION_NONE;
|
|
|
|
if (y < vps[SCREEN_MAIN][QUICKSCREEN_LEFT].y)
|
|
|
|
return ACTION_STD_CANCEL;
|
|
|
|
else if (y > vps[SCREEN_MAIN][QUICKSCREEN_LEFT].y +
|
|
|
|
vps[SCREEN_MAIN][QUICKSCREEN_LEFT].height)
|
|
|
|
return ACTION_QS_DOWN;
|
|
|
|
else if (x < vps[SCREEN_MAIN][QUICKSCREEN_LEFT].x +
|
|
|
|
vps[SCREEN_MAIN][QUICKSCREEN_LEFT].width)
|
|
|
|
return ACTION_QS_LEFT;
|
|
|
|
else if (x >= vps[SCREEN_MAIN][QUICKSCREEN_RIGHT].x)
|
|
|
|
return ACTION_QS_RIGHT;
|
|
|
|
return ACTION_STD_CANCEL;
|
|
|
|
}
|
|
|
|
#endif
|
2005-11-22 21:55:05 +00:00
|
|
|
bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2008-05-03 12:30:40 +00:00
|
|
|
int button, i;
|
|
|
|
struct viewport vp[NB_SCREENS];
|
|
|
|
bool changed = false;
|
2005-11-22 21:55:05 +00:00
|
|
|
/* To quit we need either :
|
|
|
|
* - a second press on the button that made us enter
|
|
|
|
* - an action taken while pressing the enter button,
|
|
|
|
* then release the enter button*/
|
2008-05-11 10:28:52 +00:00
|
|
|
bool can_quit = false;
|
2008-05-03 12:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].set_viewport(NULL);
|
|
|
|
screens[i].stop_scroll();
|
|
|
|
viewport_set_defaults(&vp[i], i);
|
|
|
|
quickscreen_fix_viewports(qs, &screens[i], &vp[i]);
|
|
|
|
gui_quickscreen_draw(qs, &screens[i], &vp[i]);
|
|
|
|
}
|
2008-05-04 15:02:46 +00:00
|
|
|
/* Announce current selection on entering this screen. This is all
|
|
|
|
queued up, but can be interrupted as soon as a setting is
|
|
|
|
changed. */
|
|
|
|
cond_talk_ids(VOICE_QUICKSCREEN);
|
|
|
|
talk_qs_option((struct settings_list *)qs->items[QUICKSCREEN_LEFT], true);
|
|
|
|
talk_qs_option((struct settings_list *)qs->items[QUICKSCREEN_BOTTOM], true);
|
|
|
|
talk_qs_option((struct settings_list *)qs->items[QUICKSCREEN_RIGHT], true);
|
2005-11-22 03:38:07 +00:00
|
|
|
while (true) {
|
2008-05-04 01:42:11 +00:00
|
|
|
button = get_action(CONTEXT_QUICKSCREEN,HZ/5);
|
2009-05-15 05:08:28 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
if (button == ACTION_TOUCHSCREEN)
|
|
|
|
button = quickscreen_touchscreen_button();
|
|
|
|
#endif
|
2005-11-24 00:33:00 +00:00
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
2005-11-22 03:38:07 +00:00
|
|
|
return(true);
|
2005-11-24 00:33:00 +00:00
|
|
|
if(gui_quickscreen_do_button(qs, button))
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2008-05-03 12:30:40 +00:00
|
|
|
changed = true;
|
2005-11-22 21:55:05 +00:00
|
|
|
can_quit=true;
|
2008-05-03 12:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_quickscreen_draw(qs, &screens[i], &vp[i]);
|
|
|
|
if (qs->callback)
|
2008-02-05 09:09:38 +00:00
|
|
|
qs->callback(qs);
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
2006-08-15 12:27:07 +00:00
|
|
|
else if(button==button_enter)
|
2005-11-22 21:55:05 +00:00
|
|
|
can_quit=true;
|
2006-08-15 12:27:07 +00:00
|
|
|
|
|
|
|
if((button == button_enter) && can_quit)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(button==ACTION_STD_CANCEL)
|
|
|
|
break;
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
2008-05-04 15:02:46 +00:00
|
|
|
/* Notify that we're exiting this screen */
|
|
|
|
cond_talk_ids_fq(VOICE_OK);
|
2008-05-03 12:30:40 +00:00
|
|
|
return changed;
|
|
|
|
}
|
2008-11-05 09:30:20 +00:00
|
|
|
|
2008-11-03 11:11:07 +00:00
|
|
|
static inline const struct settings_list *get_setting(int gs_value,
|
|
|
|
const struct settings_list *defaultval)
|
|
|
|
{
|
|
|
|
if (gs_value != -1 && gs_value < nb_settings &&
|
|
|
|
is_setting_quickscreenable(&settings[gs_value]))
|
|
|
|
return &settings[gs_value];
|
|
|
|
return defaultval;
|
|
|
|
}
|
2008-05-03 12:30:40 +00:00
|
|
|
bool quick_screen_quick(int button_enter)
|
|
|
|
{
|
|
|
|
struct gui_quickscreen qs;
|
|
|
|
bool oldshuffle = global_settings.playlist_shuffle;
|
|
|
|
int oldrepeat = global_settings.repeat_mode;
|
2008-11-03 11:11:07 +00:00
|
|
|
|
|
|
|
qs.items[QUICKSCREEN_LEFT] =
|
|
|
|
get_setting(global_settings.qs_item_left,
|
|
|
|
find_setting(&global_settings.playlist_shuffle, NULL));
|
|
|
|
qs.items[QUICKSCREEN_RIGHT] =
|
|
|
|
get_setting(global_settings.qs_item_right,
|
|
|
|
find_setting(&global_settings.repeat_mode, NULL));
|
|
|
|
qs.items[QUICKSCREEN_BOTTOM] =
|
|
|
|
get_setting(global_settings.qs_item_bottom,
|
|
|
|
find_setting(&global_settings.dirfilter, NULL));
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
qs.callback = NULL;
|
|
|
|
if (gui_syncquickscreen_run(&qs, button_enter))
|
|
|
|
{
|
|
|
|
settings_save();
|
|
|
|
settings_apply(false);
|
|
|
|
/* make sure repeat/shuffle/any other nasty ones get updated */
|
|
|
|
if ( oldrepeat != global_settings.repeat_mode &&
|
|
|
|
(audio_status() & AUDIO_STATUS_PLAY) )
|
|
|
|
{
|
|
|
|
audio_flush_and_reload_tracks();
|
|
|
|
}
|
|
|
|
if (oldshuffle != global_settings.playlist_shuffle
|
|
|
|
&& audio_status() & AUDIO_STATUS_PLAY)
|
|
|
|
{
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
dsp_set_replaygain();
|
|
|
|
#endif
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_randomise(NULL, current_tick, true);
|
|
|
|
else
|
|
|
|
playlist_sort(NULL, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
#ifdef BUTTON_F3
|
|
|
|
bool quick_screen_f3(int button_enter)
|
|
|
|
{
|
|
|
|
struct gui_quickscreen qs;
|
2008-05-11 10:28:52 +00:00
|
|
|
qs.items[QUICKSCREEN_LEFT] =
|
|
|
|
find_setting(&global_settings.scrollbar, NULL);
|
|
|
|
qs.items[QUICKSCREEN_RIGHT] =
|
|
|
|
find_setting(&global_settings.statusbar, NULL);
|
|
|
|
qs.items[QUICKSCREEN_BOTTOM] =
|
|
|
|
find_setting(&global_settings.flip_display, NULL);
|
2008-05-03 12:30:40 +00:00
|
|
|
qs.callback = NULL;
|
|
|
|
if (gui_syncquickscreen_run(&qs, button_enter))
|
|
|
|
{
|
|
|
|
settings_save();
|
|
|
|
settings_apply(false);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif /* BUTTON_F3 */
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2008-11-03 11:11:07 +00:00
|
|
|
/* stuff to make the quickscreen configurable */
|
2008-11-05 09:30:20 +00:00
|
|
|
bool is_setting_quickscreenable(const struct settings_list *setting)
|
2008-11-03 11:11:07 +00:00
|
|
|
{
|
|
|
|
/* to keep things simple, only settings which have a lang_id set are ok */
|
|
|
|
if (setting->lang_id < 0 || (setting->flags&F_BANFROMQS))
|
|
|
|
return false;
|
|
|
|
switch (setting->flags&F_T_MASK)
|
|
|
|
{
|
|
|
|
case F_T_BOOL:
|
|
|
|
return true;
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
|
|
|
return (setting->RESERVED != NULL);
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-05 09:30:20 +00:00
|
|
|
void set_as_qs_item(const struct settings_list *setting,
|
|
|
|
enum QUICKSCREEN_ITEM item)
|
2008-11-03 11:11:07 +00:00
|
|
|
{
|
2008-11-05 09:30:20 +00:00
|
|
|
int i;
|
2008-11-03 11:11:07 +00:00
|
|
|
for(i=0;i<nb_settings;i++)
|
|
|
|
{
|
2008-11-05 09:30:20 +00:00
|
|
|
if (&settings[i] == setting)
|
|
|
|
break;
|
2008-11-03 11:11:07 +00:00
|
|
|
}
|
2008-11-05 09:30:20 +00:00
|
|
|
switch (item)
|
2008-11-03 11:11:07 +00:00
|
|
|
{
|
|
|
|
case QUICKSCREEN_LEFT:
|
2008-11-05 09:30:20 +00:00
|
|
|
global_settings.qs_item_left = i;
|
2008-11-03 11:11:07 +00:00
|
|
|
break;
|
|
|
|
case QUICKSCREEN_RIGHT:
|
2008-11-05 09:30:20 +00:00
|
|
|
global_settings.qs_item_right = i;
|
2008-11-03 11:11:07 +00:00
|
|
|
break;
|
|
|
|
case QUICKSCREEN_BOTTOM:
|
2008-11-05 09:30:20 +00:00
|
|
|
global_settings.qs_item_bottom = i;
|
|
|
|
break;
|
|
|
|
default: /* shut the copiler up */
|
2008-11-03 11:11:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|