big cleanup to XTHEME

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-10 13:04:21 +03:00
parent d74b431b6f
commit 84a320ba5d
30 changed files with 79 additions and 6486 deletions

View File

@ -811,25 +811,16 @@ typedef struct CUSTOM_LOADER_ENTRY CUSTOM_LOADER_ENTRY;
struct CUSTOM_LOADER_ENTRY {
CUSTOM_LOADER_ENTRY *Next;
CUSTOM_LOADER_ENTRY *SubEntries;
#if USE_XTHEME
XImage Image;
XImage DriveImage;
#else
EG_IMAGE *Image;
EG_IMAGE *DriveImage;
#endif
CONST CHAR16 *ImagePath;
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
CONST CHAR16 *Path;
XString Options;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
#else
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
#endif
CONST CHAR16 *Settings;
CHAR16 Hotkey;
BOOLEAN CommonSettings;
@ -839,22 +830,12 @@ struct CUSTOM_LOADER_ENTRY {
UINT8 KernelScan;
UINT8 CustomBoot;
EG_IMAGE *CustomLogo;
#if USE_XTHEME
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor;
#else
EG_PIXEL *BootBgColor; //why it is array? It is one value!
#endif
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
#if USE_XTHEME
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), ImagePath(0), DriveImagePath(0), Volume(0), Path(0), Settings(0), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
KernelScan(0), CustomBoot(0), CustomLogo(0), BootBgColor({0,0,0,0})
{ memset(&KernelAndKextPatches, 0, sizeof(KernelAndKextPatches)); }
#else
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), Image(0), DriveImage(0), ImagePath(0), DriveImagePath(0), Volume(0), Path(0), FullTitle(0), Title(0), Settings(0), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
KernelScan(0), CustomBoot(0), CustomLogo(0), BootBgColor(0)
{ memset(&KernelAndKextPatches, 0, sizeof(KernelAndKextPatches)); }
#endif
// Not sure if default are valid. Delete them. If needed, proper ones can be created
CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY&) = delete;
@ -865,23 +846,13 @@ struct CUSTOM_LOADER_ENTRY {
typedef struct CUSTOM_LEGACY_ENTRY CUSTOM_LEGACY_ENTRY;
struct CUSTOM_LEGACY_ENTRY {
CUSTOM_LEGACY_ENTRY *Next;
#if USE_XTHEME
XImage Image;
XImage DriveImage;
#else
EG_IMAGE *Image;
EG_IMAGE *DriveImage;
#endif
CONST CHAR16 *ImagePath;
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
#else
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
#endif
CHAR16 Hotkey;
UINT8 Flags;
UINT8 Type;
@ -891,22 +862,13 @@ struct CUSTOM_LEGACY_ENTRY {
typedef struct CUSTOM_TOOL_ENTRY CUSTOM_TOOL_ENTRY;
struct CUSTOM_TOOL_ENTRY {
CUSTOM_TOOL_ENTRY *Next;
#if USE_XTHEME
XImage Image;
#else
EG_IMAGE *Image;
#endif
CHAR16 *ImagePath;
CHAR16 *Volume;
CHAR16 *Path;
XString Options;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
#else
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
#endif
CHAR16 Hotkey;
UINT8 Flags;
UINT8 VolumeType;

File diff suppressed because it is too large Load Diff

View File

@ -82,28 +82,19 @@ EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName)
}
while (Index < BuiltinIconNamesCount) {
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);
#endif
}
++Index;
}
return NULL;
}
#if USE_XTHEME
const XImage& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
#else
EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) //IN UINT8 DiskKind)
#endif
{
UINTN IconNum = 0;
#if USE_XTHEME
const XImage* IconX;
#endif
// default volume icon based on disk kind
switch (Volume->DiskKind) {
case DISK_KIND_INTERNAL:
@ -137,7 +128,6 @@ EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DE
IconNum = BUILTIN_ICON_VOL_INTERNAL;
break;
}
#if USE_XTHEME
break;
case DISK_KIND_EXTERNAL:
IconNum = BUILTIN_ICON_VOL_EXTERNAL;
@ -157,25 +147,11 @@ EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DE
}
IconX = &ThemeX.GetIcon(IconNum);
if (IconX->isEmpty()) {
DBG("asked IconNum = %llu not found, took internal\n", IconNum);
IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_INTERNAL); //including embedded which is really present
}
return *IconX;
#else
return BuiltinIcon(IconNum);
case DISK_KIND_EXTERNAL:
return BuiltinIcon(BUILTIN_ICON_VOL_EXTERNAL);
case DISK_KIND_OPTICAL:
return BuiltinIcon(BUILTIN_ICON_VOL_OPTICAL);
case DISK_KIND_FIREWIRE:
return BuiltinIcon(BUILTIN_ICON_VOL_FIREWIRE);
case DISK_KIND_BOOTER:
return BuiltinIcon(BUILTIN_ICON_VOL_BOOTER);
default:
break;
}
return NULL;
#endif
}
@ -322,7 +298,7 @@ VOID StrToLower(IN CHAR16 *Str)
}
// TODO remove that and AlertMessage with a printf-like format
#if USE_XTHEME
STATIC void CreateInfoLines(IN CONST XStringW& Message, OUT XStringWArray* Information)
{
if (Message.isEmpty()) {
@ -331,7 +307,8 @@ STATIC void CreateInfoLines(IN CONST XStringW& Message, OUT XStringWArray* Infor
Information->Empty();
//TODO will fill later
}
#else
#if 0 //not needed?
STATIC void CreateInfoLines(IN CONST CHAR16 *Message, OUT XStringWArray* Information)
{
CONST CHAR16 *Ptr;
@ -378,7 +355,6 @@ extern REFIT_MENU_ITEM_RETURN MenuEntryReturn;
// it is not good to use Options menu style for messages and one line dialogs
// it can be a semitransparent rectangular at the screen centre as it was in Clover v1.0
#if USE_XTHEME
STATIC REFIT_MENU_SCREEN AlertMessageMenu(0, XStringW(), XStringW(), &MenuEntryReturn, NULL);
VOID AlertMessage(IN XStringW& Title, IN CONST XStringW& Message)
{
@ -387,32 +363,6 @@ VOID AlertMessage(IN XStringW& Title, IN CONST XStringW& Message)
AlertMessageMenu.RunMenu(NULL);
AlertMessageMenu.InfoLines.Empty();
}
#else
STATIC REFIT_MENU_SCREEN AlertMessageMenu(0, NULL, NULL, &MenuEntryReturn, NULL);
// Display an alert message
VOID AlertMessage(IN CONST CHAR16 *Title, IN CONST CHAR16 *Message)
{
// UINTN Count = 0;
// Break message into info lines
// CHAR16 **Information = CreateInfoLines(Message, &Count);
CreateInfoLines(Message, &AlertMessageMenu.InfoLines);
AlertMessageMenu.Title = EfiStrDuplicate(Title);
AlertMessageMenu.RunMenu(NULL);
// // Check parameters
// if (Information != NULL) {
// if (Count > 0) {
// // Display the alert message
// AlertMessageMenu.InfoLineCount = Count;
// AlertMessageMenu.InfoLines = (CONST CHAR16**)Information;
// AlertMessageMenu.Title = Title;
// RunMenu(&AlertMessageMenu, NULL);
// }
// FreePool(Information);
// }
AlertMessageMenu.InfoLines.Empty();
}
#endif
#define TAG_YES 1
#define TAG_NO 2
@ -422,13 +372,8 @@ STATIC REFIT_SIMPLE_MENU_ENTRY_TAG YesMessageEntry(XStringW().takeValueFrom(L"
STATIC REFIT_SIMPLE_MENU_ENTRY_TAG NoMessageEntry(XStringW().takeValueFrom(L"No"), TAG_NO, ActionEnter);
//REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
#if USE_XTHEME
STATIC REFIT_MENU_SCREEN YesNoMessageMenu(0, XStringW(), XStringW(), &YesMessageEntry, &NoMessageEntry);
#else
STATIC REFIT_MENU_SCREEN YesNoMessageMenu(0, NULL, NULL, &YesMessageEntry, &NoMessageEntry);
#endif
// Display a yes/no prompt
#if USE_XTHEME
BOOLEAN YesNoMessage(IN XStringW& Title, IN CONST XStringW& Message)
{
BOOLEAN Result = FALSE;
@ -448,35 +393,6 @@ BOOLEAN YesNoMessage(IN XStringW& Title, IN CONST XStringW& Message)
YesNoMessageMenu.InfoLines.Empty();
return Result;
}
#else
BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CONST CHAR16 *Message)
{
BOOLEAN Result = FALSE;
UINTN /*Count = 0,*/ MenuExit;
// Break message into info lines
// CHAR16 **Information = CreateInfoLines(Message, &Count);
CreateInfoLines(Message, &YesNoMessageMenu.InfoLines);
// Display the yes/no message
// YesNoMessageMenu.InfoLineCount = Count;
// YesNoMessageMenu.InfoLines = (CONST CHAR16**)Information;
YesNoMessageMenu.Title = Title;
do
{
REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry = NULL;
MenuExit = YesNoMessageMenu.RunMenu(&ChosenEntry);
if ( ChosenEntry != NULL && ChosenEntry->getREFIT_SIMPLE_MENU_ENTRY_TAG() && ChosenEntry->getREFIT_SIMPLE_MENU_ENTRY_TAG()->Tag == TAG_YES &&
((MenuExit == MENU_EXIT_ENTER) || (MenuExit == MENU_EXIT_DETAILS))) {
Result = TRUE;
MenuExit = MENU_EXIT_ENTER;
}
} while (MenuExit != MENU_EXIT_ENTER);
YesNoMessageMenu.InfoLines.Empty();
// if (Information != NULL) {
// FreePool(Information);
// }
return Result;
}
#endif
// Ask user for file path from directory menu
BOOLEAN AskUserForFilePathFromDir(IN CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Volume,
IN CHAR16 *ParentPath OPTIONAL, IN EFI_FILE *Dir,
@ -497,28 +413,16 @@ BOOLEAN AskUserForFilePathFromDir(IN CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Vo
//STATIC REFIT_MENU_SCREEN InitialMenu = {0, L"Please Select File...", NULL, 0, NULL,
// 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
// { 0, 0, 0, 0 }, NULL};
#if USE_XTHEME
STATIC REFIT_MENU_SCREEN InitialMenu(0, L"Please Select File..."_XSW, XStringW());
#else
STATIC REFIT_MENU_SCREEN InitialMenu(0, L"Please Select File...", NULL);
#endif
// Ask user for file path from volumes menu
BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **Result)
{
REFIT_MENU_SCREEN Menu = InitialMenu;
// REFIT_MENU_ENTRY **Entries;
// REFIT_MENU_ENTRY *EntryPtr;
UINTN Index = 0, /*Count = 0,*/ MenuExit;
BOOLEAN Responded = FALSE;
if (Result == NULL) {
return FALSE;
}
// Allocate entries
// Entries = (REFIT_MENU_ENTRY **)AllocateZeroPool(sizeof(REFIT_MENU_ENTRY *) + ((sizeof(REFIT_MENU_ENTRY *) + sizeof(REFIT_MENU_ENTRY)) * Volumes.size()));
// if (Entries == NULL) {
// return FALSE;
// }
// EntryPtr = (REFIT_MENU_ENTRY *)(Entries + (Volumes.size() + 1));
// Create volume entries
for (Index = 0; Index < Volumes.size(); ++Index) {
REFIT_VOLUME *Volume = &Volumes[Index];
@ -527,23 +431,12 @@ BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_
continue;
}
REFIT_SIMPLE_MENU_ENTRY_TAG *Entry = new REFIT_SIMPLE_MENU_ENTRY_TAG(SWPrintf("%ls", (Volume->VolName == NULL) ? Volume->DevicePathString : Volume->VolName), TAG_OFFSET + Index, MENU_EXIT_ENTER);
// Entry = Entries[Count++] = EntryPtr++;
// Entry->Title = (Volume->VolName == NULL) ? Volume->DevicePathString : Volume->VolName;
// Entry->Tag = TAG_OFFSET + Index;
// Entry->AtClick = MENU_EXIT_ENTER;
Menu.Entries.AddReference(Entry, true);
}
// Setup menu
// CopyMem(&Menu, &InitialMenu, sizeof(REFIT_MENU_SCREEN));
// Entries[Count++] = &MenuEntryReturn;
Menu.Entries.AddReference(&MenuEntryReturn, false);
// Menu.Entries.size() = Count;
// Menu.Entries = Entries;
#if USE_XTHEME
Menu.Title.takeValueFrom(Title);
#else
Menu.Title = Title;
#endif
do
{
REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry = NULL;

View File

@ -46,22 +46,8 @@ extern REFIT_MENU_SCREEN MainMenu;
extern XObjArray<REFIT_VOLUME> Volumes;
// common
#if USE_XTHEME
const XImage& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath);
#else
EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName);
EG_IMAGE * ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath);
#endif
/*
INTN StrniCmp(IN CHAR16 *Str1,
IN CHAR16 *Str2,
IN UINTN Count);
CHAR16 *StriStr(IN CHAR16 *Str,
IN CHAR16 *SearchFor);
VOID StrToLower(IN CHAR16 *Str);
VOID AlertMessage(IN CHAR16 *Title, IN CHAR16 *Message);
BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CHAR16 *Message);
*/
// Ask user for file path from directory menu
BOOLEAN AskUserForFilePathFromDir(IN CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Volume,

View File

@ -50,14 +50,8 @@
#endif
//the function is not in the class and deals always with MainMenu
#if USE_XTHEME
//I made args as pointers to have an ability to call with NULL
BOOLEAN AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& LoaderTitle, IN REFIT_VOLUME *Volume, IN const XImage* Image, IN const XImage* DriveImage, IN CHAR16 Hotkey, IN BOOLEAN CustomEntry)
#else
BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN EG_IMAGE *DriveImage, IN CHAR16 Hotkey, IN BOOLEAN CustomEntry)
#endif
{
LEGACY_ENTRY *Entry, *SubEntry;
REFIT_MENU_SCREEN *SubScreen;
@ -69,21 +63,17 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
return false;
}
// Ignore this loader if it's device path is already present in another loader
// if (MainMenu.Entries) {
for (UINTN i = 0; i < MainMenu.Entries.size(); ++i) {
REFIT_ABSTRACT_MENU_ENTRY& MainEntry = MainMenu.Entries[i];
// DBG("entry %lld\n", i);
// Only want legacy
// if (MainEntry && (MainEntry->getLEGACY_ENTRY())) {
if (MainEntry.getLEGACY_ENTRY()) {
// DBG("a1\n");
if (StriCmp(MainEntry.getLEGACY_ENTRY()->DevicePathString, Volume->DevicePathString) == 0) {
return true;
}
}
}
// }
// If this isn't a custom entry make sure it's not hidden by a custom entry
if (!CustomEntry) {
CUSTOM_LEGACY_ENTRY *Custom = gSettings.CustomLegacy;
@ -110,7 +100,6 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
Custom = Custom->Next;
}
}
#if USE_XTHEME
XStringW LTitle;
if (LoaderTitle.isEmpty()) {
if (Volume->LegacyOS->Name != NULL) {
@ -121,18 +110,6 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
LTitle = L"Legacy OS"_XSW;
} else
LTitle = LoaderTitle;
#else
if (LoaderTitle == NULL) {
if (Volume->LegacyOS->Name != NULL) {
LoaderTitle = Volume->LegacyOS->Name;
if (LoaderTitle[0] == 'W' || LoaderTitle[0] == 'L')
ShortcutLetter = LoaderTitle[0];
} else
LoaderTitle = EfiStrDuplicate( L"Legacy OS");
// DBG("LoaderTitle=%ls\n", LoaderTitle);
}
#endif
if (Volume->VolName != NULL)
VolDesc = Volume->VolName;
else
@ -141,7 +118,6 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
// prepare the menu entry
Entry = new LEGACY_ENTRY();
#if USE_XTHEME
if (!FullTitle.isEmpty()) {
Entry->Title = FullTitle;
} else {
@ -152,24 +128,11 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
// Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle->wc_str(), VolDesc);
}
}
#else
if (FullTitle) {
Entry->Title.takeValueFrom(FullTitle);
} else {
if (GlobalConfig.BootCampStyle) {
Entry->Title.takeValueFrom(LoaderTitle);
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle, VolDesc);
}
}
#endif
// DBG("Title=%ls\n", Entry->Title);
// Entry->Tag = TAG_LEGACY;
Entry->Row = 0;
Entry->ShortcutLetter = (Hotkey == 0) ? ShortcutLetter : Hotkey;
#if USE_XTHEME
if (Image) {
Entry->Image = *Image;
} else {
@ -178,20 +141,10 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
Entry->Image = ThemeX.GetIcon("os_win"_XS); //we have no legacy.png
}
}
#else
if (Image) {
Entry->Image = Image;
} else {
Entry->Image = LoadOSIcon(Volume->LegacyOS->IconName, L"legacy", 128, FALSE, TRUE);
}
#endif
// DBG("IconName=%ls\n", Volume->LegacyOS->IconName);
#if USE_XTHEME
Entry->DriveImage = (DriveImage != NULL) ? *DriveImage : ScanVolumeDefaultIcon(Volume, Volume->LegacyOS->Type, Volume->DevicePath);
#else
Entry->DriveImage = (DriveImage != NULL) ? DriveImage : ScanVolumeDefaultIcon(Volume, Volume->LegacyOS->Type, Volume->DevicePath);
#endif
// DBG("HideBadges=%d Volume=%ls\n", GlobalConfig.HideBadges, Volume->VolName);
// DBG("Title=%ls OSName=%ls OSIconName=%ls\n", LoaderTitle, Volume->OSName, Volume->OSIconName);
@ -199,7 +152,6 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
Entry->AtClick = ActionSelect;
Entry->AtDoubleClick = ActionEnter;
Entry->AtRightClick = ActionDetails;
#if USE_XTHEME
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = XImage(Entry->DriveImage, ThemeX.BadgeScale/16.f); //0 accepted
@ -207,37 +159,20 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
Entry->BadgeImage = XImage(Entry->Image, ThemeX.BadgeScale/16.f);
}
}
#else
if (GlobalConfig.HideBadges & HDBADGES_SHOW) {
if (GlobalConfig.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, GlobalConfig.BadgeScale);
} else {
Entry->BadgeImage = egCopyScaledImage(Entry->Image, GlobalConfig.BadgeScale);
}
}
#endif
Entry->Volume = Volume;
Entry->DevicePathString = Volume->DevicePathString;
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD"_XS : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB"_XS : "HD"_XS);
// create the submenu
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN();
#if USE_XTHEME
SubScreen->Title = L"Boot Options for "_XSW + LoaderTitle + L" on "_XSW + VolDesc;
// SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle, VolDesc);
#else
SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", LoaderTitle, VolDesc);
#endif
// SubScreen->Title = L"Boot Options for "_XSW + LoaderTitle + L" on "_XSW + VolDesc;
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle.wc_str(), VolDesc);
SubScreen->TitleImage = Entry->Image;
SubScreen->AnimeRun = SubScreen->GetAnime();
// default entry
// SubEntry = (__typeof__(SubEntry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
SubEntry = new LEGACY_ENTRY();
#if USE_XTHEME
SubEntry->Title = L"Boot "_XSW + LoaderTitle;
#else
SubEntry->Title.SWPrintf("Boot %ls", LoaderTitle);
#endif
// SubEntry->Tag = TAG_LEGACY;
SubEntry->Volume = Entry->Volume;
SubEntry->DevicePathString = Entry->DevicePathString;
@ -338,12 +273,8 @@ VOID AddCustomLegacy(VOID)
BOOLEAN ShowVolume, HideIfOthersFound;
REFIT_VOLUME *Volume;
CUSTOM_LEGACY_ENTRY *Custom;
#if USE_XTHEME
XImage Image;
XImage DriveImage;
#else
EG_IMAGE *Image, *DriveImage;
#endif
UINTN i = 0;
// DBG("Custom legacy start\n");
@ -444,31 +375,12 @@ VOID AddCustomLegacy(VOID)
}
// Change to custom image if needed
Image = Custom->Image;
#if USE_XTHEME
if (Image.isEmpty()) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
#else
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(ThemeDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
}
}
}
}
}
#endif
// Change to custom drive image if needed
DriveImage = Custom->DriveImage;
#if USE_XTHEME
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(ThemeX.ThemeDir, Custom->DriveImagePath);
}
@ -477,28 +389,6 @@ VOID AddCustomLegacy(VOID)
{
DBG("match!\n");
}
#else
if ((DriveImage == NULL) && Custom->DriveImagePath) {
DriveImage = egLoadImage(Volume->RootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = egLoadImage(ThemeDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = egLoadImage(SelfDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = egLoadImage(SelfRootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = LoadBuiltinIcon(Custom->DriveImagePath);
}
}
}
}
}
// Create a legacy entry for this volume
if (AddLegacyEntry(Custom->FullTitle, Custom->Title, Volume, Image, DriveImage, Custom->Hotkey, TRUE))
{
DBG("match!\n");
}
#endif
}
}
//DBG("Custom legacy end\n");

