Chameleon

Chameleon Commit Details

Date:2010-07-08 23:15:09 (13 years 9 months ago)
Author:blackosx
Commit:175
Parents: 174
Message:Added rollover theme functionality while retaining compatibility with existing themes. Note: Compiling with an embedded theme currently fails as I haven't added _o.pngs in to artwork folder. But then if I do, the filesize will exceed the limit.
Changes:
M/branches/blackosx/i386/boot2/gui.h
M/branches/blackosx/i386/boot2/options.c
M/branches/blackosx/i386/boot2/gui.c

File differences

branches/blackosx/i386/boot2/gui.c
1515
1616
1717
18
19
1820
1921
2022
......
4042
4143
4244
45
4346
4447
4548
4649
4750
51
4852
53
4954
55
5056
57
5158
59
5260
61
5362
63
5464
5565
5666
......
7787
7888
7989
90
8091
8192
8293
8394
8495
96
8597
98
8699
100
87101
102
88103
104
89105
106
90107
108
91109
92110
93111
......
185203
186204
187205
206
188207
189208
190209
......
198217
199218
200219
201
202
203
204
205
206
207
208
209
210
211
212
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
213242
214243
215244
216245
217246
218247
248
219249
220250
221251
222252
223253
224254
255
225256
257
226258
259
227260
261
228262
263
229264
265
230266
267
231268
232269
233270
......
625662
626663
627664
628
665
629666
630667
631668
......
663700
664701
665702
703
704
705
706
666707
667708
668709
......
732773
733774
734775
776
777
735778
736779
737780
......
751794
752795
753796
754
797
755798
756799
757800
#define THEME_NAME_DEFAULT"Default"
static const char *theme_name = THEME_NAME_DEFAULT;
static bool rolloverfail = false; // blackosx added to this as a flag to be raised if one or more rollover images are missing in the theme folder.
#ifdef EMBED_THEME
#include "art.h"
#define LOADPNG(img) \
/*
* ATTENTION: the enum and the following array images[] MUST match !!!
*/
//blackosx - added extra variables to match rollover device images (with _o).
enum {
iBackground = 0,
iLogo,
iDeviceGeneric,
iDeviceGeneric_o,
iDeviceHFS,
iDeviceHFS_o,
iDeviceEXT3,
iDeviceEXT3_o,
iDeviceFAT16,
iDeviceFAT16_o,
iDeviceFAT32,
iDeviceFAT32_o,
iDeviceNTFS,
iDeviceNTFS_o,
iDeviceCDROM,
iDeviceCDROM_o,
iSelection,
iDeviceScrollPrev,
iDeviceScrollNext,
iFontSmall,
};
//blackosx - added extra rollover device image (with _o) to images array after each normal device image.
image_t images[] = {
{.name = "background",.image = NULL},
{.name = "logo",.image = NULL},
{.name = "device_generic",.image = NULL},
{.name = "device_generic_o",.image = NULL},
{.name = "device_hfsplus",.image = NULL},
{.name = "device_hfsplus_o",.image = NULL},
{.name = "device_ext3",.image = NULL},
{.name = "device_ext3_o",.image = NULL},
{.name = "device_fat16",.image = NULL},
{.name = "device_fat16_o",.image = NULL},
{.name = "device_fat32",.image = NULL},
{.name = "device_fat32_o",.image = NULL},
{.name = "device_ntfs",.image = NULL},
{.name = "device_ntfs_o",.image = NULL},
{.name = "device_cdrom",.image = NULL},
{.name = "device_cdrom_o",.image = NULL},
{.name = "device_selection",.image = NULL},
{.name = "device_scroll_prev",.image = NULL},
{.name = "device_scroll_next",.image = NULL},
uint16_twidth;
uint16_theight;
uint8_t*imagedata;
char*cptr; // blackosx added
if ((strlen(image) + strlen(theme_name) + 20 ) > sizeof(dirspec)) {
return 1;
width = 0;
height = 0;
imagedata = NULL;
if ((loadPngImage(dirspec, &width, &height, &imagedata)) != 0) {
#ifndef EMBED_THEME
printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
sleep(2);
#endif
return 1;
}
images[i].image->width = width;
images[i].image->height = height;
images[i].image->pixels = (pixel_t *)imagedata;
flipRB(images[i].image);
return 0;
if ((loadPngImage(dirspec, &width, &height, &imagedata)) == 0) { // blackosx - if loaded, carry on.
images[i].image->width = width;
images[i].image->height = height;
images[i].image->pixels = (pixel_t *)imagedata;
flipRB(images[i].image);
return 0;
}
else // blackosx - graphic failed to load
{
cptr = (strstr(image,"_o")); // see if the image name that's missing contains '_o'.
if (cptr == NULL) { // We have no match for '_o' in image name, which means it's a normal theme graphic missing.
printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
sleep(2);
return 1; // This means we have to drop out of using the GUI.
}
else { // We have a match for '_o' in image name, which means a rollover graphic is missing.
//printf("ERROR: GUI: ROLLOVER: could not open '%s/%s.png'!\n", theme_name, image);
//sleep(2);
rolloverfail=true;
return 0;
}
}
}
}
return 1;
}
// blackosx added extra rollover devices.
static int loadGraphics(void)
{
LOADPNG(background);
LOADPNG(logo);
LOADPNG(device_generic);
LOADPNG(device_generic_o);
LOADPNG(device_hfsplus);
LOADPNG(device_hfsplus_o);
LOADPNG(device_ext3);
LOADPNG(device_ext3_o);
LOADPNG(device_fat16);
LOADPNG(device_fat16_o);
LOADPNG(device_fat32);
LOADPNG(device_fat32_o);
LOADPNG(device_ntfs);
LOADPNG(device_ntfs_o);
LOADPNG(device_cdrom);
LOADPNG(device_cdrom_o);
LOADPNG(device_selection);
LOADPNG(device_scroll_prev);
LOADPNG(device_scroll_next);
return 1;
}
void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p)
void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool rollover) //blackosx - accept extra BOOLEAN variable 'rollover' to check for rollover image
{
int devicetype;
break;
}
}
//blackosx - check BOOLEAN 'rollover' variable to see if rollover image is required,
//blackosx - and if it is, then make devicetype point to next image in device list.
if (rollover)
devicetype++;
// draw icon
blend( images[devicetype].image, buffer, centeredAt( images[devicetype].image, p ));
drawInfoMenuItems();
blend( images[iSelection].image, gui.devicelist.pixmap, centeredAt( images[iSelection].image, p ) );
if (rolloverfail == false) // blackosx - if ALL the rollover graphics are in the theme folder
drawDeviceIcon( param, gui.devicelist.pixmap, p, true ); //blackosx - then draw the rollover image.
#if DEBUG
gui.debug.cursor = pos( 10, 100);
#endif
}
drawDeviceIcon( param, gui.devicelist.pixmap, p );
drawDeviceIcon( param, gui.devicelist.pixmap, p, false ); //blackosx - added false to draw normal icon if it's not selected.
if (gui.layout == HorizontalLayout)
{
branches/blackosx/i386/boot2/gui.h
134134
135135
136136
137
137
138
139
138140
139141
140142
int initGUI();
void drawBackground();
void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p);
//blackosx - added extra value to be passed, 'rollover' as boolean. Usage: false = normal image / true = rollover image
void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool rollover);
void drawDeviceList(int start, int end, int selection);
void drawProgressBar(pixmap_t *blendInto, uint16_t width, position_t p, uint8_t progress);
branches/blackosx/i386/boot2/options.c
112112
113113
114114
115
115
116116
117117
118118
char dummy[80];
getBootVolumeDescription( gBootVolume, dummy, 80, true );
drawDeviceIcon( gBootVolume, gui.screen.pixmap, p );
drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, false ); // blackosx added extra variable to pass. Usage: false = normal image
drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );
// make this screen the new background

Archive Download the corresponding diff file

Revision: 175