load icons as in xtheme

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-30 11:34:16 +03:00
parent 17c92d9526
commit f7254f53e6
13 changed files with 217 additions and 44 deletions

View File

@ -2484,7 +2484,6 @@
A571C2742405749900B6A2C5 /* utf8Conversion.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = utf8Conversion.cpp; sourceTree = "<group>"; }; A571C2742405749900B6A2C5 /* utf8Conversion.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = utf8Conversion.cpp; sourceTree = "<group>"; };
A571C2752405749900B6A2C5 /* utf8Conversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utf8Conversion.h; sourceTree = "<group>"; }; A571C2752405749900B6A2C5 /* utf8Conversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utf8Conversion.h; sourceTree = "<group>"; };
A571C2772405749900B6A2C5 /* XToolsCommon.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = XToolsCommon.cpp; sourceTree = "<group>"; }; A571C2772405749900B6A2C5 /* XToolsCommon.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = XToolsCommon.cpp; sourceTree = "<group>"; };
A571C2782405749900B6A2C5 /* printf_lite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = printf_lite.h; sourceTree = "<group>"; };
A571C2792405749900B6A2C5 /* XArray.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XArray.h; sourceTree = "<group>"; }; A571C2792405749900B6A2C5 /* XArray.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XArray.h; sourceTree = "<group>"; };
A571C27A2405749900B6A2C5 /* XObjArray.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XObjArray.h; sourceTree = "<group>"; }; A571C27A2405749900B6A2C5 /* XObjArray.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XObjArray.h; sourceTree = "<group>"; };
A571C27D240574A100B6A2C5 /* XStringWArray_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XStringWArray_test.h; sourceTree = "<group>"; }; A571C27D240574A100B6A2C5 /* XStringWArray_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XStringWArray_test.h; sourceTree = "<group>"; };
@ -8248,7 +8247,6 @@
A571C26E2405749900B6A2C5 /* cpp_foundation */ = { A571C26E2405749900B6A2C5 /* cpp_foundation */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A571C2782405749900B6A2C5 /* printf_lite.h */,
A571C2742405749900B6A2C5 /* utf8Conversion.cpp */, A571C2742405749900B6A2C5 /* utf8Conversion.cpp */,
A571C2752405749900B6A2C5 /* utf8Conversion.h */, A571C2752405749900B6A2C5 /* utf8Conversion.h */,
A571C2792405749900B6A2C5 /* XArray.h */, A571C2792405749900B6A2C5 /* XArray.h */,

View File

@ -61,7 +61,7 @@ UINT8 gLanMac[4][6]; // their MAC addresses
UINTN nLanPaths; // number of LAN pathes UINTN nLanPaths; // number of LAN pathes
UINTN ThemesNum = 0; UINTN ThemesNum = 0;
CHAR16 *ThemesList[50]; //no more then 50 themes? CONST CHAR16 *ThemesList[100]; //no more then 100 themes?
UINTN ConfigsNum; UINTN ConfigsNum;
CHAR16 *ConfigsList[20]; CHAR16 *ConfigsList[20];
UINTN DsdtsNum; UINTN DsdtsNum;
@ -2975,7 +2975,7 @@ GetEarlyUserSettings (
OldChosenTheme = 0xFFFF; //default for embedded OldChosenTheme = 0xFFFF; //default for embedded
for (UINTN i = 0; i < ThemesNum; i++) { for (UINTN i = 0; i < ThemesNum; i++) {
//now comparison is case sensitive //now comparison is case sensitive
if (ThemeX.Theme == ThemesList[i]) { //(StriCmp(ThemeX.Theme, ThemesList[i]) == 0) if (StriCmp(ThemeX.Theme.data(), ThemesList[i]) == 0) {
OldChosenTheme = i; OldChosenTheme = i;
break; break;
} }

View File

@ -82,7 +82,12 @@ EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName)
} }
while (Index < BuiltinIconNamesCount) { while (Index < BuiltinIconNamesCount) {
if (StriCmp(IconName, BuiltinIconNames[Index]) == 0) { if (StriCmp(IconName, BuiltinIconNames[Index]) == 0) {
#if USE_XTHEME
XImage IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_INTERNAL + Index);
return IconX.ToEGImage();
#else
return BuiltinIcon(BUILTIN_ICON_VOL_INTERNAL + Index); return BuiltinIcon(BUILTIN_ICON_VOL_INTERNAL + Index);
#endif
} }
++Index; ++Index;
} }
@ -92,6 +97,9 @@ EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName)
EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) //IN UINT8 DiskKind) EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) //IN UINT8 DiskKind)
{ {
UINTN IconNum = 0; UINTN IconNum = 0;
#if USE_XTHEME
XImage IconX;
#endif
// default volume icon based on disk kind // default volume icon based on disk kind
switch (Volume->DiskKind) { switch (Volume->DiskKind) {
case DISK_KIND_INTERNAL: case DISK_KIND_INTERNAL:
@ -125,6 +133,26 @@ EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DE
IconNum = BUILTIN_ICON_VOL_INTERNAL; IconNum = BUILTIN_ICON_VOL_INTERNAL;
break; break;
} }
#if USE_XTHEME
IconX = ThemeX.GetIcon(IconNum);
break;
case DISK_KIND_EXTERNAL:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_EXTERNAL);
break;
case DISK_KIND_OPTICAL:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_OPTICAL);
break;
case DISK_KIND_FIREWIRE:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_FIREWIRE);
break;
case DISK_KIND_BOOTER:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_BOOTER);
break;
default:
return NULL;
}
return IconX.ToEGImage();
#else
return BuiltinIcon(IconNum); return BuiltinIcon(IconNum);
case DISK_KIND_EXTERNAL: case DISK_KIND_EXTERNAL:
return BuiltinIcon(BUILTIN_ICON_VOL_EXTERNAL); return BuiltinIcon(BUILTIN_ICON_VOL_EXTERNAL);
@ -138,6 +166,7 @@ EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DE
break; break;
} }
return NULL; return NULL;
#endif
} }