View File

@ -426,7 +426,6 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry)
}
return Status;
}
#if USE_XTHEME
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST XString& LoaderOptions,
IN CONST XStringW& FullTitle,
@ -442,25 +441,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN EG_IMAGE *CustomLogo,
IN KERNEL_AND_KEXT_PATCHES *Patches,
IN BOOLEAN CustomEntry)
#else
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST XString& LoaderOptions,
IN CONST CHAR16 *FullTitle,
IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume,
IN EG_IMAGE *Image,
IN EG_IMAGE *DriveImage,
IN UINT8 OSType,
IN UINT8 Flags,
IN CHAR16 Hotkey,
EG_PIXEL *BootBgColor,
IN UINT8 CustomBoot,
IN EG_IMAGE *CustomLogo,
IN KERNEL_AND_KEXT_PATCHES *Patches,
IN BOOLEAN CustomEntry)
#endif
{
EFI_DEVICE_PATH *LoaderDevicePath;
CONST CHAR16 *LoaderDevicePathString;
@ -683,8 +663,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
break;
}
#if USE_XTHEME
Entry->Title = FullTitle;
if (Entry->Title.isEmpty() && Volume->VolLabel != NULL) {
if (Volume->VolLabel[0] == L'#') {
@ -695,22 +673,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
}
BOOLEAN BootCampStyle = ThemeX.BootCampStyle;
#else
if (FullTitle) {
Entry->Title.takeValueFrom(FullTitle);
}
if ( Entry->Title.isEmpty() && Volume->VolLabel != NULL ) {
if ( Volume->VolLabel[0] == L'#' ) {
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel+1);
}else{
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel);
}
}
BOOLEAN BootCampStyle = GlobalConfig.BootCampStyle;
#endif
#if USE_XTHEME
if ( Entry->Title.isEmpty() && ((Entry->VolName == NULL) || (StrLen(Entry->VolName) == 0)) ) {
//DBG("encounter Entry->VolName ==%ls and StrLen(Entry->VolName) ==%d\n",Entry->VolName, StrLen(Entry->VolName));
if (BootCampStyle) {
@ -741,30 +704,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->VolName);
}
}
#else
if ( Entry->Title.isEmpty() && ((Entry->VolName == NULL) || (StrLen(Entry->VolName) == 0)) ) {
//DBG("encounter Entry->VolName ==%ls and StrLen(Entry->VolName) ==%d\n",Entry->VolName, StrLen(Entry->VolName));
if (BootCampStyle) {
Entry->Title.takeValueFrom(((LoaderTitle != NULL) ? LoaderTitle : Basename(Volume->DevicePathString)));
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath),
Basename(Volume->DevicePathString));
}
}
if ( Entry->Title.isEmpty() ) {
//DBG("encounter LoaderTitle ==%ls and Entry->VolName ==%ls\n", LoaderTitle, Entry->VolName);
if (BootCampStyle) {
if ((StriCmp(LoaderTitle, L"macOS") == 0) || (StriCmp(LoaderTitle, L"Recovery") == 0)) {
Entry->Title.takeValueFrom(Entry->VolName);
} else {
Entry->Title.takeValueFrom((LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath));
}
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath),
Entry->VolName);
}
}
#endif
//DBG("Entry->Title =%ls\n", Entry->Title);
// just an example that UI can show hibernated volume to the user
// should be better to show it on entry image
@ -775,7 +714,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->ShortcutLetter = (Hotkey == 0) ? ShortcutLetter : Hotkey;
// get custom volume icon if present
#if USE_XTHEME
if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){
Entry->Image.LoadIcns(Volume->RootDir, L"\\.VolumeIcon.icns", 128);
DBG("using VolumeIcon.icns image from Volume\n");
@ -790,22 +728,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
} else {
Entry->DriveImage = ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
}
#else
if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){
Entry->Image = LoadIcns(Volume->RootDir, L"\\.VolumeIcon.icns", 128);
DBG("using VolumeIcon.icns image from Volume\n");
} else if (Image) {
Entry->Image = Image;
} else {
Entry->Image = LoadOSIcon(OSIconName, L"unknown", 128, FALSE, TRUE);
}
// Load DriveImage
Entry->DriveImage = (DriveImage != NULL) ? DriveImage : ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
#endif
// DBG("HideBadges=%d Volume=%ls ", GlobalConfig.HideBadges, Volume->VolName);
#if USE_XTHEME
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
// Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, ThemeX.BadgeScale);
@ -818,21 +741,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
}
}
Entry->BootBgColor = BootBgColor;
#else
if (GlobalConfig.HideBadges & HDBADGES_SHOW) {
if (GlobalConfig.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, GlobalConfig.BadgeScale);
// DBG(" Show badge as Drive.");
} else {
Entry->BadgeImage = egCopyScaledImage(Entry->Image, GlobalConfig.BadgeScale);
// DBG(" Show badge as OSImage.");
}
}
if (BootBgColor != NULL) {
Entry->BootBgColor = BootBgColor; //copy pointer
}
#endif
Entry->KernelAndKextPatches = ((Patches == NULL) ? (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)) : Patches);
#ifdef DUMP_KERNEL_KEXT_PATCHES
@ -872,12 +780,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
// create the submenu
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN;
#if USE_XTHEME
SubScreen->Title.SWPrintf("Options for %ls on %ls", Entry->Title.wc_str(), Entry->VolName);
#else
//very old mistake!!!
SubScreen->Title = PoolPrint(L"Options for %s on %s", Entry->Title.s(), Entry->VolName);
#endif
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Entry->LoaderType + 20;
@ -1084,17 +987,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
Entry->SubScreen = SubScreen;
// DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n", Entry->Title, Entry->LoaderType, Entry->OSVersion);
}
#if USE_XTHEME
BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XString& LoaderOptions,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume, IN XImage *Image,
IN UINT8 OSType, IN UINT8 Flags)
#else
STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XString& LoaderOptions,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image,
IN UINT8 OSType, IN UINT8 Flags)
#endif
{
LOADER_ENTRY *Entry;
INTN HVi;
@ -1121,11 +1017,7 @@ STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XString& Loa
}
}
}
#if USE_XTHEME
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, L""_XSW, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
#else
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, NULL, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, NULL, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
#endif
if (Entry != NULL) {
if ((Entry->LoaderType == OSTYPE_OSX) ||
(Entry->LoaderType == OSTYPE_OSX_INSTALLER ) ||
@ -1342,15 +1234,10 @@ VOID ScanLoader(VOID)
if ((AndroidEntryData[Index].Find[aIndex] == NULL) || FileExists(Volume->RootDir, AndroidEntryData[Index].Find[aIndex])) ++aFound;
}
if (aFound && (aFound == aIndex)) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeX.ThemeDir, AndroidEntryData[Index].Icon);
AddLoaderEntry(AndroidEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
&ImageX, OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(AndroidEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
LoadOSIcon(AndroidEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#endif
}
}
}
@ -1360,15 +1247,10 @@ VOID ScanLoader(VOID)
if (gSettings.LinuxScan) {
// check for linux loaders
for (Index = 0; Index < LinuxEntryDataCount; ++Index) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeX.ThemeDir, LinuxEntryData[Index].Icon);
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
&ImageX, OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
LoadOSIcon(LinuxEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#endif
}
// check for linux kernels
PartGUID = FindGPTPartitionGuidInDevicePath(Volume->DevicePath);
@ -1635,7 +1517,6 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
return;
}
#if 0 //if someone want to debug this
#if USE_XTHEME
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom->Title) {
DBG("Title:\"%ls\" ", Custom->Title.wc_str());
@ -1643,18 +1524,6 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
// if (Custom->FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom->FullTitle.wc_str());
// }
#else
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
if (Custom->Title) {
DBG("Title:\"%ls\" ", Custom->Title);
}
if (Custom->FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom->FullTitle);
}
#endif
if (CustomPath) {
DBG("Path:\"%ls\" ", CustomPath);
}
@ -1672,12 +1541,8 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
CUSTOM_LOADER_ENTRY *CustomSubEntry;
LOADER_ENTRY *Entry = NULL;
#if USE_XTHEME
XImage Image; // = new XImage;
XImage DriveImage;
#else
EG_IMAGE *Image, *DriveImage;
#endif
EFI_GUID *Guid = NULL;
UINT64 VolumeSize;
@ -1899,51 +1764,16 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
// Change to custom image if needed
Image = Custom->Image;
#if USE_XTHEME
if (Image.isEmpty() && Custom->ImagePath) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
#else
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(ThemeDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
}
}
}
}
}
#endif
// Change to custom drive image if needed
DriveImage = Custom->DriveImage;
#if USE_XTHEME
if (DriveImage.isEmpty() && Custom->DriveImagePath) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->DriveImagePath);
}
#else
if ((DriveImage == NULL) && Custom->DriveImagePath) {
DriveImage = egLoadImage(Volume->RootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = egLoadImage(ThemeDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = egLoadImage(SelfDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = egLoadImage(SelfRootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
DriveImage = LoadBuiltinIcon(Custom->DriveImagePath);
}
}
}
}
}
#endif
do
{
@ -2099,13 +1929,8 @@ if ((Image == NULL) && Custom->ImagePath) {
}
DBG("match!\n");
// Create an entry for this volume
#if USE_XTHEME
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom->FullTitle, Custom->Title, Volume, &Image, &DriveImage, Custom->Type, Custom->Flags, Custom->Hotkey, Custom->BootBgColor, Custom->CustomBoot, Custom->CustomLogo, /*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
#else
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom->FullTitle, Custom->Title, Volume, Image, DriveImage, Custom->Type, Custom->Flags, Custom->Hotkey, Custom->BootBgColor, Custom->CustomBoot, Custom->CustomLogo, /*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
#endif
if (Entry != NULL) {
DBG("Custom settings: %ls.plist will %s be applied\n",
Custom->Settings, Custom->CommonSettings?"not":"");
@ -2120,13 +1945,7 @@ if ((Image == NULL) && Custom->ImagePath) {
// REFIT_MENU_SCREEN *SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
REFIT_MENU_SCREEN *SubScreen = new REFIT_MENU_SCREEN;
if (SubScreen) {
#if USE_XTHEME
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom->Title != NULL) ? Custom->Title.wc_str() : CustomPath, Entry->VolName);
#else
SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", (Custom->Title != NULL) ? Custom->Title : CustomPath, Entry->VolName);
#endif
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Custom->Type + 20;
SubScreen->AnimeRun = SubScreen->GetAnime();

View File

@ -69,21 +69,13 @@ VOID AddSecureBootTool(VOID)
Entry = new REFIT_MENU_ENTRY_SECURE_BOOT();
Entry->Title.SPrintf("Clover Secure Boot Configuration");
// 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);
#endif
} else {
Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG();
Entry->Title.SPrintf("Enable Clover 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);
#endif
}
Entry->Row = 1;
//actions
@ -113,20 +105,14 @@ VOID AddSecureBootTool(VOID)
*/
STATIC REFIT_MENU_ENTRY QueryEntry[] = {
{ L"Deny authentication", SECURE_BOOT_POLICY_DENY, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
{ L"Allow authentication", SECURE_BOOT_POLICY_ALLOW, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
{ L"Insert authentication into database", SECURE_BOOT_POLICY_INSERT, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
{ L"Deny authentication"_XSW, SECURE_BOOT_POLICY_DENY, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
{ L"Allow authentication"_XSW, SECURE_BOOT_POLICY_ALLOW, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
{ L"Insert authentication into database"_XSW, SECURE_BOOT_POLICY_INSERT, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
};
STATIC REFIT_MENU_ENTRY *QueryEntries[] = { QueryEntry, QueryEntry + 1, QueryEntry + 2 };
#if USE_XTHEME
STATIC REFIT_MENU_SCREEN QueryUserMenu = { 0, XStringWP(L"Secure Boot Authentication"), XStringWP(), 3, NULL, 2, QueryEntries,
STATIC REFIT_MENU_SCREEN QueryUserMenu = { 0, L"Secure Boot Authentication"_XSW, L""_XSW, 3, NULL, 2, QueryEntries,
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
/* FILM_CENTRE, FILM_CENTRE,*/ { 0, 0, 0, 0 }, NULL };
#else
STATIC REFIT_MENU_SCREEN QueryUserMenu = { 0, L"Secure Boot Authentication", NULL, 3, NULL, 2, QueryEntries,
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
/* FILM_CENTRE, FILM_CENTRE,*/ { 0, 0, 0, 0 }, NULL };
#endif
// Query the secure boot user what to do with image
UINTN QuerySecureBootUser(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)

View File

@ -72,16 +72,9 @@
#endif
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 XString& Options)
#else
STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image,
IN CHAR16 ShortcutLetter, IN CONST XString& Options)
#endif
{
REFIT_MENU_ENTRY_LOADER_TOOL *Entry;
// Check the loader exists
@ -130,19 +123,11 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
// prepare the menu entry
// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(*Entry));
Entry = new REFIT_MENU_ENTRY_CLOVER();
//#if USE_XTHEME
Entry->Title.takeValueFrom(LoaderTitle);
//#else
// Entry->Title = EfiStrDuplicate(LoaderTitle);
//#endif
// Entry->Tag = TAG_CLOVER;
Entry->Row = 1;
Entry->ShortcutLetter = 'C';
#if USE_XTHEME
Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_CLOVER);
#else
Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_CLOVER);
#endif
Entry->Volume = Volume;
Entry->LoaderPath = EfiStrDuplicate(LoaderPath);
Entry->VolName = Volume->VolName;
@ -160,11 +145,8 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
// create the submenu
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN;
#if USE_XTHEME
SubScreen->Title.takeValueFrom(LoaderTitle);
#else
SubScreen->Title = EfiStrDuplicate(LoaderTitle);
#endif
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = SCREEN_BOOT;
@ -208,41 +190,15 @@ VOID ScanTool(VOID)
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
VOID *Interface;
#if USE_XTHEME
if (ThemeX.HideUIFlags & HIDEUI_FLAG_TOOLS)
return;
#else
if (GlobalConfig.DisableFlags & HIDEUI_FLAG_TOOLS)
return;
#endif
// 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', ""_XS)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
}
}
#else
// look for the EFI shell
if (!(GlobalConfig.DisableFlags & HIDEUI_FLAG_SHELL)) {
#if defined(MDE_CPU_X64)
// if (gFirmwareClover) {
// AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"EFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S');
// } else
//there seems to be the best version
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
}
// }
#else
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell32.efi", NULL, L"EFI Shell 32", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
#endif
}
#endif
// if (!gFirmwareClover) { //Slice: I wish to extend functionality on emulated nvram
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
@ -279,11 +235,7 @@ VOID AddCustomTool(VOID)
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
CUSTOM_TOOL_ENTRY *Custom;
#if USE_XTHEME
XImage Image;
#else
EG_IMAGE *Image;
#endif
UINTN i = 0;
// DBG("Custom tool start\n");
@ -353,39 +305,15 @@ VOID AddCustomTool(VOID)
}
// Change to custom image if needed
Image = Custom->Image;
#if USE_XTHEME
if (Image.isEmpty() && Custom->ImagePath) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
#else
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(ThemeDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
}
}
}
}
#endif
#if USE_XTHEME
if (Image.isEmpty()) {
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->Options);
} else {
// Create a legacy entry for this volume
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, Image, Custom->Hotkey, Custom->Options);
}
#else
if (Image == NULL) {
Image = BuiltinIcon(BUILTIN_ICON_TOOL_SHELL);
}
// Create a legacy entry for this volume
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, Image, Custom->Hotkey, Custom->Options);
#endif
DBG("match!\n");
// break; // break scan volumes, continue scan entries -- why?
}

File diff suppressed because it is too large Load Diff

View File

@ -72,26 +72,16 @@ public:
static XPointer mPointer;
// XPointer mPointer;
UINTN ID;
#if USE_XTHEME
XStringW Title;
XImage TitleImage;
#else
CONST CHAR16 *Title; //Title is not const, but *Title is. It will be better to make it XStringW
EG_IMAGE *TitleImage;
#endif
XStringWArray InfoLines;
XObjArray<REFIT_ABSTRACT_MENU_ENTRY> Entries;
INTN TimeoutSeconds;
#if USE_XTHEME
XStringW TimeoutText;
XStringW ThemeName; //?
EG_RECT OldTextBufferRect;
XImage OldTextBufferImage;
BOOLEAN isBootScreen;
#else
CONST CHAR16 *TimeoutText;
CONST CHAR16 *Theme;
#endif
BOOLEAN AnimeRun;
BOOLEAN Once;
UINT64 LastDraw;
@ -105,14 +95,11 @@ public:
UINTN mItemID;
SCROLL_STATE ScrollState;
BOOLEAN ScrollEnabled;
#if USE_XTHEME
INTN TextStyle;
#endif
// MENU_STYLE_FUNC StyleFunc;
//TODO scroll positions should depends on REFIT_SCREEN?
// Or it just currently calculated to be global variables?
#if USE_XTHEME
EG_RECT BarStart;
EG_RECT BarEnd;
EG_RECT ScrollStart;
@ -135,18 +122,6 @@ public:
Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
#else
REFIT_MENU_SCREEN()
: ID(0), Title(0), TitleImage(0),
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
#endif
#if USE_XTHEME
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText)
: ID(ID), Title(TTitle), TitleImage(),
TimeoutSeconds(0), TimeoutText(TTimeoutText), ThemeName(),
@ -165,17 +140,7 @@ public:
Title.takeValueFrom(TitleC);
TimeoutText.takeValueFrom(TimeoutTextC);
};
#else
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText)
: ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
#endif
#if USE_XTHEME
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: ID(ID), Title(TTitle), TitleImage(),
TimeoutSeconds(0), TimeoutText(TTimeoutText), ThemeName(),
@ -187,18 +152,6 @@ public:
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
};
#else
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
};
#endif
//Scroll functions
VOID InitScroll(IN INTN ItemCount, IN UINTN MaxCount,
@ -230,16 +183,12 @@ public:
UINTN InputDialog(IN MENU_STYLE_FUNC StyleFunc);
#if USE_XTHEME
VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos);
VOID DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos);
INTN DrawTextXY(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
void EraseTextXY();
VOID DrawTextCorner(UINTN TextC, UINT8 Align);
VOID DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor);
#else
VOID DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos);
#endif
VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID CountItems();
VOID InitAnime();

View File

@ -101,11 +101,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINTN Row;
CHAR16 ShortcutDigit;
CHAR16 ShortcutLetter;
#if USE_XTHEME
XImage Image;
#else
EG_IMAGE *Image;
#endif
EG_RECT Place;
ACTION AtClick;
ACTION AtDoubleClick;
@ -113,13 +109,8 @@ class REFIT_ABSTRACT_MENU_ENTRY
ACTION AtMouseOver;
REFIT_MENU_SCREEN *SubScreen;
#if USE_XTHEME
virtual XImage* getDriveImage() { return nullptr; };
virtual XImage* getBadgeImage() { return nullptr; };
#else
virtual EG_IMAGE* getDriveImage() const { return nullptr; };
virtual EG_IMAGE* getBadgeImage() const { return nullptr; };
#endif
virtual REFIT_SIMPLE_MENU_ENTRY_TAG* getREFIT_SIMPLE_MENU_ENTRY_TAG() { return nullptr; };
virtual REFIT_MENU_SWITCH* getREFIT_MENU_SWITCH() { return nullptr; };
@ -140,7 +131,6 @@ class REFIT_ABSTRACT_MENU_ENTRY
virtual REFIT_MENU_ENTRY_ITEM_ABSTRACT* getREFIT_MENU_ITEM_IEM_ABSTRACT() { return nullptr; };
virtual REFIT_MENU_ITEM_BOOTNUM* getREFIT_MENU_ITEM_BOOTNUM() { return nullptr; };
#if USE_XTHEME
REFIT_ABSTRACT_MENU_ENTRY() : Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
@ -159,26 +149,6 @@ class REFIT_ABSTRACT_MENU_ENTRY
AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
SubScreen(SubScreen_) {};
#else
REFIT_ABSTRACT_MENU_ENTRY() : Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, ACTION AtClick_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(NULL), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_,
CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, EG_IMAGE* Image_,
EG_RECT Place_, ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_,
REFIT_MENU_SCREEN *SubScreen_)
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_),
Image(Image_), Place(Place_),
AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
SubScreen(SubScreen_) {};
#endif
virtual ~REFIT_ABSTRACT_MENU_ENTRY() {}; // virtual destructor : this is vital
};
@ -293,7 +263,6 @@ class REFIT_ABSTRACT_MENU_ENTRY
CONST CHAR16 *DevicePathString;
XString LoadOptions; //moved here for compatibility with legacy
CONST CHAR16 *LoaderPath;
#if USE_XTHEME
XImage DriveImage;
XImage BadgeImage;
@ -303,19 +272,6 @@ class REFIT_ABSTRACT_MENU_ENTRY
virtual XImage* getDriveImage() { return &DriveImage; };
virtual XImage* getBadgeImage() { return &BadgeImage; };
#else
EG_IMAGE *DriveImage;
EG_IMAGE *BadgeImage;
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoaderPath(0), DriveImage(0), BadgeImage(0)
{}
virtual EG_IMAGE* getDriveImage() const { return DriveImage; };
virtual EG_IMAGE* getBadgeImage() const { return BadgeImage; };
#endif
virtual REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER* getREFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER() { return this; };
};
@ -388,12 +344,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINT8 LoaderType;
CHAR8 *OSVersion;
CHAR8 *BuildVersion;
#if USE_XTHEME
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor;
#else
EG_PIXEL *BootBgColor; //why it is array? It is one value!
#endif
UINT8 CustomBoot;
EG_IMAGE *CustomLogo;
@ -402,11 +353,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
LOADER_ENTRY()
: REFIT_MENU_ITEM_BOOTNUM(), VolName(0), DevicePath(0), Flags(0), LoaderType(0), OSVersion(0), BuildVersion(0),
#if USE_XTHEME
BootBgColor({0,0,0,0}),
#else
BootBgColor(0),
#endif
BootBgColor({0,0,0,0}),
CustomBoot(0), CustomLogo(0), KernelAndKextPatches(0), Settings(0)
{};
LOADER_ENTRY* getPartiallyDuplicatedEntry() const;

