All pastes #638960 Raw Edit

[Rockbox] Line Selector Option

public text v1 · immutable
#638960 ·published 2007-07-30 07:28 UTC
rendered paste body
Index: apps/screen_access.c
===================================================================
--- apps/screen_access.c	(revision 14071)
+++ apps/screen_access.c	(working copy)
@@ -154,6 +154,10 @@
             screen->get_foreground=&lcd_get_foreground;
             screen->set_background=&lcd_set_background;
             screen->set_foreground=&lcd_set_foreground;
+#ifdef HAVE_LCD_COLOR
+            screen->set_selector=&lcd_set_selector;
+            screen->set_selector_text=&lcd_set_selector_text;
+#endif
 #endif /* LCD_DEPTH > 1 */
             screen->update_rect=&lcd_update_rect;
             screen->fillrect=&lcd_fillrect;
Index: apps/screen_access.h
===================================================================
--- apps/screen_access.h	(revision 14071)
+++ apps/screen_access.h	(working copy)
@@ -103,6 +103,10 @@
     void (*set_background)(unsigned background);
     void (*set_foreground)(unsigned foreground);
 #endif /* (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) */
+#if defined(HAVE_LCD_COLOR)
+    void (*set_selector)(unsigned selector);
+    void (*set_selector_text)(unsigned selector_text);
+#endif
     void (*update_rect)(int x, int y, int width, int height);
     void (*fillrect)(int x, int y, int width, int height);
     void (*drawrect)(int x, int y, int width, int height);
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang	(revision 14071)
+++ apps/lang/english.lang	(working copy)
@@ -3269,13 +3269,13 @@
   desc: in settings_menu
   user:
   <source>
-    *: "Line Selector"
+    *: "Line Selector Type"
   </source>
   <dest>
-    *: "Line Selector"
+    *: "Line Selector Type"
   </dest>
   <voice>
-    *: "Line Selector"
+    *: "Line Selector Type"
   </voice>
 </phrase>
 <phrase>
@@ -11054,3 +11054,46 @@
     *: "Can't write to recording directory"
   </voice>
 </phrase>
+<phrase>
+  id: LANG_SELECTOR_COLOR
+  desc: line selector color option
+  user:
+  <source>
+    *: "Line Selector Colour"
+  </source>
+  <dest>
+    *: "Line Selector Colour"
+  </dest>
+  <voice>
+    *: "Line Selector Colour"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_SELECTOR_TEXT_COLOR
+  desc: line selector text color option
+  user:
+  <source>
+    *: "Line Selector Text Colour"
+  </source>
+  <dest>
+    *: "Line Selector Text Colour"
+  </dest>
+  <voice>
+    *: "Line Selector Text Colour"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_INVERT_CURSOR_COLOR
+  desc: in settings_menu
+  user:
+  <source>
+    *: "Bar (Colour)"
+  </source>
+  <dest>
+    *: "Bar (Colour)"
+  </dest>
+  <voice>
+    *: "Bar (Colour)"
+  </voice>
+</phrase>
+
Index: apps/settings.c
===================================================================
--- apps/settings.c	(revision 14071)
+++ apps/settings.c	(working copy)
@@ -764,6 +764,8 @@
 #ifdef HAVE_LCD_COLOR
     screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
     screens[SCREEN_MAIN].set_background(global_settings.bg_color);
+    screens[SCREEN_MAIN].set_selector(global_settings.ls_color);
+    screens[SCREEN_MAIN].set_selector_text(global_settings.lst_color);
 #endif
 
 #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