View File

@ -414,7 +414,15 @@ VOID AddCustomLegacy(VOID)
if (Image == NULL) { if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE); Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) { if (Image == NULL) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, "unknown");
Image = ImageX.ToEGImage();
#else
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE); Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
#endif
} }
} }
} }

View File

@ -701,7 +701,8 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
} else if (Image) { } else if (Image) {
Entry->Image.FromEGImage(Image); Entry->Image.FromEGImage(Image);
} else { } else {
Entry->Image = ThemeX.GetIcon("unknown"); // Entry->Image = ThemeX.GetIcon("unknown"); //no such icon
Entry->Image = ThemeX.GetIcon("vol_internal");
} }
#else #else
if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){ if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){
@ -1253,8 +1254,15 @@ VOID ScanLoader(VOID)
if ((AndroidEntryData[Index].Find[aIndex] == NULL) || FileExists(Volume->RootDir, AndroidEntryData[Index].Find[aIndex])) ++aFound; if ((AndroidEntryData[Index].Find[aIndex] == NULL) || FileExists(Volume->RootDir, AndroidEntryData[Index].Find[aIndex])) ++aFound;
} }
if (aFound && (aFound == aIndex)) { if (aFound && (aFound == aIndex)) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, AndroidEntryData[Index].Icon);
AddLoaderEntry(AndroidEntryData[Index].Path, L"", AndroidEntryData[Index].Title, Volume,
ImageX.ToEGImage(), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(AndroidEntryData[Index].Path, L"", AndroidEntryData[Index].Title, Volume, AddLoaderEntry(AndroidEntryData[Index].Path, L"", AndroidEntryData[Index].Title, Volume,
LoadOSIcon(AndroidEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS); LoadOSIcon(AndroidEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#endif
} }
} }
} }
@ -1264,8 +1272,15 @@ VOID ScanLoader(VOID)
if (gSettings.LinuxScan) { if (gSettings.LinuxScan) {
// check for linux loaders // check for linux loaders
for (Index = 0; Index < LinuxEntryDataCount; ++Index) { for (Index = 0; Index < LinuxEntryDataCount; ++Index) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, LinuxEntryData[Index].Icon);
AddLoaderEntry(LinuxEntryData[Index].Path, L"", LinuxEntryData[Index].Title, Volume,
ImageX.ToEGImage(), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(LinuxEntryData[Index].Path, L"", LinuxEntryData[Index].Title, Volume, AddLoaderEntry(LinuxEntryData[Index].Path, L"", LinuxEntryData[Index].Title, Volume,
LoadOSIcon(LinuxEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS); LoadOSIcon(LinuxEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#endif
} }
// check for linux kernels // check for linux kernels
PartGUID = FindGPTPartitionGuidInDevicePath(Volume->DevicePath); PartGUID = FindGPTPartitionGuidInDevicePath(Volume->DevicePath);
@ -1805,7 +1820,13 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
if (Image == NULL) { if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE); Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) { if (Image == NULL) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, Custom->ImagePath);
Image = ImageX.ToEGImage();
#else
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE); Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
#endif
} }
} }
} }
@ -1823,7 +1844,12 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
if (DriveImage == NULL) { if (DriveImage == NULL) {
DriveImage = egLoadImage(SelfRootDir, Custom->DriveImagePath, TRUE); DriveImage = egLoadImage(SelfRootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) { if (DriveImage == NULL) {
#if USE_XTHEME
XImage DriveImageX = ThemeX.GetIcon(Custom->DriveImagePath);
DriveImage = DriveImageX.ToEGImage();
#else
DriveImage = LoadBuiltinIcon(Custom->DriveImagePath); DriveImage = LoadBuiltinIcon(Custom->DriveImagePath);
#endif
} }
} }
} }