View File

@ -34,11 +34,9 @@
#define DBG(...) DebugLog(DEBUG_VEC, __VA_ARGS__)
#endif
#if USE_XTHEME
#include "XTheme.h"
extern XTheme ThemeX;
extern CONST CHAR8* IconsNames[];
#endif
#define NSVG_RGB(r, g, b) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16))
@ -48,15 +46,7 @@ extern VOID
WaitForKeyPress(CHAR16 *Message);
extern void DumpFloat2 (CONST char* s, float* t, int N);
#if !USE_XTHEME
extern EG_IMAGE *BackgroundImage;
extern EG_IMAGE *Banner;
extern EG_IMAGE *BigBack;
extern INTN BanHeight;
extern INTN row0TileSize;
extern INTN row1TileSize;
//extern INTN FontWidth;
#endif
extern UINTN NumFrames;
extern UINTN FrameTime;
extern BOOLEAN DayLight;
@ -65,7 +55,6 @@ extern BOOLEAN DayLight;
textFaces textFace[4]; //0-help 1-message 2-menu 3-test, far future it will be infinite list with id
NSVGparser *mainParser = NULL; //it must be global variable
#if USE_XTHEME
EFI_STATUS XTheme::ParseSVGXIcon(void *parser, INTN Id, const XString& IconNameX, XImage* Image)
{
EFI_STATUS Status = EFI_NOT_FOUND;
@ -243,186 +232,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(void *parser, INTN Id, const XString& IconNameX
return EFI_SUCCESS;
}
#else
EFI_STATUS ParseSVGIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float Scale, EG_IMAGE **Image)
{
EFI_STATUS Status = EFI_NOT_FOUND;
NSVGimage *SVGimage;
NSVGrasterizer* rast = nsvgCreateRasterizer();
SVGimage = p->image;
NSVGshape *shape;
NSVGgroup *group;
NSVGimage *IconImage; // = (NSVGimage*)AllocateZeroPool(sizeof(NSVGimage));
NSVGshape *shapeNext, *shapesTail=NULL, *shapePrev;
// INTN ClipCount = 0;
NSVGparser* p2 = nsvg__createParser();
IconImage = p2->image;
shape = SVGimage->shapes;
shapePrev = NULL;
while (shape) {
group = shape->group;
shapeNext = shape->next;
while (group) {
if (strcmp(group->id, IconName) == 0) {
break;
}
group = group->next;
}
if (group) { //the shape is in the group
// keep this sample for debug purpose
/* DBG("found shape %s", shape->id);
DBG(" from group %s\n", group->id);
if ((Id == BUILTIN_SELECTION_BIG) ||
(Id == BUILTIN_ICON_BACKGROUND) ||
(Id == BUILTIN_ICON_BANNER)) {
shape->debug = TRUE;
} */
if (GlobalConfig.BootCampStyle && (strstr(IconName, "selection_big") != NULL)) {
shape->opacity = 0.f;
}
if (strstr(shape->id, "BoundingRect") != NULL) {
//there is bounds after nsvgParse()
IconImage->width = shape->bounds[2] - shape->bounds[0];
IconImage->height = shape->bounds[3] - shape->bounds[1];
if ( IconImage->height == 0 ) { // doing "if (!IconImage->height)" generates a warning
IconImage->height = 200;
}
// if (Id == BUILTIN_ICON_BACKGROUND || Id == BUILTIN_ICON_BANNER) {
// DBG("IconImage size [%d,%d]\n", (int)IconImage->width, (int)IconImage->height);
// DBG("IconImage left corner x=%f y=%f\n", IconImage->realBounds[0], IconImage->realBounds[1]);
// DumpFloat2("IconImage real bounds", IconImage->realBounds, 4);
// }
if ((strstr(IconName, "selection_big") != NULL) && (!GlobalConfig.SelectionOnTop)) {
GlobalConfig.MainEntriesSize = (int)(IconImage->width * Scale); //xxx
row0TileSize = GlobalConfig.MainEntriesSize + (int)(16.f * Scale);
DBG("main entry size = %lld\n", GlobalConfig.MainEntriesSize);
}
if ((strstr(IconName, "selection_small") != NULL) && (!GlobalConfig.SelectionOnTop)) {
row1TileSize = (int)(IconImage->width * Scale);
}
// not exclude BoundingRect from IconImage?
shape->flags = 0; //invisible
if (shapePrev) {
shapePrev->next = shapeNext;
} else {
SVGimage->shapes = shapeNext;
}
shape = shapeNext;
continue; //while(shape) it is BoundingRect shape
// shape->opacity = 0.3f;
}
shape->flags = NSVG_VIS_VISIBLE;
// Add to tail
// ClipCount += shape->clip.count;
if (IconImage->shapes == NULL)
IconImage->shapes = shape;
else
shapesTail->next = shape;
shapesTail = shape;
if (shapePrev) {
shapePrev->next = shapeNext;
} else {
SVGimage->shapes = shapeNext;
}
shapePrev->next = shapeNext;
} //the shape in the group
else {
shapePrev = shape;
}
shape = shapeNext;
} //while shape
shapesTail->next = NULL;
//add clipPaths //xxx
NSVGclipPath* clipPaths = SVGimage->clipPaths;
NSVGclipPath* clipNext = NULL;
while (clipPaths) {
// ClipCount += clipPaths->shapes->clip.count;
group = clipPaths->shapes->group;
clipNext = clipPaths->next;
while (group) {
if (strcmp(group->id, IconName) == 0) {
break;
}
group = group->parent;
}
if (group) {
DBG("found clipPaths for %s\n", IconName);
IconImage->clipPaths = SVGimage->clipPaths;
break;
}
clipPaths = clipNext;
}
// DBG("found %d clips for %s\n", ClipCount, IconName);
// if (ClipCount) { //Id == BUILTIN_ICON_BANNER) {
// IconImage->clipPaths = SVGimage->clipPaths;
// }
float bounds[4];
bounds[0] = FLT_MAX;
bounds[1] = FLT_MAX;
bounds[2] = -FLT_MAX;
bounds[3] = -FLT_MAX;
nsvg__imageBounds(p2, bounds);
CopyMem(IconImage->realBounds, bounds, 4*sizeof(float));
if ((Id == BUILTIN_ICON_BANNER) && (strstr(IconName, "Banner") != NULL)) {
GlobalConfig.BannerPosX = (int)(bounds[0] * Scale - GlobalConfig.CentreShift);
GlobalConfig.BannerPosY = (int)(bounds[1] * Scale);
DBG("Banner position at parse [%lld,%lld]\n", GlobalConfig.BannerPosX, GlobalConfig.BannerPosY);
}
float Height = IconImage->height * Scale;
float Width = IconImage->width * Scale;
// DBG("icon %s width=%f height=%f\n", IconName, Width, Height);
int iWidth = (int)(Width + 0.5f);
int iHeight = (int)(Height + 0.5f);
EG_IMAGE *NewImage = egCreateFilledImage(iWidth, iHeight, TRUE, &MenuBackgroundPixel);
if (IconImage->shapes == NULL) {
*Image = NewImage;
return Status;
}
// DBG("begin rasterize %s\n", IconName);
float tx = 0.f, ty = 0.f;
if ((Id != BUILTIN_ICON_BACKGROUND) &&
(Id != BUILTIN_ICON_ANIME) &&
(strstr(IconName, "Banner") == NULL)) {
float realWidth = (bounds[2] - bounds[0]) * Scale;
float realHeight = (bounds[3] - bounds[1]) * Scale;
tx = (Width - realWidth) * 0.5f;
ty = (Height - realHeight) * 0.5f;
}
nsvgRasterize(rast, IconImage, tx,ty,Scale,Scale, (UINT8*)NewImage->PixelData, iWidth, iHeight, iWidth*4);
// DBG("%s rastered, blt\n", IconImage);
#if 0
BltImageAlpha(NewImage,
(int)(UGAWidth - NewImage->Width) / 2,
(int)(UGAHeight * 0.05f),
&MenuBackgroundPixel,
16);
// WaitForKeyPress(L"waiting for key press...\n");
#endif
nsvgDeleteRasterizer(rast);
// nsvg__deleteParser(p2);
// nsvgDelete(p2->image);
*Image = NewImage;
return EFI_SUCCESS;
}
#endif
#if USE_XTHEME
EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
{
EFI_STATUS Status;
@ -560,193 +370,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
return Status;
}
#else
EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict)
{
EFI_STATUS Status;
NSVGimage *SVGimage;
NSVGrasterizer *rast = nsvgCreateRasterizer();
// --- Parse theme.svg --- low case
mainParser = nsvgParse((CHAR8*)buffer, 72, 1.f);
SVGimage = mainParser->image;
if (!SVGimage) {
DBG("Theme not parsed!\n");
return EFI_NOT_STARTED;
}
// --- Get scale as theme design height vs screen height
float Scale;
// must be svg view-box
float vbx = mainParser->viewWidth;
float vby = mainParser->viewHeight;
DBG("Theme view-bounds: w=%d h=%d units=%s\n", (int)vbx, (int)vby, "px");
if (vby > 1.0f) {
SVGimage->height = vby;
} else {
SVGimage->height = 768.f; //default height
}
Scale = UGAHeight / SVGimage->height;
DBG("using scale %f\n", Scale);
GlobalConfig.Scale = Scale;
GlobalConfig.CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f;
if (mainParser->font) {
DBG("theme contains font-family=%s\n", mainParser->font->fontFamily);
}
// --- Make background
BackgroundImage = egCreateFilledImage(UGAWidth, UGAHeight, TRUE, &BlackPixel);
if (BigBack) {
egFreeImage(BigBack);
BigBack = NULL;
}
Status = EFI_NOT_FOUND;
if (!DayLight) {
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_BACKGROUND, "Background_night", Scale, &BigBack);
}
if (EFI_ERROR(Status)) {
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_BACKGROUND, "Background", Scale, &BigBack);
}
DBG("background parsed\n");
// --- Make Banner
if (Banner) {
egFreeImage(Banner);
Banner = NULL;
}
Status = EFI_NOT_FOUND;
if (!DayLight) {
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_BANNER, "Banner_night", Scale, &Banner);
}
if (EFI_ERROR(Status)) {
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_BANNER, "Banner", Scale, &Banner);
}
DBG("Banner parsed\n");
BuiltinIconTable[BUILTIN_ICON_BANNER].Image = Banner;
BanHeight = (int)(Banner->Height * Scale + 1.f);
DBG("parsed banner->width=%lld\n", Banner->Width);
// --- Make other icons
INTN i = BUILTIN_ICON_FUNC_ABOUT;
CHAR8 *IconName;
while (BuiltinIconTable[i].Path) {
if (i == BUILTIN_ICON_BANNER) {
i++;
continue;
}
CONST CHAR16 *IconPath = BuiltinIconTable[i].Path;
// DBG("next table icon=%ls\n", IconPath);
CONST CHAR16 *ptr = StrStr(IconPath, L"\\");
if (!ptr) {
ptr = IconPath;
} else {
ptr++;
}
// DBG("next icon=%ls Len=%d\n", ptr, StrLen(ptr));
UINTN Size = StrLen(ptr)+1;
IconName = (__typeof__(IconName))AllocateZeroPool(Size);
UnicodeStrToAsciiStrS(ptr, IconName, Size);
// DBG("search for icon name %s\n", IconName);
CHAR8 IconNight[64];
AsciiStrCpyS(IconNight, 64, IconName);
AsciiStrCatS(IconNight, 64, "_night");
Status = EFI_NOT_FOUND;
if (!DayLight) {
Status = ParseSVGIcon(mainParser, i, IconNight, Scale, &BuiltinIconTable[i].Image);
}
if (EFI_ERROR(Status)) {
Status = ParseSVGIcon(mainParser, i, IconName, Scale, &BuiltinIconTable[i].Image);
}
if (EFI_ERROR(Status)) {
DBG(" icon %lld not parsed take common %ls\n", i, BuiltinIconTable[i].Path);
if ((i >= BUILTIN_ICON_VOL_EXTERNAL) && (i <= BUILTIN_ICON_VOL_INTERNAL_REC)) {
if (BuiltinIconTable[BUILTIN_ICON_VOL_INTERNAL].Image) {
BuiltinIconTable[i].Image = egCopyImage(BuiltinIconTable[BUILTIN_ICON_VOL_INTERNAL].Image);
}
}
}
if (i == BUILTIN_SELECTION_BIG) {
DBG("icon main size=[%lld,%lld]\n", BuiltinIconTable[i].Image->Width,
BuiltinIconTable[i].Image->Height);
}
i++;
FreePool(IconName);
}
// OS icons and buttons
i = 0;
while (OSIconsTable[i].name) {
CHAR8 IconNight[64];
AsciiStrCpyS(IconNight, 64, OSIconsTable[i].name);
AsciiStrCatS(IconNight, 64, "_night");
OSIconsTable[i].image = NULL;
// DBG("search for %s\n", OSIconsTable[i].name);
Status = EFI_NOT_FOUND;
if (!DayLight) {
Status = ParseSVGIcon(mainParser, i, IconNight, Scale, &OSIconsTable[i].image);
}
if (EFI_ERROR(Status)) {
Status = ParseSVGIcon(mainParser, i, OSIconsTable[i].name, Scale, &OSIconsTable[i].image);
}
if (EFI_ERROR(Status)) {
DBG("OSicon %s not parsed\n", OSIconsTable[i].name);
if ((i > 0) && (i < 13)) {
if (OSIconsTable[0].image) {
OSIconsTable[i].image = egCopyImage(OSIconsTable[0].image);
}
} else if (i < 18) {
if (OSIconsTable[13].image) {
OSIconsTable[i].image = egCopyImage(OSIconsTable[13].image);
}
}
}
i++;
}
//selection for bootcamp style
Status = EFI_NOT_FOUND;
if (!DayLight) {
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_SELECTION, "selection_indicator_night", Scale, &SelectionImages[4]);
}
if (EFI_ERROR(Status)) {
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_SELECTION, "selection_indicator", Scale, &SelectionImages[4]);
}
//banner animation
GUI_ANIME *Anime = (__typeof__(Anime))AllocateZeroPool (sizeof(GUI_ANIME));
Anime->ID = 1; //main screen
//there is no Anime->Path in vectors
Anime->Frames = NumFrames;
Anime->FrameTime = FrameTime;
Anime->Next = GuiAnime;
Anime->FilmX = INITVALUE;
Anime->FilmY = INITVALUE;
Anime->NudgeX = INITVALUE;
Anime->NudgeY = INITVALUE;
GuiAnime = Anime;
nsvgDeleteRasterizer(rast);
*dict = (__typeof_am__(*dict))AllocateZeroPool(sizeof(TagStruct));
(*dict)->type = kTagTypeNone;
GlobalConfig.TypeSVG = TRUE;
GlobalConfig.ThemeDesignHeight = (int)SVGimage->height;
GlobalConfig.ThemeDesignWidth = (int)SVGimage->width;
if (GlobalConfig.SelectionOnTop) {
row0TileSize = (INTN)(144.f * Scale);
row1TileSize = (INTN)(64.f * Scale);
GlobalConfig.MainEntriesSize = (INTN)(128.f * Scale);
}
DBG("parsing theme finish\n");
return EFI_SUCCESS;
}
#endif
#if USE_XTHEME
EG_IMAGE * LoadSvgFrame(INTN i)
{
// EG_IMAGE *Frame = NULL;
@ -765,29 +389,12 @@ EG_IMAGE * LoadSvgFrame(INTN i)
}
return XFrame.ToEGImage();
}
#else
EG_IMAGE * LoadSvgFrame(INTN i)
{
EG_IMAGE *Frame = NULL;
EFI_STATUS Status;
CHAR8 FrameName[64];
//TODO if extend SVG syntax then we can use dynamic SVG with parameter Frame
// for example use variable instead of constant like javascript
AsciiSPrint(FrameName, 63, "frame_%04d", i+1); //we need exact number of digits which snprintf not provided
Status = ParseSVGIcon(mainParser, BUILTIN_ICON_ANIME, FrameName, GlobalConfig.Scale, &Frame);
if (EFI_ERROR(Status)) {
DBG("icon '%s' not loaded, status=%s\n", FrameName, strerror(Status));
}
return Frame;
}
#endif
// it is not draw, it is render and mainly used in egRenderText
// which is used in icns.cpp as an icon replacement if no image found, looks like not used
// in menu.cpp 3 places
//textType = 0-help 1-message 2-menu 3-test
//return text width in pixels
#if USE_XTHEME
//it is not theme member!
INTN renderSVGtext(XImage* TextBufferXY_ptr, INTN posX, INTN posY, INTN textType, const XStringW& string, UINTN Cursor)
{
@ -874,113 +481,6 @@ INTN renderSVGtext(XImage* TextBufferXY_ptr, INTN posX, INTN posY, INTN textType
nsvgDelete(p->image);
return (INTN)RealWidth; //x;
}
#else
INTN renderSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* string, UINTN Cursor)
{
INTN Width;
UINTN i;
UINTN len;
NSVGparser* p;
NSVGrasterizer* rast;
if (!textFace[textType].valid) {
for (i=0; i<4; i++) {
if (textFace[i].valid) {
textType = i;
break;
}
}
}
if (!textFace[textType].valid) {
DBG("valid fontface not found!\n");
return 0;
}
NSVGfont* fontSVG = textFace[textType].font;
UINT32 color = textFace[textType].color;
INTN Height = (INTN)(textFace[textType].size * GlobalConfig.Scale);
float Scale, sy;
float x, y;
if (!fontSVG) {
DBG("no font for renderSVGtext\n");
return 0;
}
if (!TextBufferXY) {
DBG("no buffer\n");
return 0;
}
p = nsvg__createParser();
if (!p) {
return 0;
}
NSVGtext* text = (NSVGtext*)AllocateZeroPool(sizeof(NSVGtext));
if (!text) {
return 0;
}
text->font = fontSVG;
text->fontColor = color;
text->fontSize = (float)Height;
nsvg__xformIdentity(text->xform);
p->text = text;
len = StrLen(string);
Width = TextBufferXY->Width;
// Height = TextBufferXY->Height;
// DBG("Text Height=%d Buffer Height=%d\n", Height, TextBufferXY->Height);
// Height = 180; //for test
// DBG("textBuffer: [%d,%d], fontUnits=%d\n", Width, TextBufferXY->Height, (int)fontSVG->unitsPerEm);
if ( fontSVG->unitsPerEm < 1.f ) {
fontSVG->unitsPerEm = 1000.f;
}
float fH = fontSVG->bbox[3] - fontSVG->bbox[1]; //1250
if (fH == 0.f) {
DBG("wrong font: %f\n", fontSVG->unitsPerEm);
DumpFloat2("Font bbox", fontSVG->bbox, 4);
fH = fontSVG->unitsPerEm != 0.f ? fontSVG->unitsPerEm : 1000.0f;
}
sy = (float)Height / fH; //(float)fontSVG->unitsPerEm; // 260./1250.
//in font units
// float fW = fontSVG->bbox[2] - fontSVG->bbox[0];
// sx = (float)Width / (fW * len);
// Scale = (sx > sy)?sy:sx;
Scale = sy;
x = (float)posX; //0.f;
y = (float)posY + fontSVG->bbox[1] * Scale;
p->isText = TRUE;
//DBG("renderSVGtext -> Enter. Text=%s\n", XString(string).c);
for (i=0; i < len; i++) {
CHAR16 letter = string[i];
if (!letter) {
break;
}
// DBG("add letter 0x%X\n", letter);
if (i == Cursor) {
addLetter(p, 0x5F, x, y, sy, color);
}
x = addLetter(p, letter, x, y, sy, color);
// DBG("next x=%ls\n", x);
} //end of string
p->image->realBounds[0] = fontSVG->bbox[0] * Scale;
p->image->realBounds[1] = fontSVG->bbox[1] * Scale;
p->image->realBounds[2] = fontSVG->bbox[2] * Scale + x; //last bound
p->image->realBounds[3] = fontSVG->bbox[3] * Scale;
// DBG("internal Scale=%lf\n", Scale);
// DumpFloat2("text bounds", p->image->realBounds, 4);
//We made an image, then rasterize it
rast = nsvgCreateRasterizer();
// DBG("begin raster text, scale=%ls\n", Scale);
nsvgRasterize(rast, p->image, 0, 0, 1.f, 1.f, (UINT8*)TextBufferXY->PixelData,
(int)TextBufferXY->Width, (int)TextBufferXY->Height, (int)(Width*4));
float RealWidth = p->image->realBounds[2] - p->image->realBounds[0];
// DBG("end raster text\n");
nsvgDeleteRasterizer(rast);
// nsvg__deleteParser(p);
nsvgDelete(p->image);
return (INTN)RealWidth; //x;
}
#endif
VOID testSVG()
{
do {
@ -1068,11 +568,7 @@ VOID testSVG()
}
*/
// Rasterize
#if USE_XTHEME
XImage NewImage(Width, Height);
#else
EG_IMAGE *NewImage = egCreateFilledImage(Width, Height, TRUE, &MenuBackgroundPixel);
#endif
if (SVGimage->width <= 0) SVGimage->width = (float)Width;
if (SVGimage->height <= 0) SVGimage->height = (float)Height;
@ -1082,20 +578,10 @@ VOID testSVG()
float tx = 0; //-SVGimage->realBounds[0] * Scale;
float ty = 0; //-SVGimage->realBounds[1] * Scale;
DBG("timing rasterize start tx=%f ty=%f\n", tx, ty);
#if USE_XTHEME
nsvgRasterize(rast, SVGimage, tx,ty,Scale,Scale, (UINT8*)NewImage.GetPixelPtr(0,0), (int)Width, (int)Height, (int)Width*4);
DBG("timing rasterize end\n");
NewImage.Draw((UGAWidth - Width) / 2,
(UGAHeight - Height) / 2);
#else
nsvgRasterize(rast, SVGimage, tx,ty,Scale,Scale, (UINT8*)NewImage->PixelData, (int)Width, (int)Height, (int)Width*4);
DBG("timing rasterize end\n");
//now show it!
XImage NewX(NewImage);
NewX.Draw((UGAWidth - Width) / 2,
(UGAHeight - Height) / 2);
egFreeImage(NewImage);
#endif //test XImage
FreePool(FileData);
FileData = NULL;
//
@ -1109,11 +595,7 @@ VOID testSVG()
Height = 80;
Width = UGAWidth-200;
// DBG("create test textbuffer\n");
#if USE_XTHEME
XImage TextBufferXY(Width, Height);
#else
EG_IMAGE* TextBufferXY = egCreateFilledImage(Width, Height, TRUE, &MenuBackgroundPixel);
#endif
Status = egLoadFile(SelfRootDir, L"Font.svg", &FileData, &FileDataLength);
DBG("test Font.svg loaded status=%s\n", strerror(Status));
if (!EFI_ERROR(Status)) {
@ -1129,23 +611,11 @@ VOID testSVG()
// DBG("font parsed family=%s\n", p->font->fontFamily);
FreePool(FileData);
// Scale = Height / fontSVG->unitsPerEm;
#if USE_XTHEME
renderSVGtext(&TextBufferXY, 0, 0, 3, XStringW().takeValueFrom("Clover Кловер"), 1);
#else
renderSVGtext(TextBufferXY, 0, 0, 3, L"Clover Кловер", 1);
#endif
// DBG("text ready to blit\n");
#if USE_XTHEME
TextBufferXY.Draw((UGAWidth - Width) / 2,
(UGAHeight - Height) / 2);
#else
BltImageAlpha(TextBufferXY,
(UGAWidth - Width) / 2,
(UGAHeight - Height) / 2,
&MenuBackgroundPixel,
16);
egFreeImage(TextBufferXY);
#endif
// nsvg__deleteParser(p);
// DBG("draw finished\n");
}

View File

@ -12,13 +12,7 @@
#include "../Platform/plist.h"
#include "XImage.h"
EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict);
#if USE_XTHEME
INTN renderSVGtext(XImage* TextBufferXY, INTN posX, INTN posY, INTN textType, const XStringW& string, UINTN Cursor);
#else
INTN renderSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* text, UINTN Cursor);
#endif
VOID testSVG(VOID);

