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:
parent
55be5868f2
commit
e43b78ac46
8 changed files with 111 additions and 23 deletions
|
@ -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:
|
||||
|
|
12
apps/menu.c
12
apps/menu.c
|
@ -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,6 +148,12 @@ 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))
|
||||
#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,7 +205,7 @@ static void put_cursor(int m, int target)
|
|||
do_update = false;
|
||||
}
|
||||
|
||||
if (do_update) {
|
||||
if (do_update && !global_settings.invert_cursor) {
|
||||
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
|
||||
lcd_update();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 },
|
||||
|
|
36
apps/tree.c
36
apps/tree.c
|
@ -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,6 +195,12 @@ static void showfileline(int line, int direntry, bool scroll)
|
|||
*dotpos = 0;
|
||||
}
|
||||
if(scroll)
|
||||
#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);
|
||||
|
@ -203,6 +209,12 @@ static void showfileline(int line, int direntry, bool scroll)
|
|||
}
|
||||
else {
|
||||
if(scroll)
|
||||
#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,7 +734,18 @@ 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);
|
||||
#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);
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ struct scrollinfo {
|
|||
int starty;
|
||||
bool backward; /* scroll presently forward or backward? */
|
||||
bool bidir;
|
||||
bool invert; /* invert the scrolled text */
|
||||
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 */
|
||||
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;
|
||||
|
||||
|
@ -294,6 +300,8 @@ void lcd_puts(int x, int y, unsigned char *str)
|
|||
ypos = ymargin + y*h;
|
||||
lcd_putsxy(xpos, ypos, str);
|
||||
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)
|
||||
lcd_update();
|
||||
|
@ -670,14 +678,19 @@ void lcd_invertpixel(int x, int 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;
|
||||
int w, h;
|
||||
int index;
|
||||
int free_index=0;
|
||||
|
||||
DEBUGF("puts_scroll: %s\n", string);
|
||||
DEBUGF("puts_scroll_style: %s\n", string);
|
||||
|
||||
for (index = 0; index < SCROLLABLE_LINES; index++) {
|
||||
s = &scroll[index];
|
||||
|
@ -698,8 +711,14 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
|
|||
index=free_index;
|
||||
s = &scroll[index]; /* get the proper 's' */
|
||||
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_getstringsize(string, &w, &h);
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,14 +24,20 @@
|
|||
#include "sh7034.h"
|
||||
#include "config.h"
|
||||
|
||||
#define STYLE_DEFAULT 0
|
||||
#define STYLE_INVERT 1
|
||||
|
||||
/* common functions */
|
||||
extern void lcd_init(void);
|
||||
extern void lcd_clear_display(void);
|
||||
extern void lcd_backlight(bool on);
|
||||
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_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_stop_scroll(void);
|
||||
extern void lcd_scroll_speed( int speed );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue