forked from iPodLinux/podzilla0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appearance.c
328 lines (280 loc) · 9.92 KB
/
appearance.c
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*
* appearance - color scheming and such for all of podzilla
* Copyright (C) 2005 Scott Lawrence
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/*
* $Log: appearance.c,v $
* Revision 1.9 2005/07/14 14:38:51 yorgle
* charge color icon
* it was hard to see light gray
* changed it to dark gray
*
* Revision 1.8 2005/07/13 03:27:20 yorgle
* Various color scheme tweaks
*
* Revision 1.7 2005/07/12 05:27:02 yorgle
* Decorations added: Plain (default), Amiga 1.1, Amiga 1.3, m:robe
* Moved the lock/hold widget to the left by a touch to center it better
* Added another color to the color scheme system: CS_TITLEACC title accent color
*
* Revision 1.6 2005/07/12 03:51:38 yorgle
* Added the m:robe color scheme by Stuart Clark (Decipher)
* Slight tweak to the Amiga 1.x scheme
* Always sets the number of color schemes in the menu, rather than just for mono
*
* Revision 1.5 2005/07/11 00:18:10 yorgle
* Added the "gameboy" pea-green color scheme (although it's not very accurate)
* Tweak in amiga 1.x color scheme to make the battery meter look better
*
* Revision 1.4 2005/07/10 23:18:28 yorgle
* Tweaked the Amiga2 color scheme to be more readable (black-on-blue for title)
*
* Revision 1.3 2005/07/10 22:58:49 yorgle
* Added in more color schemes: Monocrhome-inverted, Amigados 1, amigados 2
* Added a hook to menu.c to limit the choices on monochrome ipods
* Added patches to mlist to draw menu items in color
* - needs a full screen redraw when color schemes change, or a forced-restart or somesuch.
*
* Revision 1.2 2005/07/10 01:36:28 yorgle
* Added color scheming to message and pz_error
*
* Revision 1.1 2005/07/09 20:49:16 yorgle
* Added in appearance.[ch]. Currently it only supports color schemes
* Color scheme selection in menu.c
* color-scheme support in mlist.c, slider.c, pz.c (menu scrollbar, pz header, sclider)
*
*
*/
#include <stdio.h> /* NULL */
#include "pz.h"
#include "ipod.h" /* ipod_get_setting */
#include "mlist.h" /* for the menu twiddling */
/******************************************************************************
** color scheme stuff
*/
/* same as the old style */
static GR_COLOR colorscheme_mono[] = {
GR_RGB( 255, 255, 255 ), /* bg */
GR_RGB( 0, 0, 0 ), /* fg */
GR_RGB( 0, 0, 0 ), /* sel bg */
DKGRAY, /* sel bg border */
GR_RGB( 255, 255, 255 ), /* sel fg */
WHITE, GRAY, DKGRAY, BLACK, /* arrow animation */
GR_RGB( 255, 255, 255 ), /* title bg */
GR_RGB( 0, 0, 0 ), /* title fg */
GRAY, /* title accent */
BLACK, /* title line */
BLACK, WHITE, GRAY, /* scrollbar */
BLACK, WHITE, GRAY, /* slider */
BLACK, WHITE, DKGRAY, BLACK, DKGRAY, /* battery */
BLACK, BLACK, /* lock */
BLACK, GRAY, WHITE, WHITE, /* message window */
GRAY, BLACK, /* load average bg, fg */
};
/* inverted of the above */
static GR_COLOR colorscheme_monoinv[] = {
BLACK, WHITE,
WHITE, GRAY, BLACK,
BLACK, DKGRAY, GRAY, WHITE,
BLACK, WHITE, GRAY, WHITE,
WHITE, BLACK, GRAY,
WHITE, BLACK, GRAY,
WHITE, BLACK, WHITE, WHITE, WHITE,
WHITE, WHITE,
WHITE, DKGRAY, BLACK, BLACK,
DKGRAY, WHITE,
};
/* the above monochrome, but with classic gameboy pea-green hues */
#define GB_WHITE GR_RGB( 168, 168, 125)
#define GB_GRAY GR_RGB( 125, 125, 82)
#define GB_DKGRAY GR_RGB( 82, 82, 38)
#define GB_BLACK GR_RGB( 0, 0, 0)
static GR_COLOR colorscheme_gameboy[] = {
GB_WHITE, GB_BLACK,
GB_BLACK, GB_DKGRAY, GB_WHITE,
GB_WHITE, GB_GRAY, GB_DKGRAY, GB_BLACK,
GB_WHITE, GB_BLACK, GB_GRAY, GB_BLACK,
GB_BLACK, GB_WHITE, GB_DKGRAY,
GB_BLACK, GB_WHITE, GB_DKGRAY,
GB_BLACK, GB_WHITE, GB_DKGRAY, GB_BLACK, GB_GRAY,
GB_BLACK, GB_BLACK,
GB_BLACK, GB_GRAY, GB_WHITE, GB_WHITE,
GB_GRAY, GB_BLACK,
};
/* a basic blueish scheme. it looks ok, but nothing to write home about */
static GR_COLOR colorscheme_cyans[] = {
/* menu colors */
GR_RGB( 184, 241, 255 ), /* light blue */
GR_RGB( 0, 0, 0 ), /* black */
GR_RGB( 70, 130, 180 ), /* steel blue */
GR_RGB( 0, 0, 139 ), /* dark blue */
GR_RGB( 255, 255, 255 ), /* white */
WHITE, /* animated arrow */
GR_RGB( 175, 238, 238 ),
GR_RGB( 135, 206, 235 ),
GR_RGB( 0, 0, 139 ),
/* title */
GR_RGB( 212, 246, 246 ), /* light blue */
GR_RGB( 0, 0, 128 ), /* navy */
GR_RGB( 0, 0, 128 ), /* navy */
GR_RGB( 0, 128, 128 ), /* teal */
BLACK, /* scrollbar */
GR_RGB( 200, 232, 253 ), /* lt blue */
GR_RGB( 0, 128, 128 ), /* teal */
BLACK, /* slider */
GR_RGB( 200, 232, 253 ), /* lt blue */
GR_RGB( 0, 128, 128 ), /* teal */
BLACK, /* battery */
GR_RGB( 255, 255, 255 ), /* white */
GR_RGB( 0, 192, 0 ), /* green */
GR_RGB( 255, 165, 0 ), /* orange */
GR_RGB( 0, 0, 255 ), /* blue */
GR_RGB( 139, 0, 0 ), /* lock */
GR_RGB( 255, 0, 0 ),
BLACK, GREEN, /* messages */
GR_RGB( 200, 232, 253 ), /* lt blue */
GR_RGB( 255, 255, 0 ), /* yellow */
GR_RGB( 0, 0, 128 ), /* load average */
WHITE
};
#define A1_BLUE GR_RGB( 0, 85, 170 )
#define A1_BLACK GR_RGB( 0, 0, 34 )
#define A1_WHITE GR_RGB( 255, 255, 255 )
#define A1_ORANGE GR_RGB( 255, 136, 0 )
static GR_COLOR colorscheme_amiga1[] = {
A1_BLUE, A1_WHITE, /* menu bg/fg */
A1_WHITE, A1_BLUE, A1_ORANGE, /* selected items */
A1_ORANGE, A1_BLACK, A1_ORANGE, A1_BLACK, /* anim */
A1_WHITE, A1_BLACK, A1_BLUE, A1_ORANGE, /* titlebar */
A1_WHITE, A1_BLACK, A1_ORANGE, /* scrollbar */
A1_WHITE, A1_BLACK, A1_ORANGE, /* slider */
A1_BLACK, A1_WHITE, A1_BLUE, A1_ORANGE, A1_BLUE, /* battery */
A1_ORANGE, A1_ORANGE, /* hold */
A1_BLACK, A1_BLUE, A1_WHITE, A1_ORANGE, /* error/warning */
A1_BLACK, A1_ORANGE, /* load average */
};
#define A2_GRAY GR_RGB( 170, 170, 170 )
#define A2_WHITE GR_RGB( 255, 255, 255 )
#define A2_BLACK GR_RGB( 0, 0, 0 )
#define A2_BLUE GR_RGB( 131, 172, 214 )
static GR_COLOR colorscheme_amiga2[] = {
A2_GRAY, A2_BLACK, /* menu items */
A2_BLACK, A2_GRAY, A2_BLUE, /* selected items */
A2_BLACK, A2_WHITE, A2_WHITE, A2_BLUE, /* anim */
A2_BLUE, A2_BLACK, A2_BLACK, A2_BLACK, /* title */
A2_BLUE, A2_BLACK, A2_WHITE, /* scrollbar */
A2_WHITE, A2_BLACK, A2_BLUE, /* slider */
A2_WHITE, A2_BLACK, A2_BLUE, A2_BLUE, A2_BLUE, /* battery */
A2_WHITE, A2_WHITE, /* hold */
A2_BLACK, A2_BLUE, A2_WHITE, A2_BLUE, /* error */
A2_GRAY, A2_WHITE, /* load */
};
/* m:robe scheme by Stuart Clark (Decipher) */
#define MR_RED GR_RGB( 255, 0, 0 )
static GR_COLOR colorscheme_mrobe[] = {
BLACK, MR_RED, /* menu items */
MR_RED, MR_RED, BLACK, /* selected items */
BLACK, BLACK, BLACK, BLACK, /* anim */
BLACK, MR_RED, MR_RED, MR_RED, /* title */
MR_RED, BLACK, MR_RED, /* scrollbar */
MR_RED, BLACK, MR_RED, /* slider */
MR_RED, BLACK, MR_RED, MR_RED, MR_RED, /* battery */
MR_RED, MR_RED, /* hold */
MR_RED, MR_RED, BLACK, BLACK, /* error */
BLACK, MR_RED, /* load */
};
int colorscheme_max = CS_NSCHEMES;
static GR_COLOR * schemes[] = {
colorscheme_mono,
colorscheme_monoinv,
colorscheme_gameboy,
colorscheme_cyans,
colorscheme_amiga1,
colorscheme_amiga2,
colorscheme_mrobe
};
/* these are separate, since they are also used in the menu system.
* these need to be in sync with the above schemes[] table.
*/
char * colorscheme_names[] = {
"Mono",
"Mono Inv",
"Gameboy",
"Cyan",
"Amiga 1.x",
"Amiga 2.x",
"m:robe"
};
GR_COLOR * colorscheme_current = colorscheme_mono; /* current color scheme */
static int colorscheme_current_idx = 0; /* current index */
/* this sets a new scheme. It constrains the input value to something valid */
void appearance_set_color_scheme( int index )
{
if( index < 0 ) index = 0;
if( index > colorscheme_max) index = colorscheme_max;
colorscheme_current_idx = index;
colorscheme_current = schemes[ colorscheme_current_idx ];
}
/* this gets the current color scheme value */
int appearance_get_color_scheme( void )
{
return( colorscheme_current_idx );
}
/* this gets a color from the current color scheme */
GR_COLOR appearance_get_color( int index )
{
if( index < 0 ) index = 0;
if( index > CS_MAX ) index = CS_MAX;
return( colorscheme_current[index] );
}
/******************************************************************************
** Decoration stuff
*/
char * appearance_decorations[] = { "Plain",
"Amiga 1.1", "Amiga 1.3",
"m:robe" };
static int decoration_current_idx = 0;
void appearance_set_decorations( int index )
{
if( index < 0 ) index = 0;
if( index >= NDECORATIONS ) index = 0;
decoration_current_idx = index;
}
int appearance_get_decorations( void )
{
return( decoration_current_idx );
}
/* rendering code is over in pz.c for now. */
/******************************************************************************
** General stuff
*/
/* for tweaking the number of schemes - limiting for monochrome ipods */
extern void menu_adjust_nschemes( int val );
/* this sets up the tables and such. Eventually this might load in files */
void appearance_init( void )
{
int reqscheme = ipod_get_setting( COLORSCHEME );
if( screen_info.bpp < 16 ) {
colorscheme_max = CS_MONO_LAST;
}
if( reqscheme > colorscheme_max ) reqscheme = 0;
appearance_set_color_scheme( reqscheme );
appearance_set_decorations( ipod_get_setting( DECORATIONS ));
/* and now some magic twiddling to tweak the menus... */
menu_adjust_nschemes( colorscheme_max+1 );
}