View File

@ -1,6 +1,7 @@
#include "XImage.h"
#include "lodepng.h"
#include "nanosvg.h"
#include "libegint.h" //for egDecodeIcns
#ifndef DEBUG_ALL
@ -741,3 +742,34 @@ EG_IMAGE* XImage::ToEGImage()
CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes());
return Tmp;
}
//
// Load an image from a .icns file
//
EFI_STATUS XImage::LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize)
{
if (GlobalConfig.TextOnly) // skip loading if it's not used anyway
return EFI_SUCCESS;
if (BaseDir) {
EFI_STATUS Status = EFI_NOT_FOUND;
UINT8 *FileData = NULL;
UINTN FileDataLength = 0;
//TODO - make XImage
EG_IMAGE *NewImage;
// load file
Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength);
if (EFI_ERROR(Status)) {
return Status;
}
// decode it
NewImage = egDecodeICNS(FileData, FileDataLength, PixelSize, TRUE);
Status = FromEGImage(NewImage);
FreePool(FileData);
return Status;
}
return EFI_NOT_FOUND;
}

View File

@ -88,14 +88,7 @@ EFI_STATUS XPointer::MouseBirth()
PointerImage = nullptr;
}
// 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));
#endif
oldImage.setSizeInPixels(PointerImage->GetWidth(), PointerImage->GetHeight());
LastClickTime = 0;

View File

@ -34,7 +34,6 @@ public:
VOID KillMouse();
VOID UpdatePointer();
bool MouseInRect(EG_RECT *Place);
// EFI_STATUS CheckMouseEvent(REFIT_MENU_SCREEN *Screen);
bool isEmpty() const { return PointerImage->isEmpty(); }
void ClearEvent() { MouseEvent = NoEvents; }

View File

@ -12,8 +12,6 @@ extern "C" {
#include "XTheme.h"
#if USE_XTHEME
#ifndef DEBUG_ALL
#define DEBUG_XTHEME 1
#else
@ -26,29 +24,6 @@ extern "C" {
#define DBG(...) DebugLog(DEBUG_XTHEME, __VA_ARGS__)
#endif
#if !USE_XTHEME
//these are XTHEME members
//extern INTN ScrollWidth;
//extern INTN ScrollButtonsHeight;
//extern INTN ScrollBarDecorationsHeight;
//extern INTN ScrollScrollDecorationsHeight;
//These are SCREEN members
//extern EG_RECT UpButton;
//extern EG_RECT DownButton;
//extern EG_RECT BarStart;
//extern EG_RECT BarEnd;
//extern EG_RECT ScrollbarBackground;
//extern EG_RECT Scrollbar;
//extern EG_RECT ScrollStart;
//extern EG_RECT ScrollEnd;
//extern EG_RECT ScrollTotal;
//extern EG_RECT ScrollbarOldPointerPlace;
//extern EG_RECT ScrollbarNewPointerPlace;
#endif
//dynamic variables
//extern INTN ScrollbarYMovement;
//extern BOOLEAN IsDragging;
CONST CHAR8* IconsNames[] = {
"func_about",
"func_options",
@ -879,6 +854,6 @@ VOID XTheme::FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN
// TmpBuffer.Draw(X, YPos, 0, true);
}
#endif // USE_XTHEME

View File

@ -174,134 +174,6 @@ EG_IMAGE * egCopyScaledImage(IN EG_IMAGE *OldImage, IN INTN Ratio) //will be N/1
return NewImage;
}
#if !USE_XTHEME
BOOLEAN BigDiff(UINT8 a, UINT8 b)
{
if (a > b) {
if (!GlobalConfig.BackgroundDark) {
return (a - b) > (UINT8)(0xFF - GlobalConfig.BackgroundSharp);
}
} else if (GlobalConfig.BackgroundDark) {
return (b - a) > (UINT8)(0xFF - GlobalConfig.BackgroundSharp);
}
return 0;
}
//(c)Slice 2013
#define EDGE(P) \
do { \
if (BigDiff(a11.P, a10.P)) { \
if (!BigDiff(a11.P, a01.P) && !BigDiff(a11.P, a21.P)) { \
a10.P = a11.P; \
} else if (BigDiff(a11.P, a01.P)) { \
if ((dx + dy) < cell) { \
a11.P = a21.P = a12.P = (UINT8)((a10.P * (cell - dy + dx) + a01.P * (cell - dx + dy)) / (cell * 2)); \
} else { \
a10.P = a01.P = a11.P; \
} \
} else if (BigDiff(a11.P, a21.P)) { \
if (dx > dy) { \
a11.P = a01.P = a12.P = (UINT8)((a10.P * (cell * 2 - dy - dx) + a21.P * (dx + dy)) / (cell * 2)); \
}else { \
a10.P = a21.P = a11.P; \
} \
} \
} else if (BigDiff(a11.P, a21.P)) { \
if (!BigDiff(a11.P, a12.P)){ \
a21.P = a11.P; \
} else { \
if ((dx + dy) > cell) { \
a11.P = a01.P = a10.P = (UINT8)((a21.P * (cell + dx - dy) + a12.P * (cell - dx + dy)) / (cell * 2)); \
} else { \
a21.P = a12.P = a11.P; \
} \
} \
} else if (BigDiff(a11.P, a01.P)) { \
if (!BigDiff(a11.P, a12.P)){ \
a01.P = a11.P; \
} else { \
if (dx < dy) { \
a11.P = a21.P = a10.P = (UINT8)((a01.P * (cell * 2 - dx - dy) + a12.P * (dy + dx )) / (cell * 2)); \
} else { \
a01.P = a12.P = a11.P; \
} \
} \
} else if (BigDiff(a11.P, a12.P)) { \
a12.P = a11.P; \
} \
} while(0)
#define SMOOTH(P) \
do { \
norm = (INTN)a01.P + a10.P + 4 * a11.P + a12.P + a21.P; \
if (norm == 0) { \
Dest->P = 0; \
} else { \
Dest->P = (UINT8)(a11.P * 2 * (a01.P * (cell - dx) + a10.P * (cell - dy) + \
a21.P * dx + a12.P * dy + a11.P * 2 * cell) / (cell * norm)); \
} \
} while(0)
#define SMOOTH2(P) \
do { \
Dest->P = (UINT8)((a01.P * (cell - dx) * 3 + a10.P * (cell - dy) * 3 + \
a21.P * dx * 3 + a12.P * dy * 3 + a11.P * 2 * cell) / (cell * 8)); \
} while(0)
VOID ScaleImage(OUT EG_IMAGE *NewImage, IN EG_IMAGE *OldImage)
{
INTN W1, W2, H1, H2, i, j, f, cell;
INTN x, dx, y, y1, dy; //, norm;
EG_PIXEL a10, a11, a12, a01, a21;
EG_PIXEL *Src = OldImage->PixelData;
EG_PIXEL *Dest = NewImage->PixelData;
W1 = OldImage->Width;
H1 = OldImage->Height;
W2 = NewImage->Width;
H2 = NewImage->Height;
if (H1 * W2 < H2 * W1) {
f = (H2 << 12) / H1;
} else {
f = (W2 << 12) / W1;
}
if (f == 0) return;
cell = ((f - 1) >> 12) + 1;
for (j = 0; j < H2; j++) {
y = (j << 12) / f;
y1 = y * W1;
dy = j - ((y * f) >> 12);
for (i = 0; i < W2; i++) {
x = (i << 12) / f;
dx = i - ((x * f) >> 12);
a11 = Src[x + y1];
a10 = (y == 0)?a11: Src[x + y1 - W1];
a01 = (x == 0)?a11: Src[x + y1 - 1];
a21 = (x >= W1)?a11: Src[x + y1 + 1];
a12 = (y >= H1)?a11: Src[x + y1 + W1];
if (a11.a == 0) {
Dest->r = Dest->g = Dest->b = 0x55;
} else {
EDGE(r);
EDGE(g);
EDGE(b);
SMOOTH2(r);
SMOOTH2(g);
SMOOTH2(b);
}
Dest->a = 0xFF;
Dest++;
}
}
}
//
#endif
VOID egFreeImage(IN EG_IMAGE *Image)
{
if (Image != NULL) {
@ -516,17 +388,9 @@ EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
UINTN FileDataLength = 0;
EG_IMAGE *NewImage;
#if USE_XTHEME
if (ThemeX.TypeSVG) {
return NULL;
}
#else
if (GlobalConfig.TypeSVG) {
return NULL;
}
#endif
if (BaseDir == NULL || FileName == NULL)
return NULL;
@ -546,64 +410,6 @@ EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
return NewImage;
}
//will be replaced by ThemeX.LoadIcon(Name);
//caller is responsible for free image
#if !USE_XTHEME
EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN IconSize)
{
EFI_STATUS Status;
UINT8 *FileData;
UINTN FileDataLength;
EG_IMAGE *NewImage;
CHAR8 *IconName;
if (!BaseDir || !FileName) {
return NULL;
}
if (GlobalConfig.TypeSVG) {
INTN i = 0;
UINTN Size;
CONST CHAR16 *ptr = StrStr(FileName, L"\\");
if (!ptr) {
ptr = FileName;
} else {
ptr++;
}
CONST CHAR16 *ptr2 = StrStr(ptr, L".");
Size = ptr2 - ptr + 2;
IconName = (__typeof__(IconName))AllocateZeroPool(Size);
UnicodeStrToAsciiStrS(ptr, IconName, Size - 1);
while (OSIconsTable[i].name) {
if (AsciiStrCmp(OSIconsTable[i].name, IconName) == 0) {
// DBG("theme defined %s\n", IconName);
// DBG(" icon size=[%d,%d]\n", OSIconsTable[i].image->Width, OSIconsTable[i].image->Height);
FreePool(IconName);
return OSIconsTable[i].image;
}
i++;
}
FreePool(IconName);
return NULL;
}
// load file
Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength);
if (EFI_ERROR(Status)) {
return NULL;
}
// decode it
NewImage = egDecodePNG(FileData, FileDataLength, TRUE);
// if (!NewImage) {
// NewImage = egDecodeICNS(FileData, FileDataLength, IconSize, TRUE);
// }
FreePool(FileData);
return NewImage;
}
#endif
//
// Compositing
//
@ -822,15 +628,9 @@ VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN P
// compose
if (CompWidth > 0) {
#if USE_XTHEME
if (CompImage->HasAlpha && ThemeX.Background.isEmpty()) {
CompImage->HasAlpha = FALSE;
}
#else
if (CompImage->HasAlpha && !BackgroundImage) {
CompImage->HasAlpha = FALSE;
}
#endif
if (TopImage->HasAlpha) {
if (CompImage->HasAlpha) { //aaaa
@ -849,32 +649,13 @@ VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN P
}
}
}
#if !USE_XTHEME
EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN 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;
}
egComposeImage(NewImage, Image, 0, 0);
egFreeImage(Image);
return NewImage;
}
#endif
//
// misc internal functions
//
EG_IMAGE * egDecodePNG(IN const UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN WantAlpha) {
EG_IMAGE * egDecodePNG(IN const UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN WantAlpha)
{
EG_IMAGE *NewImage = NULL;
UINTN Error, i, ImageSize;
size_t Width, Height;

View File

@ -37,10 +37,6 @@
#ifndef __LIBEG_LIBEG_H__
#define __LIBEG_LIBEG_H__
#ifndef USE_XTHEME
#define USE_XTHEME 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -497,14 +493,7 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY);
#if USE_XTHEME
VOID egClearScreen(IN const void *Color);
#else
VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height);
VOID PrepareFont(VOID);
VOID egClearScreen(IN EG_PIXEL *Color);
#endif
//VOID egDrawImage(IN EG_IMAGE *Image, IN INTN ScreenPosX, IN INTN ScreenPosY);
// will be replaced by XImage.Draw(ScreenPosX, ScreenPosY, 1.f); assuming Area* = 0

View File

@ -181,14 +181,6 @@ EG_IMAGE * egDecodePNG(IN const UINT8 *FileData, IN UINTN FileDataLength, IN BOO
//VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength);
#if USE_XTHEME
// now it is in XTHEME
//INTN egRenderText(IN const XStringW& Text, OUT XImage* CompImage,
// IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType);
#else
INTN egRenderText(IN CONST CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType);
#endif
#endif /* __LIBEG_LIBEGINT_H__ */

View File

@ -514,7 +514,7 @@ VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable)
//
// Drawing to the screen
//
#if USE_XTHEME
VOID egClearScreen(IN const void *Color)
{
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColor = *(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Color;
@ -533,33 +533,6 @@ VOID egClearScreen(IN const void *Color)
}
}
#else
VOID egClearScreen(IN EG_PIXEL *Color)
{
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColor;
if (!egHasGraphics)
return;
FillColor.Red = Color->r;
FillColor.Green = Color->g;
FillColor.Blue = Color->b;
FillColor.Reserved = 0;
if (GraphicsOutput != NULL) {
// EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same
// layout, and the header from TianoCore actually defines them
// to be the same type.
GraphicsOutput->Blt(GraphicsOutput, &FillColor, EfiBltVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
} else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL*)&FillColor, EfiUgaVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
}
}
#endif
VOID egDrawImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY,

View File

@ -2872,11 +2872,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
NSVGparser *p1 = NULL;
EFI_STATUS Status;
DBG("required font %s not found, try to load external\n", text->fontFace->fontFamily);
#if USE_XTHEME
Status = egLoadFile(ThemeX.ThemeDir, PoolPrint(L"%a.svg", text->fontFace->fontFamily), &FileData, &FileDataLength);
#else
Status = egLoadFile(ThemeDir, PoolPrint(L"%a.svg", text->fontFace->fontFamily), &FileData, &FileDataLength);
#endif
Status = egLoadFile(ThemeX.ThemeDir, PoolPrint(L"%s.svg", text->fontFace->fontFamily), &FileData, &FileDataLength);
DBG("font %s loaded status=%s\n", text->fontFace->fontFamily, strerror(Status));
if (!EFI_ERROR(Status)) {
@ -2884,15 +2880,8 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
if (!p1) {
DBG("font %s not parsed\n", text->fontFace->fontFamily);
} else {
/* fontSVG = (__typeof__(fontSVG))AllocateCopyPool(sizeof(NSVGfont), p1->font);
DBG("font family %s parsed\n", fontSVG->fontFamily);
fontChain = (__typeof__(fontChain))AllocatePool(sizeof(*fontChain));
fontChain->font = fontSVG;
fontChain->next = fontsDB;
fontsDB = fontChain;
*/
fontSVG = fontsDB->font; //last added during parse file data
text->font = fontSVG; //this is the same pointer as in fontChain but we will never free text->font. We will free fontChain
text->font = fontSVG;
}
FreePool(FileData); //after load
FileData = NULL;
@ -3480,7 +3469,6 @@ static void nsvg__parseGroup(NSVGparser* p, const char** dict)
}
//parse Clover settings for theme
#if USE_XTHEME
void XTheme::parseTheme(void* parser, const char** dict)
{
NSVGparser* p = (NSVGparser*)parser;
@ -3553,81 +3541,6 @@ void XTheme::parseTheme(void* parser, const char** dict)
}
}
#else
static void parseTheme(NSVGparser* p, const char** dict)
{
int i;
BOOLEAN found = FALSE;
UINT32 Color = 0x80808080; //default value
for (i = 0; dict[i]; i += 2) {
if (strcmp(dict[i], "SelectionOnTop") == 0) {
GlobalConfig.SelectionOnTop = getIntegerDict(dict[i+1])>0; } else if (strcmp(dict[i], "BadgeOffsetX") == 0) {
GlobalConfig.BadgeOffsetX = getIntegerDict(dict[i + 1]);
} else if (strcmp(dict[i], "BadgeOffsetY") == 0) {
GlobalConfig.BadgeOffsetY = getIntegerDict(dict[i + 1]);
} else if (strcmp(dict[i], "NonSelectedGrey") == 0) {
GlobalConfig.NonSelectedGrey = getIntegerDict(dict[i + 1])>0; } else if (strcmp(dict[i], "CharWidth") == 0) {
GlobalConfig.CharWidth = getIntegerDict(dict[i + 1]);
} else if (strcmp(dict[i], "BackgroundDark") == 0) {
GlobalConfig.BackgroundDark = getIntegerDict(dict[i + 1])>0; } else if (strcmp(dict[i], "BackgroundSharp") == 0) {
GlobalConfig.BackgroundSharp = getIntegerDict(dict[i + 1]);
} else if (strcmp(dict[i], "BackgroundScale") == 0) {
GlobalConfig.BackgroundScale = imNone;
if (strstr(dict[i+1], "scale") != NULL) {
GlobalConfig.BackgroundScale = imScale;
}
if (strstr(dict[i+1], "crop") != NULL) {
GlobalConfig.BackgroundScale = imCrop;
}
if (strstr(dict[i+1], "tile") != NULL) {
GlobalConfig.BackgroundScale = imTile;
}
} else if (strcmp(dict[i], "Badges") == 0) {
GlobalConfig.HideBadges = 0;
if (strstr(dict[i+1], "show") != NULL) {
GlobalConfig.HideBadges |= HDBADGES_SHOW;
}
if (strstr(dict[i+1], "swap") != NULL) {
GlobalConfig.HideBadges |= HDBADGES_SWAP;
}
if (strstr(dict[i+1], "inline") != NULL) {
GlobalConfig.HideBadges |= HDBADGES_INLINE;
}
} else if (strcmp(dict[i], "BadgeScale") == 0) {
GlobalConfig.BadgeScale = getIntegerDict(dict[i + 1]);
} else if (strcmp(dict[i], "SelectionColor") == 0) {
Color = getIntegerDict(dict[i + 1]);
if (DayLight) {
GlobalConfig.SelectionColor = Color;
}
} else if (strcmp(dict[i], "SelectionColor_night") == 0) {
found = TRUE;
if (!DayLight) {
GlobalConfig.SelectionColor = getIntegerDict(dict[i + 1]);
}
} else if (strcmp(dict[i], "VerticalLayout") == 0) {
GlobalConfig.VerticalLayout = getIntegerDict(dict[i + 1])>0;
} else if (strcmp(dict[i], "BootCampStyle") == 0) {
GlobalConfig.BootCampStyle = getIntegerDict(dict[i + 1])>0;
} else if (strcmp(dict[i], "AnimeFrames") == 0) {
NumFrames = getIntegerDict(dict[i + 1]);
if (NumFrames == 0xFFFF) {
NumFrames = 0;
}
} else if (strcmp(dict[i], "FrameTime") == 0) {
FrameTime = getIntegerDict(dict[i + 1]);
} else nsvg__parseAttr(p, dict[i], dict[i + 1]);
}
if (!found) {
GlobalConfig.SelectionColor = Color;
}
}
#endif
// parse embedded font
static void nsvg__parseFont(NSVGparser* p, const char** dict)
@ -3974,11 +3887,7 @@ static void nsvg__startElement(void* ud, const char* el, const char** dict)
p->patternFlag = 1;
} else if (strcmp(el, "clover:theme") == 0) {
#if USE_XTHEME
ThemeX.parseTheme((void*)p, dict);
#else
parseTheme(p, dict);
#endif
} else {
strncpy(p->unknown, el, 63);

View File

@ -59,26 +59,12 @@ extern "C" {
#define DBG(...) DebugLog(DEBUG_TEXT, __VA_ARGS__)
#endif
#if USE_XTHEME
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL SemiWhitePixel = {0xFF, 0xFF, 0xFF, 0xD2}; //semitransparent white
#else
EG_IMAGE *FontImage = NULL; //theme member
CONST EG_PIXEL SemiWhitePixel = {255, 255, 255, 210}; //semitransparent
#endif
#if USE_XTHEME
#else
INTN FontWidth = 9; //local variable
INTN FontHeight = 18;
INTN TextHeight = 19;
#endif
NSVGfontChain *fontsDB = NULL;
//
// Text rendering
//
#if USE_XTHEME
//it is not good for vector theme
//it will be better to sum each letter width for the chosen font
// so one more parameter is TextStyle
@ -95,20 +81,6 @@ VOID XTheme::MeasureText(IN const XStringW& Text, OUT INTN *Width, OUT INTN *Hei
if (Height != NULL)
*Height = ScaledHeight;
}
#else
VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height)
{
INTN ScaledWidth = (INTN)(GlobalConfig.CharWidth * GlobalConfig.Scale);
if (Width != NULL)
*Width = StrLen(Text) * ((FontWidth > ScaledWidth)?FontWidth:ScaledWidth);
if (Height != NULL)
*Height = FontHeight;
}
#endif
#if USE_XTHEME
void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
{
EFI_STATUS Status = EFI_NOT_FOUND;
@ -195,95 +167,6 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
}
}
#else
//should be rewritten to use XImage and XStringW
EG_IMAGE * egLoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
{
EG_IMAGE *NewImage = NULL, *NewFontImage;
INTN ImageWidth, ImageHeight, x, y, Ypos, j;
EG_PIXEL *PixelPtr, FirstPixel;
BOOLEAN isKorean = (gLanguage == korean);
CHAR16 *fontFilePath = NULL;
CONST CHAR16 *commonFontDir = L"EFI\\CLOVER\\font";
if (IsEmbeddedTheme() && !isKorean) { //or initial screen before theme init
NewImage = egDecodePNG(ACCESS_EMB_DATA(emb_font_data), ACCESS_EMB_SIZE(emb_font_data), TRUE);
MsgLog("Using embedded font: %s\n", NewImage ? "Success" : "Error");
} else {
if (!GlobalConfig.TypeSVG) {
NewImage = egLoadImage(ThemeDir, isKorean ? L"FontKorean.png" : GlobalConfig.FontFileName, TRUE);
MsgLog("Loading font from ThemeDir: %s\n", NewImage ? "Success" : "Error");
} else {
MsgLog("Using SVG font\n");
return FontImage;
}
}
if (!NewImage) {
//then take from common font folder
fontFilePath = PoolPrint(L"%s\\%s", commonFontDir, isKorean ? L"FontKorean.png" : GlobalConfig.FontFileName);
NewImage = egLoadImage(SelfRootDir, fontFilePath, TRUE);
//else use embedded
if (!NewImage) {
if (UseEmbedded) {
NewImage = egDecodePNG(ACCESS_EMB_DATA(emb_font_data), ACCESS_EMB_SIZE(emb_font_data), TRUE);
} else {
MsgLog("Font %ls is not loaded\n", fontFilePath);
FreePool(fontFilePath);
return NULL;
}
}
FreePool(fontFilePath);
}
ImageWidth = NewImage->Width;
// DBG("ImageWidth=%lld\n", ImageWidth);
ImageHeight = NewImage->Height;
// DBG("ImageHeight=%lld\n", ImageHeight);
PixelPtr = NewImage->PixelData;
NewFontImage = egCreateImage(ImageWidth * Rows, ImageHeight / Rows, TRUE);
if (NewFontImage == NULL) {
DBG("Can't create new font image!\n");
if (NewImage) {
egFreeImage(NewImage);
}
return NULL;
}
FontWidth = ImageWidth / Cols;
FontHeight = ImageHeight / Rows;
TextHeight = FontHeight + (int)(TEXT_YMARGIN * 2 * GlobalConfig.Scale);
FirstPixel = *PixelPtr;
for (y = 0; y < Rows; y++) {
for (j = 0; j < FontHeight; j++) {
Ypos = ((j * Rows) + y) * ImageWidth;
for (x = 0; x < ImageWidth; x++) {
if (
//First pixel is accounting as "blue key"
(PixelPtr->b == FirstPixel.b) &&
(PixelPtr->g == FirstPixel.g) &&
(PixelPtr->r == FirstPixel.r)
) {
PixelPtr->a = 0; //if a pixel has same color as first pixel then it will be transparent
} else if (GlobalConfig.DarkEmbedded) {
*PixelPtr = SemiWhitePixel;
}
NewFontImage->PixelData[Ypos + x] = *PixelPtr++;
}
}
}
egFreeImage(NewImage);
return NewFontImage;
}
#endif
#if USE_XTHEME
VOID XTheme::PrepareFont()
{
@ -319,66 +202,7 @@ VOID XTheme::PrepareFont()
}
}
#else
VOID PrepareFont()
{
EG_PIXEL *p;
INTN Width, Height;
TextHeight = FontHeight + (int)(TEXT_YMARGIN * 2 * GlobalConfig.Scale);
if (GlobalConfig.TypeSVG) {
// FontImage = RenderSVGfont();
return;
}
if (FontImage) {
egFreeImage(FontImage);
FontImage = NULL;
}
if (gLanguage == korean) {
FontImage = egLoadFontImage(FALSE, 10, 28);
if (FontImage) {
GlobalConfig.CharWidth = 22;
MsgLog("Using Korean font matrix\n");
return;
} else {
MsgLog("Korean font image not loaded, use english\n");
gLanguage = english;
}
}
// load the font
if (FontImage == NULL){
DBG("load font image type %d\n", GlobalConfig.Font);
FontImage = egLoadFontImage(TRUE, 16, 16); //anyway success
}
if (FontImage) {
if (GlobalConfig.Font == FONT_GRAY) {
//invert the font. embedded is dark
p = FontImage->PixelData;
for (Height = 0; Height < FontImage->Height; Height++){
for (Width = 0; Width < FontImage->Width; Width++, p++){
p->b ^= 0xFF;
p->g ^= 0xFF;
p->r ^= 0xFF;
//p->a = 0xFF; //huh!
}
}
}
DBG("Font %d prepared WxH=%lldx%lld CharWidth=%lld\n", GlobalConfig.Font, FontWidth, FontHeight, GlobalConfig.CharWidth);
// TextHeight = FontHeight + TEXT_YMARGIN * 2;
} else {
DBG("Failed to load font\n");
}
}
#endif
//search pixel similar to first
#if USE_XTHEME
inline bool SamePix(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Ptr, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& FirstPixel)
{
//compare with first pixel of the array top-left point [0][0]
@ -422,42 +246,7 @@ INTN XTheme::GetEmpty(const XImage& Buffer, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL&
}
return m;
}
#else
static inline BOOLEAN EmptyPix(EG_PIXEL *Ptr, EG_PIXEL *FirstPixel)
{
//compare with first pixel of the array top-left point [0][0]
return ((Ptr->r >= FirstPixel->r - (FirstPixel->r >> 2)) &&
(Ptr->r <= FirstPixel->r + (FirstPixel->r >> 2)) &&
(Ptr->g >= FirstPixel->g - (FirstPixel->g >> 2)) &&
(Ptr->g <= FirstPixel->g + (FirstPixel->g >> 2)) &&
(Ptr->b >= FirstPixel->b - (FirstPixel->b >> 2)) &&
(Ptr->b <= FirstPixel->b + (FirstPixel->b >> 2)) &&
(Ptr->a == FirstPixel->a)); //hack for transparent fonts
}
INTN GetEmpty(EG_PIXEL *Ptr, EG_PIXEL *FirstPixel, INTN MaxWidth, INTN Step, INTN Row)
{
INTN i, j, m;
EG_PIXEL *Ptr0, *Ptr1;
Ptr1 = (Step > 0)?Ptr:Ptr - 1;
m = MaxWidth;
for (j = 0; j < FontHeight; j++) {
Ptr0 = Ptr1 + j * Row;
for (i = 0; i < MaxWidth; i++) {
if (!EmptyPix(Ptr0, FirstPixel)) {
break;
}
Ptr0 += Step;
}
m = (i > m)?m:i;
}
return m;
}
#endif
#if USE_XTHEME
INTN XTheme::RenderText(IN const XString& Text, OUT XImage* CompImage_ptr,
IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType, float textScale)
{
@ -634,147 +423,5 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
}
return PosX;
}
#else
INTN egRenderText(IN CONST CHAR16 *Text, IN OUT EG_IMAGE *CompImage,
IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType)
{
EG_PIXEL *BufferPtr;
EG_PIXEL *FontPixelData;
EG_PIXEL *FirstPixelBuf;
INTN BufferLineWidth, BufferLineOffset, FontLineOffset;
INTN TextLength /*, NewTextLength = 0 */;
INTN i;
UINT16 c, c1, c0;
UINTN Shift = 0;
UINTN Cho = 0, Jong = 0, Joong = 0;
UINTN LeftSpace, RightSpace;
INTN RealWidth = 0;
INTN ScaledWidth = (INTN)(GlobalConfig.CharWidth * GlobalConfig.Scale);
if (GlobalConfig.TypeSVG) {
return renderSVGtext(CompImage, PosX, PosY, textType, Text, Cursor);
}
// clip the text
TextLength = StrLen(Text);
if (!FontImage) {
// GlobalConfig.Font = FONT_ALFA;
PrepareFont(); //at the boot screen there is embedded font
}
// DBG("TextLength =%d PosX=%d PosY=%d\n", TextLength, PosX, PosY);
// render it
BufferPtr = CompImage->PixelData;
BufferLineOffset = CompImage->Width;
BufferLineWidth = BufferLineOffset - PosX; // remove indent from drawing width
BufferPtr += PosX + PosY * BufferLineOffset;
FirstPixelBuf = BufferPtr;
FontPixelData = FontImage->PixelData;
FontLineOffset = FontImage->Width;
// DBG("BufferLineOffset=%d FontLineOffset=%d\n", BufferLineOffset, FontLineOffset);
if (ScaledWidth < FontWidth) {
Shift = (FontWidth - ScaledWidth) >> 1;
}
c0 = 0;
RealWidth = ScaledWidth;
// DBG("FontWidth=%d, CharWidth=%d\n", FontWidth, RealWidth);
for (i = 0; i < TextLength; i++) {
c = Text[i];
if (gLanguage != korean) {
c1 = (((c >= GlobalConfig.Codepage) ? (c - (GlobalConfig.Codepage - AsciiPageSize)) : c) & 0xff); //International letters
c = c1;
if (GlobalConfig.Proportional) {
if (c0 <= 0x20) { // space before or at buffer edge
LeftSpace = 2;
} else {
LeftSpace = GetEmpty(BufferPtr, FirstPixelBuf, ScaledWidth, -1, BufferLineOffset);
}
if (c <= 0x20) { //new space will be half width
RightSpace = 1;
RealWidth = (ScaledWidth >> 1) + 1;
} else {
RightSpace = GetEmpty(FontPixelData + c * FontWidth, FontPixelData, FontWidth, 1, FontLineOffset);
if (RightSpace >= ScaledWidth + Shift) {
RightSpace = 0; //empty place for invisible characters
}
RealWidth = FontWidth - RightSpace;
}
} else {
LeftSpace = 2;
RightSpace = Shift;
}
c0 = c; //old value
if ((UINTN)BufferPtr + RealWidth * 4 > (UINTN)FirstPixelBuf + BufferLineWidth * 4) {
break;
}
egRawCompose(BufferPtr - LeftSpace + 2, FontPixelData + c * FontWidth + RightSpace,
RealWidth, FontHeight,
BufferLineOffset, FontLineOffset);
if (i == Cursor) {
c = 0x5F;
egRawCompose(BufferPtr - LeftSpace + 2, FontPixelData + c * FontWidth + RightSpace,
RealWidth, FontHeight,
BufferLineOffset, FontLineOffset);
}
BufferPtr += RealWidth - LeftSpace + 2;
} else {
//
if ((c >= 0x20) && (c <= 0x7F)) {
c1 = ((c - 0x20) >> 4) * 28 + (c & 0x0F);
Cho = c1;
Shift = 12;
} else if ((c < 0x20) || ((c > 0x7F) && (c < 0xAC00))) {
Cho = 0x0E; //just a dot
Shift = 8;
} else if ((c >= 0xAC00) && (c <= 0xD638)) {
//korean
Shift = 18;
c -= 0xAC00;
c1 = c / 28;
Jong = c % 28;
Cho = c1 / 21;
Joong = c1 % 21;
Cho += 28 * 7;
Joong += 28 * 8;
Jong += 28 * 9;
}
// DBG("Cho=%d Joong=%d Jong=%d\n", Cho, Joong, Jong);
if (Shift == 18) {
egRawCompose(BufferPtr, FontPixelData + Cho * FontWidth + 4 + FontLineOffset,
ScaledWidth, FontHeight,
BufferLineOffset, FontLineOffset);
} else {
egRawCompose(BufferPtr + BufferLineOffset * 3, FontPixelData + Cho * FontWidth + 2,
ScaledWidth, FontHeight,
BufferLineOffset, FontLineOffset);
}
if (i == Cursor) {
c = 99;
egRawCompose(BufferPtr, FontPixelData + c * FontWidth + 2,
ScaledWidth, FontHeight,
BufferLineOffset, FontLineOffset);
}
if (Shift == 18) {
egRawCompose(BufferPtr + 9, FontPixelData + Joong * FontWidth + 6, //9 , 4 are tunable
ScaledWidth - 8, FontHeight,
BufferLineOffset, FontLineOffset);
egRawCompose(BufferPtr + BufferLineOffset * 9, FontPixelData + Jong * FontWidth + 1,
ScaledWidth, FontHeight - 3,
BufferLineOffset, FontLineOffset);
}
BufferPtr += Shift;
}
}
return ((INTN)BufferPtr - (INTN)FirstPixelBuf) / sizeof(EG_PIXEL);
}
#endif
/* EOF */

View File

