forked from len0rd/rockbox
Added scrollbar to tree view and menus.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2084 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4b0e8b0b56
commit
000c2db035
5 changed files with 121 additions and 41 deletions
63
apps/menu.c
63
apps/menu.c
|
|
@ -26,9 +26,12 @@
|
|||
#include "panic.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#include "widgets.h"
|
||||
#endif
|
||||
|
||||
#ifdef LOADABLE_FONTS
|
||||
#include "ajf.h"
|
||||
#endif
|
||||
|
|
@ -43,12 +46,37 @@ struct menu {
|
|||
#define MAX_MENUS 4
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
||||
#define MARGIN_X (global_settings.scrollbar ? SCROLLBAR_WIDTH : 0) + CURSOR_WIDTH /* X pixel margin */
|
||||
#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* Y pixel margin */
|
||||
|
||||
#define LINE_X 0 /* X position the entry-list starts at */
|
||||
#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */
|
||||
#define LINE_HEIGTH 8 /* pixels for each text line */
|
||||
|
||||
#define MENU_LINES (LCD_HEIGHT / LINE_HEIGTH - LINE_Y)
|
||||
#else
|
||||
|
||||
#define CURSOR_X (global_settings.scrollbar ? 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 */
|
||||
#define CURSOR_WIDTH 4
|
||||
|
||||
#define SCROLLBAR_X 0
|
||||
#define SCROLLBAR_Y lcd_getymargin()
|
||||
#define SCROLLBAR_WIDTH 6
|
||||
|
||||
#else /* HAVE_LCD_BITMAP */
|
||||
|
||||
#define LINE_X 0 /* X position the entry-list starts at */
|
||||
|
||||
#define MENU_LINES 2
|
||||
#endif
|
||||
|
||||
#define CURSOR_X 0
|
||||
#define CURSOR_Y 0 /* not really used for players */
|
||||
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
||||
#ifdef HAVE_NEW_CHARCELL_LCD
|
||||
#define CURSOR_CHAR "\x7e"
|
||||
|
|
@ -117,10 +145,7 @@ static void menu_draw(int m)
|
|||
lcd_scroll_pause(); /* halt scroll first... */
|
||||
lcd_clear_display(); /* ...then clean the screen */
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if(global_settings.statusbar)
|
||||
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
||||
else
|
||||
lcd_setmargins(0, 0);
|
||||
lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */
|
||||
lcd_setfont(0);
|
||||
#endif
|
||||
/* correct cursor pos if out of screen */
|
||||
|
|
@ -131,16 +156,20 @@ static void menu_draw(int m)
|
|||
(i < menus[m].itemcount) && (i<menus[m].top+menu_lines);
|
||||
i++) {
|
||||
if((menus[m].cursor - menus[m].top)==(i-menus[m].top))
|
||||
lcd_puts_scroll(1, i-menus[m].top, menus[m].items[i].desc);
|
||||
lcd_puts_scroll(LINE_X, i-menus[m].top, menus[m].items[i].desc);
|
||||
else
|
||||
lcd_puts(1, i-menus[m].top, menus[m].items[i].desc);
|
||||
lcd_puts(LINE_X, i-menus[m].top, menus[m].items[i].desc);
|
||||
}
|
||||
|
||||
/* place the cursor */
|
||||
put_cursorxy(0, menus[m].cursor - menus[m].top, true);
|
||||
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
status_draw();
|
||||
if (global_settings.scrollbar)
|
||||
scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
|
||||
LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top,
|
||||
menus[m].top + menu_lines, VERTICAL);
|
||||
#endif
|
||||
status_draw();
|
||||
lcd_update();
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +192,7 @@ static void put_cursor(int m, int target)
|
|||
#else
|
||||
int menu_lines = MENU_LINES;
|
||||
#endif
|
||||
put_cursorxy(0, menus[m].cursor - menus[m].top, false);
|
||||
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, false);
|
||||
menus[m].cursor = target;
|
||||
menu_draw(m);
|
||||
|
||||
|
|
@ -179,7 +208,7 @@ static void put_cursor(int m, int target)
|
|||
}
|
||||
|
||||
if (do_update) {
|
||||
put_cursorxy(0, menus[m].cursor - menus[m].top, true);
|
||||
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
|
||||
lcd_update();
|
||||
}
|
||||
|
||||
|
|
@ -282,12 +311,18 @@ Menu menu_run(int m)
|
|||
return result;
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
case BUTTON_F3:
|
||||
case BUTTON_F3: {
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
global_settings.statusbar = !global_settings.statusbar;
|
||||
unsigned char state;
|
||||
state = global_settings.statusbar << 1 | global_settings.scrollbar;
|
||||
state = (state + 1) % 4;
|
||||
global_settings.statusbar = state >> 1;
|
||||
global_settings.scrollbar = state & 0x1;
|
||||
settings_save();
|
||||
|
||||
menu_draw(m);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,8 @@ int settings_save( void )
|
|||
((global_settings.sort_case & 1) << 2) |
|
||||
((global_settings.discharge & 1) << 3) |
|
||||
((global_settings.statusbar & 1) << 4) |
|
||||
((global_settings.show_hidden_files & 1) << 5));
|
||||
((global_settings.show_hidden_files & 1) << 5) |
|
||||
((global_settings.scrollbar & 1) << 6));
|
||||
|
||||
config_block[0xf] = (unsigned char)
|
||||
((global_settings.scroll_speed << 3) |
|
||||
|
|
@ -350,6 +351,7 @@ void settings_load(void)
|
|||
global_settings.discharge = (config_block[0xe] >> 3) & 1;
|
||||
global_settings.statusbar = (config_block[0xe] >> 4) & 1;
|
||||
global_settings.show_hidden_files = (config_block[0xe] >> 5) & 1;
|
||||
global_settings.scrollbar = (config_block[0xe] >> 6) & 1;
|
||||
}
|
||||
|
||||
c = config_block[0xf] >> 3;
|
||||
|
|
@ -414,6 +416,7 @@ void settings_reset(void) {
|
|||
global_settings.mp3filter = true;
|
||||
global_settings.sort_case = false;
|
||||
global_settings.statusbar = true;
|
||||
global_settings.scrollbar = true;
|
||||
global_settings.loop_playlist = true;
|
||||
global_settings.playlist_shuffle = false;
|
||||
global_settings.discharge = 0;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ struct user_settings
|
|||
/* show status bar */
|
||||
bool statusbar; /* 0=hide, 1=show */
|
||||
|
||||
/* show scroll bar */
|
||||
bool scrollbar; /* 0=hide, 1=show */
|
||||
|
||||
/* Hidden and dotfile settings */
|
||||
bool show_hidden_files; /* 1=show dotfiles/hidden,
|
||||
0=hide dotfiles/hidden */
|
||||
|
|
|
|||
72
apps/tree.c
72
apps/tree.c
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#include "widgets.h"
|
||||
#endif
|
||||
|
||||
#ifdef LOADABLE_FONTS
|
||||
|
|
@ -73,16 +74,25 @@ void browse_root(void)
|
|||
#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH)
|
||||
#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */
|
||||
|
||||
#define MARGIN_X (global_settings.scrollbar ? SCROLLBAR_WIDTH : 0) + CURSOR_WIDTH + ICON_WIDTH /* X pixel margin */
|
||||
#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* Y pixel margin */
|
||||
#define MARGIN_X 10 /* X pixel margin */
|
||||
#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */
|
||||
|
||||
#define LINE_X 0 /* X position the entry-list starts at */
|
||||
#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */
|
||||
#define LINE_HEIGTH 8 /* pixels for each text line */
|
||||
|
||||
#define CURSOR_X (global_settings.scrollbar ? 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 */
|
||||
#define CURSOR_WIDTH 4
|
||||
|
||||
#define ICON_WIDTH 6
|
||||
|
||||
#define SCROLLBAR_X 0
|
||||
#define SCROLLBAR_Y lcd_getymargin()
|
||||
#define SCROLLBAR_WIDTH 6
|
||||
|
||||
extern unsigned char bitmap_icons_6x8[LastIcon][6];
|
||||
|
||||
|
|
@ -90,9 +100,10 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6];
|
|||
|
||||
#define TREE_MAX_ON_SCREEN 2
|
||||
#define TREE_MAX_LEN_DISPLAY 11 /* max length that fits on screen */
|
||||
#define LINE_Y 0 /* Y position the entry-list starts at */
|
||||
#define LINE_X 1 /* X position the entry-list starts at */
|
||||
#define LINE_Y 0 /* Y position the entry-list starts at */
|
||||
|
||||
#define CURSOR_X 0
|
||||
#define CURSOR_Y 0 /* not really used for players */
|
||||
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
|
@ -290,7 +301,7 @@ static int showdir(char *path, int start)
|
|||
|
||||
if (icon_type)
|
||||
lcd_bitmap(bitmap_icons_6x8[icon_type],
|
||||
4, MARGIN_Y+(i-start)*line_height, 6, 8, true);
|
||||
CURSOR_X * 6 + CURSOR_WIDTH, MARGIN_Y+(i-start)*line_height, 6, 8, true);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -307,6 +318,12 @@ static int showdir(char *path, int start)
|
|||
lcd_puts(LINE_X, i-start, dircache[i].name);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if (global_settings.scrollbar)
|
||||
scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
|
||||
LCD_HEIGHT - SCROLLBAR_Y, filesindir, start,
|
||||
start + tree_max_on_screen, VERTICAL);
|
||||
#endif
|
||||
status_draw();
|
||||
return filesindir;
|
||||
}
|
||||
|
|
@ -445,7 +462,7 @@ bool dirbrowse(char *root)
|
|||
if (numentries == -1)
|
||||
return -1; /* root is not a directory */
|
||||
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
|
||||
while(1) {
|
||||
bool restore = false;
|
||||
|
|
@ -568,6 +585,11 @@ bool dirbrowse(char *root)
|
|||
start = 0;
|
||||
global_settings.resume_index = -1;
|
||||
}
|
||||
#ifdef LOADABLE_FONTS
|
||||
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
|
||||
#else
|
||||
tree_max_on_screen = TREE_MAX_ON_SCREEN;
|
||||
#endif
|
||||
}
|
||||
restore = true;
|
||||
break;
|
||||
|
|
@ -577,29 +599,29 @@ bool dirbrowse(char *root)
|
|||
case BUTTON_VOL_UP:
|
||||
if(filesindir) {
|
||||
if(dircursor) {
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, false);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false);
|
||||
dircursor--;
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
else {
|
||||
if (start) {
|
||||
start--;
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
else {
|
||||
if (numentries < tree_max_on_screen) {
|
||||
put_cursorxy(0, CURSOR_Y + dircursor,
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
|
||||
false);
|
||||
dircursor = numentries - 1;
|
||||
put_cursorxy(0, CURSOR_Y + dircursor,
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
|
||||
true);
|
||||
}
|
||||
else {
|
||||
start = numentries - tree_max_on_screen;
|
||||
dircursor = tree_max_on_screen - 1;
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y +
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y +
|
||||
tree_max_on_screen - 1, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -615,28 +637,28 @@ bool dirbrowse(char *root)
|
|||
{
|
||||
if (dircursor + start + 1 < numentries ) {
|
||||
if(dircursor+1 < tree_max_on_screen) {
|
||||
put_cursorxy(0, CURSOR_Y + dircursor,
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
|
||||
false);
|
||||
dircursor++;
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
else {
|
||||
start++;
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(numentries < tree_max_on_screen) {
|
||||
put_cursorxy(0, CURSOR_Y + dircursor,
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
|
||||
false);
|
||||
start = dircursor = 0;
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
else {
|
||||
start = dircursor = 0;
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
}
|
||||
lcd_update();
|
||||
|
|
@ -675,14 +697,23 @@ bool dirbrowse(char *root)
|
|||
dircursor = 0;
|
||||
start = 0;
|
||||
}
|
||||
#ifdef LOADABLE_FONTS
|
||||
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
|
||||
#else
|
||||
tree_max_on_screen = TREE_MAX_ON_SCREEN;
|
||||
#endif
|
||||
restore = true;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
case BUTTON_F3:
|
||||
case BUTTON_F3: {
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
global_settings.statusbar = !global_settings.statusbar;
|
||||
unsigned char state;
|
||||
state = global_settings.statusbar << 1 | global_settings.scrollbar;
|
||||
state = (state + 1) % 4;
|
||||
global_settings.statusbar = state >> 1;
|
||||
global_settings.scrollbar = state & 0x1;
|
||||
settings_save();
|
||||
#ifdef LOADABLE_FONTS
|
||||
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
|
||||
|
|
@ -691,6 +722,7 @@ bool dirbrowse(char *root)
|
|||
#endif
|
||||
restore = true;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
|
@ -733,7 +765,7 @@ bool dirbrowse(char *root)
|
|||
dircursor--;
|
||||
}
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + dircursor, true);
|
||||
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
|
||||
}
|
||||
|
||||
if ( numentries ) {
|
||||
|
|
|
|||
|
|
@ -752,6 +752,13 @@ int wps_show(void)
|
|||
#endif
|
||||
if (menu())
|
||||
return SYS_USB_CONNECTED;
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if(global_settings.statusbar)
|
||||
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
||||
else
|
||||
lcd_setmargins(0, 0);
|
||||
#endif
|
||||
restore = true;
|
||||
break;
|
||||
|
||||
/* toggle status bar */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue