1
0
Fork 0
forked from len0rd/rockbox

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 desc: The context menu entry
eng: "Update VBR file" eng: "Update VBR file"
new: 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 the margins, so this is the amount of lines
we add to the cursor Y position to position we add to the cursor Y position to position
it on a line */ it on a line */
#define CURSOR_WIDTH 4 #define CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4)
#define SCROLLBAR_X 0 #define SCROLLBAR_X 0
#define SCROLLBAR_Y lcd_getymargin() #define SCROLLBAR_Y lcd_getymargin()
@ -92,6 +92,8 @@ void put_cursorxy(int x, int y, bool on)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int fh, fw; int fh, fw;
int xpos, ypos; int xpos, ypos;
if (global_settings.invert_cursor)
return;
lcd_getstringsize("A", &fw, &fh); lcd_getstringsize("A", &fw, &fh);
xpos = x*6; xpos = x*6;
ypos = y*fh + lcd_getymargin(); 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 < menus[m].itemcount) && (i<menus[m].top+menu_lines);
i++) { i++) {
if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) 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 else
lcd_puts(LINE_X, i-menus[m].top, menus[m].items[i].desc); 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; do_update = false;
} }
if (do_update) { if (do_update && !global_settings.invert_cursor) {
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true); put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
lcd_update(); lcd_update();
} }

View file

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

View file

@ -79,6 +79,8 @@ struct user_settings
int contrast; /* lcd contrast: 0-63 0=low 63=high */ int contrast; /* lcd contrast: 0-63 0=low 63=high */
bool invert; /* invert display */ 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 poweroff; /* power off timer */
int backlight_timeout; /* backlight off timeout: 0-18 0=never, int backlight_timeout; /* backlight off timeout: 0-18 0=never,
1=always, 1=always,
@ -191,6 +193,7 @@ extern char rockboxdir[];
#endif #endif
#define MIN_CONTRAST_SETTING 5 #define MIN_CONTRAST_SETTING 5
#define DEFAULT_INVERT_SETTING false #define DEFAULT_INVERT_SETTING false
#define DEFAULT_INVERT_CURSOR_SETTING false
#define DEFAULT_POWEROFF_SETTING 0 #define DEFAULT_POWEROFF_SETTING 0
#define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5 #define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5
#define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0 #define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0

View file

@ -59,6 +59,14 @@ static bool invert(void)
return rc; 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 * Menu to configure the battery display on status bar
*/ */
@ -726,6 +734,7 @@ static bool display_settings_menu(void)
{ str(LANG_CONTRAST), contrast }, { str(LANG_CONTRAST), contrast },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ str(LANG_INVERT), invert }, { str(LANG_INVERT), invert },
{ str(LANG_INVERT_CURSOR), invert_cursor },
{ str(LANG_PM_MENU), peak_meter_menu }, { str(LANG_PM_MENU), peak_meter_menu },
{ str(LANG_VOLUME_DISPLAY), volume_type }, { str(LANG_VOLUME_DISPLAY), volume_type },
{ str(LANG_BATTERY_DISPLAY), battery_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 the margins, so this is the amount of lines
we add to the cursor Y position to position we add to the cursor Y position to position
it on a line */ it on a line */
#define CURSOR_WIDTH 4 #define CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4)
#define ICON_WIDTH 6 #define ICON_WIDTH 6
@ -195,7 +195,13 @@ static void showfileline(int line, int direntry, bool scroll)
*dotpos = 0; *dotpos = 0;
} }
if(scroll) 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 else
lcd_puts(LINE_X, line, dircache[direntry].name); lcd_puts(LINE_X, line, dircache[direntry].name);
if (temp) if (temp)
@ -203,7 +209,13 @@ static void showfileline(int line, int direntry, bool scroll)
} }
else { else {
if(scroll) 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 else
lcd_puts(LINE_X, line, dircache[direntry].name); 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; int dircursor = *dc;
char buf[MAX_PATH]; char buf[MAX_PATH];
#ifdef HAVE_LCD_BITMAP
int fw, fh;
lcd_getstringsize("A", &fw, &fh);
#endif
while (!exit) { while (!exit) {
switch (button_get(true)) { switch (button_get(true)) {
case TREE_PREV: case TREE_PREV:
@ -717,8 +734,19 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
break; break;
} }
if ( used && !exit ) { if ( used && !exit ) {
#ifdef HAVE_LCD_BITMAP
int xpos,ypos;
#endif
showdir(currdir, dirstart); 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(); lcd_update();
} }
} }
@ -1020,8 +1048,7 @@ bool dirbrowse(char *root)
{ {
if (dircursor + dirstart + 1 < numentries ) { if (dircursor + dirstart + 1 < numentries ) {
if(dircursor+1 < tree_max_on_screen) { if(dircursor+1 < tree_max_on_screen) {
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false);
false);
dircursor++; dircursor++;
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
} }
@ -1034,8 +1061,7 @@ bool dirbrowse(char *root)
} }
else { else {
if(numentries < tree_max_on_screen) { if(numentries < tree_max_on_screen) {
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false);
false);
dirstart = dircursor = 0; dirstart = dircursor = 0;
put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
} }

View file

@ -81,6 +81,7 @@ struct scrollinfo {
int starty; int starty;
bool backward; /* scroll presently forward or backward? */ bool backward; /* scroll presently forward or backward? */
bool bidir; bool bidir;
bool invert; /* invert the scrolled text */
long start_tick; long start_tick;
}; };
@ -269,6 +270,11 @@ int lcd_getstringsize(unsigned char *str, int *w, int *h)
/* put a string at a given char position */ /* put a string at a given char position */
void lcd_puts(int x, int y, unsigned char *str) void lcd_puts(int x, int y, unsigned char *str)
{
lcd_puts_style(x, y, str, STYLE_DEFAULT);
}
void lcd_puts_style(int x, int y, unsigned char *str, int style)
{ {
int xpos,ypos,w,h; int xpos,ypos,w,h;
@ -294,6 +300,8 @@ void lcd_puts(int x, int y, unsigned char *str)
ypos = ymargin + y*h; ypos = ymargin + y*h;
lcd_putsxy(xpos, ypos, str); lcd_putsxy(xpos, ypos, str);
lcd_clearrect(xpos + w, ypos, LCD_WIDTH - (xpos + w), h); lcd_clearrect(xpos + w, ypos, LCD_WIDTH - (xpos + w), h);
if (style & STYLE_INVERT)
lcd_invertrect(xpos, ypos, LCD_WIDTH - xpos, h);
#if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS)
lcd_update(); lcd_update();
@ -670,14 +678,19 @@ void lcd_invertpixel(int x, int y)
INVERT_PIXEL(x,y); INVERT_PIXEL(x,y);
} }
void lcd_puts_scroll(int x, int y, unsigned char* string) void lcd_puts_scroll(int x, int y, unsigned char *string)
{
lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT);
}
void lcd_puts_scroll_style(int x, int y, unsigned char *string, int style)
{ {
struct scrollinfo* s; struct scrollinfo* s;
int w, h; int w, h;
int index; int index;
int free_index=0; int free_index=0;
DEBUGF("puts_scroll: %s\n", string); DEBUGF("puts_scroll_style: %s\n", string);
for (index = 0; index < SCROLLABLE_LINES; index++) { for (index = 0; index < SCROLLABLE_LINES; index++) {
s = &scroll[index]; s = &scroll[index];
@ -698,8 +711,14 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
index=free_index; index=free_index;
s = &scroll[index]; /* get the proper 's' */ s = &scroll[index]; /* get the proper 's' */
s->start_tick = current_tick + scroll_delay; s->start_tick = current_tick + scroll_delay;
s->invert = false;
if (style & STYLE_INVERT) {
s->invert = true;
lcd_puts_style(x,y,string,STYLE_INVERT);
}
else
lcd_puts(x,y,string);
lcd_puts(x,y,string);
lcd_getstringsize(string, &w, &h); lcd_getstringsize(string, &w, &h);
if (LCD_WIDTH - x * 8 - xmargin < w) { if (LCD_WIDTH - x * 8 - xmargin < w) {
@ -819,6 +838,8 @@ static void scroll_thread(void)
lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h); lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h);
lcd_putsxyofs(xpos, ypos, s->offset, s->line); lcd_putsxyofs(xpos, ypos, s->offset, s->line);
if (s->invert)
lcd_invertrect(xpos, ypos, LCD_WIDTH - xmargin, h);
lcd_update_rect(xpos, ypos, LCD_WIDTH - xmargin, h); lcd_update_rect(xpos, ypos, LCD_WIDTH - xmargin, h);
} }

View file

@ -24,14 +24,20 @@
#include "sh7034.h" #include "sh7034.h"
#include "config.h" #include "config.h"
#define STYLE_DEFAULT 0
#define STYLE_INVERT 1
/* common functions */ /* common functions */
extern void lcd_init(void); extern void lcd_init(void);
extern void lcd_clear_display(void); extern void lcd_clear_display(void);
extern void lcd_backlight(bool on); extern void lcd_backlight(bool on);
extern void lcd_puts(int x, int y, unsigned char *string); extern void lcd_puts(int x, int y, unsigned char *string);
extern void lcd_puts_style(int x, int y, unsigned char *string, int style);
extern void lcd_putc(int x, int y, unsigned short ch); extern void lcd_putc(int x, int y, unsigned short ch);
extern void lcd_puts_scroll(int x, int y, unsigned char* string ); extern void lcd_puts_scroll(int x, int y, unsigned char* string );
extern void lcd_puts_scroll_style(int x, int y, unsigned char* string,
int style);
extern void lcd_icon(int icon, bool enable); extern void lcd_icon(int icon, bool enable);
extern void lcd_stop_scroll(void); extern void lcd_stop_scroll(void);
extern void lcd_scroll_speed( int speed ); extern void lcd_scroll_speed( int speed );