@ -49,430 +49,3 @@
#define DBG(...) DebugLog(DEBUG_ICNS, __VA_ARGS__)
#endif
//
// well-known icons
//
#if !USE_XTHEME
BUILTIN_ICON BuiltinIconTable[] = {
{ NULL, L"icons\\func_about" , L"png", /*48*/32 },
{ NULL, L"icons\\func_options" , L"png", /*48*/32 },
{ NULL, L"icons\\func_clover" , L"png", /*48*/32 },
{ NULL, L"icons\\func_secureboot" , L"png", /*48*/32 },
{ NULL, L"icons\\func_secureboot_config" , L"png", /*48*/32 },
{ NULL, L"icons\\func_reset" , L"png", /*48*/32 },
{ NULL, L"icons\\func_shutdown" , L"png", /*48*/32 },
{ NULL, L"icons\\func_help" , L"png", /*48*/32 },
{ NULL, L"icons\\tool_shell" , L"png", /*48*/32 },
{ NULL, L"icons\\tool_part" , L"png", /*48*/32 },
{ NULL, L"icons\\tool_rescue" , L"png", /*48*/32 },
{ NULL, L"icons\\pointer" , L"png", /*48*/32 },//11
{ NULL, L"icons\\vol_internal" , L"icns", 128 },
{ NULL, L"icons\\vol_external" , L"icns", 128 },
{ NULL, L"icons\\vol_optical" , L"icns", 128 },
{ NULL, L"icons\\vol_firewire" , L"icns", 128 },
{ NULL, L"icons\\vol_clover" , L"icns", 128 },
{ NULL, L"icons\\vol_internal_hfs" , L"icns", 128 },
{ NULL, L"icons\\vol_internal_apfs" , L"icns", 128 },
{ NULL, L"icons\\vol_internal_ntfs" , L"icns", 128 },
{ NULL, L"icons\\vol_internal_ext3" , L"icns", 128 },
{ NULL, L"icons\\vol_recovery" , L"icns", 128 },//21
{ NULL, L"logo" , L"png", 128 },
{ NULL, L"selection_small" , L"png", 64 },
{ NULL, L"selection_big" , L"png", 144 },
{ NULL, NULL , NULL, 0 }
};
/*
typedef struct MISC_ICONS {
EG_IMAGE *image;
CHAR8 *name;
} MISC_ICONS;
*/
MISC_ICONS OSIconsTable[] = {
{NULL, "os_mac"}, //0
{NULL, "os_tiger"},
{NULL, "os_leo"},
{NULL, "os_snow"},
{NULL, "os_lion"},
{NULL, "os_cougar"},
{NULL, "os_mav"},
{NULL, "os_yos"},
{NULL, "os_cap"},
{NULL, "os_sierra"},
{NULL, "os_hsierra"},
{NULL, "os_moja"}, //11
{NULL, "os_cata"}, //12
{NULL, "os_linux"},
{NULL, "os_ubuntu"},
{NULL, "os_suse"},
{NULL, "os_freebsd"}, //16
{NULL, "os_freedos"},
{NULL, "os_win"},
{NULL, "os_vista"},
{NULL, "radio_button"},
{NULL, "radio_button_selected"},
{NULL, "checkbox"},
{NULL, "checkbox_checked"},
{NULL, "scrollbar_background"}, //24
{NULL, "scrollbar_holder"},
// {NULL, "selection_indicator"},
{NULL, NULL}
};
//#define DEC_BUILTIN_ICON(id, ico) BuiltinIconTable[id].Image = egDecodePNG(ico, sizeof(ico), BuiltinIconTable[id].PixelSize, TRUE)
//#define DEC_BUILTIN_ICON(id, ico) BuiltinIconTable[id].Image = egDecodePNG(&ico[0], SZ_##ico, TRUE)
#define DEC_BUILTIN_ICON(id, ico) BuiltinIconTable[id].Image = egDecodePNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico), TRUE)
CHAR16 * GetIconsExt(IN CONST CHAR16 *Icon, IN CONST CHAR16 *Def)
{
return PoolPrint(L"%s.%s", Icon, ((GlobalConfig.IconFormat != ICON_FORMAT_DEF) && (IconFormat != NULL)) ? IconFormat : Def);
}
#endif
#if !USE_XTHEME
EG_IMAGE * BuiltinIcon(IN UINTN Id)
{
INTN Size;
EG_IMAGE *TextBuffer = NULL;
CONST CHAR16 *p;
CHAR16 *Text;
// DBG("Take image for %d\n", Id);
if (Id >= BUILTIN_ICON_COUNT) {
return NULL;
}
if (BuiltinIconTable[Id].Image != NULL) {
// DBG(" ... the image present\n");
return BuiltinIconTable[Id].Image;
}
Size = BuiltinIconTable[Id].PixelSize;
// DBG("Load Icon [id:%d]");
if (ThemeDir && !GlobalConfig.TypeSVG) {
CHAR16 *Path;
Path = GetIconsExt(BuiltinIconTable[Id].Path, BuiltinIconTable[Id].Format);
BuiltinIconTable[Id].Image = LoadIcnsFallback(ThemeDir, Path, Size);
if (!BuiltinIconTable[Id].Image) {
DebugLog(1, " [!] Icon %llu (%ls) not found (path: %ls)\n", Id, Path, ThemePath);
if (Id >= BUILTIN_ICON_VOL_INTERNAL) {
FreePool(Path);
Path = GetIconsExt(BuiltinIconTable[BUILTIN_ICON_VOL_INTERNAL].Path, BuiltinIconTable[BUILTIN_ICON_VOL_INTERNAL].Format);
BuiltinIconTable[Id].Image = LoadIcnsFallback(ThemeDir, Path, Size);
}
}
FreePool(Path);
}
if (BuiltinIconTable[Id].Image) {
return BuiltinIconTable[Id].Image;
}
if (GlobalConfig.DarkEmbedded) {
switch (Id) {
case BUILTIN_ICON_POINTER:
DEC_BUILTIN_ICON(Id, emb_pointer); break;
case BUILTIN_ICON_FUNC_ABOUT:
DEC_BUILTIN_ICON(Id, emb_dark_func_about); break;
case BUILTIN_ICON_FUNC_OPTIONS:
DEC_BUILTIN_ICON(Id, emb_dark_func_options); break;
case BUILTIN_ICON_FUNC_CLOVER:
DEC_BUILTIN_ICON(Id, emb_dark_func_clover); break;
case BUILTIN_ICON_FUNC_SECURE_BOOT:
DEC_BUILTIN_ICON(Id, emb_dark_func_secureboot); break;
case BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG:
DEC_BUILTIN_ICON(Id, emb_dark_func_secureboot_config); break;
case BUILTIN_ICON_FUNC_RESET:
DEC_BUILTIN_ICON(Id, emb_dark_func_reset); break;
case BUILTIN_ICON_FUNC_EXIT:
DEC_BUILTIN_ICON(Id, emb_dark_func_exit); break;
case BUILTIN_ICON_FUNC_HELP:
DEC_BUILTIN_ICON(Id, emb_dark_func_help); break;
case BUILTIN_ICON_TOOL_SHELL:
DEC_BUILTIN_ICON(Id, emb_dark_func_shell); break;
case BUILTIN_ICON_VOL_INTERNAL:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal); break;
case BUILTIN_ICON_VOL_EXTERNAL:
DEC_BUILTIN_ICON(Id, emb_dark_vol_external); break;
case BUILTIN_ICON_VOL_OPTICAL:
DEC_BUILTIN_ICON(Id, emb_dark_vol_optical); break;
case BUILTIN_ICON_VOL_BOOTER:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal_booter); break;
case BUILTIN_ICON_VOL_INTERNAL_HFS:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal_hfs); break;
case BUILTIN_ICON_VOL_INTERNAL_APFS:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal_apfs); break;
case BUILTIN_ICON_VOL_INTERNAL_NTFS:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal_ntfs); break;
case BUILTIN_ICON_VOL_INTERNAL_EXT3:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal_ext); break;
case BUILTIN_ICON_VOL_INTERNAL_REC:
DEC_BUILTIN_ICON(Id, emb_dark_vol_internal_recovery); break;
case BUILTIN_ICON_BANNER:
DEC_BUILTIN_ICON(Id, emb_dark_logo); break;
case BUILTIN_SELECTION_SMALL:
DEC_BUILTIN_ICON(Id, emb_dark_selection_small); break;
case BUILTIN_SELECTION_BIG:
DEC_BUILTIN_ICON(Id, emb_dark_selection_big); break;
}
} else {
switch (Id) {
case BUILTIN_ICON_POINTER:
DEC_BUILTIN_ICON(Id, emb_pointer); break;
case BUILTIN_ICON_FUNC_ABOUT:
DEC_BUILTIN_ICON(Id, emb_func_about); break;
case BUILTIN_ICON_FUNC_OPTIONS:
DEC_BUILTIN_ICON(Id, emb_func_options); break;
case BUILTIN_ICON_FUNC_CLOVER:
DEC_BUILTIN_ICON(Id, emb_func_clover); break;
case BUILTIN_ICON_FUNC_SECURE_BOOT:
DEC_BUILTIN_ICON(Id, emb_func_secureboot); break;
case BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG:
DEC_BUILTIN_ICON(Id, emb_func_secureboot_config); break;
case BUILTIN_ICON_FUNC_RESET:
DEC_BUILTIN_ICON(Id, emb_func_reset); break;
case BUILTIN_ICON_FUNC_EXIT:
DEC_BUILTIN_ICON(Id, emb_func_exit); break;
case BUILTIN_ICON_FUNC_HELP:
DEC_BUILTIN_ICON(Id, emb_func_help); break;
case BUILTIN_ICON_TOOL_SHELL:
DEC_BUILTIN_ICON(Id, emb_func_shell); break;
case BUILTIN_ICON_VOL_INTERNAL:
DEC_BUILTIN_ICON(Id, emb_vol_internal); break;
case BUILTIN_ICON_VOL_EXTERNAL:
DEC_BUILTIN_ICON(Id, emb_vol_external); break;
case BUILTIN_ICON_VOL_OPTICAL:
DEC_BUILTIN_ICON(Id, emb_vol_optical); break;
case BUILTIN_ICON_VOL_BOOTER:
DEC_BUILTIN_ICON(Id, emb_vol_internal_booter); break;
case BUILTIN_ICON_VOL_INTERNAL_HFS:
DEC_BUILTIN_ICON(Id, emb_vol_internal_hfs); break;
case BUILTIN_ICON_VOL_INTERNAL_APFS:
DEC_BUILTIN_ICON(Id, emb_vol_internal_apfs); break;
case BUILTIN_ICON_VOL_INTERNAL_NTFS:
DEC_BUILTIN_ICON(Id, emb_vol_internal_ntfs); break;
case BUILTIN_ICON_VOL_INTERNAL_EXT3:
DEC_BUILTIN_ICON(Id, emb_vol_internal_ext); break;
case BUILTIN_ICON_VOL_INTERNAL_REC:
DEC_BUILTIN_ICON(Id, emb_vol_internal_recovery); break;
case BUILTIN_ICON_BANNER:
DEC_BUILTIN_ICON(Id, emb_logo); break;
case BUILTIN_SELECTION_SMALL:
DEC_BUILTIN_ICON(Id, emb_selection_small); break;
case BUILTIN_SELECTION_BIG:
DEC_BUILTIN_ICON(Id, emb_selection_big); break;
}
}
// DBG("Icon %d decoded, pointer %X\n", Id, (UINTN)(BuiltinIconTable[Id].Image));
if (!BuiltinIconTable[Id].Image) {
TextBuffer = egCreateFilledImage(Size, Size, TRUE, &MenuBackgroundPixel); //new pointer
// egFillImage(TextBuffer, &MenuBackgroundPixel);
p = StrStr(BuiltinIconTable[Id].Path, L"_"); p++;
Text = (CHAR16*)AllocateCopyPool(30, (VOID*)p);
// the 2 next lines seems to be useless, because there is no '.' in BuiltinIconTable
// TODO jief : double check
// p = StrStr(Text, L".");
// *p = L'\0';
if (StrCmp(Text, L"shutdown") == 0) {
// icon name is shutdown from historic reasons, but function is now exit
snwprintf(Text, 30, "exit");
}
egRenderText(Text, TextBuffer, 0, 0, 0xFFFF, 1);
BuiltinIconTable[Id].Image = TextBuffer;
DebugLog(1, " [!] Icon %llu: Text <%ls> rendered\n", Id, Text);
FreePool(Text);
}
return BuiltinIconTable[Id].Image;
}
#endif
//
// Load an icon for an operating system
//
#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 *Image;
CHAR16 CutoutName[16], FirstName[16];
CHAR16 FileName[256];
UINTN StartIndex, Index, NextIndex;
if (GlobalConfig.TextOnly) // skip loading if it's not used anyway
return NULL;
Image = NULL;
*FirstName = 0;
// try the names from OSIconName
for (StartIndex = 0; OSIconName != NULL && OSIconName[StartIndex]; StartIndex = NextIndex) {
// find the next name in the list
NextIndex = 0;
for (Index = StartIndex; OSIconName[Index]; Index++) {
if (OSIconName[Index] == ',') {
NextIndex = Index + 1;
break;
}
}
if (OSIconName[Index] == 0)
NextIndex = Index;
// construct full path
if (Index > StartIndex + 15) // prevent buffer overflow
continue;
CopyMem(CutoutName, OSIconName + StartIndex, (Index - StartIndex) * sizeof(CHAR16));
CutoutName[Index - StartIndex] = 0;
snwprintf(FileName, 512, "icons\\%ls_%ls.icns",
BootLogo ? L"boot" : L"os", CutoutName);
// try to load it
Image = egLoadIcon(ThemeDir, FileName, PixelSize);
if (Image != NULL) {
return Image;
}
if (*FirstName == '\0') {
CopyMem(FirstName, CutoutName, StrSize(CutoutName));
if ('a' <= FirstName[0] && FirstName[0] <= 'z') {
FirstName[0] = (CHAR16) (FirstName[0] - 0x20);
}
}
}
// try the fallback name
snwprintf(FileName, 512, "icons\\%ls_%ls.icns",
BootLogo ? L"boot" : L"os", FallbackIconName);
Image = egLoadIcon(ThemeDir, FileName, PixelSize);
if (Image != NULL) {
return Image;
}
// try the fallback name with os_ instead of boot_
if (BootLogo) {
Image = LoadOSIcon(NULL, FallbackIconName, PixelSize, FALSE, WantDummy);
if (Image != NULL)
return Image;
}
if (!WantDummy) {
return NULL;
}
if (IsEmbeddedTheme()) { // embedded theme - return rendered icon name
// EG_IMAGE *TextBuffer = egCreateFilledImage(PixelSize, PixelSize, TRUE, &MenuBackgroundPixel);
// egFillImage(TextBuffer, &MenuBackgroundPixel);
// egRenderText(FirstName, TextBuffer, PixelSize/4, PixelSize/3, 0xFFFF, 1);
// DebugLog(1, "Text <%s> rendered\n", FirstName);
return NULL; //TextBuffer;
}
return DummyImage(PixelSize);
}
#endif
//
// Load an image from a .icns file
//
#if USE_XTHEME
EFI_STATUS XImage::LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize)
{
if (GlobalConfig.TextOnly) // skip loading if it's not used anyway
return EFI_SUCCESS;
if (BaseDir) {
EFI_STATUS Status = EFI_NOT_FOUND;
UINT8 *FileData = NULL;
UINTN FileDataLength = 0;
EG_IMAGE *NewImage;
// load file
Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength);
if (EFI_ERROR(Status)) {
return Status;
}
// decode it
NewImage = egDecodeICNS(FileData, FileDataLength, PixelSize, TRUE);
Status = FromEGImage(NewImage);
FreePool(FileData);
return Status;
}
return EFI_NOT_FOUND;
}
#else
EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize)
{
if (GlobalConfig.TextOnly) // skip loading if it's not used anyway
return NULL;
if (BaseDir) {
EFI_STATUS Status = EFI_NOT_FOUND;
UINT8 *FileData = NULL;
UINTN FileDataLength = 0;
EG_IMAGE *NewImage;
// load file
Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength);
if (EFI_ERROR(Status)) {
return NULL;
}
// decode it
NewImage = egDecodeICNS(FileData, FileDataLength, PixelSize, TRUE);
FreePool(FileData);
return NewImage;
}
return DummyImage(PixelSize);
}
#endif
#if !USE_XTHEME
EG_IMAGE * DummyImage(IN UINTN PixelSize)
{
EG_IMAGE *Image;
UINTN x, y, LineOffset;
CHAR8 *Ptr, *YPtr;
Image = egCreateFilledImage(PixelSize, PixelSize, TRUE, &BlackPixel);
LineOffset = PixelSize * 4;
YPtr = (CHAR8 *)Image->PixelData + ((PixelSize - 32) >> 1) * (LineOffset + 4);
for (y = 0; y < 32; y++) {
Ptr = YPtr;
for (x = 0; x < 32; x++) {
if (((x + y) % 12) < 6) {
*Ptr++ = 0;
*Ptr++ = 0;
*Ptr++ = 0;
} else {
*Ptr++ = 0;
*Ptr++ = ~0; //yellow
*Ptr++ = ~0;
}
*Ptr++ = ~111;
}
YPtr += LineOffset;
}
return Image;
}
EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize)
{
EG_IMAGE *Image;
if (GlobalConfig.TextOnly) // skip loading if it's not used anyway
return NULL;
Image = egLoadIcon(BaseDir, FileName, PixelSize);
// if (Image == NULL)
// Image = DummyImage(PixelSize);
return Image;
}
#endif

View File

@ -59,12 +59,8 @@ CHAR16 *SelfDirPath;
EFI_DEVICE_PATH *SelfDevicePath;
EFI_DEVICE_PATH *SelfFullDevicePath;
#if USE_XTHEME
XTheme ThemeX;
#else
EFI_FILE *ThemeDir = NULL; //it is XTheme member
#endif
CHAR16 *ThemePath;
BOOLEAN gThemeChanged = FALSE;
//BOOLEAN gBootArgsChanged = FALSE;
@ -244,17 +240,10 @@ VOID UninitRefitLib(VOID)
OEMDir->Close(OEMDir);
OEMDir = NULL;
}
#if USE_XTHEME
if (ThemeX.ThemeDir != NULL) {
ThemeX.ThemeDir->Close(ThemeX.ThemeDir);
ThemeX.ThemeDir = NULL;
}
#else
if (ThemeDir != NULL) {
ThemeDir->Close(ThemeDir);
ThemeDir = NULL;
}
#endif
if (SelfRootDir != NULL) {
@ -309,11 +298,7 @@ EFI_STATUS ReinitSelfLib(VOID)
return EFI_NOT_FOUND;
}
SelfDeviceHandle = NewSelfHandle;
#if USE_XTHEME
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeX.ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#else
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#endif
/*Status = */SelfRootDir->Open(SelfRootDir, &OEMDir, OEMPath, EFI_FILE_MODE_READ, 0);
@ -336,17 +321,12 @@ EFI_STATUS FinishInitRefitLib(VOID)
return EFI_LOAD_ERROR;
}
}
#if USE_XTHEME
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeX.ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#else
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#endif
/*Status = */SelfRootDir->Open(SelfRootDir, &OEMDir, OEMPath, EFI_FILE_MODE_READ, 0);
Status = SelfRootDir->Open(SelfRootDir, &SelfDir, SelfDirPath, EFI_FILE_MODE_READ, 0);
CheckFatalError(Status, L"while opening our installation directory");
return Status;
}
#if USE_XTHEME
BOOLEAN IsEmbeddedTheme()
{
if (ThemeX.embedded) {
@ -354,62 +334,9 @@ BOOLEAN IsEmbeddedTheme()
}
return ThemeX.ThemeDir == NULL;
}
#else
BOOLEAN IsEmbeddedTheme()
{
if (!GlobalConfig.Theme || !StriCmp(GlobalConfig.Theme, L"embedded")) {
ThemeDir = NULL;
}
return ThemeDir == NULL;
}
#endif
//
// list functions
//
//
//VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount)
//{
// UINTN AllocateCount;
//
// *ElementCount = InitialElementCount;
// if (*ElementCount > 0) {
// AllocateCount = (*ElementCount + 7) & ~7; // next multiple of 8
// *ListPtr = (__typeof_am__(*ListPtr))AllocatePool(sizeof(VOID *) * AllocateCount);
// } else {
// *ListPtr = NULL;
// }
//}
//
//VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID *NewElement)
//{
// UINTN AllocateCount;
//
// if ((*ElementCount & 7) == 0) {
// AllocateCount = *ElementCount + 8;
// if (*ElementCount == 0)
// *ListPtr = (__typeof_am__(*ListPtr))AllocatePool(sizeof(VOID *) * AllocateCount);
// else
// *ListPtr = (__typeof_am__(*ListPtr))EfiReallocatePool((VOID *)*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount);
// }
// (*ListPtr)[*ElementCount] = NewElement;
// (*ElementCount)++;
//}
/*
VOID FreeList(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount)
{
UINTN i;
if (*ElementCount > 0) {
for (i = 0; i < *ElementCount; i++) {
// TODO: call a user-provided routine for each element here
FreePool((*ListPtr)[i]);
}
FreePool(*ListPtr);
}
}
*/
//
// firmware device path discovery
//

View File