View File

@ -69,12 +69,21 @@ VOID AddSecureBootTool(VOID)
Entry = new REFIT_MENU_ENTRY_SECURE_BOOT(); Entry = new REFIT_MENU_ENTRY_SECURE_BOOT();
Entry->Title.SPrintf("Clover Secure Boot Configuration"); Entry->Title.SPrintf("Clover Secure Boot Configuration");
// Entry->Tag = TAG_SECURE_BOOT_CONFIG; // Entry->Tag = TAG_SECURE_BOOT_CONFIG;
#if USE_XTHEME
Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG);
#else
Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG); Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG);
#endif
} else { } else {
Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG(); Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG();
Entry->Title.SPrintf("Enable Clover Secure Boot"); Entry->Title.SPrintf("Enable Clover Secure Boot");
// Entry->Tag = TAG_SECURE_BOOT; // Entry->Tag = TAG_SECURE_BOOT;
#if USE_XTHEME
Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT);
#else
Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_SECURE_BOOT); Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_SECURE_BOOT);
#endif
} }
Entry->Row = 1; Entry->Row = 1;
//actions //actions

View File

@ -36,6 +36,7 @@
#include "entry_scan.h" #include "entry_scan.h"
#include "../refit/menu.h" #include "../refit/menu.h"
#include "../refit/screen.h" #include "../refit/screen.h"
#include "../libeg/XImage.h"
// //
// Clover File location to boot from on removable media devices // Clover File location to boot from on removable media devices
@ -71,10 +72,16 @@
#endif #endif
extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl; extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl;
#if USE_XTHEME
STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, const XImage& Image,
IN CHAR16 ShortcutLetter, IN CONST CHAR16 *Options)
#else
STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle, STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image,
IN CHAR16 ShortcutLetter, IN CONST CHAR16 *Options) IN CHAR16 ShortcutLetter, IN CONST CHAR16 *Options)
#endif
{ {
REFIT_MENU_ENTRY_LOADER_TOOL *Entry; REFIT_MENU_ENTRY_LOADER_TOOL *Entry;
// Check the loader exists // Check the loader exists
@ -131,7 +138,11 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
// Entry->Tag = TAG_CLOVER; // Entry->Tag = TAG_CLOVER;
Entry->Row = 1; Entry->Row = 1;
Entry->ShortcutLetter = 'C'; Entry->ShortcutLetter = 'C';
#if USE_XTHEME
Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_CLOVER);
#else
Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_CLOVER); Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_CLOVER);
#endif
Entry->Volume = Volume; Entry->Volume = Volume;
Entry->LoaderPath = EfiStrDuplicate(LoaderPath); Entry->LoaderPath = EfiStrDuplicate(LoaderPath);
Entry->VolName = Volume->VolName; Entry->VolName = Volume->VolName;
@ -197,11 +208,24 @@ VOID ScanTool(VOID)
UINTN VolumeIndex; UINTN VolumeIndex;
REFIT_VOLUME *Volume; REFIT_VOLUME *Volume;
VOID *Interface; VOID *Interface;
#if USE_XTHEME
if (ThemeX.HideUIFlags & HIDEUI_FLAG_TOOLS)
return;
#else
if (GlobalConfig.DisableFlags & HIDEUI_FLAG_TOOLS) if (GlobalConfig.DisableFlags & HIDEUI_FLAG_TOOLS)
return; return;
#endif
// DBG("Scanning for tools...\n"); // DBG("Scanning for tools...\n");
#if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_SHELL)) {
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL);
}
}
#else
// look for the EFI shell // look for the EFI shell
if (!(GlobalConfig.DisableFlags & HIDEUI_FLAG_SHELL)) { if (!(GlobalConfig.DisableFlags & HIDEUI_FLAG_SHELL)) {
@ -218,6 +242,7 @@ VOID ScanTool(VOID)
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell32.efi", NULL, L"EFI Shell 32", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL); AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell32.efi", NULL, L"EFI Shell 32", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL);
#endif #endif
} }
#endif
// if (!gFirmwareClover) { //Slice: I wish to extend functionality on emulated nvram // if (!gFirmwareClover) { //Slice: I wish to extend functionality on emulated nvram
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) { for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
@ -336,14 +361,20 @@ VOID AddCustomTool(VOID)
} }
} }
} }
#if USE_XTHEME
if (Image == NULL) {
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->Options);
} else {
// Create a legacy entry for this volume
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, XImage().FromEGImage(Image), Custom->Hotkey, Custom->Options);
}
#else
if (Image == NULL) { if (Image == NULL) {
Image = BuiltinIcon(BUILTIN_ICON_TOOL_SHELL); Image = BuiltinIcon(BUILTIN_ICON_TOOL_SHELL);
} }
// Create a legacy entry for this volume // Create a legacy entry for this volume
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, Image, Custom->Hotkey, Custom->Options); AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, Image, Custom->Hotkey, Custom->Options);
#endif
DBG("match!\n"); DBG("match!\n");
// break; // break scan volumes, continue scan entries -- why? // break; // break scan volumes, continue scan entries -- why?
} }

