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"
|
2021-02-24 11:44:39 +00:00
|
|
|
#include "sound.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 "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"
|
2009-08-29 14:42:03 +00:00
|
|
|
#include "debug.h"
|
2012-03-27 13:38:30 +00:00
|
|
|
#include "shortcuts.h"
|
2021-11-19 04:11:13 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
|
|
|
#include "playback.h"
|
|
|
|
#endif
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2009-08-29 14:42:03 +00:00
|
|
|
/* 1 top, 1 bottom, 2 on either side, 1 for the icons
|
|
|
|
* if enough space, top and bottom have 2 lines */
|
|
|
|
#define MIN_LINES 5
|
|
|
|
#define MAX_NEEDED_LINES 10
|
|
|
|
/* pixels between the 2 center items minimum or between text and icons,
|
|
|
|
* and between text and parent boundaries */
|
|
|
|
#define MARGIN 10
|
|
|
|
#define CENTER_ICONAREA_SIZE (MARGIN+8*2)
|
2008-05-03 12:30:40 +00:00
|
|
|
|
|
|
|
static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
|
2009-09-05 18:52:44 +00:00
|
|
|
struct screen *display,
|
|
|
|
struct viewport *parent,
|
|
|
|
struct viewport
|
|
|
|
vps[QUICKSCREEN_ITEM_COUNT],
|
|
|
|
struct viewport *vp_icons)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2009-08-29 14:42:03 +00:00
|
|
|
int char_height, width, pad = 0;
|
2010-02-25 06:01:53 +00:00
|
|
|
int left_width = 0, right_width = 0, vert_lines;
|
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.
|
|
|
|
*/
|
2009-10-10 07:46:54 +00:00
|
|
|
if (nb_lines == 0)
|
2009-05-06 02:17:04 +00:00
|
|
|
nb_lines++;
|
2010-02-25 06:01:53 +00:00
|
|
|
|
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 */
|
2009-09-05 18:52:44 +00:00
|
|
|
*vp_icons = *parent;
|
|
|
|
vp_icons->width = CENTER_ICONAREA_SIZE; /* abosulte smallest allowed */
|
|
|
|
vp_icons->x = parent->x;
|
|
|
|
vp_icons->x += (parent->width-CENTER_ICONAREA_SIZE)/2;
|
2009-08-29 14:42:03 +00:00
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_BOTTOM] = *parent;
|
|
|
|
vps[QUICKSCREEN_TOP] = *parent;
|
2009-08-29 14:42:03 +00:00
|
|
|
/* depending on the space the top/buttom items use 1 or 2 lines */
|
|
|
|
if (nb_lines < MIN_LINES)
|
|
|
|
vert_lines = 1;
|
2008-05-03 12:30:40 +00:00
|
|
|
else
|
2009-08-29 14:42:03 +00:00
|
|
|
vert_lines = 2;
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_TOP].y = parent->y;
|
|
|
|
vps[QUICKSCREEN_TOP].height = vps[QUICKSCREEN_BOTTOM].height
|
2009-08-29 14:42:03 +00:00
|
|
|
= vert_lines*char_height;
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_BOTTOM].y
|
|
|
|
= parent->y + parent->height - vps[QUICKSCREEN_BOTTOM].height;
|
2009-08-29 14:42:03 +00:00
|
|
|
|
|
|
|
/* enough space vertically, so put a nice margin */
|
2008-05-03 12:30:40 +00:00
|
|
|
if (nb_lines >= MAX_NEEDED_LINES)
|
2006-04-02 10:41:16 +00:00
|
|
|
{
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_TOP].y += MARGIN;
|
|
|
|
vps[QUICKSCREEN_BOTTOM].y -= MARGIN;
|
2008-02-05 05:50:20 +00:00
|
|
|
}
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
vp_icons->y = vps[QUICKSCREEN_TOP].y
|
|
|
|
+ vps[QUICKSCREEN_TOP].height;
|
2010-02-25 06:01:53 +00:00
|
|
|
vp_icons->height = vps[QUICKSCREEN_BOTTOM].y - vp_icons->y;
|
2009-08-29 14:42:03 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
/* adjust the left/right items widths to fit the screen nicely */
|
2010-02-25 06:01:53 +00:00
|
|
|
if (qs->items[QUICKSCREEN_LEFT])
|
|
|
|
{
|
|
|
|
s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id));
|
|
|
|
left_width = display->getstringsize(s, NULL, NULL);
|
|
|
|
}
|
|
|
|
if (qs->items[QUICKSCREEN_RIGHT])
|
|
|
|
{
|
|
|
|
s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id));
|
|
|
|
right_width = display->getstringsize(s, NULL, NULL);
|
|
|
|
}
|
2009-08-29 14:42:03 +00:00
|
|
|
|
2008-10-31 04:58:33 +00:00
|
|
|
width = MAX(left_width, right_width);
|
2009-09-05 18:52:44 +00:00
|
|
|
if (width*2 + vp_icons->width > parent->width)
|
2009-09-05 14:38:29 +00:00
|
|
|
{ /* crop text viewports */
|
2009-09-05 18:52:44 +00:00
|
|
|
width = (parent->width - vp_icons->width)/2;
|
2009-09-05 14:38:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* add more gap in icons vp */
|
2009-09-05 18:52:44 +00:00
|
|
|
int excess = parent->width - vp_icons->width - width*2;
|
2009-08-29 14:42:03 +00:00
|
|
|
if (excess > MARGIN*4)
|
2008-10-31 04:58:33 +00:00
|
|
|
{
|
2009-08-29 14:42:03 +00:00
|
|
|
pad = MARGIN;
|
|
|
|
excess -= MARGIN*2;
|
2008-10-31 04:58:33 +00:00
|
|
|
}
|
2009-09-05 18:52:44 +00:00
|
|
|
vp_icons->x -= excess/2;
|
|
|
|
vp_icons->width += excess;
|
2008-10-31 04:58:33 +00:00
|
|
|
}
|
2009-08-29 14:42:03 +00:00
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_LEFT] = *parent;
|
|
|
|
vps[QUICKSCREEN_LEFT].x = parent->x + pad;
|
|
|
|
vps[QUICKSCREEN_LEFT].width = width;
|
2010-02-25 06:01:53 +00:00
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_RIGHT] = *parent;
|
|
|
|
vps[QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad;
|
|
|
|
vps[QUICKSCREEN_RIGHT].width = width;
|
2009-08-29 14:42:03 +00:00
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_LEFT].height = vps[QUICKSCREEN_RIGHT].height
|
2009-08-29 14:42:03 +00:00
|
|
|
= 2*char_height;
|
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
vps[QUICKSCREEN_LEFT].y = vps[QUICKSCREEN_RIGHT].y
|
2009-08-29 14:42:03 +00:00
|
|
|
= parent->y + (parent->height/2) - char_height;
|
|
|
|
|
2008-10-31 04:58:33 +00:00
|
|
|
/* 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 */
|
2009-09-05 18:52:44 +00:00
|
|
|
if (vp_icons->width > CENTER_ICONAREA_SIZE*2)
|
2008-10-31 04:58:33 +00:00
|
|
|
{
|
2009-09-05 18:52:44 +00:00
|
|
|
vp_icons->width -= CENTER_ICONAREA_SIZE*2/3;
|
|
|
|
vp_icons->x += CENTER_ICONAREA_SIZE*2/6;
|
2009-08-29 14:42:03 +00:00
|
|
|
}
|
2009-09-05 18:52:44 +00:00
|
|
|
if (vp_icons->height > CENTER_ICONAREA_SIZE*2)
|
2009-08-29 14:42:03 +00:00
|
|
|
{
|
2009-09-05 18:52:44 +00:00
|
|
|
vp_icons->height -= CENTER_ICONAREA_SIZE*2/3;
|
|
|
|
vp_icons->y += CENTER_ICONAREA_SIZE*2/6;
|
2008-10-31 04:58:33 +00:00
|
|
|
}
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2009-10-19 22:49:47 +00:00
|
|
|
/* text alignment */
|
|
|
|
vps[QUICKSCREEN_LEFT].flags &= ~VP_FLAG_ALIGNMENT_MASK; /* left-aligned */
|
|
|
|
vps[QUICKSCREEN_TOP].flags |= VP_FLAG_ALIGN_CENTER; /* centered */
|
|
|
|
vps[QUICKSCREEN_BOTTOM].flags |= VP_FLAG_ALIGN_CENTER; /* centered */
|
|
|
|
vps[QUICKSCREEN_RIGHT].flags &= ~VP_FLAG_ALIGNMENT_MASK;/* right aligned*/
|
|
|
|
vps[QUICKSCREEN_RIGHT].flags |= VP_FLAG_ALIGN_RIGHT;
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
|
|
|
|
2009-09-05 18:52:44 +00:00
|
|
|
static void gui_quickscreen_draw(const struct gui_quickscreen *qs,
|
2008-05-03 12:30:40 +00:00
|
|
|
struct screen *display,
|
2009-09-05 18:52:44 +00:00
|
|
|
struct viewport *parent,
|
|
|
|
struct viewport vps[QUICKSCREEN_ITEM_COUNT],
|
|
|
|
struct viewport *vp_icons)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
|
|
|
int i;
|
2008-05-03 12:30:40 +00:00
|
|
|
char buf[MAX_PATH];
|
2009-08-20 16:47:44 +00:00
|
|
|
unsigned const char *title, *value;
|
2008-05-03 12:30:40 +00:00
|
|
|
int temp;
|
2020-10-07 06:01:35 +00:00
|
|
|
struct viewport *last_vp = display->set_viewport(parent);
|
2008-05-03 12:30:40 +00:00
|
|
|
display->clear_viewport();
|
2020-10-12 23:26:26 +00:00
|
|
|
|
2009-10-10 07:46:54 +00:00
|
|
|
for (i = 0; i < QUICKSCREEN_ITEM_COUNT; i++)
|
2008-05-03 12:30:40 +00:00
|
|
|
{
|
2009-10-19 22:49:47 +00:00
|
|
|
struct viewport *vp = &vps[i];
|
2008-05-03 12:30:40 +00:00
|
|
|
if (!qs->items[i])
|
|
|
|
continue;
|
2009-10-19 22:49:47 +00:00
|
|
|
display->set_viewport(vp);
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
title = P2STR(ID2P(qs->items[i]->lang_id));
|
2008-05-28 10:55:39 +00:00
|
|
|
temp = option_value_as_int(qs->items[i]);
|
2009-10-29 15:09:09 +00:00
|
|
|
value = option_get_valuestring(qs->items[i],
|
2008-05-11 10:28:52 +00:00
|
|
|
buf, MAX_PATH, temp);
|
|
|
|
|
2009-10-19 22:49:47 +00:00
|
|
|
if (viewport_get_nb_lines(vp) < 2)
|
2008-05-03 12:30:40 +00:00
|
|
|
{
|
|
|
|
char text[MAX_PATH];
|
|
|
|
snprintf(text, MAX_PATH, "%s: %s", title, value);
|
2009-10-19 22:49:47 +00:00
|
|
|
display->puts_scroll(0, 0, text);
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-19 22:49:47 +00:00
|
|
|
display->puts_scroll(0, 0, title);
|
|
|
|
display->puts_scroll(0, 1, value);
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* draw the icons */
|
2009-09-05 18:52:44 +00:00
|
|
|
display->set_viewport(vp_icons);
|
2009-08-29 14:42:03 +00:00
|
|
|
|
2010-02-23 21:30:16 +00:00
|
|
|
if (qs->items[QUICKSCREEN_TOP] != NULL)
|
|
|
|
{
|
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow],
|
|
|
|
(vp_icons->width/2) - 4, 0, 7, 8);
|
|
|
|
}
|
|
|
|
if (qs->items[QUICKSCREEN_RIGHT] != NULL)
|
|
|
|
{
|
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
|
|
|
|
vp_icons->width - 8, (vp_icons->height/2) - 4, 7, 8);
|
|
|
|
}
|
|
|
|
if (qs->items[QUICKSCREEN_LEFT] != NULL)
|
|
|
|
{
|
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
|
|
|
0, (vp_icons->height/2) - 4, 7, 8);
|
|
|
|
}
|
|
|
|
if (qs->items[QUICKSCREEN_BOTTOM] != NULL)
|
|
|
|
{
|
|
|
|
display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
|
|
|
(vp_icons->width/2) - 4, vp_icons->height - 8, 7, 8);
|
|
|
|
}
|
2008-05-11 10:28:52 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
display->set_viewport(parent);
|
|
|
|
display->update_viewport();
|
2020-10-07 06:01:35 +00:00
|
|
|
display->set_viewport(last_vp);
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
|
|
|
|
2009-10-29 15:09:09 +00:00
|
|
|
static void talk_qs_option(const struct settings_list *opt, bool enqueue)
|
2008-05-04 15:02:46 +00:00
|
|
|
{
|
2010-02-23 21:30:16 +00:00
|
|
|
if (!global_settings.talk_menu || !opt)
|
|
|
|
return;
|
|
|
|
|
2019-08-05 02:42:46 +00:00
|
|
|
if (enqueue)
|
|
|
|
talk_id(opt->lang_id, enqueue);
|
|
|
|
option_talk_value(opt, option_value_as_int(opt), enqueue);
|
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;
|
2021-11-12 19:51:29 +00:00
|
|
|
bool previous = false;
|
2005-11-22 03:38:07 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2009-08-29 14:42:03 +00:00
|
|
|
case ACTION_QS_TOP:
|
|
|
|
item = QUICKSCREEN_TOP;
|
|
|
|
break;
|
2021-11-12 19:51:29 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_QS_LEFT:
|
2008-05-03 12:30:40 +00:00
|
|
|
item = QUICKSCREEN_LEFT;
|
2021-11-12 19:51:29 +00:00
|
|
|
previous = true;
|
2008-05-03 12:30:40 +00:00
|
|
|
break;
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2009-01-09 11:07:26 +00:00
|
|
|
case ACTION_QS_DOWN:
|
2008-05-03 12:30:40 +00:00
|
|
|
item = QUICKSCREEN_BOTTOM;
|
2021-11-12 19:51:29 +00:00
|
|
|
previous = true;
|
2008-05-03 12:30:40 +00:00
|
|
|
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
|
|
|
}
|
2021-11-12 19:51:29 +00:00
|
|
|
|
2010-02-25 06:01:53 +00:00
|
|
|
if (qs->items[item] == NULL)
|
|
|
|
return false;
|
2021-11-12 19:51:29 +00:00
|
|
|
|
|
|
|
option_select_next_val(qs->items[item], previous, true);
|
2009-10-29 15:09:09 +00:00
|
|
|
talk_qs_option(qs->items[item], false);
|
2008-05-03 12:30:40 +00:00
|
|
|
return true;
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
2009-09-05 23:32:16 +00:00
|
|
|
|
2009-09-05 23:57:09 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2021-10-07 22:38:01 +00:00
|
|
|
static int quickscreen_touchscreen_button(void)
|
2009-05-15 05:08:28 +00:00
|
|
|
{
|
|
|
|
short x,y;
|
|
|
|
if (action_get_touchscreen_press(&x, &y) != BUTTON_REL)
|
|
|
|
return ACTION_NONE;
|
2021-10-07 22:38:01 +00:00
|
|
|
|
|
|
|
enum { left=1, right=2, top=4, bottom=8 };
|
|
|
|
|
2022-03-16 23:48:46 +00:00
|
|
|
int bits = 0;
|
|
|
|
|
|
|
|
if(x < LCD_WIDTH/3)
|
|
|
|
bits |= left;
|
|
|
|
else if(x > 2*LCD_WIDTH/3)
|
|
|
|
bits |= right;
|
|
|
|
|
|
|
|
if(y < LCD_HEIGHT/3)
|
|
|
|
bits |= top;
|
|
|
|
else if(y > 2*LCD_HEIGHT/3)
|
|
|
|
bits |= bottom;
|
2021-10-07 22:38:01 +00:00
|
|
|
|
|
|
|
switch(bits) {
|
|
|
|
case top:
|
2009-09-05 23:32:16 +00:00
|
|
|
return ACTION_QS_TOP;
|
2021-10-07 22:38:01 +00:00
|
|
|
case bottom:
|
2009-05-15 05:08:28 +00:00
|
|
|
return ACTION_QS_DOWN;
|
2021-10-07 22:38:01 +00:00
|
|
|
case left:
|
2009-05-15 05:08:28 +00:00
|
|
|
return ACTION_QS_LEFT;
|
2021-10-07 22:38:01 +00:00
|
|
|
case right:
|
2009-05-15 05:08:28 +00:00
|
|
|
return ACTION_QS_RIGHT;
|
2021-10-07 22:38:01 +00:00
|
|
|
default:
|
|
|
|
return ACTION_STD_CANCEL;
|
|
|
|
}
|
2010-02-25 06:01:53 +00:00
|
|
|
}
|
2009-05-15 05:08:28 +00:00
|
|
|
#endif
|
2009-09-05 23:57:09 +00:00
|
|
|
|
2021-10-26 01:05:50 +00:00
|
|
|
static int gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter, bool *usb)
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2011-10-15 19:35:02 +00:00
|
|
|
int button;
|
2009-09-05 18:52:44 +00:00
|
|
|
struct viewport parent[NB_SCREENS];
|
|
|
|
struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT];
|
|
|
|
struct viewport vp_icons[NB_SCREENS];
|
2021-10-26 01:05:50 +00:00
|
|
|
int ret = QUICKSCREEN_OK;
|
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;
|
2014-03-18 11:23:59 +00:00
|
|
|
|
2011-06-01 14:41:49 +00:00
|
|
|
push_current_activity(ACTIVITY_QUICKSCREEN);
|
2020-10-12 23:26:26 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].set_viewport(NULL);
|
2013-04-03 14:33:23 +00:00
|
|
|
screens[i].scroll_stop();
|
2010-02-26 06:17:04 +00:00
|
|
|
viewportmanager_theme_enable(i, true, &parent[i]);
|
2009-09-05 18:52:44 +00:00
|
|
|
quickscreen_fix_viewports(qs, &screens[i], &parent[i], vps[i], &vp_icons[i]);
|
|
|
|
gui_quickscreen_draw(qs, &screens[i], &parent[i], vps[i], &vp_icons[i]);
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
2014-03-18 11:23:59 +00:00
|
|
|
*usb = false;
|
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);
|
2009-10-29 15:09:09 +00:00
|
|
|
talk_qs_option(qs->items[QUICKSCREEN_TOP], true);
|
2019-08-05 02:42:46 +00:00
|
|
|
if (qs->items[QUICKSCREEN_TOP] != qs->items[QUICKSCREEN_BOTTOM])
|
|
|
|
talk_qs_option(qs->items[QUICKSCREEN_BOTTOM], true);
|
2009-10-29 15:09:09 +00:00
|
|
|
talk_qs_option(qs->items[QUICKSCREEN_LEFT], true);
|
2019-08-05 02:42:46 +00:00
|
|
|
if (qs->items[QUICKSCREEN_LEFT] != qs->items[QUICKSCREEN_RIGHT])
|
|
|
|
talk_qs_option(qs->items[QUICKSCREEN_RIGHT], true);
|
2005-11-22 03:38:07 +00:00
|
|
|
while (true) {
|
2009-10-10 07:46:54 +00:00
|
|
|
button = get_action(CONTEXT_QUICKSCREEN, HZ/5);
|
2009-05-15 05:08:28 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
if (button == ACTION_TOUCHSCREEN)
|
2021-10-07 22:38:01 +00:00
|
|
|
button = quickscreen_touchscreen_button();
|
2009-05-15 05:08:28 +00:00
|
|
|
#endif
|
2009-10-10 07:46:54 +00:00
|
|
|
if (default_event_handler(button) == SYS_USB_CONNECTED)
|
2014-03-18 11:23:59 +00:00
|
|
|
{
|
|
|
|
*usb = true;
|
|
|
|
break;
|
|
|
|
}
|
2009-10-10 07:46:54 +00:00
|
|
|
if (gui_quickscreen_do_button(qs, button))
|
2005-11-22 03:38:07 +00:00
|
|
|
{
|
2021-10-26 01:05:50 +00:00
|
|
|
ret |= QUICKSCREEN_CHANGED;
|
2009-10-10 07:46:54 +00:00
|
|
|
can_quit = true;
|
2008-05-03 12:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2009-10-10 07:46:54 +00:00
|
|
|
gui_quickscreen_draw(qs, &screens[i], &parent[i],
|
|
|
|
vps[i], &vp_icons[i]);
|
2008-05-03 12:30:40 +00:00
|
|
|
if (qs->callback)
|
2008-02-05 09:09:38 +00:00
|
|
|
qs->callback(qs);
|
2005-11-22 03:38:07 +00:00
|
|
|
}
|
2009-10-10 07:46:54 +00:00
|
|
|
else if (button == button_enter)
|
|
|
|
can_quit = true;
|
2021-02-24 11:44:39 +00:00
|
|
|
else if (button == ACTION_QS_VOLUP) {
|
2022-11-22 04:10:35 +00:00
|
|
|
adjust_volume(1);
|
2021-04-03 22:14:37 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_NON_STATIC);
|
2021-02-24 11:44:39 +00:00
|
|
|
}
|
|
|
|
else if (button == ACTION_QS_VOLDOWN) {
|
2022-11-22 04:10:35 +00:00
|
|
|
adjust_volume(-1);
|
2021-04-03 22:14:37 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_NON_STATIC);
|
2021-02-24 11:44:39 +00:00
|
|
|
}
|
2021-10-26 01:05:50 +00:00
|
|
|
else if (button == ACTION_STD_CONTEXT)
|
|
|
|
{
|
|
|
|
ret |= QUICKSCREEN_GOTO_SHORTCUTS_MENU;
|
|
|
|
break;
|
|
|
|
}
|
2009-10-10 07:46:54 +00:00
|
|
|
if ((button == button_enter) && can_quit)
|
2006-08-15 12:27:07 +00:00
|
|
|
break;
|
2010-02-25 06:01:53 +00:00
|
|
|
|
2009-10-10 07:46:54 +00:00
|
|
|
if (button == ACTION_STD_CANCEL)
|
2006-08-15 12:27:07 +00:00
|
|
|
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);
|
2009-09-05 14:38:29 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{ /* stop scrolling before exiting */
|
2011-10-15 19:35:02 +00:00
|
|
|
for (int j = 0; j < QUICKSCREEN_ITEM_COUNT; j++)
|
2013-04-03 14:33:23 +00:00
|
|
|
screens[i].scroll_stop_viewport(&vps[i][j]);
|
2022-11-27 00:15:14 +00:00
|
|
|
viewportmanager_theme_undo(i, !(ret & QUICKSCREEN_GOTO_SHORTCUTS_MENU));
|
2009-09-05 14:38:29 +00:00
|
|
|
}
|
2010-02-25 06:01:53 +00:00
|
|
|
|
2022-11-27 00:15:14 +00:00
|
|
|
if (ret & QUICKSCREEN_GOTO_SHORTCUTS_MENU) /* Eliminate flashing of parent during */
|
2022-12-14 08:06:04 +00:00
|
|
|
pop_current_activity_without_refresh(); /* transition to Shortcuts */
|
2022-11-27 00:15:14 +00:00
|
|
|
else
|
2022-12-14 08:06:04 +00:00
|
|
|
pop_current_activity();
|
2021-10-26 01:05:50 +00:00
|
|
|
|
|
|
|
return ret;
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
2008-11-05 09:30:20 +00:00
|
|
|
|
2021-03-07 15:07:49 +00:00
|
|
|
int quick_screen_quick(int button_enter)
|
2008-05-03 12:30:40 +00:00
|
|
|
{
|
|
|
|
struct gui_quickscreen qs;
|
|
|
|
bool oldshuffle = global_settings.playlist_shuffle;
|
|
|
|
int oldrepeat = global_settings.repeat_mode;
|
2021-11-19 04:11:13 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
|
|
|
int old_album_art = global_settings.album_art;
|
|
|
|
#endif
|
2014-03-18 11:23:59 +00:00
|
|
|
bool usb = false;
|
2008-11-03 11:11:07 +00:00
|
|
|
|
2022-11-30 14:28:31 +00:00
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
qs.items[i] = global_settings.qs_items[i];
|
|
|
|
|
|
|
|
if (!is_setting_quickscreenable(qs.items[i]))
|
|
|
|
qs.items[i] = NULL;
|
|
|
|
}
|
2008-11-03 11:11:07 +00:00
|
|
|
|
2008-05-03 12:30:40 +00:00
|
|
|
qs.callback = NULL;
|
2021-10-26 01:05:50 +00:00
|
|
|
int ret = gui_syncquickscreen_run(&qs, button_enter, &usb);
|
|
|
|
if (ret & QUICKSCREEN_CHANGED)
|
2008-05-03 12:30:40 +00:00
|
|
|
{
|
|
|
|
settings_save();
|
|
|
|
/* 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)
|
|
|
|
{
|
2012-04-30 20:27:01 +00:00
|
|
|
replaygain_update();
|
2008-05-03 12:30:40 +00:00
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_randomise(NULL, current_tick, true);
|
|
|
|
else
|
|
|
|
playlist_sort(NULL, true);
|
|
|
|
}
|
2021-11-19 04:11:13 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
|
|
|
if (old_album_art != global_settings.album_art)
|
|
|
|
set_albumart_mode(global_settings.album_art);
|
|
|
|
#endif
|
2008-05-03 12:30:40 +00:00
|
|
|
}
|
2021-10-26 01:05:50 +00:00
|
|
|
if (usb)
|
|
|
|
return QUICKSCREEN_IN_USB;
|
|
|
|
return ret & QUICKSCREEN_GOTO_SHORTCUTS_MENU ? QUICKSCREEN_GOTO_SHORTCUTS_MENU :
|
|
|
|
QUICKSCREEN_OK;
|
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
|
|
|
{
|
2022-11-30 14:28:31 +00:00
|
|
|
if (!setting)
|
|
|
|
return true;
|
|
|
|
|
2008-11-03 11:11:07 +00:00
|
|
|
/* to keep things simple, only settings which have a lang_id set are ok */
|
2022-11-30 14:28:31 +00:00
|
|
|
if (setting->lang_id < 0 || (setting->flags & F_BANFROMQS))
|
2008-11-03 11:11:07 +00:00
|
|
|
return false;
|
2022-11-30 14:28:31 +00:00
|
|
|
|
|
|
|
switch (setting->flags & F_T_MASK)
|
2008-11-03 11:11:07 +00:00
|
|
|
{
|
|
|
|
case F_T_BOOL:
|
|
|
|
return true;
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
|
|
|
return (setting->RESERVED != NULL);
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|