@ -62,10 +62,8 @@
#include "../cpp_foundation/XObjArray.h"
#include "../cpp_foundation/XStringWArray.h"
#include "../cpp_foundation/XStringW.h"
#if USE_XTHEME
#include "../libeg/XTheme.h"
extern XTheme ThemeX; //global variable defined in lib.cpp
#endif
#endif
@ -220,22 +218,6 @@ typedef struct _pointers {
// Allow for 255 unicode characters + 2 byte unicode null terminator.
#define SVALUE_MAX_SIZE 512
//extern BOOLEAN ScrollEnabled;
#if !USE_XTHEME
//extern EG_RECT UpButton;
//extern EG_RECT DownButton;
//extern EG_RECT BarStart;
//extern EG_RECT BarEnd;
//extern EG_RECT ScrollbarBackground;
//extern EG_RECT Scrollbar;
//extern EG_RECT ScrollStart;
//extern EG_RECT ScrollEnd;
//extern EG_RECT ScrollTotal;
//extern EG_RECT ScrollbarOldPointerPlace;
//extern EG_RECT ScrollbarNewPointerPlace;
#endif
//extern INTN ScrollbarYMovement;
//extern BOOLEAN IsDragging;
#define SCREEN_UNKNOWN 0
#define SCREEN_MAIN 1
@ -309,10 +291,6 @@ typedef struct _pointers {
typedef struct {
INTN Timeout;
UINTN DisableFlags; //to disable some volume types (optical, firewire etc)
#if !USE_XTHEME
UINTN HideBadges;
UINTN HideUIFlags;
#endif
BOOLEAN TextOnly;
BOOLEAN Quiet;
BOOLEAN LegacyFirst;
@ -324,60 +302,16 @@ typedef struct {
BOOLEAN RtcHibernateAware;
BOOLEAN HibernationFixup;
BOOLEAN SignatureFixup;
#if !USE_XTHEME
FONT_TYPE Font;
INTN CharWidth;
UINTN SelectionColor;
CHAR16 *FontFileName;
CHAR16 *BannerFileName;
CHAR16 *SelectionSmallFileName;
CHAR16 *SelectionBigFileName;
CHAR16 *SelectionIndicatorName;
CHAR16 *DefaultSelection;
#endif
CHAR16 *Theme;
CHAR16 *ScreenResolution;
INTN ConsoleMode;
BOOLEAN CustomIcons;
#if !USE_XTHEME
CHAR16 *BackgroundName;
SCALING BackgroundScale;
UINTN BackgroundSharp;
BOOLEAN BackgroundDark;
BOOLEAN SelectionOnTop;
BOOLEAN BootCampStyle;
INTN BadgeOffsetX;
INTN BadgeOffsetY;
INTN BadgeScale;
INTN ThemeDesignWidth;
INTN ThemeDesignHeight;
INTN BannerPosX;
INTN BannerPosY;
INTN BannerEdgeHorizontal;
INTN BannerEdgeVertical;
INTN BannerNudgeX;
INTN BannerNudgeY;
BOOLEAN VerticalLayout;
BOOLEAN NonSelectedGrey;
INTN MainEntriesSize;
INTN TileXSpace;
INTN TileYSpace;
#endif
INTN IconFormat;
BOOLEAN NoEarlyProgress;
INT32 Timezone;
BOOLEAN ShowOptimus;
#if !USE_XTHEME
BOOLEAN Proportional;
BOOLEAN DarkEmbedded;
BOOLEAN TypeSVG;
#endif
INTN Codepage;
INTN CodepageSize;
#if !USE_XTHEME
float Scale;
float CentreShift;
#endif
} REFIT_CONFIG;
// types
@ -410,9 +344,6 @@ extern EFI_FILE *SelfDir;
extern CHAR16 *SelfDirPath;
extern EFI_DEVICE_PATH *SelfDevicePath;
extern EFI_DEVICE_PATH *SelfFullDevicePath;
#if !USE_XTHEME
extern EFI_FILE *ThemeDir;
#endif
extern CHAR16 *ThemePath;
extern EFI_FILE *OEMDir;
extern CHAR16 *OEMPath;
@ -427,14 +358,6 @@ extern XObjArray<REFIT_VOLUME> Volumes;
#endif
//extern UINTN VolumesCount;
#if !USE_XTHEME
extern EG_IMAGE *Banner;
extern EG_IMAGE *BigBack;
extern EG_IMAGE *SelectionImages[];
extern EG_IMAGE *Buttons[];
extern EG_IMAGE *FontImage; //not yet converted to XImage
#endif
extern BOOLEAN gThemeChanged;
//extern BOOLEAN gBootArgsChanged;
extern BOOLEAN gBootChanged;
@ -516,13 +439,7 @@ EFI_STATUS InitializeUnicodeCollationProtocol (VOID);
//extern INTN FontWidth;
//extern INTN FontHeight;
#if !USE_XTHEME
extern INTN row0TileSize;
extern INTN row1TileSize;
extern INTN TextHeight;
#endif
extern const INTN BCSMargin;
#if USE_XTHEME
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel;
@ -534,14 +451,6 @@ extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel;
extern const EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel;
#else
//extern INTN LayoutBannerOffset;
//extern INTN LayoutButtonOffset;
//extern INTN LayoutTextOffset;
//extern INTN LayoutAnimMoveForMenuX;
//extern INTN LayoutMainMenuHeight;
#endif
extern UINTN ConWidth;
extern UINTN ConHeight;
extern CHAR16 *BlankLine;
@ -550,22 +459,6 @@ extern INTN UGAWidth;
extern INTN UGAHeight;
extern BOOLEAN AllowGraphicsMode;
#if !USE_XTHEME
extern EG_PIXEL StdBackgroundPixel;
extern EG_PIXEL MenuBackgroundPixel;
extern EG_PIXEL InputBackgroundPixel;
extern EG_PIXEL BlueBackgroundPixel;
//extern EG_PIXEL DarkBackgroundPixel;
extern EG_PIXEL SelectionBackgroundPixel;
extern EG_PIXEL DarkEmbeddedBackgroundPixel;
extern EG_PIXEL DarkSelectionPixel;
extern EG_PIXEL WhitePixel;
extern EG_PIXEL BlackPixel;
extern EG_RECT BannerPlace;
extern EG_IMAGE *BackgroundImage;
#endif
#if REFIT_DEBUG > 0
VOID DebugPause(VOID);
#else
@ -576,18 +469,6 @@ VOID EndlessIdleLoop(VOID);
BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where);
//
// 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 * 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 * DummyImage(IN UINTN PixelSize);
EG_IMAGE * BuiltinIcon(IN UINTN Id);
CHAR16 * GetIconsExt(IN CONST CHAR16 *Icon, IN CONST CHAR16 *Def);
EG_IMAGE * GetSmallHover(IN UINTN Id);
#endif
#define BUILTIN_ICON_FUNC_ABOUT (0)
#define BUILTIN_ICON_FUNC_OPTIONS (1)
@ -652,15 +533,6 @@ BOOLEAN ReadAllKeyStrokes(VOID);
// config module
//
#if !USE_XTHEME
typedef struct MISC_ICONS {
EG_IMAGE *image;
CONST CHAR8 *name;
} MISC_ICONS;
extern MISC_ICONS OSIconsTable[];
extern BUILTIN_ICON BuiltinIconTable[];
#endif
extern REFIT_CONFIG GlobalConfig;
VOID ReadConfig(INTN What);

View File

@ -647,11 +647,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
DBG("Image is not loaded, status=%s\n", strerror(Status));
return; // no reason to continue if loading image failed
}
#if USE_XTHEME
egClearScreen(&Entry->BootBgColor); //if not set then it is already MenuBackgroundPixel
#else
egClearScreen(Entry->BootBgColor ? Entry->BootBgColor : &MenuBackgroundPixel);
#endif
// KillMouse();
@ -1011,24 +1007,12 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
}
#if USE_XTHEME
egClearScreen(&MenuBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
XImage BootLogoX;
BootLogoX.LoadXImage(ThemeX.ThemeDir, Entry->Volume->LegacyOS->IconName);
BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1,
(UGAHeight - BootLogoX.GetHeight()) >> 1);
#else
egClearScreen(&MenuBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
EG_IMAGE *BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE);
if (BootLogoImage != NULL) {
BltImageAlpha(BootLogoImage,
(UGAWidth - BootLogoImage->Width) >> 1,
(UGAHeight - BootLogoImage->Height) >> 1,
&StdBackgroundPixel, 16);
}
#endif
//try my LegacyBoot
switch (Entry->Volume->BootType) {
@ -2014,12 +1998,8 @@ RefitMain (IN EFI_HANDLE ImageHandle,
BOOLEAN UniteConfigs = FALSE;
EFI_TIME Now;
BOOLEAN HaveDefaultVolume;
#if USE_XTHEME
REFIT_MENU_SCREEN BootScreen;
BootScreen.isBootScreen = true; //other screens will be constructed as false
#else
CHAR16 *FirstMessage;
#endif
// CHAR16 *InputBuffer; //, *Y;
// EFI_INPUT_KEY Key;
@ -2252,9 +2232,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GetListOfConfigs();
}
#if USE_XTHEME
ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings
#endif
for (i=0; i<2; i++) {
if (gConfigDict[i]) {
@ -2317,18 +2295,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// DBG("DBG: messages\n");
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME
XStringW Message = SWPrintf(" Welcome to Clover %ls ", gFirmwareRevision);
BootScreen.DrawTextXY(Message, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER);
BootScreen.DrawTextXY(L"... testing hardware ..."_XSW, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else
FirstMessage = PoolPrint(L" Welcome to Clover %s ", gFirmwareRevision);
DrawTextXY(FirstMessage, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER);
FreePool(FirstMessage);
FirstMessage = PoolPrint(L"... testing hardware ...");
DrawTextXY(FirstMessage, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
FreePool(FirstMessage);
#endif
}
// DumpBiosMemoryMap();
@ -2388,16 +2357,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME
XStringW Message = SWPrintf("... user settings ...");
BootScreen.EraseTextXY();
BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else
FirstMessage = PoolPrint(L"... user settings ...");
// i = (UGAWidth - StrLen(FirstMessage) * GlobalConfig.CharWidth) >> 1;
DrawTextXY(FirstMessage, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
FreePool(FirstMessage);
#endif
}
//Second step. Load config.plist into gSettings
@ -2466,15 +2428,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME
XStringW Message = SWPrintf("... scan entries ...");
BootScreen.EraseTextXY();
BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else
FirstMessage = PoolPrint(L"... scan entries ...");
DrawTextXY(FirstMessage, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
FreePool(FirstMessage);
#endif
}
@ -2536,19 +2492,11 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
DBG("theme inited\n");
gThemeChanged = FALSE;
#if USE_XTHEME
if (ThemeX.embedded) {
DBG("Chosen embedded theme\n");
} else {
DBG("Chosen theme %ls\n", ThemeX.Theme.data());
}
#else
if (GlobalConfig.Theme) {
DBG("Chosen theme %ls\n", GlobalConfig.Theme);
} else {
DBG("Chosen embedded theme\n");
}
#endif
// DBG("initial boot-args=%s\n", gSettings.BootArgs);
//now it is a time to set RtVariables
@ -2588,7 +2536,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
// fixed other menu entries
#if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_TOOLS)) {
AddCustomTool();
if (!gSettings.DisableToolScan) {
@ -2599,41 +2546,18 @@ RefitMain (IN EFI_HANDLE ImageHandle,
#endif // ENABLE_SECURE_BOOT
}
}
#else
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_TOOLS)) {
AddCustomTool();
if (!gSettings.DisableToolScan) {
ScanTool();
#ifdef ENABLE_SECURE_BOOT
// Check for secure boot setup mode
AddSecureBootTool();
#endif // ENABLE_SECURE_BOOT
}
}
#endif
#if USE_XTHEME
MenuEntryOptions.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS);
#else
MenuEntryOptions.Image = BuiltinIcon(BUILTIN_ICON_FUNC_OPTIONS);
#endif
if (gSettings.DisableCloverHotkeys)
MenuEntryOptions.ShortcutLetter = 0x00;
MainMenu.AddMenuEntry(&MenuEntryOptions, false);
#if USE_XTHEME
MenuEntryAbout.Image = ThemeX.GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT);
#else
MenuEntryAbout.Image = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
#endif
if (gSettings.DisableCloverHotkeys)
MenuEntryAbout.ShortcutLetter = 0x00;
MainMenu.AddMenuEntry(&MenuEntryAbout, false);
#if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_FUNCS) || MainMenu.Entries.size() == 0) {
if (gSettings.DisableCloverHotkeys)
MenuEntryReset.ShortcutLetter = 0x00;
@ -2644,29 +2568,12 @@ RefitMain (IN EFI_HANDLE ImageHandle,
MenuEntryShutdown.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_EXIT);
MainMenu.AddMenuEntry(&MenuEntryShutdown, false);
}
#else
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_FUNCS) || MainMenu.Entries.size() == 0) {
if (gSettings.DisableCloverHotkeys)
MenuEntryReset.ShortcutLetter = 0x00;
MenuEntryReset.Image = BuiltinIcon(BUILTIN_ICON_FUNC_RESET);
MainMenu.AddMenuEntry(&MenuEntryReset, false);
if (gSettings.DisableCloverHotkeys)
MenuEntryShutdown.ShortcutLetter = 0x00;
MenuEntryShutdown.Image = BuiltinIcon(BUILTIN_ICON_FUNC_EXIT);
MainMenu.AddMenuEntry(&MenuEntryShutdown, false);
}
#endif
// font already changed and this message very quirky, clear line here
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME
// XStringW Message = L" "_XSW;
BootScreen.EraseTextXY();
// DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else
DrawTextXY(L" ", (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@ -12,15 +12,8 @@
//UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
//UINTN RunMainMenu(IN REFIT_MENU_SCREEN *Screen, IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
extern EG_IMAGE* ScrollbarImage;
extern EG_IMAGE* UpButtonImage;
extern EG_IMAGE* DownButtonImage;
extern EG_IMAGE* ScrollbarBackgroundImage;
extern EG_IMAGE* BarStartImage;
extern EG_IMAGE* BarEndImage;
extern EG_IMAGE* ScrollStartImage;
extern EG_IMAGE* ScrollEndImage;
//included into SCREEN
/*
extern EG_RECT UpButton;
extern EG_RECT DownButton;
extern EG_RECT BarStart;
@ -32,33 +25,13 @@ extern EG_RECT ScrollEnd;
extern EG_RECT ScrollTotal;
extern EG_RECT ScrollbarOldPointerPlace;
extern EG_RECT ScrollbarNewPointerPlace;
*/
extern INTN LayoutAnimMoveForMenuX;
extern INTN LayoutMainMenuHeight;
extern INTN ScrollWidth;
#if !USE_XTHEME
VOID InitBar(VOID);
VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color, IN UINT8 XAlign);
VOID InitSelection(VOID);
#endif
VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
VOID FreeScrollBar(VOID);
#if USE_XTHEME
//it will be REFIT_SCREEN MEMBER, others as well?
#else
INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID DrawMenuText(IN CONST CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor);
VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos);
VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID DrawTextCorner(UINTN TextC, UINT8 Align);
#endif
UINT64 TimeDiff(UINT64 t0, UINT64 t1); //double in Platform.h

View File

