forked from len0rd/rockbox
Textviewer night mode
Add a night mode to textviewer. Change-Id: I6ddcd9c3c87473cbbffaeacf63a21ef11c0e5f44
This commit is contained in:
parent
8742f6f0e2
commit
ab1b67f37b
6 changed files with 52 additions and 6 deletions
|
@ -69,6 +69,7 @@
|
|||
#define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width
|
||||
#define TV_SCROLLBAR_HEIGHT 4
|
||||
|
||||
|
||||
#ifndef HAVE_LCD_BITMAP
|
||||
#define TV_BOOKMARK_ICON 0xe101
|
||||
#endif
|
||||
|
@ -220,6 +221,7 @@ void tv_draw_text(int row, const unsigned char *text, int offset)
|
|||
}
|
||||
|
||||
display->set_viewport(&vp_text);
|
||||
tv_night_mode();
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
display->putsxy(xpos, row * row_height, text);
|
||||
#else
|
||||
|
@ -231,6 +233,7 @@ void tv_draw_text(int row, const unsigned char *text, int offset)
|
|||
void tv_start_display(void)
|
||||
{
|
||||
display->set_viewport(&vp_info);
|
||||
tv_night_mode();
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
display->set_drawmode(DRMODE_SOLID);
|
||||
#endif
|
||||
|
@ -239,6 +242,7 @@ void tv_start_display(void)
|
|||
rb->lcd_set_backdrop(NULL);
|
||||
#endif
|
||||
display->clear_viewport();
|
||||
|
||||
}
|
||||
|
||||
void tv_end_display(void)
|
||||
|
@ -403,6 +407,21 @@ bool tv_init_display(unsigned char **buf, size_t *size)
|
|||
return true;
|
||||
}
|
||||
|
||||
void tv_night_mode(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
if(preferences->night_mode)
|
||||
{
|
||||
rb->lcd_set_foreground(LCD_RGBPACK(0xBF,0xBF,0x00));
|
||||
rb->lcd_set_background(LCD_RGBPACK(0x96,0x0D,0x00));
|
||||
}else
|
||||
{
|
||||
rb->lcd_set_foreground(LCD_WHITE);
|
||||
rb->lcd_set_background(LCD_BLACK);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tv_finalize_display(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
|
|
@ -103,6 +103,9 @@ void tv_start_display(void);
|
|||
/* end the display processing */
|
||||
void tv_end_display(void);
|
||||
|
||||
/*change color scheme*/
|
||||
void tv_night_mode(void);
|
||||
|
||||
|
||||
/* layout functions */
|
||||
|
||||
|
|
|
@ -247,6 +247,13 @@ static bool tv_indent_spaces_setting(void)
|
|||
&new_prefs.indent_spaces, NULL, 1, 0, 5, NULL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
static bool tv_night_mode_setting(void)
|
||||
{
|
||||
return rb->set_bool("Night Mode", &new_prefs.night_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
MENUITEM_FUNCTION(encoding_item, 0, "Encoding", tv_encoding_setting,
|
||||
NULL, NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", tv_word_wrap_setting,
|
||||
|
@ -269,6 +276,10 @@ MENUITEM_FUNCTION(font_item, 0, "Font", tv_font_setting,
|
|||
#endif
|
||||
MENUITEM_FUNCTION(indent_spaces_item, 0, "Indent Spaces", tv_indent_spaces_setting,
|
||||
NULL, NULL, Icon_NOICON);
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
MENUITEM_FUNCTION(night_mode_item, 0, "Night Mode", tv_night_mode_setting,
|
||||
NULL, NULL, Icon_NOICON);
|
||||
#endif
|
||||
|
||||
MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
|
||||
&encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
|
||||
|
@ -276,7 +287,11 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
&header_item, &footer_item, &font_item, &statusbar_item,
|
||||
#endif
|
||||
&scroll_menu, &indent_spaces_item);
|
||||
&scroll_menu, &indent_spaces_item
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
, &night_mode_item
|
||||
#endif
|
||||
);
|
||||
|
||||
static unsigned tv_options_menu(void)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ static bool tv_notify_change_preferences(const struct tv_preferences *oldp)
|
|||
* - font
|
||||
* - autoscroll_speed
|
||||
* - narrow_mode
|
||||
* - night_mode
|
||||
*/
|
||||
if ((oldp == NULL) ||
|
||||
(oldp->word_mode != preferences->word_mode) ||
|
||||
|
@ -120,7 +121,8 @@ void tv_set_default_preferences(struct tv_preferences *p)
|
|||
p->footer_mode = false;
|
||||
p->statusbar = false;
|
||||
#endif
|
||||
p->autoscroll_speed = 1;
|
||||
p->autoscroll_speed = 10;
|
||||
p->night_mode = false;
|
||||
p->narrow_mode = NM_PAGE;
|
||||
p->indent_spaces = 2;
|
||||
/* Set codepage to system default */
|
||||
|
|
|
@ -93,6 +93,8 @@ struct tv_preferences {
|
|||
|
||||
bool statusbar;
|
||||
|
||||
bool night_mode;
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
unsigned char font_name[MAX_PATH];
|
||||
int font_id;
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
* narrow_mode 1
|
||||
* indent_spaces 1
|
||||
* statusbar 1
|
||||
* (reserved) 11
|
||||
* night_mode 1
|
||||
* (reserved) 10
|
||||
* font name MAX_PATH
|
||||
*/
|
||||
|
||||
|
@ -58,7 +59,7 @@
|
|||
#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DATA_DIR "/tv_global.dat"
|
||||
|
||||
#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */
|
||||
#define TV_GLOBAL_SETTINGS_VERSION 0x38
|
||||
#define TV_GLOBAL_SETTINGS_VERSION 0x39
|
||||
#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
|
||||
#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
|
||||
|
||||
|
@ -93,7 +94,8 @@
|
|||
* narrow_mode 1
|
||||
* indent_spaces 1
|
||||
* statusbar 1
|
||||
* (reserved) 11
|
||||
* night_mode 1
|
||||
* (reserved) 10
|
||||
* font name MAX_PATH
|
||||
* bookmark count 1
|
||||
* [1st bookmark]
|
||||
|
@ -115,7 +117,7 @@
|
|||
#define TV_SETTINGS_TMP_FILE VIEWERS_DATA_DIR "/tv_file.tmp"
|
||||
|
||||
#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
|
||||
#define TV_SETTINGS_VERSION 0x39
|
||||
#define TV_SETTINGS_VERSION 0x3A
|
||||
#define TV_SETTINGS_HEADER_SIZE 4
|
||||
#define TV_SETTINGS_FIRST_VERSION 0x32
|
||||
|
||||
|
@ -214,6 +216,8 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
|
|||
|
||||
if (version > 6)
|
||||
prefs->statusbar = (*p++ != 0);
|
||||
if (version > 6)
|
||||
prefs->night_mode = (*p++ != 0);
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
rb->strlcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
|
||||
|
@ -247,6 +251,7 @@ static void tv_serialize_preferences(unsigned char *buf, const struct tv_prefere
|
|||
*p++ = prefs->narrow_mode;
|
||||
*p++ = prefs->indent_spaces;
|
||||
*p++ = prefs->statusbar;
|
||||
*p++ = prefs->night_mode;
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
rb->strlcpy(buf + 28, prefs->font_name, MAX_PATH);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue