Magnus Öman's long awaited inverted cursor patch

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3565 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2003-04-16 00:12:31 +00:00
parent 55be5868f2
commit e43b78ac46
8 changed files with 111 additions and 23 deletions

View file

@ -1462,3 +1462,8 @@ id: LANG_VBRFIX
desc: The context menu entry
eng: "Update VBR file"
new:
id: LANG_INVERT_CURSOR
desc: in settings_menu
eng: "Invert cursor"
new:

View file

@ -64,7 +64,7 @@ struct menu {
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 CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4)
#define SCROLLBAR_X 0
#define SCROLLBAR_Y lcd_getymargin()
@ -92,6 +92,8 @@ void put_cursorxy(int x, int y, bool on)
#ifdef HAVE_LCD_BITMAP
int fh, fw;
int xpos, ypos;
if (global_settings.invert_cursor)
return;
lcd_getstringsize("A", &fw, &fh);
xpos = x*6;
ypos = y*fh + lcd_getymargin();
@ -146,7 +148,13 @@ 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(LINE_X, i-menus[m].top, menus[m].items[i].desc);
#ifdef HAVE_LCD_BITMAP
if (global_settings.invert_cursor)
lcd_puts_scroll_style(LINE_X, i-menus[m].top,
menus[m].items[i].desc, STYLE_INVERT);
else
#endif
lcd_puts_scroll(LINE_X, i-menus[m].top, menus[m].items[i].desc);
else
lcd_puts(LINE_X, i-menus[m].top, menus[m].items[i].desc);
}
@ -197,8 +205,8 @@ static void put_cursor(int m, int target)
do_update = false;
}
if (do_update) {
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
if (do_update && !global_settings.invert_cursor) {
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
lcd_update();
}

View file

@ -84,7 +84,7 @@ offset abs
0x08 0x1c <loudness byte>
0x09 0x1d <bass boost byte>
0x0a 0x1e <contrast (bit 0-5), invert bit (bit 6)>
0x0b 0x1f <backlight_on_when_charging, backlight_timeout>
0x0b 0x1f <backlight_on_when_charging, invert_cursor, backlight_timeout>
0x0c 0x20 <poweroff timer byte>
0x0d 0x21 <resume settings byte>
0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden,
@ -304,7 +304,8 @@ int settings_save( void )
config_block[0xb] = (unsigned char)
((global_settings.backlight_on_when_charging?0x40:0) |
(global_settings.backlight_timeout & 0x3f));
(global_settings.invert_cursor ? 0x20 : 0) |
(global_settings.backlight_timeout & 0x1f));
config_block[0xc] = (unsigned char)global_settings.poweroff;
config_block[0xd] = (unsigned char)global_settings.resume;
@ -560,7 +561,9 @@ void settings_load(void)
if (config_block[0xb] != 0xFF) {
/* Bit 7 is unused to be able to detect uninitialized entry */
global_settings.backlight_timeout = config_block[0xb] & 0x3f;
global_settings.backlight_timeout = config_block[0xb] & 0x1f;
global_settings.invert_cursor =
config_block[0xb] & 0x20 ? true : false;
global_settings.backlight_on_when_charging =
config_block[0xb] & 0x40 ? true : false;
}
@ -657,7 +660,7 @@ void settings_load(void)
config_block[0x28] | (config_block[0x29] << 8);
global_settings.fade_on_stop=config_block[0xae];
global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f;
global_settings.peak_meter_performance =
(config_block[0xb0] & 0x80) != 0;
@ -679,9 +682,9 @@ void settings_load(void)
if (config_block[0xb7] != 0xff)
global_settings.bidir_limit = config_block[0xb7];
if (config_block[0xae] != 0xff)
global_settings.fade_on_stop = config_block[0xae];
if (config_block[0xae] != 0xff)
global_settings.fade_on_stop = config_block[0xae];
memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
@ -941,6 +944,8 @@ bool settings_load_config(char* file)
set_cfg_bool(&global_settings.scrollbar, value);
else if (!strcasecmp(name, "invert"))
set_cfg_bool(&global_settings.invert, value);
else if (!strcasecmp(name, "invert cursor"))
set_cfg_bool(&global_settings.invert_cursor, value);
#endif
else if (!strcasecmp(name, "shuffle"))
set_cfg_bool(&global_settings.playlist_shuffle, value);
@ -1305,6 +1310,10 @@ bool settings_save_config(void)
snprintf(buf, sizeof(buf), "invert: %s\r\n",
options[global_settings.invert]);
write(fd, buf, strlen(buf));
snprintf(buf, sizeof(buf), "invert cursor: %s\r\n",
options[global_settings.invert_cursor]);
write(fd, buf, strlen(buf));
}
snprintf(buf, sizeof(buf), "peak meter release: %d\r\n",
@ -1463,6 +1472,7 @@ void settings_reset(void) {
global_settings.invert = DEFAULT_INVERT_SETTING;
global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
global_settings.invert_cursor = DEFAULT_INVERT_CURSOR_SETTING;
global_settings.backlight_on_when_charging =
DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING;
global_settings.battery_capacity = 1500; /* mAh */
@ -1684,7 +1694,7 @@ bool set_option(char* string, int* variable, char* options[],
#endif
if ( *variable < (numoptions-1) )
(*variable)++;
else
else
(*variable) -= (numoptions-1);
break;

View file

@ -79,6 +79,8 @@ struct user_settings
int contrast; /* lcd contrast: 0-63 0=low 63=high */
bool invert; /* invert display */
bool invert_cursor; /* invert the current file in dir browser and menu
instead of using the default cursor */
int poweroff; /* power off timer */
int backlight_timeout; /* backlight off timeout: 0-18 0=never,
1=always,
@ -191,6 +193,7 @@ extern char rockboxdir[];
#endif
#define MIN_CONTRAST_SETTING 5
#define DEFAULT_INVERT_SETTING false
#define DEFAULT_INVERT_CURSOR_SETTING false
#define DEFAULT_POWEROFF_SETTING 0
#define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5
#define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0

View file

@ -59,6 +59,14 @@ static bool invert(void)
return rc;
}
static bool invert_cursor(void)
{
bool rc = set_bool( str(LANG_INVERT_CURSOR),
&global_settings.invert_cursor);
return rc;
}
/**
* Menu to configure the battery display on status bar
*/
@ -726,6 +734,7 @@ static bool display_settings_menu(void)
{ str(LANG_CONTRAST), contrast },
#ifdef HAVE_LCD_BITMAP
{ str(LANG_INVERT), invert },
{ str(LANG_INVERT_CURSOR), invert_cursor },
{ str(LANG_PM_MENU), peak_meter_menu },
{ str(LANG_VOLUME_DISPLAY), volume_type },
{ str(LANG_BATTERY_DISPLAY), battery_type },

View file

@ -107,7 +107,7 @@ void browse_root(void)
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 CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4)
#define ICON_WIDTH 6
@ -195,7 +195,13 @@ static void showfileline(int line, int direntry, bool scroll)
*dotpos = 0;
}
if(scroll)
lcd_puts_scroll(LINE_X, line, dircache[direntry].name);
#ifdef HAVE_LCD_BITMAP
if (global_settings.invert_cursor)
lcd_puts_scroll_style(LINE_X, line, dircache[direntry].name,
STYLE_INVERT);
else
#endif
lcd_puts_scroll(LINE_X, line, dircache[direntry].name);
else
lcd_puts(LINE_X, line, dircache[direntry].name);
if (temp)
@ -203,7 +209,13 @@ static void showfileline(int line, int direntry, bool scroll)
}
else {
if(scroll)
lcd_puts_scroll(LINE_X, line, dircache[direntry].name);
#ifdef HAVE_LCD_BITMAP
if (global_settings.invert_cursor)
lcd_puts_scroll_style(LINE_X, line, dircache[direntry].name,
STYLE_INVERT);
else
#endif
lcd_puts_scroll(LINE_X, line, dircache[direntry].name);
else
lcd_puts(LINE_X, line, dircache[direntry].name);
}
@ -666,6 +678,11 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
int dircursor = *dc;
char buf[MAX_PATH];
#ifdef HAVE_LCD_BITMAP
int fw, fh;
lcd_getstringsize("A", &fw, &fh);
#endif
while (!exit) {
switch (button_get(true)) {
case TREE_PREV:
@ -717,8 +734,19 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
break;
}
if ( used && !exit ) {
#ifdef HAVE_LCD_BITMAP
int xpos,ypos;
#endif
showdir(currdir, dirstart);
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
#ifdef HAVE_LCD_BITMAP
if (global_settings.invert_cursor) {
xpos = lcd_getxmargin();
ypos = (CURSOR_Y + dircursor) * fh + lcd_getymargin();
lcd_invertrect(xpos, ypos, LCD_WIDTH-xpos, fh);
}
else
#endif
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
lcd_update();
}
}
@ -1020,8 +1048,7 @@ bool dirbrowse(char *root)
{
if (dircursor + dirstart + 1 < numentries ) {
if(dircursor+1 < tree_max_on_screen) {
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
false);
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false);
dircursor++;
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
}
@ -1034,8 +1061,7 @@ bool dirbrowse(char *root)
}
else {
if(numentries < tree_max_on_screen) {
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
false);
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false);
dirstart = dircursor = 0;
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
}