View File

@ -640,7 +640,10 @@ void XImage::CopyRect(const XImage& Image, INTN XPos, INTN YPos)
EG_IMAGE* XImage::ToEGImage() EG_IMAGE* XImage::ToEGImage()
{ {
EG_IMAGE* Tmp = egCreateImage(Width, Height, TRUE); if (isEmpty()) {
return NULL; // what is better, return NULL or empty image?
}
EG_IMAGE* Tmp = egCreateImage(Width, Height, TRUE); //memory leak
CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes()); CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes());
return Tmp; return Tmp;
} }

View File

@ -88,7 +88,15 @@ EFI_STATUS XPointer::MouseBirth()
PointerImage = nullptr; PointerImage = nullptr;
} }
// Now update image because of other theme has other image // Now update image because of other theme has other image
#if USE_XTHEME
// XImage PointerImageX = ThemeX.GetIcon(BUILTIN_ICON_POINTER);
// PointerImage = &PointerImageX;
PointerImage = new XImage(ThemeX.GetIcon(BUILTIN_ICON_POINTER));
#else
PointerImage = new XImage(BuiltinIcon(BUILTIN_ICON_POINTER)); PointerImage = new XImage(BuiltinIcon(BUILTIN_ICON_POINTER));
#endif
oldImage.setSizeInPixels(PointerImage->GetWidth(), PointerImage->GetHeight()); oldImage.setSizeInPixels(PointerImage->GetWidth(), PointerImage->GetHeight());
LastClickTime = 0; LastClickTime = 0;
oldPlace.XPos = (INTN)(UGAWidth >> 2); oldPlace.XPos = (INTN)(UGAWidth >> 2);

