summaryrefslogtreecommitdiff
path: root/apps/gui/color_picker.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-10-13 04:16:49 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-10-13 04:16:49 +0000
commit661c3406a928bad14102a09219774884f9e1db91 (patch)
treeb232f67fe1000fc82c03d896fc949ef4d6f5d502 /apps/gui/color_picker.c
parent65ef2dbb9417953179317b2f9254f67254da673c (diff)
downloadrockbox-661c3406a928bad14102a09219774884f9e1db91.tar.gz
rockbox-661c3406a928bad14102a09219774884f9e1db91.zip
Added inner fill option to normal scrollbar and foreground only option. Added a left-pointing cursor for using pointer. Updated color picker and now sliders look very good on color, grayscale and mono screens when using bar selector. Some misc. changes for appearance.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11210 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/color_picker.c')
-rw-r--r--apps/gui/color_picker.c132
1 files changed, 73 insertions, 59 deletions
diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c
index 719112df87..32b392c717 100644
--- a/apps/gui/color_picker.c
+++ b/apps/gui/color_picker.c
@@ -31,6 +31,7 @@
31#include "lang.h" 31#include "lang.h"
32#include "splash.h" 32#include "splash.h"
33#include "action.h" 33#include "action.h"
34#include "icons.h"
34 35
35/* structure for color info */ 36/* structure for color info */
36struct rgb_pick 37struct rgb_pick
@@ -51,20 +52,31 @@ struct rgb_pick
51 }; 52 };
52}; 53};
53 54
54/* maximum values for components */
55static const unsigned char max_val[3] =
56{
57 LCD_MAX_RED,
58 LCD_MAX_GREEN,
59 LCD_MAX_BLUE
60};
61 55
62/* list of primary colors */ 56/* list of primary colors */
63static const unsigned prim_rgb[3] = 57#define SB_PRIM 0
58#define SB_FILL 1
59#define SB_MAX 2
60static const unsigned short prim_rgb[][3] =
64{ 61{
65 LCD_RGBPACK(255, 0, 0), 62 /* Foreground colors for sliders */
66 LCD_RGBPACK(0, 255, 0), 63 {
67 LCD_RGBPACK(0, 0 ,255), 64 LCD_RGBPACK(255, 0, 0),
65 LCD_RGBPACK( 0, 255, 0),
66 LCD_RGBPACK( 0, 0, 255),
67 },
68 /* Fill colors for sliders */
69 {
70 LCD_RGBPACK( 85, 0, 0),
71 LCD_RGBPACK( 0, 85, 0),
72 LCD_RGBPACK( 0, 0, 85),
73 },
74 /* maximum values for components */
75 {
76 LCD_MAX_RED,
77 LCD_MAX_GREEN,
78 LCD_MAX_BLUE
79 }
68}; 80};
69 81
70/* Unpacks the color value into native rgb values and 24 bit rgb values */ 82/* Unpacks the color value into native rgb values and 24 bit rgb values */
@@ -98,20 +110,22 @@ static void pack_rgb(struct rgb_pick *rgb)
98 else return LCD_WHITE */ 110 else return LCD_WHITE */
99static inline unsigned get_black_or_white(const struct rgb_pick *rgb) 111static inline unsigned get_black_or_white(const struct rgb_pick *rgb)
100{ 112{
101 return (4*rgb->r + 5*rgb->g + 2*rgb->b) >= 256 ? 113 return (2*rgb->red + 5*rgb->green + rgb->blue) >= 1024 ?
102 LCD_BLACK : LCD_WHITE; 114 LCD_BLACK : LCD_WHITE;
103} 115}
104 116
105#define MARGIN_LEFT 2 /* Left margin of screen */ 117#define MARGIN_LEFT 0 /* Left margin of screen */
106#define MARGIN_TOP 4 /* Top margin of screen */ 118#define MARGIN_TOP 2 /* Top margin of screen */
107#define MARGIN_RIGHT 2 /* Right margin of screen */ 119#define MARGIN_RIGHT 0 /* Right margin of screen */
108#define MARGIN_BOTTOM 4 /* Bottom margin of screen */ 120#define MARGIN_BOTTOM 6 /* Bottom margin of screen */
109#define SLIDER_MARGIN_LEFT 2 /* Gap to left of sliders */ 121#define SLIDER_MARGIN_LEFT 2 /* Gap to left of sliders */
110#define SLIDER_MARGIN_RIGHT 2 /* Gap to right of sliders */ 122#define SLIDER_MARGIN_RIGHT 2 /* Gap to right of sliders */
111#define TITLE_MARGIN_BOTTOM 4 /* Space below title bar */ 123#define TITLE_MARGIN_BOTTOM 4 /* Space below title bar */
112#define SELECTOR_LR_MARGIN 1 /* Margin between ">" and text */ 124#define SELECTOR_LR_MARGIN 0 /* Margin between ">" and text */
113#define SELECTOR_TB_MARGIN 1 /* Margin on top and bottom of selector */ 125#define SELECTOR_TB_MARGIN 1 /* Margin on top and bottom of selector */
114#define SWATCH_TOP_MARGIN 4 /* Space between last slider and swatch */ 126#define SWATCH_TOP_MARGIN 4 /* Space between last slider and swatch */
127#define SELECTOR_WIDTH 6 /* Width of > and < bitmaps */
128#define SELECTOR_HEIGHT 8 /* Height of > and < bitmaps */
115 129
116/* dunno why lcd_set_drawinfo should be left out of struct screen */ 130/* dunno why lcd_set_drawinfo should be left out of struct screen */
117static void set_drawinfo(struct screen *display, int mode, 131static void set_drawinfo(struct screen *display, int mode,
@@ -173,19 +187,21 @@ static void draw_screen(struct screen *display, char *title,
173 187
174 /* Get slider positions and top starting position */ 188 /* Get slider positions and top starting position */
175 text_top = MARGIN_TOP + y + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; 189 text_top = MARGIN_TOP + y + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN;
176 slider_left = MARGIN_LEFT + SELECTOR_LR_MARGIN + display->char_width + 190 slider_left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN +
177 max_label_width + SLIDER_MARGIN_LEFT; 191 max_label_width + SLIDER_MARGIN_LEFT;
178 slider_width = display->width - slider_left - SLIDER_MARGIN_RIGHT - 192 slider_width = display->width - slider_left - SLIDER_MARGIN_RIGHT -
179 SELECTOR_LR_MARGIN - display->char_width*3 - MARGIN_RIGHT; 193 display->char_width*2 - SELECTOR_LR_MARGIN - SELECTOR_WIDTH -
194 MARGIN_RIGHT;
180 195
181 for (i = 0; i < 3; i++) 196 for (i = 0; i < 3; i++)
182 { 197 {
183 int mode = DRMODE_SOLID; 198 unsigned sb_flags = HORIZONTAL;
184 unsigned fg = text_color; 199 int mode = DRMODE_SOLID;
185 unsigned bg = background_color; 200 unsigned fg = text_color;
201 unsigned bg = background_color;
186 202
187 if (!display_three_rows) 203 if (!display_three_rows)
188 i = row; 204 i = row;
189 205
190 if (i == row) 206 if (i == row)
191 { 207 {
@@ -201,39 +217,35 @@ static void draw_screen(struct screen *display, char *title,
201 display->char_height + 217 display->char_height +
202 SELECTOR_TB_MARGIN*2); 218 SELECTOR_TB_MARGIN*2);
203 219
204 if (display->depth == 1) 220 if (display->depth < 16)
205 {
206 /* Just invert for low mono display */
207 mode |= DRMODE_INVERSEVID;
208 }
209 else
210 { 221 {
211 if (display->depth >= 16) 222 sb_flags |= FOREGROUND | INNER_FILL;
212 { 223 mode |= DRMODE_INVERSEVID;
213 /* Backdrops will show through text in
214 DRMODE_SOLID */
215 mode = DRMODE_FG;
216 fg = prim_rgb[i];
217 }
218 else
219 {
220 fg = background_color;
221 }
222
223 bg = text_color;
224 } 224 }
225 } 225 }
226 else if (display_three_rows) 226 else if (display_three_rows)
227 { 227 {
228 /* Draw "> <" around sliders */ 228 /* Draw "> <" around sliders */
229 display->putsxy(MARGIN_LEFT, text_top, ">"); 229 int top = text_top + (display->char_height -
230 display->putsxy(display->width-display->char_width - 230 SELECTOR_HEIGHT) / 2;
231 MARGIN_RIGHT, text_top, "<"); 231 display->mono_bitmap(bitmap_icons_6x8[Icon_Cursor],
232 if (display->depth >= 16) 232 MARGIN_LEFT, top,
233 fg = prim_rgb[i]; 233 SELECTOR_WIDTH, SELECTOR_HEIGHT);
234 display->mono_bitmap(bitmap_icons_6x8[Icon_Reverse_Cursor],
235 display->width - MARGIN_RIGHT -
236 SELECTOR_WIDTH, top, SELECTOR_WIDTH,
237 SELECTOR_HEIGHT);
238 }
239
240 if (display->depth >= 16)
241 {
242 sb_flags |= FOREGROUND | INNER_BGFILL;
243 mode = DRMODE_FG;
244 fg = prim_rgb[SB_PRIM][i];
245 bg = prim_rgb[SB_FILL][i];
234 } 246 }
235 } 247 }
236 248
237 set_drawinfo(display, mode, fg, bg); 249 set_drawinfo(display, mode, fg, bg);
238 250
239 /* Draw label */ 251 /* Draw label */
@@ -253,17 +265,20 @@ static void draw_screen(struct screen *display, char *title,
253 text_top + display->char_height / 4, 265 text_top + display->char_height / 4,
254 slider_width, 266 slider_width,
255 display->char_height / 2, 267 display->char_height / 2,
256 max_val[i], 268 prim_rgb[SB_MAX][i],
257 0, 269 0,
258 rgb->rgb_val[i], 270 rgb->rgb_val[i],
259 HORIZONTAL); 271 sb_flags);
260 272
261 /* Advance to next line */ 273 /* Advance to next line */
262 text_top += display->char_height + 2*SELECTOR_TB_MARGIN; 274 text_top += display->char_height + 2*SELECTOR_TB_MARGIN;
263 275
264 if (!display_three_rows) 276 if (!display_three_rows)
265 break; 277 break;
266 } 278 } /* end for */
279
280 /* Draw color value in system font */
281 display->setfont(FONT_SYSFIXED);
267 282
268 /* Format RGB: #rrggbb */ 283 /* Format RGB: #rrggbb */
269 snprintf(buf, sizeof(buf), str(LANG_COLOR_RGB_VALUE), 284 snprintf(buf, sizeof(buf), str(LANG_COLOR_RGB_VALUE),
@@ -272,13 +287,12 @@ static void draw_screen(struct screen *display, char *title,
272 if (display->depth >= 16) 287 if (display->depth >= 16)
273 { 288 {
274 /* Display color swatch on color screens only */ 289 /* Display color swatch on color screens only */
275 int left = slider_left; 290 int left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN;
276 int top = text_top + SWATCH_TOP_MARGIN; 291 int top = text_top + SWATCH_TOP_MARGIN;
277 int width = display->width - slider_left - left; 292 int width = display->width - left - SELECTOR_LR_MARGIN -
293 SELECTOR_WIDTH - MARGIN_RIGHT;
278 int height = display->height - top - MARGIN_BOTTOM; 294 int height = display->height - top - MARGIN_BOTTOM;
279 295
280 display->setfont(FONT_SYSFIXED);
281
282 /* Only draw if room */ 296 /* Only draw if room */
283 if (height >= display->char_height + 2) 297 if (height >= display->char_height + 2)
284 { 298 {
@@ -298,10 +312,8 @@ static void draw_screen(struct screen *display, char *title,
298 312
299 /* Draw border */ 313 /* Draw border */
300 display->set_foreground(text_color); 314 display->set_foreground(text_color);
301 display->drawrect(left - 1, top - 1, width + 2, height + 2); 315 display->drawrect(left, top, width, height);
302 } 316 }
303
304 display->setfont(FONT_UI);
305 } 317 }
306 else 318 else
307 { 319 {
@@ -318,6 +330,8 @@ static void draw_screen(struct screen *display, char *title,
318 } 330 }
319 } 331 }
320 332
333 display->setfont(FONT_UI);
334
321 display->update(); 335 display->update();
322 /* Be sure screen mode is reset */ 336 /* Be sure screen mode is reset */
323 set_drawinfo(display, DRMODE_SOLID, text_color, background_color); 337 set_drawinfo(display, DRMODE_SOLID, text_color, background_color);
@@ -363,7 +377,7 @@ bool set_color(struct screen *display, char *title, int* color, int banned_color
363 377
364 case ACTION_SETTINGS_INC: 378 case ACTION_SETTINGS_INC:
365 case ACTION_SETTINGS_INCREPEAT: 379 case ACTION_SETTINGS_INCREPEAT:
366 if (rgb.rgb_val[slider] < max_val[slider]) 380 if (rgb.rgb_val[slider] < prim_rgb[SB_MAX][slider])
367 rgb.rgb_val[slider]++; 381 rgb.rgb_val[slider]++;
368 pack_rgb(&rgb); 382 pack_rgb(&rgb);
369 break; 383 break;