@ -81,7 +81,6 @@ INTN UGAHeight;
BOOLEAN AllowGraphicsMode;
EG_RECT BannerPlace; // default ctor called, so it's zero
#if USE_XTHEME
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel = { 0xcf, 0xcf, 0xcf, 0x80};
@ -92,23 +91,6 @@ const EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33,
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
#else
EG_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
EG_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
EG_PIXEL InputBackgroundPixel = { 0xcf, 0xcf, 0xcf, 0x80};
EG_PIXEL BlueBackgroundPixel = { 0x7f, 0x0f, 0x0f, 0xff};
EG_PIXEL EmbeddedBackgroundPixel = { 0xaa, 0xaa, 0xaa, 0xff};
EG_PIXEL DarkSelectionPixel = { 66, 66, 66, 0xff};
EG_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33, 0x33, 0xff};
EG_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff};
EG_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff};
EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
EG_IMAGE *BackgroundImage = NULL;
EG_IMAGE *Banner = NULL;
EG_IMAGE *BigBack = NULL;
#endif
static BOOLEAN GraphicsScreenDirty;
@ -348,16 +330,7 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
VOID SwitchToGraphicsAndClear(VOID) //called from MENU_FUNCTION_INIT
{
SwitchToGraphics();
#if USE_XTHEME
// DBG("clear screen and draw back\n");
// ThemeX.ClearScreen();
// egClearScreen(&MenuBackgroundPixel);
ThemeX.Background.DrawWithoutCompose(0,0,0,0);
#else
if (GraphicsScreenDirty) { //Invented in rEFIt 15 years ago
BltClearScreen();
}
#endif
}
/*
@ -371,181 +344,6 @@ typedef struct {
//same as EgRect but INTN <-> UINTN
*/
#if !USE_XTHEME
VOID BltClearScreen() //ShowBanner always TRUE. Called from line 400
{
EG_PIXEL *p1;
INTN i, j, x, x1, x2, y, y1, y2;
if (BanHeight < 2) {
BanHeight = ((UGAHeight - (int)(LAYOUT_TOTAL_HEIGHT * GlobalConfig.Scale)) >> 1);
//+ (int)(LAYOUT_TOTAL_HEIGHT * GlobalConfig.Scale); //LAYOUT_TOTAL_HEIGHT=376
}
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_BANNER)) {
// Banner is used in this theme
if (!Banner) {
// Banner is not loaded yet
if (IsEmbeddedTheme()) {
// embedded theme - use text as banner
// Banner = egCreateImage(7 * StrLen(L"CLOVER"), 32, TRUE);
// egFillImage(Banner, &MenuBackgroundPixel);
// egRenderText(L"CLOVER", Banner, 0, 0, 0xFFFF);
// CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL));
// DebugLog(1, "Text <%s> rendered\n", L"Clover");
Banner = BuiltinIcon(BUILTIN_ICON_BANNER);
if (GlobalConfig.DarkEmbedded) {
CopyMem(&BlueBackgroundPixel, &DarkEmbeddedBackgroundPixel, sizeof(EG_PIXEL));
} else {
CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL));
}
} else {
Banner = egLoadImage(ThemeDir, GlobalConfig.BannerFileName, FALSE);
if (Banner) {
// Banner was changed, so copy into BlueBackgroundBixel first pixel of banner
CopyMem(&BlueBackgroundPixel, &Banner->PixelData[0], sizeof(EG_PIXEL));
} else {
DBG("banner file not read use embedded\n");
Banner = BuiltinIcon(BUILTIN_ICON_BANNER);
}
}
}
if (Banner) {
// Banner was loaded, so calculate its size and position
BannerPlace.Width = Banner->Width;
BannerPlace.Height = (BanHeight >= Banner->Height) ? (INTN)Banner->Height : BanHeight;
// DBG("banner width-height [%d,%d]\n", BannerPlace.Width, BannerPlace.Height);
// DBG("global banner pos [%d,%d]\n", GlobalConfig.BannerPosX, GlobalConfig.BannerPosY);
if (GlobalConfig.TypeSVG) {
BannerPlace.XPos = GlobalConfig.BannerPosX;
BannerPlace.YPos = GlobalConfig.BannerPosY;
} else {
// Check if new style placement value was used for banner in theme.plist
if ((GlobalConfig.BannerPosX >=0 && GlobalConfig.BannerPosX <=1000) && (GlobalConfig.BannerPosY >=0 && GlobalConfig.BannerPosY <=1000)) {
// Check if screen size being used is different from theme origination size.
// If yes, then recalculate the placement % value.
// This is necessary because screen can be a different size, but banner is not scaled.
BannerPlace.XPos = HybridRepositioning(GlobalConfig.BannerEdgeHorizontal, GlobalConfig.BannerPosX, BannerPlace.Width, UGAWidth, GlobalConfig.ThemeDesignWidth );
BannerPlace.YPos = HybridRepositioning(GlobalConfig.BannerEdgeVertical, GlobalConfig.BannerPosY, BannerPlace.Height, UGAHeight, GlobalConfig.ThemeDesignHeight);
// Check if banner is required to be nudged.
BannerPlace.XPos = CalculateNudgePosition(BannerPlace.XPos, GlobalConfig.BannerNudgeX, Banner->Width, UGAWidth);
BannerPlace.YPos = CalculateNudgePosition(BannerPlace.YPos, GlobalConfig.BannerNudgeY, Banner->Height, UGAHeight);
// DBG("banner position new style\n");
} else {
// Use rEFIt default (no placement values speicifed)
BannerPlace.XPos = (UGAWidth - Banner->Width) >> 1;
BannerPlace.YPos = (BanHeight >= Banner->Height) ? (BanHeight - Banner->Height) : 0;
// DBG("banner position old style\n");
}
}
}
}
// DBG("Banner position [%d,%d]\n", BannerPlace.XPos, BannerPlace.YPos);
if (!Banner || (GlobalConfig.HideUIFlags & HIDEUI_FLAG_BANNER) ||
!IsImageWithinScreenLimits(BannerPlace.XPos, BannerPlace.Width, UGAWidth) ||
!IsImageWithinScreenLimits(BannerPlace.YPos, BannerPlace.Height, UGAHeight)) {
// Banner is disabled or it cannot be used, apply defaults for placement
if (Banner) {
FreePool(Banner);
Banner = NULL;
}
BannerPlace.XPos = 0;
BannerPlace.YPos = 0;
BannerPlace.Width = UGAWidth;
BannerPlace.Height = BanHeight;
}
// Load Background and scale
if (!BigBack && (GlobalConfig.BackgroundName != NULL)) {
BigBack = egLoadImage(ThemeDir, GlobalConfig.BackgroundName, FALSE);
}
if (BackgroundImage != NULL && (BackgroundImage->Width != UGAWidth || BackgroundImage->Height != UGAHeight)) {
// Resolution changed
egFreeImage(BackgroundImage);
BackgroundImage = NULL;
}
if (BackgroundImage == NULL) {
/* DBG("BltClearScreen(%c): calling egCreateFilledImage UGAWidth %ld, UGAHeight %ld, BlueBackgroundPixel %02X%02X%02X%02X\n",
ShowBanner?'Y':'N', UGAWidth, UGAHeight,
BlueBackgroundPixel.r, BlueBackgroundPixel.g, BlueBackgroundPixel.b, BlueBackgroundPixel.a); */
BackgroundImage = egCreateFilledImage(UGAWidth, UGAHeight, FALSE, &BlueBackgroundPixel);
}
if (BigBack != NULL) {
switch (GlobalConfig.BackgroundScale) {
case imScale:
ScaleImage(BackgroundImage, BigBack);
break;
case imCrop:
x = UGAWidth - BigBack->Width;
if (x >= 0) {
x1 = x >> 1;
x2 = 0;
x = BigBack->Width;
} else {
x1 = 0;
x2 = (-x) >> 1;
x = UGAWidth;
}
y = UGAHeight - BigBack->Height;
if (y >= 0) {
y1 = y >> 1;
y2 = 0;
y = BigBack->Height;
} else {
y1 = 0;
y2 = (-y) >> 1;
y = UGAHeight;
}
egRawCopy(BackgroundImage->PixelData + y1 * UGAWidth + x1,
BigBack->PixelData + y2 * BigBack->Width + x2,
x, y, UGAWidth, BigBack->Width);
break;
case imTile:
x = (BigBack->Width * ((UGAWidth - 1) / BigBack->Width + 1) - UGAWidth) >> 1;
y = (BigBack->Height * ((UGAHeight - 1) / BigBack->Height + 1) - UGAHeight) >> 1;
p1 = BackgroundImage->PixelData;
for (j = 0; j < UGAHeight; j++) {
y2 = ((j + y) % BigBack->Height) * BigBack->Width;
for (i = 0; i < UGAWidth; i++) {
*p1++ = BigBack->PixelData[y2 + ((i + x) % BigBack->Width)];
}
}
break;
case imNone:
default:
// already scaled
break;
}
}
// Draw background
if (BackgroundImage) {
/* DBG("BltClearScreen(%c): calling BltImage BackgroundImage %p\n",
ShowBanner?'Y':'N', BackgroundImage); */
BltImage(BackgroundImage, 0, 0); //if NULL then do nothing
} else {
/* DBG("BltClearScreen(%c): calling egClearScreen StdBackgroundPixel %02X%02X%02X%02X\n",
ShowBanner?'Y':'N', StdBackgroundPixel.r, StdBackgroundPixel.g, StdBackgroundPixel.b, StdBackgroundPixel.a); */
egClearScreen(&StdBackgroundPixel);
}
// Draw banner
if (Banner) {
BltImageAlpha(Banner, BannerPlace.XPos, BannerPlace.YPos, &MenuBackgroundPixel, 16);
}
//what is the idea for the conversion?
InputBackgroundPixel.r = (MenuBackgroundPixel.r + 0) & 0xFF;
InputBackgroundPixel.g = (MenuBackgroundPixel.g + 0) & 0xFF;
InputBackgroundPixel.b = (MenuBackgroundPixel.b + 0) & 0xFF;
InputBackgroundPixel.a = (MenuBackgroundPixel.a + 0) & 0xFF;
GraphicsScreenDirty = FALSE;
}
#endif
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos)
{
if (!Image) {
@ -570,45 +368,26 @@ VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *
}
// DBG("w=%d, h=%d\n", Width, Height);
// compose on background
#if USE_XTHEME
CompImage = egCreateFilledImage(Width, Height, !ThemeX.Background.isEmpty(), BackgroundPixel); //no matter
#else
CompImage = egCreateFilledImage(Width, Height, (BackgroundImage != NULL), BackgroundPixel);
#endif
egComposeImage(CompImage, NewImage, 0, 0);
if (NewImage) {
egFreeImage(NewImage);
}
#if USE_XTHEME
if (ThemeX.Background.isEmpty()) {
egDrawImageArea(CompImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(CompImage);
return;
}
#else
if (!BackgroundImage) {
egDrawImageArea(CompImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(CompImage);
return;
}
#endif
NewImage = egCreateImage(Width, Height, FALSE);
if (!NewImage) return;
// DBG("draw on background\n");
#if USE_XTHEME
egRawCopy(NewImage->PixelData,
(EG_PIXEL*)ThemeX.Background.GetPixelPtr(0,0) + YPos * ThemeX.Background.GetWidth() + XPos,
Width, Height,
Width,
ThemeX.Background.GetWidth());
#else
egRawCopy(NewImage->PixelData,
BackgroundImage->PixelData + YPos * BackgroundImage->Width + XPos,
Width, Height,
Width,
BackgroundImage->Width);
#endif
egComposeImage(NewImage, CompImage, 0, 0);
egFreeImage(CompImage);
@ -616,40 +395,7 @@ VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *
egDrawImageArea(NewImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(NewImage);
}
//not used
/*
VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos)
{
INTN TotalWidth, TotalHeight, CompWidth, CompHeight, OffsetX, OffsetY;
EG_IMAGE *CompImage;
if (!BaseImage || !TopImage) {
return;
}
// initialize buffer with base image
CompImage = egCopyImage(BaseImage);
TotalWidth = BaseImage->Width;
TotalHeight = BaseImage->Height;
// place the top image
CompWidth = TopImage->Width;
if (CompWidth > TotalWidth)
CompWidth = TotalWidth;
OffsetX = (TotalWidth - CompWidth) >> 1;
CompHeight = TopImage->Height;
if (CompHeight > TotalHeight)
CompHeight = TotalHeight;
OffsetY = (TotalHeight - CompHeight) >> 1;
egComposeImage(CompImage, TopImage, OffsetX, OffsetY);
// blit to screen and clean up
// egDrawImageArea(CompImage, 0, 0, TotalWidth, TotalHeight, XPos, YPos);
BltImageAlpha(CompImage, XPos, YPos, &MenuBackgroundPixel, 16);
egFreeImage(CompImage);
GraphicsScreenDirty = TRUE;
}
*/
/*
--------------------------------------------------------------------
Pos : Bottom -> Mid -> Top
@ -661,143 +407,6 @@ VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XP
BaseImage = MainImage, TopImage = Selection
*/
#if USE_XTHEME
/*
// TopImage = SelectionImages[index]
// The procedure will be replaced by
if(SelectionOnTop) {
BaseImage.Draw(XPos, YPos, Scale/16.f);
BadgeImage.Draw(XPos, YPos, Scale/16.f);
TopImage.Draw(XPos, YPos, Scale/16.f);
} else {
TopImage.Draw(XPos, YPos, Scale/16.f);
BaseImage.Draw(XPos, YPos, Scale/16.f);
BadgeImage.Draw(XPos, YPos, Scale/16.f);
}
*/
#else
VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG_IMAGE *BadgeImage, IN INTN XPos, IN INTN YPos, INTN Scale)
{
INTN TotalWidth, TotalHeight, CompWidth, CompHeight, OffsetX, OffsetY, OffsetXTmp, OffsetYTmp;
BOOLEAN Selected = TRUE;
EG_IMAGE *CompImage;
EG_IMAGE *NewBaseImage;
EG_IMAGE *NewTopImage;
EG_PIXEL *BackgroundPixel = &EmbeddedBackgroundPixel;
if (!IsEmbeddedTheme()) {
BackgroundPixel = &MenuBackgroundPixel;
} else if (GlobalConfig.DarkEmbedded) {
BackgroundPixel = &DarkEmbeddedBackgroundPixel;
}
if (!BaseImage || !TopImage) {
return;
}
if (Scale < 0) {
Scale = -Scale;
Selected = FALSE;
}
NewBaseImage = egCopyScaledImage(BaseImage, Scale); //will be Scale/16
TotalWidth = NewBaseImage->Width; //mainImage sizes if GlobalConfig.SelectionOnTop
TotalHeight = NewBaseImage->Height;
NewTopImage = egCopyScaledImage(TopImage, Scale); //will be Scale/16
CompWidth = NewTopImage->Width; //selection sizes if GlobalConfig.SelectionOnTop
CompHeight = NewTopImage->Height;
CompImage = egCreateFilledImage((CompWidth > TotalWidth)?CompWidth:TotalWidth,
(CompHeight > TotalHeight)?CompHeight:TotalHeight,
TRUE,
BackgroundPixel);
if (!CompImage) {
DBG("Can't create CompImage\n");
return;
}
// DBG("compose image total=[%d,%d], comp=[%d,%d] at [%d,%d] scale=%d\n", TotalWidth, TotalHeight,
// CompWidth, CompHeight, XPos, YPos, Scale);
//to simplify suppose square images
if (CompWidth < TotalWidth) {
OffsetX = (TotalWidth - CompWidth) >> 1;
OffsetY = (TotalHeight - CompHeight) >> 1;
egComposeImage(CompImage, NewBaseImage, 0, 0);
if (!GlobalConfig.SelectionOnTop) {
egComposeImage(CompImage, NewTopImage, OffsetX, OffsetY);
}
CompWidth = TotalWidth;
CompHeight = TotalHeight;
} else {
OffsetX = (CompWidth - TotalWidth) >> 1;
OffsetY = (CompHeight - TotalHeight) >> 1;
egComposeImage(CompImage, NewBaseImage, OffsetX, OffsetY);
if (!GlobalConfig.SelectionOnTop) {
egComposeImage(CompImage, NewTopImage, 0, 0);
}
}
OffsetXTmp = OffsetX;
OffsetYTmp = OffsetY;
// place the badge image
if (BadgeImage != NULL &&
(BadgeImage->Width + 8) < CompWidth &&
(BadgeImage->Height + 8) < CompHeight) {
//blackosx
// Check for user badge x offset from theme.plist
if (GlobalConfig.BadgeOffsetX != 0xFFFF) {
// Check if value is between 0 and ( width of the main icon - width of badge )
if (GlobalConfig.BadgeOffsetX < 0 || GlobalConfig.BadgeOffsetX > (CompWidth - BadgeImage->Width)) {
DBG("User offset X %lld is out of range\n", GlobalConfig.BadgeOffsetX);
GlobalConfig.BadgeOffsetX = CompWidth - 8 - BadgeImage->Width;
DBG(" corrected to default %lld\n", GlobalConfig.BadgeOffsetX);
}
OffsetX += GlobalConfig.BadgeOffsetX;
} else {
// Set default position
OffsetX += CompWidth - 8 - BadgeImage->Width;
}
// Check for user badge y offset from theme.plist
if (GlobalConfig.BadgeOffsetY != 0xFFFF) {
// Check if value is between 0 and ( height of the main icon - height of badge )
if (GlobalConfig.BadgeOffsetY < 0 || GlobalConfig.BadgeOffsetY > (CompHeight - BadgeImage->Height)) {
DBG("User offset Y %lld is out of range\n",GlobalConfig.BadgeOffsetY);
GlobalConfig.BadgeOffsetY = CompHeight - 8 - BadgeImage->Height;
DBG(" corrected to default %lld\n", GlobalConfig.BadgeOffsetY);
}
OffsetY += GlobalConfig.BadgeOffsetY;
} else {
// Set default position
OffsetY += CompHeight - 8 - BadgeImage->Height;
}
egComposeImage(CompImage, BadgeImage, OffsetX, OffsetY);
}
if (GlobalConfig.SelectionOnTop) {
if (CompWidth < TotalWidth) {
egComposeImage(CompImage, NewTopImage, OffsetXTmp, OffsetYTmp);
} else {
egComposeImage(CompImage, NewTopImage, 0, 0);
}
}
// blit to screen and clean up
// if (!IsEmbeddedTheme()) { // regular theme
if (GlobalConfig.NonSelectedGrey && !Selected) {
BltImageAlpha(CompImage, XPos, YPos, &MenuBackgroundPixel, -16);
} else {
BltImageAlpha(CompImage, XPos, YPos, &MenuBackgroundPixel, 16);
}
/* } else { // embedded theme - don't use BltImageAlpha as it can't handle refit's built in image
egDrawImageArea(CompImage, 0, 0, TotalWidth, TotalHeight, XPos, YPos);
} */
egFreeImage(CompImage);
egFreeImage(NewBaseImage);
egFreeImage(NewTopImage);
GraphicsScreenDirty = TRUE;
}
#endif
#define MAX_SIZE_ANIME 256
@ -813,49 +422,6 @@ VOID FreeAnime(GUI_ANIME *Anime)
}
}
/* Replaced for now with Reposition* below
INTN RecalculateImageOffset(INTN AnimDimension, INTN ValueToScale, INTN ScreenDimensionToFit, INTN ThemeDesignDimension)
{
INTN SuppliedGapDimensionPxDesigned=0;
INTN OppositeGapDimensionPxDesigned=0;
INTN OppositeGapPcDesigned=0;
INTN ScreenDimensionLessAnim=0;
INTN GapNumTimesLarger=0;
INTN GapNumFinal=0;
INTN NewSuppliedGapPx=0;
INTN NewOppositeGapPx=0;
INTN ReturnValue=0;
SuppliedGapDimensionPxDesigned = (ThemeDesignDimension * ValueToScale) / 100;
OppositeGapDimensionPxDesigned = ThemeDesignDimension - (SuppliedGapDimensionPxDesigned + AnimDimension);
OppositeGapPcDesigned = (OppositeGapDimensionPxDesigned * 100)/ThemeDesignDimension;
ScreenDimensionLessAnim = (ScreenDimensionToFit - AnimDimension);
if (ValueToScale > OppositeGapPcDesigned) {
GapNumTimesLarger = (ValueToScale * 100)/OppositeGapPcDesigned;
GapNumFinal = GapNumTimesLarger + 100;
NewOppositeGapPx = (ScreenDimensionLessAnim * 100)/GapNumFinal;
NewSuppliedGapPx = (NewOppositeGapPx * GapNumTimesLarger)/100;
} else if (ValueToScale < OppositeGapPcDesigned) {
GapNumTimesLarger = (OppositeGapPcDesigned * 100)/ValueToScale;
GapNumFinal = (GapNumTimesLarger + 100);
NewSuppliedGapPx = (ScreenDimensionLessAnim * 100)/GapNumFinal;
NewOppositeGapPx = (NewSuppliedGapPx * GapNumTimesLarger)/100;
} else if (ValueToScale == OppositeGapPcDesigned) {
NewSuppliedGapPx = (ScreenDimensionLessAnim * 100)/200;
NewOppositeGapPx = (NewSuppliedGapPx * 100)/100;
}
ReturnValue = (NewSuppliedGapPx * 100)/ScreenDimensionToFit;
if (ReturnValue>0 && ReturnValue<100) {
//DBG("Different screen size being used. Adjusted original anim gap to %d\n",ReturnValue);
return ReturnValue;
} else {
DBG("Different screen size being used. Adjusted value %d invalid. Returning original value %d\n",ReturnValue, ValueToScale);
return ValueToScale;
}
}
*/
static INTN ConvertEdgeAndPercentageToPixelPosition(INTN Edge, INTN DesiredPercentageFromEdge, INTN ImageDimension, INTN ScreenDimension)
{
if (Edge == SCREEN_EDGE_LEFT || Edge == SCREEN_EDGE_TOP) {
@ -948,7 +514,6 @@ VOID REFIT_MENU_SCREEN::UpdateAnime()
// Check if the theme.plist setting for allowing an anim to be moved horizontally in the quest
// to avoid overlapping the menu text on menu pages at lower resolutions is set.
#if USE_XTHEME
if ((ID > 1) && (ThemeX.LayoutAnimMoveForMenuX != 0)) { // these screens have text menus which the anim may interfere with.
MenuWidth = (INTN)(TEXT_XMARGIN * 2 + (50 * ThemeX.CharWidth * ThemeX.Scale)); // taken from menu.c
if ((x + Film[0]->Width) > (UGAWidth - MenuWidth) >> 1) {
@ -957,18 +522,7 @@ VOID REFIT_MENU_SCREEN::UpdateAnime()
}
}
}
#else
if ((ID > 1) && (LayoutAnimMoveForMenuX != 0)) { // these screens have text menus which the anim may interfere with.
MenuWidth = (INTN)(TEXT_XMARGIN * 2 + (50 * GlobalConfig.CharWidth * GlobalConfig.Scale)); // taken from menu.c
if ((x + Film[0]->Width) > (UGAWidth - MenuWidth) >> 1) {
if ((x + LayoutAnimMoveForMenuX >= 0) || (UGAWidth-(x + LayoutAnimMoveForMenuX + Film[0]->Width)) <= 100) {
x += LayoutAnimMoveForMenuX;
}
}
}
#endif
Now = AsmReadTsc();
if (LastDraw == 0) {
//first start, we should save background into last frame
@ -996,8 +550,8 @@ VOID REFIT_MENU_SCREEN::UpdateAnime()
}
LastDraw = Now;
}
#if USE_XTHEME
//by initial we use EG_IMAGE anime
//TODO will be rewritten by XCinema class
VOID REFIT_MENU_SCREEN::InitAnime()
{
CHAR16 FileName[256];
@ -1103,119 +657,6 @@ VOID REFIT_MENU_SCREEN::InitAnime()
// DBG("anime inited\n");
}
#else
VOID REFIT_MENU_SCREEN::InitAnime()
{
CHAR16 FileName[256];
CHAR16 *Path;
EG_IMAGE *p = NULL;
EG_IMAGE *Last = NULL;
GUI_ANIME *Anime;
if (GlobalConfig.TextOnly) return;
//
for (Anime = GuiAnime; Anime != NULL && Anime->ID != ID; Anime = Anime->Next);
// Check if we should clear old film vars (no anime or anime path changed)
//
if (gThemeOptionsChanged || !Anime || !Film || IsEmbeddedTheme() || !Theme ||
(/*gThemeChanged && */StriCmp(GlobalConfig.Theme, Theme) != 0)) {
// DBG(" free screen\n");
if (Film) {
//free images in the film
INTN i;
for (i = 0; i <= Frames; i++) { //really there are N+1 frames
// free only last occurrence of repeated frames
if (Film[i] != NULL && (i == Frames || Film[i] != Film[i+1])) {
FreePool(Film[i]);
}
}
FreePool(Film);
Film = NULL;
Frames = 0;
}
if (Theme) {
FreePool(Theme);
Theme = NULL;
}
}
// Check if we should load anime files (first run or after theme change)
if (Anime && Film == NULL) {
Path = Anime->Path;
Film = (EG_IMAGE**)AllocateZeroPool((Anime->Frames + 1) * sizeof(VOID*));
if ((GlobalConfig.TypeSVG || Path) && Film) {
// Look through contents of the directory
UINTN i;
for (i = 0; i < Anime->Frames; i++) {
// DBG("Try to load file %ls\n", FileName);
if (GlobalConfig.TypeSVG) {
p = LoadSvgFrame(i);
// DBG("frame %d loaded\n", i);
} else {
snwprintf(FileName, 512, "%ls\\%ls_%03llu.png", Path, Path, i);
p = egLoadImage(ThemeDir, FileName, TRUE);
}
if (!p) {
p = Last;
if (!p) break;
} else {
Last = p;
}
Film[i] = p;
}
if (Film[0] != NULL) {
Frames = i;
DBG(" found %llu frames of the anime\n", i);
// Create background frame
Film[i] = egCreateImage(Film[0]->Width, Film[0]->Height, FALSE);
// Copy some settings from Anime into Screen
FrameTime = Anime->FrameTime;
Once = Anime->Once;
Theme = (__typeof__(Theme))AllocateCopyPool(StrSize(GlobalConfig.Theme), GlobalConfig.Theme);
} /*else {
DBG("Film[0] == NULL\n");
} */
}
}
// Check if a new style placement value has been specified
if (Anime && (Anime->FilmX >=0) && (Anime->FilmX <=100) &&
(Anime->FilmY >=0) && (Anime->FilmY <=100) &&
(Film != NULL) && (Film[0] != NULL)) {
// Check if screen size being used is different from theme origination size.
// If yes, then recalculate the animation placement % value.
// This is necessary because screen can be a different size, but anim is not scaled.
FilmPlace.XPos = HybridRepositioning(Anime->ScreenEdgeHorizontal, Anime->FilmX, Film[0]->Width, UGAWidth, GlobalConfig.ThemeDesignWidth );
FilmPlace.YPos = HybridRepositioning(Anime->ScreenEdgeVertical, Anime->FilmY, Film[0]->Height, UGAHeight, GlobalConfig.ThemeDesignHeight);
// Does the user want to fine tune the placement?
FilmPlace.XPos = CalculateNudgePosition(FilmPlace.XPos, Anime->NudgeX, Film[0]->Width, UGAWidth);
FilmPlace.YPos = CalculateNudgePosition(FilmPlace.YPos, Anime->NudgeY, Film[0]->Height, UGAHeight);
FilmPlace.Width = Film[0]->Width;
FilmPlace.Height = Film[0]->Height;
DBG("recalculated Film position\n");
} else {
// We are here if there is no anime, or if we use oldstyle placement values
// For both these cases, FilmPlace will be set after banner/menutitle positions are known
FilmPlace.XPos = 0;
FilmPlace.YPos = 0;
FilmPlace.Width = 0;
FilmPlace.Height = 0;
}
if (Film != NULL && Film[0] != NULL) {
DBG(" Anime seems OK, init it\n");
AnimeRun = TRUE;
CurrentFrame = 0;
LastDraw = 0;
} else {
// DBG("not run anime\n");
AnimeRun = FALSE;
}
// DBG("anime inited\n");
}
#endif
BOOLEAN REFIT_MENU_SCREEN::GetAnime()
{
GUI_ANIME *Anime;