Index: apps/gui/list.c
===================================================================
--- apps/gui/list.c	(revision 14071)
+++ apps/gui/list.c	(working copy)
@@ -390,10 +390,16 @@
            current_item <  gui_list->selected_item + gui_list->selected_size)
         {/* The selected item must be displayed scrolling */
 #ifdef HAVE_LCD_BITMAP
-            if (global_settings.invert_cursor)/* Display inverted-line-style*/
+            if (global_settings.invert_cursor == 1)/* Display inverted-line-style*/
             {
                 style |= STYLE_INVERT;
             }
+#ifdef HAVE_LCD_COLOR
+            else if (global_settings.invert_cursor == 2)
+            {
+                style |= STYLE_HIGHLIGHT;
+            }
+#endif
             else  /*  if (!global_settings.invert_cursor) */
             {
                 if (current_item % gui_list->selected_size != 0)
Index: apps/settings.h
===================================================================
--- apps/settings.h	(revision 14071)
+++ apps/settings.h	(working copy)
@@ -407,7 +407,7 @@
     int contrast;   /* lcd contrast */
 #endif
     bool invert;    /* invert display */
-    bool invert_cursor; /* invert the current file in dir browser and menu
+    int invert_cursor; /* invert the current file in dir browser and menu
                            instead of using the default cursor */
     bool flip_display; /* turn display (and button layout) by 180 degrees */
     int poweroff;   /* power off timer */
@@ -630,6 +630,8 @@
 #ifdef HAVE_LCD_COLOR
     int bg_color; /* background color native format */
     int fg_color; /* foreground color native format */
+    int ls_color; /* background color for the selector */
+    int lst_color; /* color of the text for the selector */
 #endif
     bool party_mode;    /* party mode - unstoppable music */
     
Index: apps/menus/display_menu.c
===================================================================
--- apps/menus/display_menu.c	(revision 14071)
+++ apps/menus/display_menu.c	(working copy)
@@ -157,13 +157,40 @@
     settings_save();
     return res;
 }
+
+static int set_ls_color(void)
+{
+    int res;
+    res = (int)set_color(&screens[SCREEN_MAIN],str(LANG_SELECTOR_COLOR),
+                     &global_settings.ls_color,-1);
+
+    screens[SCREEN_MAIN].set_selector(global_settings.ls_color);
+    settings_save();
+    return res;
+}
+
+static int set_lst_color(void)
+{
+    int res;
+    res = (int)set_color(&screens[SCREEN_MAIN],str(LANG_SELECTOR_COLOR),
+                     &global_settings.lst_color,global_settings.ls_color);
+
+    screens[SCREEN_MAIN].set_selector_text(global_settings.lst_color);
+    settings_save();
+    return res;
+}
+
 static int reset_color(void)
 {
     global_settings.fg_color = LCD_DEFAULT_FG;
     global_settings.bg_color = LCD_DEFAULT_BG;
+    global_settings.ls_color = LCD_DEFAULT_LS;
+    global_settings.lst_color = LCD_DEFAULT_FG;
 
     screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
     screens[SCREEN_MAIN].set_background(global_settings.bg_color);
+    screens[SCREEN_MAIN].set_selector(global_settings.ls_color);
+    screens[SCREEN_MAIN].set_selector_text(global_settings.lst_color);
     settings_save();
     return 0;
 }
@@ -171,6 +198,10 @@
                     set_bg_color, NULL, NULL, Icon_NOICON);
 MENUITEM_FUNCTION(set_fg_col, 0, ID2P(LANG_FOREGROUND_COLOR),
                     set_fg_color, NULL, NULL, Icon_NOICON);
+MENUITEM_FUNCTION(set_ls_col, 0, ID2P(LANG_SELECTOR_COLOR),
+                    set_ls_color, NULL, NULL, Icon_NOICON); 
+MENUITEM_FUNCTION(set_lst_col, 0, ID2P(LANG_SELECTOR_TEXT_COLOR),
+                    set_lst_color, NULL, NULL, Icon_NOICON);
 MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
                     reset_color, NULL, NULL, Icon_NOICON);
 #endif
@@ -214,7 +245,7 @@
             ,&clear_main_bd,
 #endif
 #ifdef HAVE_LCD_COLOR
-            &set_bg_col, &set_fg_col, &reset_colors
+            &set_bg_col, &set_fg_col, &set_ls_col, &set_lst_col, &reset_colors
 #endif
          );
 /*    LCD MENU                    */
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c	(revision 14071)
+++ apps/settings_list.c	(working copy)
@@ -444,8 +444,15 @@
         LANG_INVERT_LCD_INVERSE, LANG_INVERT_LCD_NORMAL, lcd_set_invert_display),
     OFFON_SETTING(0,flip_display, LANG_FLIP_DISPLAY, false,"flip display", NULL),
     /* display */
-    BOOL_SETTING(F_TEMPVAR, invert_cursor, LANG_INVERT_CURSOR, true ,"invert cursor", off_on,
-        LANG_INVERT_CURSOR_BAR, LANG_INVERT_CURSOR_POINTER, NULL),
+    CHOICE_SETTING(F_TEMPVAR|F_THEMESETTING, invert_cursor, LANG_INVERT_CURSOR, 1, 
+#ifdef HAVE_LCD_COLOR
+        "selector type", "pointer, bar (inverse), bar (color)", NULL, 3,
+        ID2P(LANG_INVERT_CURSOR_POINTER), ID2P(LANG_INVERT_CURSOR_BAR), 
+        ID2P(LANG_INVERT_CURSOR_COLOR)),
+#else
+        "selector type", "pointer, bar (inverse)", NULL, 2,
+        ID2P(LANG_INVERT_CURSOR_POINTER), ID2P(LANG_INVERT_CURSOR_BAR)),
+#endif        
     OFFON_SETTING(F_THEMESETTING,statusbar, LANG_STATUS_BAR, true,"statusbar", NULL),
     OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true,"scrollbar", NULL),
 #if CONFIG_KEYPAD == RECORDER_PAD
@@ -611,6 +618,10 @@
         "foreground color",NULL,UNUSED},
     {F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.bg_color,-1,INT(LCD_DEFAULT_BG),
         "background color",NULL,UNUSED},
+    {F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.ls_color,-1,INT(LCD_DEFAULT_LS),
+        "line selector color",NULL,UNUSED},
+    {F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.lst_color,-1,INT(LCD_DEFAULT_FG),
+        "line selector text color",NULL,UNUSED},
 #endif
     /* more playback */
     OFFON_SETTING(0,play_selected,LANG_PLAY_SELECTED,true,"play selected",NULL),
