2002-05-17 12:22:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert E. Hak
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2002-05-26 17:03:17 +00:00
|
|
|
#include <stdbool.h>
|
2004-03-12 10:20:33 +00:00
|
|
|
#include <stdlib.h>
|
2002-08-31 04:58:35 +00:00
|
|
|
|
2002-10-15 12:25:57 +00:00
|
|
|
#include "hwcompat.h"
|
2002-05-17 12:22:24 +00:00
|
|
|
#include "lcd.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2002-08-31 04:58:35 +00:00
|
|
|
#include "backlight.h"
|
2002-05-17 12:22:24 +00:00
|
|
|
#include "menu.h"
|
2002-05-21 14:25:45 +00:00
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "debug.h"
|
2002-08-23 02:17:00 +00:00
|
|
|
#include "usb.h"
|
2002-08-11 09:17:47 +00:00
|
|
|
#include "panic.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#include "settings.h"
|
|
|
|
#include "status.h"
|
2002-09-24 18:04:15 +00:00
|
|
|
#include "screens.h"
|
2004-03-14 21:33:53 +00:00
|
|
|
#include "talk.h"
|
2004-07-23 23:01:20 +00:00
|
|
|
#include "lang.h"
|
2002-08-30 13:49:32 +00:00
|
|
|
|
2002-06-14 08:47:44 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "icons.h"
|
2002-08-30 13:49:32 +00:00
|
|
|
#include "widgets.h"
|
2002-06-14 08:47:44 +00:00
|
|
|
#endif
|
2002-08-30 13:49:32 +00:00
|
|
|
|
2002-05-26 17:03:17 +00:00
|
|
|
struct menu {
|
2002-05-28 15:35:33 +00:00
|
|
|
int top;
|
2002-05-26 17:03:17 +00:00
|
|
|
int cursor;
|
2004-03-16 13:44:56 +00:00
|
|
|
struct menu_item* items;
|
2002-05-26 17:03:17 +00:00
|
|
|
int itemcount;
|
2004-03-12 10:20:33 +00:00
|
|
|
int (*callback)(int, int);
|
2004-03-16 13:44:56 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
bool use_buttonbar; /* true if a buttonbar is defined */
|
|
|
|
char *buttonbar[3];
|
|
|
|
#endif
|
2002-05-26 17:03:17 +00:00
|
|
|
};
|
|
|
|
|
2004-01-26 17:05:21 +00:00
|
|
|
#define MAX_MENUS 5
|
2002-05-26 17:03:17 +00:00
|
|
|
|
2002-05-28 15:35:33 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-30 13:49:32 +00:00
|
|
|
|
2002-09-24 19:41:23 +00:00
|
|
|
/* pixel margins */
|
|
|
|
#define MARGIN_X (global_settings.scrollbar && \
|
|
|
|
menu_lines < menus[m].itemcount ? SCROLLBAR_WIDTH : 0) +\
|
|
|
|
CURSOR_WIDTH
|
|
|
|
#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0)
|
|
|
|
|
|
|
|
/* position the entry-list starts at */
|
|
|
|
#define LINE_X 0
|
|
|
|
#define LINE_Y (global_settings.statusbar ? 1 : 0)
|
|
|
|
|
|
|
|
#define CURSOR_X (global_settings.scrollbar && \
|
|
|
|
menu_lines < menus[m].itemcount ? 1 : 0)
|
|
|
|
#define CURSOR_Y 0 /* the cursor is not positioned in regard to
|
|
|
|
the margins, so this is the amount of lines
|
|
|
|
we add to the cursor Y position to position
|
|
|
|
it on a line */
|
2003-04-16 00:12:31 +00:00
|
|
|
#define CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4)
|
2002-08-30 13:49:32 +00:00
|
|
|
|
|
|
|
#define SCROLLBAR_X 0
|
|
|
|
#define SCROLLBAR_Y lcd_getymargin()
|
|
|
|
#define SCROLLBAR_WIDTH 6
|
|
|
|
|
|
|
|
#else /* HAVE_LCD_BITMAP */
|
|
|
|
|
2002-08-31 04:58:35 +00:00
|
|
|
#define LINE_X 1 /* X position the entry-list starts at */
|
2002-08-30 13:49:32 +00:00
|
|
|
|
2002-05-28 15:35:33 +00:00
|
|
|
#define MENU_LINES 2
|
2002-08-30 13:49:32 +00:00
|
|
|
|
|
|
|
#define CURSOR_X 0
|
|
|
|
#define CURSOR_Y 0 /* not really used for players */
|
|
|
|
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2002-05-28 15:35:33 +00:00
|
|
|
|
2003-01-10 09:55:50 +00:00
|
|
|
#define CURSOR_CHAR 0x92
|
2002-05-31 09:04:51 +00:00
|
|
|
|
2002-05-26 17:03:17 +00:00
|
|
|
static struct menu menus[MAX_MENUS];
|
|
|
|
static bool inuse[MAX_MENUS] = { false };
|
2002-05-17 12:22:24 +00:00
|
|
|
|
2002-09-12 13:33:59 +00:00
|
|
|
/* count in letter positions, NOT pixels */
|
2002-06-14 08:47:44 +00:00
|
|
|
void put_cursorxy(int x, int y, bool on)
|
|
|
|
{
|
2002-08-11 09:20:53 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-12 13:33:59 +00:00
|
|
|
int fh, fw;
|
2002-09-20 08:07:51 +00:00
|
|
|
int xpos, ypos;
|
2003-06-05 09:38:26 +00:00
|
|
|
|
|
|
|
/* check here instead of at every call (ugly, but cheap) */
|
2003-04-16 00:12:31 +00:00
|
|
|
if (global_settings.invert_cursor)
|
|
|
|
return;
|
2003-06-05 09:38:26 +00:00
|
|
|
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize("A", &fw, &fh);
|
2002-09-20 08:07:51 +00:00
|
|
|
xpos = x*6;
|
|
|
|
ypos = y*fh + lcd_getymargin();
|
|
|
|
if ( fh > 8 )
|
|
|
|
ypos += (fh - 8) / 2;
|
2002-08-11 09:17:47 +00:00
|
|
|
#endif
|
|
|
|
|
2002-06-14 08:47:44 +00:00
|
|
|
/* place the cursor */
|
|
|
|
if(on) {
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
lcd_bitmap ( bitmap_icons_6x8[Cursor],
|
2002-09-20 08:07:51 +00:00
|
|
|
xpos, ypos, 4, 8, true);
|
2002-06-14 08:47:44 +00:00
|
|
|
#else
|
2003-01-10 09:55:50 +00:00
|
|
|
lcd_putc(x, y, CURSOR_CHAR);
|
2002-06-14 08:47:44 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
2002-06-19 13:00:14 +00:00
|
|
|
#if defined(HAVE_LCD_BITMAP)
|
2002-06-14 08:47:44 +00:00
|
|
|
/* I use xy here since it needs to disregard the margins */
|
2002-09-20 08:07:51 +00:00
|
|
|
lcd_clearrect (xpos, ypos, 4, 8);
|
2002-06-14 08:47:44 +00:00
|
|
|
#else
|
2002-09-09 23:57:00 +00:00
|
|
|
lcd_putc(x, y, ' ');
|
2002-06-14 08:47:44 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-12 10:20:33 +00:00
|
|
|
void menu_draw(int m)
|
2002-05-28 15:35:33 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
Daniel,
The following patch makes loadable fonts actually work (finally!).
It took me quite a while, but I finally figured out why the sim
worked and the target didn't: the SH1 processor won't read
longwords from a shortword alignment... I had to rev the .fnt
file to version 1.1 (requires remaking *.fnt files) in order
to fix this. Please apply the following patch completely.
It's diffed against the latest CVS.
I've also attached rockbox-fonts-1.1.tar.gz which includes
known working *.fnt files, including a courB08 system.fnt,
for demonstration.
Now the real work can begin... Although the new
system.fnt will work fine, if you try going to a really
big font (try copying courB14.fnt to system.fnt), then
you will find that it comes up and works in tree mode,
but will crash the system when going into WPS
mode... I'm sure this is because of the low-level
lcd_bitmap not clipping properly when given a too-large
bitmap, which the characters become. I haven't yet
tried to debug the low-level driver. Of course, it all
works on the sim...
So the apps developers will now have to make sure that
all apps screen sizes may vary according to the loaded font.
The font height can be gotten through the lcd_getfontsize API.
Files patched in fonts-6.patch
1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin)
2. firmware/font.c - fixes and reformatting. Please check this in as is,
my vi editor requires more reformatting changes since I left tabs in the
file, these are removed now (2nd resubmission on this, please checkin)
3. firmware/fonts.h - doc change on .fnt file format, .fnt version
number incremented.
4. firmware/loadfont.c - fixes to load font properly, typedefs
removed.
5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before
issuing error, otherwise font may not exist.
6. tools/bdf2c - fixes for correct output when filename starts
with a number, as well as when no DEFAULT_CHAR in .bdf
file. (2nd resubmission on this, please checkin)
7. tools/writerbf.c - fixes for bugfixed fontfile format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
2002-09-16 03:18:49 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-12 13:33:59 +00:00
|
|
|
int fw, fh;
|
2002-08-11 09:17:47 +00:00
|
|
|
int menu_lines;
|
2004-03-16 13:44:56 +00:00
|
|
|
int height = LCD_HEIGHT;
|
|
|
|
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
lcd_getstringsize("A", &fw, &fh);
|
2002-08-20 19:37:00 +00:00
|
|
|
if (global_settings.statusbar)
|
2004-03-16 13:44:56 +00:00
|
|
|
height -= STATUSBAR_HEIGHT;
|
|
|
|
|
|
|
|
if(global_settings.buttonbar && menus[m].use_buttonbar) {
|
|
|
|
buttonbar_set(menus[m].buttonbar[0],
|
|
|
|
menus[m].buttonbar[1],
|
|
|
|
menus[m].buttonbar[2]);
|
|
|
|
height -= BUTTONBAR_HEIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_lines = height / fh;
|
|
|
|
|
2002-08-11 09:17:47 +00:00
|
|
|
#else
|
|
|
|
int menu_lines = MENU_LINES;
|
|
|
|
#endif
|
2002-05-28 15:35:33 +00:00
|
|
|
|
2004-04-09 17:47:18 +00:00
|
|
|
lcd_clear_display();
|
2002-05-28 15:35:33 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-30 13:49:32 +00:00
|
|
|
lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */
|
2002-05-28 15:35:33 +00:00
|
|
|
#endif
|
2004-04-09 17:47:18 +00:00
|
|
|
/* Adjust cursor pos if it's below the screen */
|
2002-08-20 19:37:00 +00:00
|
|
|
if (menus[m].cursor - menus[m].top >= menu_lines)
|
|
|
|
menus[m].top++;
|
|
|
|
|
2004-04-09 17:47:18 +00:00
|
|
|
/* Adjust cursor pos if it's above the screen */
|
|
|
|
if(menus[m].cursor < menus[m].top)
|
|
|
|
menus[m].top = menus[m].cursor;
|
|
|
|
|
2002-05-28 15:35:33 +00:00
|
|
|
for (i = menus[m].top;
|
2002-08-11 09:17:47 +00:00
|
|
|
(i < menus[m].itemcount) && (i<menus[m].top+menu_lines);
|
2002-05-28 15:35:33 +00:00
|
|
|
i++) {
|
2004-04-09 17:47:18 +00:00
|
|
|
|
|
|
|
/* We want to scroll the line where the cursor is */
|
2002-08-02 07:59:25 +00:00
|
|
|
if((menus[m].cursor - menus[m].top)==(i-menus[m].top))
|
2003-04-16 00:12:31 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
if (global_settings.invert_cursor)
|
|
|
|
lcd_puts_scroll_style(LINE_X, i-menus[m].top,
|
2004-07-23 23:01:20 +00:00
|
|
|
P2STR(menus[m].items[i].desc), STYLE_INVERT);
|
2003-04-16 00:12:31 +00:00
|
|
|
else
|
|
|
|
#endif
|
2004-07-23 23:01:20 +00:00
|
|
|
lcd_puts_scroll(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
|
2002-08-02 07:59:25 +00:00
|
|
|
else
|
2004-07-23 23:01:20 +00:00
|
|
|
lcd_puts(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
|
2002-05-28 15:35:33 +00:00
|
|
|
}
|
2002-05-30 08:06:42 +00:00
|
|
|
|
2002-06-14 08:47:44 +00:00
|
|
|
/* place the cursor */
|
2002-08-30 13:49:32 +00:00
|
|
|
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
|
2004-04-09 17:47:18 +00:00
|
|
|
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-24 19:41:23 +00:00
|
|
|
if (global_settings.scrollbar && menus[m].itemcount > menu_lines)
|
2002-08-30 13:49:32 +00:00
|
|
|
scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
|
2004-03-16 13:44:56 +00:00
|
|
|
height, menus[m].itemcount, menus[m].top,
|
2002-08-30 13:49:32 +00:00
|
|
|
menus[m].top + menu_lines, VERTICAL);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
|
|
|
if(global_settings.buttonbar && menus[m].use_buttonbar)
|
|
|
|
buttonbar_draw();
|
2002-08-20 19:37:00 +00:00
|
|
|
#endif
|
2003-04-23 11:26:25 +00:00
|
|
|
status_draw(true);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
2002-05-28 15:35:33 +00:00
|
|
|
lcd_update();
|
|
|
|
}
|
|
|
|
|
2002-05-21 14:25:45 +00:00
|
|
|
/*
|
|
|
|
* Move the cursor to a particular id,
|
|
|
|
* target: where you want it to be
|
|
|
|
*/
|
2002-05-26 17:03:17 +00:00
|
|
|
static void put_cursor(int m, int target)
|
2002-05-17 12:22:24 +00:00
|
|
|
{
|
2004-04-09 17:47:18 +00:00
|
|
|
int voice_id;
|
2004-03-16 13:44:56 +00:00
|
|
|
|
2002-05-30 08:06:42 +00:00
|
|
|
menus[m].cursor = target;
|
2002-08-02 07:59:25 +00:00
|
|
|
menu_draw(m);
|
2002-05-28 15:35:33 +00:00
|
|
|
|
2004-04-09 17:47:18 +00:00
|
|
|
/* "say" the entry under the cursor */
|
|
|
|
if(global_settings.talk_menu)
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
voice_id = P2ID(menus[m].items[menus[m].cursor].desc);
|
2004-04-09 17:47:18 +00:00
|
|
|
if (voice_id >= 0) /* valid ID given? */
|
2004-03-14 21:33:53 +00:00
|
|
|
talk_id(voice_id, false); /* say it */
|
|
|
|
}
|
2002-05-17 12:22:24 +00:00
|
|
|
}
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int),
|
2004-03-16 13:44:56 +00:00
|
|
|
char *button1, char *button2, char *button3)
|
2002-05-17 12:22:24 +00:00
|
|
|
{
|
2002-05-26 17:03:17 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for ( i=0; i<MAX_MENUS; i++ ) {
|
|
|
|
if ( !inuse[i] ) {
|
|
|
|
inuse[i] = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( i == MAX_MENUS ) {
|
|
|
|
DEBUGF("Out of menus!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2004-07-23 23:01:20 +00:00
|
|
|
menus[i].items = (struct menu_item*)mitems; /* de-const */
|
2002-05-26 17:03:17 +00:00
|
|
|
menus[i].itemcount = count;
|
2002-05-28 15:35:33 +00:00
|
|
|
menus[i].top = 0;
|
2002-05-26 17:03:17 +00:00
|
|
|
menus[i].cursor = 0;
|
2004-03-12 10:20:33 +00:00
|
|
|
menus[i].callback = callback;
|
2004-03-16 13:44:56 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
menus[i].buttonbar[0] = button1;
|
|
|
|
menus[i].buttonbar[1] = button2;
|
|
|
|
menus[i].buttonbar[2] = button3;
|
2002-05-26 17:03:17 +00:00
|
|
|
|
2004-03-16 13:44:56 +00:00
|
|
|
if(button1 || button2 || button3)
|
|
|
|
menus[i].use_buttonbar = true;
|
|
|
|
else
|
|
|
|
menus[i].use_buttonbar = false;
|
|
|
|
#else
|
|
|
|
(void)button1;
|
|
|
|
(void)button2;
|
|
|
|
(void)button3;
|
|
|
|
#endif
|
2002-05-26 17:03:17 +00:00
|
|
|
return i;
|
2002-05-17 12:22:24 +00:00
|
|
|
}
|
|
|
|
|
2002-05-26 17:03:17 +00:00
|
|
|
void menu_exit(int m)
|
2002-05-17 12:22:24 +00:00
|
|
|
{
|
2002-05-26 17:03:17 +00:00
|
|
|
inuse[m] = false;
|
2002-05-17 12:22:24 +00:00
|
|
|
}
|
|
|
|
|
2003-01-29 08:26:11 +00:00
|
|
|
int menu_show(int m)
|
2002-05-18 11:41:37 +00:00
|
|
|
{
|
2002-09-24 17:22:12 +00:00
|
|
|
bool exit = false;
|
2004-03-12 10:20:33 +00:00
|
|
|
int key;
|
2003-11-20 01:51:15 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int fw, fh;
|
|
|
|
int menu_lines;
|
2004-03-16 13:44:56 +00:00
|
|
|
int height = LCD_HEIGHT;
|
|
|
|
|
2003-11-20 01:51:15 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
lcd_getstringsize("A", &fw, &fh);
|
|
|
|
if (global_settings.statusbar)
|
2004-03-16 13:44:56 +00:00
|
|
|
height -= STATUSBAR_HEIGHT;
|
|
|
|
|
|
|
|
if(global_settings.buttonbar && menus[m].use_buttonbar) {
|
|
|
|
buttonbar_set(menus[m].buttonbar[0],
|
|
|
|
menus[m].buttonbar[1],
|
|
|
|
menus[m].buttonbar[2]);
|
|
|
|
height -= BUTTONBAR_HEIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_lines = height / fh;
|
2003-11-20 01:51:15 +00:00
|
|
|
#endif
|
2002-08-23 02:17:00 +00:00
|
|
|
|
2004-04-09 17:47:18 +00:00
|
|
|
/* Put the cursor on the first line and draw the menu */
|
2004-04-14 06:04:38 +00:00
|
|
|
put_cursor(m, menus[m].cursor);
|
2004-03-14 21:33:53 +00:00
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
while (!exit) {
|
2004-03-12 10:20:33 +00:00
|
|
|
key = button_get_w_tmo(HZ/2);
|
2004-03-14 21:33:53 +00:00
|
|
|
|
2004-03-12 10:20:33 +00:00
|
|
|
/*
|
2004-04-09 17:47:18 +00:00
|
|
|
* "short-circuit" the default keypresses by running the
|
|
|
|
* callback function
|
|
|
|
* The callback may return a new key value, often this will be
|
|
|
|
* BUTTON_NONE or the same key value, but it's perfectly legal
|
|
|
|
* to "simulate" key presses by returning another value.
|
2004-03-12 10:20:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if( menus[m].callback != NULL )
|
2004-04-09 17:47:18 +00:00
|
|
|
key = menus[m].callback(key, m);
|
|
|
|
|
2004-03-12 10:20:33 +00:00
|
|
|
switch( key ) {
|
2004-03-14 21:33:53 +00:00
|
|
|
|
2002-05-21 14:25:45 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_UP:
|
2002-08-10 09:04:55 +00:00
|
|
|
case BUTTON_UP | BUTTON_REPEAT:
|
2002-05-21 14:25:45 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_LEFT:
|
2002-08-02 07:59:25 +00:00
|
|
|
case BUTTON_LEFT | BUTTON_REPEAT:
|
2002-05-21 14:25:45 +00:00
|
|
|
#endif
|
2002-05-29 14:25:06 +00:00
|
|
|
if (menus[m].cursor) {
|
2002-05-21 14:25:45 +00:00
|
|
|
/* move up */
|
2002-05-26 17:03:17 +00:00
|
|
|
put_cursor(m, menus[m].cursor-1);
|
2002-05-21 14:25:45 +00:00
|
|
|
}
|
2002-09-04 04:21:10 +00:00
|
|
|
else {
|
|
|
|
/* move to bottom */
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
2003-11-20 01:51:15 +00:00
|
|
|
menus[m].top = menus[m].itemcount-(menu_lines+1);
|
2002-09-04 04:21:10 +00:00
|
|
|
#else
|
|
|
|
menus[m].top = menus[m].itemcount-3;
|
|
|
|
#endif
|
|
|
|
if (menus[m].top < 0)
|
|
|
|
menus[m].top = 0;
|
|
|
|
menus[m].cursor = menus[m].itemcount-1;
|
|
|
|
put_cursor(m, menus[m].itemcount-1);
|
|
|
|
}
|
2002-05-21 14:25:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_DOWN:
|
2002-08-10 09:04:55 +00:00
|
|
|
case BUTTON_DOWN | BUTTON_REPEAT:
|
2002-05-18 11:41:37 +00:00
|
|
|
#else
|
2002-05-21 14:25:45 +00:00
|
|
|
case BUTTON_RIGHT:
|
2002-08-02 07:59:25 +00:00
|
|
|
case BUTTON_RIGHT | BUTTON_REPEAT:
|
2002-05-18 11:41:37 +00:00
|
|
|
#endif
|
2002-05-29 14:25:06 +00:00
|
|
|
if (menus[m].cursor < menus[m].itemcount-1) {
|
2002-05-21 14:25:45 +00:00
|
|
|
/* move down */
|
2002-05-26 17:03:17 +00:00
|
|
|
put_cursor(m, menus[m].cursor+1);
|
2002-05-21 14:25:45 +00:00
|
|
|
}
|
2002-09-04 04:21:10 +00:00
|
|
|
else {
|
|
|
|
/* move to top */
|
|
|
|
menus[m].top = 0;
|
|
|
|
menus[m].cursor = 0;
|
|
|
|
put_cursor(m, 0);
|
|
|
|
}
|
2002-05-21 14:25:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
#endif
|
|
|
|
case BUTTON_PLAY:
|
|
|
|
/* Erase current display state */
|
|
|
|
lcd_clear_display();
|
2003-01-29 08:26:11 +00:00
|
|
|
return menus[m].cursor;
|
2002-05-21 14:25:45 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_LEFT:
|
2002-07-27 19:53:26 +00:00
|
|
|
case BUTTON_F1:
|
2003-12-04 00:08:25 +00:00
|
|
|
case BUTTON_OFF | BUTTON_REPEAT:
|
2002-05-21 14:25:45 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_STOP:
|
2002-05-29 12:28:08 +00:00
|
|
|
case BUTTON_MENU:
|
2003-12-04 00:08:25 +00:00
|
|
|
case BUTTON_STOP | BUTTON_REPEAT:
|
2002-05-21 14:25:45 +00:00
|
|
|
#endif
|
2003-01-23 14:28:16 +00:00
|
|
|
lcd_stop_scroll();
|
2002-09-24 17:22:12 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
2002-05-21 08:47:34 +00:00
|
|
|
|
2002-08-23 02:17:00 +00:00
|
|
|
case SYS_USB_CONNECTED:
|
2002-09-24 17:22:12 +00:00
|
|
|
usb_screen();
|
2002-09-01 20:08:08 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2002-10-15 12:56:05 +00:00
|
|
|
status_set_param(false);
|
2002-08-23 02:17:00 +00:00
|
|
|
#endif
|
2003-01-29 08:26:11 +00:00
|
|
|
return MENU_ATTACHED_USB;
|
2002-05-21 14:25:45 +00:00
|
|
|
}
|
|
|
|
|
2003-04-23 11:26:25 +00:00
|
|
|
status_draw(false);
|
2002-05-21 14:25:45 +00:00
|
|
|
}
|
2003-01-29 08:26:11 +00:00
|
|
|
return MENU_SELECTED_EXIT;
|
|
|
|
}
|
|
|
|
|
2002-08-23 12:32:52 +00:00
|
|
|
|
2003-01-29 08:26:11 +00:00
|
|
|
bool menu_run(int m)
|
|
|
|
{
|
|
|
|
bool stop=false;
|
|
|
|
while (!stop) {
|
|
|
|
int result=menu_show(m);
|
|
|
|
if (result == MENU_SELECTED_EXIT)
|
|
|
|
return false;
|
|
|
|
else if (result == MENU_ATTACHED_USB)
|
|
|
|
return true;
|
|
|
|
if (menus[m].items[menus[m].cursor].function()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2002-05-18 11:41:37 +00:00
|
|
|
}
|
2004-03-12 10:20:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Property function - return the current cursor for "menu"
|
|
|
|
*/
|
|
|
|
|
|
|
|
int menu_cursor(int menu)
|
|
|
|
{
|
|
|
|
return menus[menu].cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Property function - return the "menu" description at "position"
|
|
|
|
*/
|
|
|
|
|
|
|
|
char* menu_description(int menu, int position)
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
return P2STR(menus[menu].items[position].desc);
|
2004-03-12 10:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete the element "position" from the menu items in "menu"
|
|
|
|
*/
|
|
|
|
|
|
|
|
void menu_delete(int menu, int position)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* copy the menu item from the one below */
|
|
|
|
for( i = position; i < (menus[menu].itemcount - 1); i++)
|
|
|
|
menus[menu].items[i] = menus[menu].items[i + 1];
|
|
|
|
|
|
|
|
/* reduce the count */
|
|
|
|
menus[menu].itemcount--;
|
|
|
|
|
|
|
|
/* adjust if this was the last menu item and the cursor was on it */
|
|
|
|
if( menus[menu].itemcount <= menus[menu].cursor)
|
|
|
|
menus[menu].cursor = menus[menu].itemcount - 1;
|
|
|
|
}
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
void menu_insert(int menu, int position, char *desc, bool (*function) (void))
|
2004-07-05 14:26:58 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(position < 0)
|
|
|
|
position = menus[menu].itemcount;
|
|
|
|
|
|
|
|
/* Move the items below one position forward */
|
|
|
|
for( i = menus[menu].itemcount; i > position; i--)
|
|
|
|
menus[menu].items[i] = menus[menu].items[i - 1];
|
|
|
|
|
|
|
|
/* Increase the count */
|
|
|
|
menus[menu].itemcount++;
|
|
|
|
|
|
|
|
/* Update the current item */
|
|
|
|
menus[menu].items[position].desc = desc;
|
|
|
|
menus[menu].items[position].function = function;
|
|
|
|
}
|
|
|
|
|
2004-03-12 10:20:33 +00:00
|
|
|
/*
|
|
|
|
* Property function - return the "count" of menu items in "menu"
|
|
|
|
*/
|
|
|
|
|
|
|
|
int menu_count(int menu)
|
|
|
|
{
|
|
|
|
return menus[menu].itemcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allows a menu item at the current cursor position in "menu" to be moved up the list
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool menu_moveup(int menu)
|
|
|
|
{
|
2004-03-16 13:44:56 +00:00
|
|
|
struct menu_item swap;
|
2004-03-12 10:20:33 +00:00
|
|
|
|
|
|
|
/* can't be the first item ! */
|
|
|
|
if( menus[menu].cursor == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* use a temporary variable to do the swap */
|
|
|
|
swap = menus[menu].items[menus[menu].cursor - 1];
|
|
|
|
menus[menu].items[menus[menu].cursor - 1] = menus[menu].items[menus[menu].cursor];
|
|
|
|
menus[menu].items[menus[menu].cursor] = swap;
|
|
|
|
menus[menu].cursor--;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allows a menu item at the current cursor position in "menu" to be moved down the list
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool menu_movedown(int menu)
|
|
|
|
{
|
2004-03-16 13:44:56 +00:00
|
|
|
struct menu_item swap;
|
2004-03-12 10:20:33 +00:00
|
|
|
|
|
|
|
/* can't be the last item ! */
|
|
|
|
if( menus[menu].cursor == menus[menu].itemcount - 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* use a temporary variable to do the swap */
|
|
|
|
swap = menus[menu].items[menus[menu].cursor + 1];
|
|
|
|
menus[menu].items[menus[menu].cursor + 1] = menus[menu].items[menus[menu].cursor];
|
|
|
|
menus[menu].items[menus[menu].cursor] = swap;
|
|
|
|
menus[menu].cursor++;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|