1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) Jonathan Gordon (2006)
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "stdarg.h"
#include "string.h"
#include "stdio.h"
#include "kernel.h"
#include "system.h"
#include "screen_access.h"
#include "debug.h"
#include "misc.h"
#include "settings.h"
#include "scrollbar.h"
#include "lang.h"
#include "splash.h"
#define TEXT_MARGIN display->char_width+2
#define SLIDER_START 20
#if (CONFIG_KEYPAD == IRIVER_H300_PAD)
#define SLIDER_UP BUTTON_UP
#define SLIDER_DOWN BUTTON_DOWN
#define SLIDER_LEFT BUTTON_LEFT
#define SLIDER_RIGHT BUTTON_RIGHT
#define SLIDER_OK BUTTON_ON
#define SLIDER_OK2 BUTTON_SELECT
#define SLIDER_CANCEL BUTTON_OFF
#define SLIDER_RC_UP BUTTON_RC_REW
#define SLIDER_RC_DOWN BUTTON_RC_FF
#define SLIDER_RC_LEFT BUTTON_RC_SOURCE
#define SLIDER_RC_RIGHT BUTTON_RC_BITRATE
#define SLIDER_RC_OK BUTTON_RC_ON
#define SLIDER_RC_CANCEL BUTTON_RC_STOP
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
#define SLIDER_UP BUTTON_UP
#define SLIDER_DOWN BUTTON_DOWN
#define SLIDER_LEFT BUTTON_LEFT
#define SLIDER_RIGHT BUTTON_RIGHT
#define SLIDER_OK BUTTON_POWER
#define SLIDER_CANCEL BUTTON_A
#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
#define SLIDER_UP BUTTON_LEFT
#define SLIDER_DOWN BUTTON_RIGHT
#define SLIDER_LEFT BUTTON_SCROLL_BACK
#define SLIDER_RIGHT BUTTON_SCROLL_FWD
#define SLIDER_OK BUTTON_SELECT
#define SLIDER_CANCEL BUTTON_MENU
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
#define SLIDER_UP BUTTON_UP
#define SLIDER_DOWN BUTTON_DOWN
#define SLIDER_LEFT BUTTON_LEFT
#define SLIDER_RIGHT BUTTON_RIGHT
#define SLIDER_OK BUTTON_SELECT
#define SLIDER_CANCEL BUTTON_PLAY
#endif
static const int max_val[3] = {LCD_MAX_RED,LCD_MAX_GREEN,LCD_MAX_BLUE};
static void draw_screen(struct screen *display, char *title,
int *rgb_val, int color, int row)
{
int i;
char *textrgb = str(LANG_COLOR_RGB_LABELS), rgb_dummy[2] = {0,0};
int text_top;
int text_centre, bg_col;
char buf[32];
int slider_width = (display->width-SLIDER_START-(display->char_width*5));
int background_color = global_settings.bg_color;
int text_color = global_settings.fg_color;
display->clear_display();
if (display->depth > 1) {
display->set_foreground(text_color);
}
i = display->getstringsize(title,0,0);
display->putsxy((display->width-i)/2,6,title );
for (i=0;i<3;i++)
{
text_top =display->char_height*((i*2)+2);
if (i==row)
{
if (global_settings.invert_cursor)
{
display->fillrect(0,text_top-1,display->width,display->char_height+2);
bg_col = text_color;
}
else
{
display->putsxy(0,text_top,">");
display->putsxy(display->width-TEXT_MARGIN,text_top,"<");
bg_col = background_color;
}
if (display->depth > 1)
{
if (i==0)
display->set_foreground(LCD_RGBPACK(255, 0, 0));
else if (i==1)
display->set_foreground(LCD_RGBPACK(0, 255, 0));
else if (i==2)
display->set_foreground(LCD_RGBPACK(0 ,0 ,255));
}
}
else
{
if (display->depth > 1)
display->set_foreground(text_color);
bg_col = background_color;
}
if (display->depth > 1)
display->set_background(bg_col);
text_centre = text_top+(display->char_height/2);
rgb_dummy[0] = textrgb[i];
display->putsxy(TEXT_MARGIN,text_top,rgb_dummy);
snprintf(buf,3,"%02d",rgb_val[i]);
display->putsxy(display->width-(display->char_width*4),text_top,buf);
text_top += display->char_height/4;
gui_scrollbar_draw(display,SLIDER_START,text_top,slider_width,
display->char_height/2,
max_val[i],0,rgb_val[i],HORIZONTAL);
}
if (display->depth > 1) {
display->set_background(background_color);
display->set_foreground(text_color);
}
if (text_top + (display->char_height*2) < (LCD_HEIGHT-40-display->char_height))
text_top += (display->char_height*2);
else text_top += (display->char_height);
/* Display RGB: #rrggbb */
snprintf(buf,sizeof(buf),str(LANG_COLOR_RGB_VALUE),
RGB_UNPACK_RED(color),
RGB_UNPACK_GREEN(color),
RGB_UNPACK_BLUE(color));
display->putsxy((LCD_WIDTH-(display->char_width*21))/2,text_top,buf);
if (display->depth > 1) {
display->set_foreground(color);
display->fillrect(SLIDER_START,LCD_HEIGHT-40,slider_width,35);
display->set_foreground(LCD_BLACK);
display->drawrect(SLIDER_START-1,LCD_HEIGHT-41,slider_width+2,37);
}
display->update();
}
/***********
set_color
returns true if USB was inserted, false otherwise
color is a pointer to the colour (in native format) to modify
set banned_color to -1 to allow all
***********/
bool set_color(struct screen *display,char *title, int* color, int banned_color)
{
int exit = 0, button, slider=0;
int rgb_val[3]; /* native depth r,g,b*/;
int fgcolor = display->get_foreground();
int newcolor = *color;
int i;
#if LCD_PIXELFORMAT == RGB565
rgb_val[0] = ((*color)&0xf800) >> 11;
rgb_val[1] = ((*color)&0x07e0) >> 5;
rgb_val[2] = ((*color)&0x001f);
#elif LCD_PIXELFORMAT == RGB565SWAPPED
rgb_val[0] = ((swap16(*color))&0xf800) >> 11;
rgb_val[1] = ((swap16(*color))&0x07e0) >> 5;
rgb_val[2] = ((swap16(*color))&0x001f);
#endif
while (!exit)
{
/* We need to maintain three versions of the colour:
rgb_val[3] - the native depth RGB values
newcolor - the native format packed colour
*/
#if LCD_PIXELFORMAT == RGB565
newcolor = (rgb_val[0] << 11) | (rgb_val[1] << 5) | (rgb_val[2]);
#elif LCD_PIXELFORMAT == RGB565SWAPPED
newcolor = swap16((rgb_val[0] << 11) | (rgb_val[1] << 5) | (rgb_val[2]));
#endif
FOR_NB_SCREENS(i)
draw_screen(&screens[i], title, rgb_val, newcolor, slider);
button = button_get(true);
switch (button)
{
case SLIDER_UP:
#ifdef HAVE_LCD_REMOTE
case SLIDER_RC_UP:
#endif
slider = (slider+2)%3;
break;
case SLIDER_DOWN:
#ifdef HAVE_LCD_REMOTE
case SLIDER_RC_DOWN:
#endif
slider = (slider+1)%3;
break;
case SLIDER_RIGHT:
case SLIDER_RIGHT|BUTTON_REPEAT:
#ifdef HAVE_LCD_REMOTE
case SLIDER_RC_RIGHT:
case SLIDER_RC_RIGHT|BUTTON_REPEAT:
#endif
if (rgb_val[slider] < max_val[slider])
rgb_val[slider]++;
break;
case SLIDER_LEFT:
case SLIDER_LEFT|BUTTON_REPEAT:
#ifdef HAVE_LCD_REMOTE
case SLIDER_RC_LEFT:
case SLIDER_RC_LEFT|BUTTON_REPEAT:
#endif
if (rgb_val[slider] > 0)
rgb_val[slider]--;
break;
case SLIDER_OK:
#ifdef HAVE_LCD_REMOTE
case SLIDER_RC_OK:
#endif
#ifdef SLIDER_OK2
case SLIDER_OK2:
#endif
if ((banned_color!=-1) && (banned_color == newcolor))
{
gui_syncsplash(HZ*2,true,str(LANG_COLOR_UNACCEPTABLE));
break;
}
*color = newcolor;
exit = 1;
break;
case SLIDER_CANCEL:
#ifdef HAVE_LCD_REMOTE
case SLIDER_RC_CANCEL:
#endif
exit = 1;
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED) {
display->set_foreground(fgcolor);
return true;
}
break;
}
}
display->set_foreground(fgcolor);
return false;
}
|