Index: firmware/export/lcd.h
===================================================================
--- firmware/export/lcd.h	(revision 14071)
+++ firmware/export/lcd.h	(working copy)
@@ -27,6 +27,7 @@
 #define STYLE_DEFAULT    0x00000000
 #define STYLE_INVERT     0x20000000
 #define STYLE_COLORED    0x10000000
+#define STYLE_HIGHLIGHT  0x40000000
 #define STYLE_COLOR_MASK 0x0000FFFF
 
 #ifdef SIMULATOR
@@ -229,6 +230,7 @@
 #define LCD_WHITE      LCD_RGBPACK(255, 255, 255)
 #define LCD_DEFAULT_FG LCD_BLACK
 #define LCD_DEFAULT_BG LCD_RGBPACK(182, 198, 229) /* rockbox blue */
+#define LCD_DEFAULT_LS LCD_WHITE
 
 #elif LCD_DEPTH > 1 /* greyscale */
 #define LCD_MAX_LEVEL ((1 << LCD_DEPTH) - 1)
@@ -348,6 +350,10 @@
 extern unsigned lcd_get_foreground(void);
 extern void     lcd_set_background(unsigned background);
 extern unsigned lcd_get_background(void);
+#ifdef HAVE_LCD_COLOR
+extern void     lcd_set_selector(unsigned selector);
+extern void     lcd_set_selector_text(unsigned selector_text);
+#endif
 extern void     lcd_set_drawinfo(int mode, unsigned foreground,
                                  unsigned background);
 void lcd_set_backdrop(fb_data* backdrop);
Index: firmware/export/scroll_engine.h
===================================================================
--- firmware/export/scroll_engine.h	(revision 14071)
+++ firmware/export/scroll_engine.h	(working copy)
@@ -43,8 +43,12 @@
     int startx;
 #ifdef HAVE_LCD_BITMAP
     int width;  /* length of line in pixels */
-    bool invert; /* invert the scrolled text */
+#ifdef HAVE_LCD_COLOR
+    int invert; /* invert the scrolled text */
+#else
+    bool invert;
 #endif
+#endif/* HAVE_LCD_BITMAP */
     bool backward; /* scroll presently forward or backward? */
     bool bidir;
     long start_tick;
Index: firmware/drivers/lcd-16bit.c
===================================================================
--- firmware/drivers/lcd-16bit.c	(revision 14071)
+++ firmware/drivers/lcd-16bit.c	(working copy)
@@ -51,9 +51,13 @@
 #if !defined(TOSHIBA_GIGABEAT_F) || defined(SIMULATOR)
 static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG;
 static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG;
+static unsigned ls_pattern IDATA_ATTR = LCD_DEFAULT_LS;
+static unsigned lst_pattern IDATA_ATTR = LCD_DEFAULT_FG;
 #else
 unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG;
 unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG;
+unsigned ls_pattern IDATA_ATTR = LCD_DEFAULT_LS;
+unsigned lst_pattern IDATA_ATTR = LCD_DEFAULT_FG;
 #endif
 
 static int drawmode = DRMODE_SOLID;
@@ -103,6 +107,16 @@
     return bg_pattern;
 }
 
+void lcd_set_selector(unsigned color)
+{
+    ls_pattern = color;
+}
+
+void lcd_set_selector_text(unsigned color)
+{
+    lst_pattern = color;
+}
+
 void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color)
 {
     lcd_set_drawmode(mode);
@@ -807,7 +821,11 @@
     ypos = ymargin + y*h;
     drawmode = (style & STYLE_INVERT) ?
                (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
-    if (style & STYLE_COLORED) {
+    if (style & STYLE_HIGHLIGHT) {
+        fg_pattern = lst_pattern;
+        bg_pattern = ls_pattern;
+    }    
+    else if (style & STYLE_COLORED) {
         if (drawmode == DRMODE_SOLID)
             fg_pattern = style & STYLE_COLOR_MASK;
         else
@@ -851,8 +869,11 @@
     s->start_tick = current_tick + lcd_scroll_info.delay;
     s->invert = false;
     if (style & STYLE_INVERT) {
-        s->invert = true;
+        s->invert = 1;
     }
+    else if (style & STYLE_HIGHLIGHT) {
+        s->invert = 2;
+    }
     lcd_puts_style_offset(x,y,string,style,offset);
 
     lcd_getstringsize(string, &w, &h);
@@ -960,8 +981,12 @@
         }
 
         lastmode = drawmode;
-        drawmode = s->invert ?
+        drawmode = s->invert == 1 ?
             (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
+        if (s->invert == 2) {
+            fg_pattern = lst_pattern;
+            bg_pattern = ls_pattern;
+        }
         lcd_putsxyofs(xpos, ypos, s->offset, s->line);
         drawmode = lastmode;
         lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);