summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/menu.c139
-rw-r--r--uisimulator/menu.h50
2 files changed, 189 insertions, 0 deletions
diff --git a/uisimulator/menu.c b/uisimulator/menu.c
new file mode 100644
index 0000000000..6468e9f545
--- /dev/null
+++ b/uisimulator/menu.c
@@ -0,0 +1,139 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Robert E. Hak
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "types.h"
21#include "lcd.h"
22#include "menu.h"
23
24#include "tree.h"
25
26#ifdef HAVE_LCD_BITMAP
27
28#include "screensaver.h"
29extern void tetris(void);
30
31
32#define MENU_ITEM_FONT 0
33#define MENU_ITEM_Y_LOC 6
34#define MENU_LINE_HEIGHT 8
35
36enum Main_Menu_Ids {
37 Tetris, Screen_Saver, Browse, Last_Id
38};
39
40struct Main_Menu_Items items[] = {
41 { Tetris, "Tetris", tetris },
42 { Screen_Saver, "Screen Saver", screensaver },
43 { Browse, "Browse", browse_root },
44};
45
46/* Global values for menuing */
47int menu_top;
48int menu_bottom;
49int menu_line_height;
50int cursor;
51
52int get_line_height(void)
53{
54 return menu_line_height;
55}
56
57int is_cursor_menu_top(void)
58{
59 return ((cursor == menu_top) ? 1 : 0);
60}
61
62int is_cursor_menu_bottom(void)
63{
64 return ((cursor == menu_bottom) ? 1 : 0);
65}
66
67void put_cursor_menu_top(void)
68{
69 put_cursor(menu_top);
70}
71
72void put_cursor_menu_bottom(void)
73{
74 put_cursor(menu_bottom);
75}
76
77void move_cursor_up(void)
78{
79 put_cursor(cursor-1);
80}
81
82void move_cursor_down(void)
83{
84 put_cursor(cursor+1);
85}
86
87void redraw_cursor(void)
88{
89 lcd_puts(0, cursor*menu_line_height, "-", 0);
90}
91
92/*
93 * Move the cursor to a particular id,
94 * current: where it is now
95 * target: where you want it to be
96 */
97void put_cursor(int target)
98{
99 lcd_puts(0, cursor*menu_line_height, " ", 0);
100 cursor = target;
101 lcd_puts(0, cursor*menu_line_height, "-", 0);
102}
103
104/* We call the function pointer related to the current cursor position */
105void execute_menu_item(void)
106{
107 /* call the proper function for this line */
108 items[cursor].function();
109}
110
111void add_menu_item(int location, char *string)
112{
113 lcd_puts(MENU_ITEM_Y_LOC, MENU_LINE_HEIGHT*location,
114 string, MENU_ITEM_FONT);
115 if (location < menu_top)
116 menu_top = location;
117 if (location > menu_bottom)
118 menu_bottom = location;
119}
120
121void menu_init(void)
122{
123 int i = 0;
124
125 menu_top = Tetris;
126 menu_bottom = Last_Id-1;
127 menu_line_height = MENU_LINE_HEIGHT;
128 cursor = menu_top;
129
130 for (i = i; i < Last_Id; i++)
131 add_menu_item(items[i].menu_id, (char *) items[i].menu_desc);
132
133 lcd_puts(8, 38, "Rockbox!", 2);
134 redraw_cursor();
135}
136
137#endif /* end HAVE_LCD_BITMAP */
138
139
diff --git a/uisimulator/menu.h b/uisimulator/menu.h
new file mode 100644
index 0000000000..25dfd393a2
--- /dev/null
+++ b/uisimulator/menu.h
@@ -0,0 +1,50 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Robert E. Hak
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef __MENU_H__
21#define __MENU_H__
22
23struct Main_Menu_Items {
24 int menu_id;
25 const char *menu_desc;
26 void (*function) (void);
27};
28
29int get_line_height(void);
30
31/* Cursor calls */
32void put_cursor(int target);
33void put_cursor_menu_top(void);
34void put_cursor_menu_bottom(void);
35void move_cursor_up(void);
36void move_cursor_down(void);
37int is_cursor_menu_top(void);
38int is_cursor_menu_bottom(void);
39
40/* Menu calls */
41void add_menu_item(int location, char *string);
42void menu_init(void);
43void execute_menu_item(void);
44
45#endif /* End __MENU_H__ */
46
47
48
49
50