View File

@ -281,13 +281,8 @@ EG_IMAGE * BuiltinIcon(IN UINTN Id)
// icon name is shutdown from historic reasons, but function is now exit // icon name is shutdown from historic reasons, but function is now exit
UnicodeSPrint(Text, 30, L"exit"); UnicodeSPrint(Text, 30, L"exit");
} }
#if USE_XTHEME
#else
egRenderText(Text, TextBuffer, 0, 0, 0xFFFF, 1); egRenderText(Text, TextBuffer, 0, 0, 0xFFFF, 1);
BuiltinIconTable[Id].Image = TextBuffer; BuiltinIconTable[Id].Image = TextBuffer;
#endif
DebugLog(1, " [!] Icon %llu: Text <%ls> rendered\n", Id, Text); DebugLog(1, " [!] Icon %llu: Text <%ls> rendered\n", Id, Text);
FreePool(Text); FreePool(Text);
} }

View File

@ -307,7 +307,7 @@ extern INTN ScrollbarYMovement;
typedef struct { typedef struct {
INTN Timeout; INTN Timeout;
UINTN DisableFlags; UINTN DisableFlags; //to disable some volume types (optical, firewire etc)
#if !USE_XTHEME #if !USE_XTHEME
UINTN HideBadges; UINTN HideBadges;
UINTN HideUIFlags; UINTN HideUIFlags;
@ -507,8 +507,8 @@ EFI_STATUS InitializeUnicodeCollationProtocol (VOID);
// local variables // local variables
//extern INTN FontWidth; //extern INTN FontWidth;
//extern INTN FontHeight; //extern INTN FontHeight;
#if !USE_XTHEME
extern INTN TextHeight; extern INTN TextHeight;
#if !USE_XTHEME
extern INTN row0TileSize; extern INTN row0TileSize;
extern INTN row1TileSize; extern INTN row1TileSize;
#endif #endif
@ -557,7 +557,7 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
// //
// icns loader module // icns loader module
// //
#if !USE_XTHEME
EG_IMAGE * LoadOSIcon(IN CONST CHAR16 *OSIconName OPTIONAL, IN CONST CHAR16 *FallbackIconName, IN UINTN PixelSize, IN BOOLEAN BootLogo, IN BOOLEAN WantDummy); EG_IMAGE * LoadOSIcon(IN CONST CHAR16 *OSIconName OPTIONAL, IN CONST CHAR16 *FallbackIconName, IN UINTN PixelSize, IN BOOLEAN BootLogo, IN BOOLEAN WantDummy);
EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize); EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize);
EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize); EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize);
@ -565,6 +565,7 @@ EG_IMAGE * DummyImage(IN UINTN PixelSize);
EG_IMAGE * BuiltinIcon(IN UINTN Id); EG_IMAGE * BuiltinIcon(IN UINTN Id);
CHAR16 * GetIconsExt(IN CONST CHAR16 *Icon, IN CONST CHAR16 *Def); CHAR16 * GetIconsExt(IN CONST CHAR16 *Icon, IN CONST CHAR16 *Def);
EG_IMAGE * GetSmallHover(IN UINTN Id); EG_IMAGE * GetSmallHover(IN UINTN Id);
#endif
#define BUILTIN_ICON_FUNC_ABOUT (0) #define BUILTIN_ICON_FUNC_ABOUT (0)
#define BUILTIN_ICON_FUNC_OPTIONS (1) #define BUILTIN_ICON_FUNC_OPTIONS (1)
@ -623,11 +624,13 @@ EG_IMAGE * GetSmallHover(IN UINTN Id);
#define ICON_FORMAT_PNG (2) #define ICON_FORMAT_PNG (2)
#define ICON_FORMAT_BMP (3) #define ICON_FORMAT_BMP (3)
VOID ReinitVolumes(VOID); VOID ReinitVolumes(VOID);
BOOLEAN ReadAllKeyStrokes(VOID); BOOLEAN ReadAllKeyStrokes(VOID);
// //
// config module // config module
// //
#if !USE_XTHEME
typedef struct MISC_ICONS { typedef struct MISC_ICONS {
EG_IMAGE *image; EG_IMAGE *image;
CONST CHAR8 *name; CONST CHAR8 *name;
@ -635,6 +638,7 @@ typedef struct MISC_ICONS {
extern MISC_ICONS OSIconsTable[]; extern MISC_ICONS OSIconsTable[];
extern BUILTIN_ICON BuiltinIconTable[]; extern BUILTIN_ICON BuiltinIconTable[];
#endif
extern REFIT_CONFIG GlobalConfig; extern REFIT_CONFIG GlobalConfig;
VOID ReadConfig(INTN What); VOID ReadConfig(INTN What);

View File

@ -111,7 +111,7 @@ extern VOID AboutRefit(VOID);
extern BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize, LOADER_ENTRY *Entry); extern BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize, LOADER_ENTRY *Entry);
extern UINTN ThemesNum; extern UINTN ThemesNum;
extern CHAR16 *ThemesList[]; extern CONST CHAR16 *ThemesList[];
extern UINTN ConfigsNum; extern UINTN ConfigsNum;
extern CHAR16 *ConfigsList[]; extern CHAR16 *ConfigsList[];
extern UINTN DsdtsNum; extern UINTN DsdtsNum;
@ -1026,7 +1026,12 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
egClearScreen(&DarkBackgroundPixel); egClearScreen(&DarkBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/); BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
#if USE_XTHEME
XImage BootLogoX;
BootLogoX.LoadXImage(ThemeDir, Entry->Volume->LegacyOS->IconName);
BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1,
(UGAHeight - BootLogoX.GetHeight()) >> 1);
#else
BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE); BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE);
if (BootLogoImage != NULL) { if (BootLogoImage != NULL) {
BltImageAlpha(BootLogoImage, BltImageAlpha(BootLogoImage,
@ -1034,6 +1039,8 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
(UGAHeight - BootLogoImage->Height) >> 1, (UGAHeight - BootLogoImage->Height) >> 1,
&StdBackgroundPixel, 16); &StdBackgroundPixel, 16);
} }
#endif
//try my LegacyBoot //try my LegacyBoot
switch (Entry->Volume->BootType) { switch (Entry->Volume->BootType) {
case BOOTING_BY_CD: case BOOTING_BY_CD:

View File

@ -74,7 +74,7 @@ static INTN MaxItemOnScreen = -1;
REFIT_MENU_SCREEN OptionMenu(4, L"Options", NULL); REFIT_MENU_SCREEN OptionMenu(4, L"Options", NULL);
extern REFIT_MENU_ITEM_RETURN MenuEntryReturn; extern REFIT_MENU_ITEM_RETURN MenuEntryReturn;
extern UINTN ThemesNum; extern UINTN ThemesNum;
extern CHAR16 *ThemesList[]; extern CONST CHAR16 *ThemesList[];
extern UINTN ConfigsNum; extern UINTN ConfigsNum;
extern CHAR16 *ConfigsList[]; extern CHAR16 *ConfigsList[];
extern UINTN DsdtsNum; extern UINTN DsdtsNum;
@ -787,6 +787,15 @@ VOID ApplyInputs(VOID)
} }
i++; //3 i++; //3
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
#if USE_XTHEME
if (OldChosenTheme == 0xFFFF) {
ThemeX.Theme.takeValueFrom("embedded");
} else {
ThemeX.Theme.takeValueFrom(ThemesList[OldChosenTheme]);
ThemeX.DarkEmbedded = FALSE;
ThemeX.Font = FONT_ALFA;
}
#else
if (GlobalConfig.Theme) { if (GlobalConfig.Theme) {
FreePool(GlobalConfig.Theme); FreePool(GlobalConfig.Theme);
} }
@ -797,6 +806,7 @@ VOID ApplyInputs(VOID)
GlobalConfig.DarkEmbedded = FALSE; GlobalConfig.DarkEmbedded = FALSE;
GlobalConfig.Font = FONT_ALFA; GlobalConfig.Font = FONT_ALFA;
} }
#endif
//will change theme after ESC //will change theme after ESC
gThemeChanged = TRUE; gThemeChanged = TRUE;
@ -1340,7 +1350,6 @@ VOID ApplyInputs(VOID)
gBootChanged = TRUE; gBootChanged = TRUE;
} }
if (NeedSave) { if (NeedSave) {
SaveSettings(); SaveSettings();
} }
@ -1375,12 +1384,20 @@ VOID REFIT_MENU_SCREEN::AddMenuInfo_f(CONST char *format, ...)
VOID AboutRefit(VOID) VOID AboutRefit(VOID)
{ {
// CHAR8* Revision = NULL; #if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
AboutMenu.TitleImage = ThemeX.GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT);
} else {
AboutMenu.TitleImage.setEmpty();
}
#else
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
} else { } else {
AboutMenu.TitleImage = NULL; AboutMenu.TitleImage = NULL;
} }
#endif
if (AboutMenu.Entries.size() == 0) { if (AboutMenu.Entries.size() == 0) {
// AboutMenu.AddMenuInfo_f(("Clover Version 5.0")); // AboutMenu.AddMenuInfo_f(("Clover Version 5.0"));
#ifdef REVISION_STR #ifdef REVISION_STR
@ -1436,11 +1453,19 @@ VOID AboutRefit(VOID)
VOID HelpRefit(VOID) VOID HelpRefit(VOID)
{ {
#if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
HelpMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_HELP);
} else {
HelpMenu.TitleImage.setEmpty();
}
#else
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
HelpMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_HELP); HelpMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_HELP);
} else { } else {
HelpMenu.TitleImage = NULL; HelpMenu.TitleImage = NULL;
} }
#endif
if (HelpMenu.Entries.size() == 0) { if (HelpMenu.Entries.size() == 0) {
switch (gLanguage) switch (gLanguage)
{ {
@ -3241,6 +3266,21 @@ VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAl
CHAR16 *BCSText = NULL; CHAR16 *BCSText = NULL;
// more space, more characters // more space, more characters
#if USE_XTHEME
if (ThemeX.TileXSpace >= 25 && ThemeX.TileXSpace < 30) {
MaxTextLen = 14;
} else if (ThemeX.TileXSpace >= 30 && ThemeX.TileXSpace < 35) {
MaxTextLen = 15;
} else if (ThemeX.TileXSpace >= 35 && ThemeX.TileXSpace < 40) {
MaxTextLen = 16;
} else if (ThemeX.TileXSpace >= 40 && ThemeX.TileXSpace < 45) {
MaxTextLen = 17;
} else if (ThemeX.TileXSpace >= 45 && ThemeX.TileXSpace < 50) {
MaxTextLen = 18;
} else if (ThemeX.TileXSpace >= 50) {
MaxTextLen = 19;
}
#else
if (GlobalConfig.TileXSpace >= 25 && GlobalConfig.TileXSpace < 30) { if (GlobalConfig.TileXSpace >= 25 && GlobalConfig.TileXSpace < 30) {
MaxTextLen = 14; MaxTextLen = 14;
} else if (GlobalConfig.TileXSpace >= 30 && GlobalConfig.TileXSpace < 35) { } else if (GlobalConfig.TileXSpace >= 30 && GlobalConfig.TileXSpace < 35) {
@ -3254,6 +3294,7 @@ VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAl
} else if (GlobalConfig.TileXSpace >= 50) { } else if (GlobalConfig.TileXSpace >= 50) {
MaxTextLen = 19; MaxTextLen = 19;
} }
#endif
MaxTextLen += EllipsisLen; MaxTextLen += EllipsisLen;
@ -5117,7 +5158,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
row0PosXRunning += EntriesWidth + EntriesGap; row0PosXRunning += EntriesWidth + EntriesGap;
} else { } else {
itemPosX[i] = row1PosXRunning; itemPosX[i] = row1PosXRunning;
row1PosXRunning += row1TileSize + (INTN)(TILE1_XSPACING * ThemeX.Scale); row1PosXRunning += ThemeX.row1TileSize + (INTN)(TILE1_XSPACING * ThemeX.Scale);
//DBG("next item in row1 at x=%d\n", row1PosXRunning); //DBG("next item in row1 at x=%d\n", row1PosXRunning);
} }
} }
@ -5149,12 +5190,12 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
// draw static text for the boot options, BootCampStyle // draw static text for the boot options, BootCampStyle
if (ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) { if (ThemeX.BootCampStyle && !(ThemeX.HideUIFlags & HIDEUI_FLAG_LABEL)) {
INTN textPosX = itemPosX[i - ScrollState.FirstVisible] + (row0TileSize / 2); INTN textPosX = itemPosX[i - ScrollState.FirstVisible] + (ThemeX.row0TileSize / 2);
// clear the screen // clear the screen
ThemeX.FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + GlobalConfig.TileXSpace, ThemeX.FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + ThemeX.TileXSpace,
MessageHeight); MessageHeight);
DrawBCSText(Entries[i].Title, textPosX, textPosY, X_IS_CENTER); DrawBCSText(Entries[i].Title.data(), textPosX, textPosY, X_IS_CENTER);
} }
} }
} else { } else {
@ -5356,7 +5397,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + GlobalConfig.TileXSpace, FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + GlobalConfig.TileXSpace,
MessageHeight, &MenuBackgroundPixel, X_IS_CENTER); MessageHeight, &MenuBackgroundPixel, X_IS_CENTER);
// draw the text // draw the text
DrawBCSText(Entries[i].Title, textPosX, textPosY, X_IS_CENTER); DrawBCSText(Entries[i].Title.data(), textPosX, textPosY, X_IS_CENTER);
} }
} }
} else { } else {
@ -6632,9 +6673,9 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
// FillInputs and ApplyInputs // FillInputs and ApplyInputs
#if USE_XTHEME #if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
OptionMenu.TitleImage = (*ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS)).ToEGImage(); OptionMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS);
} else { } else {
OptionMenu.TitleImage = NULL; OptionMenu.TitleImage.setEmpty();
} }
#else #else
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
@ -6720,7 +6761,13 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
} // if MENU_EXIT_ENTER } // if MENU_EXIT_ENTER
} }
//exit: //exit:
#if USE_XTHEME
ThemeX.Proportional = OldFontStyle;
#else
GlobalConfig.Proportional = OldFontStyle; GlobalConfig.Proportional = OldFontStyle;
#endif
ApplyInputs(); ApplyInputs();
} }
@ -6797,11 +6844,19 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
if (AllowGraphicsMode) { if (AllowGraphicsMode) {
Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle; Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle;
#if USE_XTHEME
if (ThemeX.VerticalLayout) {
MainStyle = &REFIT_MENU_SCREEN::MainMenuVerticalStyle;
} else {
MainStyle = &REFIT_MENU_SCREEN::MainMenuStyle;
}
#else
if (GlobalConfig.VerticalLayout) { if (GlobalConfig.VerticalLayout) {
MainStyle = &REFIT_MENU_SCREEN::MainMenuVerticalStyle; MainStyle = &REFIT_MENU_SCREEN::MainMenuVerticalStyle;
} else { } else {
MainStyle = &REFIT_MENU_SCREEN::MainMenuStyle; MainStyle = &REFIT_MENU_SCREEN::MainMenuStyle;
} }
#endif
} }
while (!MenuExit) { while (!MenuExit) {