<li class="tight"><a href="#hiding">Hiding and Displaying EFI Boot Loaders</li>
+<li class="tight"><a href="#icons">Setting OS Icons</li>
+
<li class="tight"><a href="#adjusting">Adjusting the Global Configuration</a></li>
<li class="tight"><a href="#stanzas">Creating OS Stanzas</a></li>
<p>Another way to hide a boot loader is to move it into rEFInd's own directory. In order to keep rEFInd from showing up in its own menu, it ignores boot loaders in its own directory. This obviously includes the rEFInd binary file itself, but also anything else you might store there.</p>
-<p>In addition to hiding boot loaders, you can adjust their icons. You can do this in any of five ways for auto-detected boot loaders:</p>
+<a name="icons">
+<h2>Setting OS Icons</h2>
+</a>
+
+<p>In addition to hiding boot loaders, you can adjust their icons. You can do this in any of six ways for auto-detected boot loaders:</p>
<ul>
-<li>You can name an icon file after your boot loader, but with an extension of <tt>.icns</tt> or <tt>.png</tt> for ICNS-format and PNG-format icons, respectively. For instance, if you're using <tt class="variable">loader</tt><tt>.efi</tt>, you would name the icon file <tt class="variable">loader</tt><tt>.icns</tt>. (If you use the <tt>scan_all_linux_kernels</tt> option, you can give an icon for a Linux kernel without a <tt>.efi</tt> extension a name based on the kernel name but with a <tt>.icns</tt> or <tt>.png</tt> extension—for instance, <tt>bzImage-3.6.9.png</tt> will serve as the icon for the <tt>bzImage-3.6.9</tt> kernel.) These icon files should be 128x128 images in <a href="http://en.wikipedia.org/wiki/Apple_Icon_Image_format">Apple's ICNS</a> or <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">Portable Network Graphics (PNG)</a> format, depending on the filename extension.</li>
+<li>You can name an icon file after your boot loader, but with an extension of <tt>.icns</tt> or <tt>.png</tt> for ICNS-format and PNG-format icons, respectively. For instance, if you're using <tt class="variable">loader</tt><tt>.efi</tt>, you would name the icon file <tt class="variable">loader</tt><tt>.icns</tt>. (If you use the <tt>scan_all_linux_kernels</tt> option, you can give an icon for a Linux kernel without a <tt>.efi</tt> extension a name based on the kernel name but with a <tt>.icns</tt> or <tt>.png</tt> extension—for instance, <tt>bzImage-3.13.6.png</tt> will serve as the icon for the <tt>bzImage-3.13.6</tt> kernel.) These icon files should be in <a href="http://en.wikipedia.org/wiki/Apple_Icon_Image_format">Apple's ICNS</a> or <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">Portable Network Graphics (PNG)</a> format, depending on the filename extension.</li>
-<li>If you're booting OS X from its standard boot loader, or if you place a boot loader file for any OS in the root directory of a partition, you can create a file called <tt>.VolumeIcon.icns</tt> or <tt>.VolumeIcon.png</tt> that holds an icon file. OS X uses the <tt>.VolumeIcon.icns</tt> file for its volume icons, so rEFInd picks up these icons automatically, provided they include 128x128 bitmaps.</li>
+<li>If you're booting OS X from its standard boot loader, or if you place a boot loader file for any OS in the root directory of a partition, you can create a file called <tt>.VolumeIcon.icns</tt> or <tt>.VolumeIcon.png</tt> that holds an icon file. OS X uses the <tt>.VolumeIcon.icns</tt> file for its volume icons, so rEFInd picks up these icons automatically, provided they include appropriate bitmaps.</li>
<li>You can place a boot loader in a directory with a name that matches one of rEFInd's standard icons, which take names of the form <tt>os_<tt class="variable">name</tt>.icns</tt> or <tt>os_<tt class="variable">name</tt>.png</tt>. To use such an icon, you would place the boot loader in the directory called <tt class="variable">name</tt>.</li>
<li>Certain boot loaders have hard-coded icons associated with them. For instance, filenames beginning with <tt>vmlinuz</tt> or <tt>bzImage</tt> acquire Linux "Tux" icons and the <tt>bootmgfw.efi</tt> loader acquires a Windows icon. For the most part, these are the associations you want to overcome with the preceding rules, but sometimes renaming a boot loader to a more conventional name is the better approach.</li>
+<li>rEFInd attempts to guess the Linux distribution based on clues in the kernel's filename and data in the <tt>/etc/os-release</tt> file. This file will only be accessible if a separate <tt>/boot</tt> partition is <i>not</i> used, though. Fedora and Red Hat kernels can be identified by the presence of <tt>.fc</tt> or <tt>.el</tt> strings in their filenames, and so acquire suitable icons automatically. Manually adjusting the <tt>os-release</tt> file to change an OS icon in rEFInd is <i>not</i> recommended. Renaming a locally-compiled kernel so that it acquires a Fedora or Red Hat icon is reasonable, but I don't recommend renaming precompiled kernels unless you also manually copy them to the ESP.</li>
+
</ul>
<p>As a special case, rEFInd assigns icons to the Windows and OS X boot loaders based on their conventional locations, so they get suitable icons even if they don't follow these rules.</p>
-<p>In addition to the main OS tag icon, you can set the <i>badge</i> icon for a volume by creating a file called <tt>.VolumeBadge.icns</tt> or <tt>.VolumeBadge.png</tt> in the root directory of a partition. This icon file must include a 32x32 bitmap. If present, it replaces the disk-type icons that are overlaid on the main OS icon. If you use this feature, the badge is applied to all the boot loaders read from the disk, not just those stored in the root directory or the Apple boot loader location. You could use this feature to set a custom badge for different specific disks or to help differentiate multiple OS X installations on one computer. If you don't want any badges, you can replace the three badge icons in the rEFInd <tt>icons</tt> subdirectory (<tt>vol_external.icns</tt>, <tt>vol_internal.icns</tt>, and <tt>vol_optical.icns</tt>) with a completely transparent badge. The <tt>transparent.icns</tt> file in the rEFInd <tt>icons</tt> directory may be used for this purpose.</p>
+<p>In addition to the main OS tag icon, you can set the <i>badge</i> icon for a volume by creating a file called <tt>.VolumeBadge.icns</tt> or <tt>.VolumeBadge.png</tt> in the root directory of a partition. If present, it replaces the disk-type icons that are overlaid on the main OS icon. If you use this feature, the badge is applied to all the boot loaders read from the disk, not just those stored in the root directory or the Apple boot loader location. You could use this feature to set a custom badge for different specific disks or to help differentiate multiple OS X installations on one computer. If you don't want any badges, you can replace the three badge icons in the rEFInd <tt>icons</tt> subdirectory (<tt>vol_external.icns</tt>, <tt>vol_internal.icns</tt>, and <tt>vol_optical.icns</tt>) with a completely transparent badge. The <tt>transparent.icns</tt> file in the rEFInd <tt>icons</tt> directory may be used for this purpose.</p>
+
+<p>The default icon sizes are 128x128 pixels for OS icons, 48x48 pixels for the second-row tools, and 32x32 pixels for badges. You can change the sizes of the big OS icons and the small tool icons with the <tt>big_icon_size</tt> and <tt>small_icon_size</tt> tokens in <tt>refind.conf</tt>, as noted in <a href="#table1">Table 1.</a> The size of the disk-type badges is 1/4 the size of OS icons.</p>
<a name="adjusting">
<h2>Adjusting the Global Configuration</h2>
<td>filename</td>
<td>Specifies a custom banner file to replace the rEFInd banner image. The file should be a BMP or PNG image with a color depth of 24, 8, 4, or 1 bits. The file path is relative to the directory where the rEFInd binary is stored.</td>
</tr>
+<tr>
+ <td><tt>banner_scale</tt></td>
+ <td><tt>noscale</tt> or <tt>fillscreen</tt></td>
+ <td>Tells rEFInd whether to display banner images pixel-for-pixel (<tt>noscale</tt>) or to scale banner images to fill the screen (<tt>fillscreen</tt>). The former is the default.</td>
+</tr>
+<tr>
+ <td><tt>big_icon_size</tt></td>
+ <td>numeric value (at least <tt>32</tt>)</td>
+ <td>Sets the size of big icons (those used for OSes on the first row). All icons are square, so only one value is specified. If icon files don't contain images of the specified size, the available images are scaled to this size. The disk-type badge size is set indirectly by this token; badges are 1/4 the size of big icons. The default value is <tt>128<tt>.</td>
+</tr>
+<tr>
+ <td><tt>small_icon_size</tt></td>
+ <td>numeric value (at least <tt>32</tt>)</td>
+ <td>Sets the size of small icons (those used for tools on the second row). All icons are square, so only one value is specified. If icon files don't contain images of the specified size, the available images are scaled to this size. The default value is <tt>128<tt>.</td>
+</tr>
<tr>
<td><tt>selection_big</tt></td>
<td>filename</td>
return NULL;
NewImage->PixelData = (EG_PIXEL *) AllocatePool(Width * Height * sizeof(EG_PIXEL));
if (NewImage->PixelData == NULL) {
- FreePool(NewImage);
+ egFreeImage(NewImage);
return NULL;
}
// code presented at http://tech-algorithm.com/articles/bilinear-image-scaling/.
// Resize an image; returns pointer to resized image if successful, NULL otherwise.
// Calling function is responsible for freeing allocated memory.
-EG_IMAGE * egScaleImage(EG_IMAGE *Image, UINTN NewWidth, UINTN NewHeight) {
+EG_IMAGE * egScaleImage(IN EG_IMAGE *Image, IN UINTN NewWidth, IN UINTN NewHeight) {
EG_IMAGE *NewImage = NULL;
EG_PIXEL a, b, c, d;
UINTN x, y, Index ;
if (NewImage == NULL)
return NULL;
- x_ratio = ((float)(Image->Width-1))/NewWidth ;
- y_ratio = ((float)(Image->Height-1))/NewHeight ;
+ x_ratio = ((float)(Image->Width - 1)) / NewWidth;
+ y_ratio = ((float)(Image->Height - 1)) / NewHeight;
for (i = 0; i < NewHeight; i++) {
for (j = 0; j < NewWidth; j++) {
- x = (UINTN)(x_ratio * j) ;
- y = (UINTN)(y_ratio * i) ;
- x_diff = (x_ratio * j) - x ;
- y_diff = (y_ratio * i) - y ;
- Index = ((y * Image->Width) + x) ;
- a = Image->PixelData[Index] ;
- b = Image->PixelData[Index + 1] ;
- c = Image->PixelData[Index + Image->Width] ;
- d = Image->PixelData[Index + Image->Width + 1] ;
+ x = (UINTN)(x_ratio * j);
+ y = (UINTN)(y_ratio * i);
+ x_diff = (x_ratio * j) - x;
+ y_diff = (y_ratio * i) - y;
+ Index = ((y * Image->Width) + x);
+ a = Image->PixelData[Index];
+ b = Image->PixelData[Index + 1];
+ c = Image->PixelData[Index + Image->Width];
+ d = Image->PixelData[Index + Image->Width + 1];
// blue element
// Yb = Ab(1-Image->Width)(1-Image->Height) + Bb(Image->Width)(1-Image->Height) + Cb(Image->Height)(1-Image->Width) + Db(wh)
return NULL;
// decode it
- NewImage = egDecodeAny(FileData, FileDataLength, 128, WantAlpha);
+ NewImage = egDecodeAny(FileData, FileDataLength, 128 /* arbitrary value */, WantAlpha);
FreePool(FileData);
return NewImage;
NewImage = egScaleImage(Image, IconSize, IconSize);
if (!NewImage)
Print(L"Warning: Unable to scale icon of the wrong size from '%s'\n", Path);
- MyFreePool(Image);
+ egFreeImage(Image);
Image = NewImage;
}
}
} /* VOID egComposeImage() */
-EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN UINTN Width, IN UINTN Height, IN EG_PIXEL *Color)
-{
- EG_IMAGE *NewImage;
-
- if (Image == NULL)
- return NULL;
- if (Image->Width == Width && Image->Height == Height)
- return Image;
-
- NewImage = egCreateFilledImage(Width, Height, Image->HasAlpha, Color);
- if (NewImage == NULL) {
- egFreeImage(Image);
- return NULL;
- }
- Image->HasAlpha = FALSE;
- egComposeImage(NewImage, Image, 0, 0);
- egFreeImage(Image);
-
- return NewImage;
-}
+// EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN UINTN Width, IN UINTN Height, IN EG_PIXEL *Color)
+// {
+// EG_IMAGE *NewImage;
+//
+// if (Image == NULL)
+// return NULL;
+// if (Image->Width == Width && Image->Height == Height)
+// return Image;
+//
+// NewImage = egCreateFilledImage(Width, Height, Image->HasAlpha, Color);
+// if (NewImage == NULL) {
+// egFreeImage(Image);
+// return NULL;
+// }
+// Image->HasAlpha = FALSE;
+// egComposeImage(NewImage, Image, 0, 0);
+// egFreeImage(Image);
+//
+// return NewImage;
+// }
//
// misc internal functions
}
} while ((DataPtr == NULL) && (SizeToTry++ < MAX_ICNS_SIZES));
- /* FUTURE: try to load a different size and scale it later
- if (DataPtr == NULL && IconSize == 32) {
- IconSize = 128;
- continue;
- }
- */
break;
}
#
#banner_scale fillscreen
+# Icon sizes. All icons are square, so just one value is specified. The
+# big icons are used for OS selectors in the first row and the small
+# icons are used for tools on the second row. Drive-type badges are 1/4
+# the size of the big icons. Legal values are 32 and above. If the icon
+# files do not hold icons of the proper size, the icons are scaled to
+# the specified size. The default values are 48 and 128 for small and
+# big icons, respectively.
+#
+#small_icon_size 96
+#big_icon_size 256
+
# Custom images for the selection background. There is a big one (144 x 144)
# for the OS icons, and a small one (64 x 64) for the function icons in the
# second row. If only a small image is given, that one is also used for
} else if ((StriCmp(TokenList[0], L"banner_scale") == 0) && (TokenCount == 2)) {
if (StriCmp(TokenList[1], L"noscale") == 0) {
GlobalConfig.BannerScale = BANNER_NOSCALE;
- } else if (StriCmp(TokenList[1], L"fillscreen") == 0) {
+ } else if ((StriCmp(TokenList[1], L"fillscreen") == 0) || (StriCmp(TokenList[1], L"fullscreen") == 0)) {
GlobalConfig.BannerScale = BANNER_FILLSCREEN;
} else {
Print(L" unknown banner_type flag: '%s'\n", TokenList[1]);
} // if/else
+ } else if ((StriCmp(TokenList[0], L"small_icon_size") == 0) && (TokenCount == 2)) {
+ HandleInt(TokenList, TokenCount, &i);
+ if (i >= 32)
+ GlobalConfig.IconSizes[ICON_SIZE_SMALL] = i;
+
+ } else if ((StriCmp(TokenList[0], L"big_icon_size") == 0) && (TokenCount == 2)) {
+ HandleInt(TokenList, TokenCount, &i);
+ if (i >= 32) {
+ GlobalConfig.IconSizes[ICON_SIZE_BIG] = i;
+ GlobalConfig.IconSizes[ICON_SIZE_BADGE] = i / 4;
+ }
+
} else if (StriCmp(TokenList[0], L"selection_small") == 0) {
HandleString(TokenList, TokenCount, &(GlobalConfig.SelectionSmallFileName));
} else if ((StriCmp(TokenList[0], L"icon") == 0) && (TokenCount > 1)) {
MyFreePool(Entry->me.Image);
- Entry->me.Image = egLoadIcon(CurrentVolume->RootDir, TokenList[1], 128);
+ Entry->me.Image = egLoadIcon(CurrentVolume->RootDir, TokenList[1], GlobalConfig.IconSizes[ICON_SIZE_BIG]);
if (Entry->me.Image == NULL) {
- Entry->me.Image = DummyImage(128);
+ Entry->me.Image = DummyImage(GlobalConfig.IconSizes[ICON_SIZE_BIG]);
}
} else if ((StriCmp(TokenList[0], L"initrd") == 0) && (TokenCount > 1)) {
#define BANNER_NOSCALE 0
#define BANNER_FILLSCREEN 1
+// Sizes of the default icons; badges are 1/4 the big icon size
+#define DEFAULT_SMALL_ICON_SIZE 48
+#define DEFAULT_BIG_ICON_SIZE 128
+
+// Codes for types of icon sizes; used for indexing into GlobalConfig.IconSizes[]
+#define ICON_SIZE_BADGE 0
+#define ICON_SIZE_SMALL 1
+#define ICON_SIZE_BIG 2
+
// Names of binaries that can manage MOKs....
#define MOK_NAMES L"MokManager.efi,HashTool.efi,HashTool-signed.efi"
// Directories to search for these MOK-managing programs. Note that SelfDir is
UINTN LegacyType;
UINTN ScanDelay;
UINTN ScreensaverTime;
+ UINTN IconSizes[3];
UINTN BannerScale;
CHAR16 *BannerFileName;
EG_IMAGE *ScreenBackground;
typedef struct {
EG_IMAGE *Image;
CHAR16 *FileName;
- UINTN PixelSize;
+ UINTN IconSize;
} BUILTIN_ICON;
BUILTIN_ICON BuiltinIconTable[BUILTIN_ICON_COUNT] = {
- { NULL, L"func_about", 48 },
- { NULL, L"func_reset", 48 },
- { NULL, L"func_shutdown", 48 },
- { NULL, L"func_exit", 48 },
- { NULL, L"func_firmware", 48 },
- { NULL, L"tool_shell", 48 },
- { NULL, L"tool_part", 48 },
- { NULL, L"tool_rescue", 48 },
- { NULL, L"tool_apple_rescue", 48 },
- { NULL, L"tool_windows_rescue", 48 },
- { NULL, L"tool_mok_tool", 48 },
- { NULL, L"tool_memtest", 48 },
- { NULL, L"vol_internal", 32 },
- { NULL, L"vol_external", 32 },
- { NULL, L"vol_optical", 32 },
+ { NULL, L"func_about", ICON_SIZE_SMALL },
+ { NULL, L"func_reset", ICON_SIZE_SMALL },
+ { NULL, L"func_shutdown", ICON_SIZE_SMALL },
+ { NULL, L"func_exit", ICON_SIZE_SMALL },
+ { NULL, L"func_firmware", ICON_SIZE_SMALL },
+ { NULL, L"tool_shell", ICON_SIZE_SMALL },
+ { NULL, L"tool_part", ICON_SIZE_SMALL },
+ { NULL, L"tool_rescue", ICON_SIZE_SMALL },
+ { NULL, L"tool_apple_rescue", ICON_SIZE_SMALL },
+ { NULL, L"tool_windows_rescue", ICON_SIZE_SMALL },
+ { NULL, L"tool_mok_tool", ICON_SIZE_SMALL },
+ { NULL, L"tool_memtest", ICON_SIZE_SMALL },
+ { NULL, L"vol_internal", ICON_SIZE_BADGE },
+ { NULL, L"vol_external", ICON_SIZE_BADGE },
+ { NULL, L"vol_optical", ICON_SIZE_BADGE },
};
EG_IMAGE * BuiltinIcon(IN UINTN Id)
return NULL;
if (BuiltinIconTable[Id].Image == NULL) {
- BuiltinIconTable[Id].Image = egFindIcon(BuiltinIconTable[Id].FileName, BuiltinIconTable[Id].PixelSize);
+ BuiltinIconTable[Id].Image = egFindIcon(BuiltinIconTable[Id].FileName, GlobalConfig.IconSizes[BuiltinIconTable[Id].IconSize]);
if (BuiltinIconTable[Id].Image == NULL)
- BuiltinIconTable[Id].Image = DummyImage(BuiltinIconTable[Id].PixelSize);
+ BuiltinIconTable[Id].Image = DummyImage(GlobalConfig.IconSizes[BuiltinIconTable[Id].IconSize]);
} // if
return BuiltinIconTable[Id].Image;
// First, try to find an icon from the OSIconName list....
while (((CutoutName = FindCommaDelimited(OSIconName, Index++)) != NULL) && (Image == NULL)) {
SPrint(BaseName, 255, L"%s_%s", BootLogo ? L"boot" : L"os", CutoutName);
- Image = egFindIcon(BaseName, 128);
+ Image = egFindIcon(BaseName, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
}
// If that fails, try again using the FallbackIconName....
if (Image == NULL) {
SPrint(BaseName, 255, L"%s_%s", BootLogo ? L"boot" : L"os", FallbackIconName);
- Image = egFindIcon(BaseName, 128);
+ Image = egFindIcon(BaseName, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
}
// If that fails and if BootLogo was set, try again using the "os_" start of the name....
if (BootLogo && (Image == NULL)) {
SPrint(BaseName, 255, L"os_%s", FallbackIconName);
- Image = egFindIcon(BaseName, 128);
+ Image = egFindIcon(BaseName, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
}
// If all of these fail, return the dummy image....
if (Image == NULL)
- Image = DummyImage(128);
+ Image = DummyImage(GlobalConfig.IconSizes[ICON_SIZE_BIG]);
return Image;
} /* EG_IMAGE * LoadOSIcon() */
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * Modifications copyright (c) 2012 Roderick W. Smith
+ * Modifications copyright (c) 2012-2014 Roderick W. Smith
*
* Modifications distributed under the terms of the GNU General Public
* License (GPL) version 3 (GPLv3), a copy of which must be distributed
VOID SetVolumeBadgeIcon(REFIT_VOLUME *Volume)
{
if (Volume->VolBadgeImage == NULL) {
- Volume->VolBadgeImage = egLoadIconAnyType(Volume->RootDir, L"", L".VolumeBadge", 128);
+ Volume->VolBadgeImage = egLoadIconAnyType(Volume->RootDir, L"", L".VolumeBadge", GlobalConfig.IconSizes[ICON_SIZE_BADGE]);
}
if (Volume->VolBadgeImage == NULL) {
// get custom volume icons if present
if (!Volume->VolIconImage)
- Volume->VolIconImage = egLoadIconAnyType(Volume->RootDir, L"", L".VolumeIcon", 128);
+ Volume->VolIconImage = egLoadIconAnyType(Volume->RootDir, L"", L".VolumeIcon", GlobalConfig.IconSizes[ICON_SIZE_BIG]);
} // ScanVolume()
static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_INFO *MbrEntry)
static REFIT_MENU_SCREEN AboutMenu = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL, L"Press Enter to return to main menu", L"" };
REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 0, DONT_CHANGE_TEXT_MODE, 20, 0, 0, GRAPHICS_FOR_OSX, LEGACY_TYPE_MAC, 0, 0,
- BANNER_NOSCALE,
+ { DEFAULT_BIG_ICON_SIZE / 4, DEFAULT_SMALL_ICON_SIZE, DEFAULT_BIG_ICON_SIZE }, BANNER_NOSCALE,
NULL, NULL, CONFIG_FILE_NAME, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
{ TAG_SHELL, TAG_MEMTEST, TAG_APPLE_RECOVERY, TAG_WINDOWS_RECOVERY, TAG_MOK_TOOL, TAG_ABOUT,
TAG_SHUTDOWN, TAG_REBOOT, TAG_FIRMWARE, 0, 0, 0, 0, 0, 0 }
{
if (AboutMenu.EntryCount == 0) {
AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
- AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.7.7");
+ AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.7.7.2");
AddMenuInfoLine(&AboutMenu, L"");
AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2013 Roderick W. Smith");
// locate a custom icon for the loader
// Anything found here takes precedence over the "hints" in the OSIconName variable
if (!Entry->me.Image)
- Entry->me.Image = egLoadIconAnyType(Volume->RootDir, PathOnly, NoExtension, 128);
+ Entry->me.Image = egLoadIconAnyType(Volume->RootDir, PathOnly, NoExtension, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
if (!Entry->me.Image)
Entry->me.Image = egCopyImage(Volume->VolIconImage);
EFI_STATUS Status;
INTN Where;
- Status = uefi_call_wrapper(BS->HandleProtocol, 3, ImageHandle,
- &LoadedImageProtocol, (VOID **) &Info);
+ Status = refit_call3_wrapper(BS->HandleProtocol, ImageHandle, &LoadedImageProtocol, (VOID **) &Info);
if ((Status == EFI_SUCCESS) && (Info->LoadOptionsSize > 0)) {
Options = (CHAR16 *) Info->LoadOptions;
Where = FindSubString(L" -c ", Options);
#include "../include/refit_call_wrapper.h"
#include "../include/egemb_back_selected_small.h"
+#include "../include/egemb_back_selected_big.h"
#include "../include/egemb_arrow_left.h"
#include "../include/egemb_arrow_right.h"
static CHAR16 ArrowUp[2] = { ARROW_UP, 0 };
static CHAR16 ArrowDown[2] = { ARROW_DOWN, 0 };
+static UINTN TileSizes[2] = { 144, 64 };
// Text and icon spacing constants....
#define TEXT_YMARGIN (2)
-//#define TEXT_XMARGIN (8)
-//#define TEXT_LINE_HEIGHT (FONT_CELL_HEIGHT + TEXT_YMARGIN * 2)
#define TITLEICON_SPACING (16)
-#define ROW0_TILESIZE (144)
-#define ROW1_TILESIZE (64)
#define TILE_XSPACING (8)
#define TILE_YSPACING (16)
static VOID InitSelection(VOID)
{
- UINTN x, y, src_x, src_y;
- EG_PIXEL *DestPtr, *SrcPtr;
+ EG_IMAGE *TempSmallImage = NULL, *TempBigImage = NULL;
+ BOOLEAN LoadedSmallImage = FALSE;
if (!AllowGraphicsMode)
return;
// load small selection image
if (GlobalConfig.SelectionSmallFileName != NULL) {
- SelectionImages[1] = egLoadImage(SelfDir, GlobalConfig.SelectionSmallFileName, TRUE);
+ TempSmallImage = egLoadImage(SelfDir, GlobalConfig.SelectionSmallFileName, TRUE);
}
- if (SelectionImages[1] == NULL)
- SelectionImages[1] = egPrepareEmbeddedImage(&egemb_back_selected_small, TRUE);
- SelectionImages[1] = egEnsureImageSize(SelectionImages[1], ROW1_TILESIZE, ROW1_TILESIZE, &MenuBackgroundPixel);
- if (SelectionImages[1] == NULL)
- return;
+ if (TempSmallImage == NULL)
+ TempSmallImage = egPrepareEmbeddedImage(&egemb_back_selected_small, TRUE);
+ else
+ LoadedSmallImage = TRUE;
+ SelectionImages[1] = egScaleImage(TempSmallImage, TileSizes[1], TileSizes[1]);
// load big selection image
if (GlobalConfig.SelectionBigFileName != NULL) {
- SelectionImages[0] = egLoadImage(SelfDir, GlobalConfig.SelectionBigFileName, TRUE);
- SelectionImages[0] = egEnsureImageSize(SelectionImages[0], ROW0_TILESIZE, ROW0_TILESIZE, &MenuBackgroundPixel);
+ TempBigImage = egLoadImage(SelfDir, GlobalConfig.SelectionBigFileName, TRUE);
}
- if (SelectionImages[0] == NULL) {
- // calculate big selection image from small one
-
- SelectionImages[0] = egCreateImage(ROW0_TILESIZE, ROW0_TILESIZE, TRUE);
- if (SelectionImages[0] == NULL) {
- egFreeImage(SelectionImages[1]);
- SelectionImages[1] = NULL;
- return;
- }
-
- DestPtr = SelectionImages[0]->PixelData;
- SrcPtr = SelectionImages[1]->PixelData;
- for (y = 0; y < ROW0_TILESIZE; y++) {
- if (y < (ROW1_TILESIZE >> 1))
- src_y = y;
- else if (y < (ROW0_TILESIZE - (ROW1_TILESIZE >> 1)))
- src_y = (ROW1_TILESIZE >> 1);
- else
- src_y = y - (ROW0_TILESIZE - ROW1_TILESIZE);
-
- for (x = 0; x < ROW0_TILESIZE; x++) {
- if (x < (ROW1_TILESIZE >> 1))
- src_x = x;
- else if (x < (ROW0_TILESIZE - (ROW1_TILESIZE >> 1)))
- src_x = (ROW1_TILESIZE >> 1);
- else
- src_x = x - (ROW0_TILESIZE - ROW1_TILESIZE);
-
- *DestPtr++ = SrcPtr[src_y * ROW1_TILESIZE + src_x];
- }
+ if (TempBigImage == NULL) {
+ if (LoadedSmallImage) {
+ // calculate big selection image from small one
+ TempBigImage = egCopyImage(TempSmallImage);
+ } else {
+ TempBigImage = egPrepareEmbeddedImage(&egemb_back_selected_big, TRUE);
}
}
+ SelectionImages[0] = egScaleImage(TempBigImage, TileSizes[0], TileSizes[0]);
+
+ if (TempSmallImage)
+ egFreeImage(TempSmallImage);
+ if (TempBigImage)
+ egFreeImage(TempBigImage);
} // VOID InitSelection()
//
State->MaxIndex = (INTN)ItemCount - 1;
State->FirstVisible = 0;
if (AllowGraphicsMode) {
- State->MaxVisible = UGAWidth / (ROW0_TILESIZE + TILE_XSPACING) - 1;
+ State->MaxVisible = UGAWidth / (TileSizes[0] + TILE_XSPACING) - 1;
} else
State->MaxVisible = ConHeight - 4;
if ((VisibleSpace > 0) && (VisibleSpace < State->MaxVisible))
static VOID PaintIcon(IN EG_EMBEDDED_IMAGE *BuiltInIcon, IN CHAR16 *ExternalFilename, UINTN PosX, UINTN PosY, UINTN Alignment) {
EG_IMAGE *Icon = NULL;
- Icon = egFindIcon(ExternalFilename, 48);
+ Icon = egFindIcon(ExternalFilename, GlobalConfig.IconSizes[ICON_SIZE_SMALL]);
if (Icon == NULL)
Icon = egPrepareEmbeddedImage(BuiltInIcon, TRUE);
if (Icon != NULL) {
} // static VOID ()
inline UINTN ComputeRow0PosY(VOID) {
- return ((UGAHeight / 2) - ROW0_TILESIZE / 2);
+ return ((UGAHeight / 2) - TileSizes[0] / 2);
} // UINTN ComputeRow0PosY()
// Display (or erase) the arrow icons to the left and right of an icon's row,
// NOTE: Assume that left and right arrows are of the same size....
Width = egemb_arrow_left.Width;
Height = egemb_arrow_left.Height;
- RightX = (UGAWidth + (ROW0_TILESIZE + TILE_XSPACING) * State->MaxVisible) / 2 + TILE_XSPACING;
+ RightX = (UGAWidth + (TileSizes[0] + TILE_XSPACING) * State->MaxVisible) / 2 + TILE_XSPACING;
AdjPosY = PosY - (Height / 2);
// For PaintIcon() calls, the starting Y position is moved to the midpoint
row0Count++;
}
}
- row0PosX = (UGAWidth + TILE_XSPACING - (ROW0_TILESIZE + TILE_XSPACING) * row0Count) >> 1;
+ row0PosX = (UGAWidth + TILE_XSPACING - (TileSizes[0] + TILE_XSPACING) * row0Count) >> 1;
row0PosY = ComputeRow0PosY();
- row1PosX = (UGAWidth + TILE_XSPACING - (ROW1_TILESIZE + TILE_XSPACING) * row1Count) >> 1;
- row1PosY = row0PosY + ROW0_TILESIZE + TILE_YSPACING;
+ row1PosX = (UGAWidth + TILE_XSPACING - (TileSizes[1] + TILE_XSPACING) * row1Count) >> 1;
+ row1PosY = row0PosY + TileSizes[0] + TILE_YSPACING;
if (row1Count > 0)
- textPosY = row1PosY + ROW1_TILESIZE + TILE_YSPACING;
+ textPosY = row1PosY + TileSizes[1] + TILE_YSPACING;
else
textPosY = row1PosY;
for (i = 0; i <= State->MaxIndex; i++) {
if (Screen->Entries[i]->Row == 0) {
itemPosX[i] = row0PosXRunning;
- row0PosXRunning += ROW0_TILESIZE + TILE_XSPACING;
+ row0PosXRunning += TileSizes[0] + TILE_XSPACING;
} else {
itemPosX[i] = row1PosXRunning;
- row1PosXRunning += ROW1_TILESIZE + TILE_XSPACING;
+ row1PosXRunning += TileSizes[1] + TILE_XSPACING;
}
}
// initial painting
// For PaintArrows(), the starting Y position is moved to the midpoint
// of the surrounding row; PaintIcon() adjusts this back up by half the
// icon's height to properly center it.
- PaintArrows(State, row0PosX - TILE_XSPACING, row0PosY + (ROW0_TILESIZE / 2), row0Loaders);
+ PaintArrows(State, row0PosX - TILE_XSPACING, row0PosY + (TileSizes[0] / 2), row0Loaders);
break;
case MENU_FUNCTION_PAINT_SELECTION:
INTN DefaultEntryIndex = -1;
INTN DefaultSubmenuIndex = -1;
+ TileSizes[0] = (GlobalConfig.IconSizes[ICON_SIZE_BIG] * 9) / 8;
+ TileSizes[1] = (GlobalConfig.IconSizes[ICON_SIZE_SMALL] * 4) / 3;
+
if (DefaultSelection != NULL) {
// Find a menu entry that includes *DefaultSelection as a substring
DefaultEntryIndex = FindMenuShortcutEntry(Screen, DefaultSelection);
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * Modifications copyright (c) 2012 Roderick W. Smith
+ * Modifications copyright (c) 2012-2014 Roderick W. Smith
*
* Modifications distributed under the terms of the GNU General Public
* License (GPL) version 3 (GPLv3), a copy of which must be distributed