From 84a320ba5dbbeedca85d1765d4cfe5ae00934c7f Mon Sep 17 00:00:00 2001 From: Sergey Isakov Date: Fri, 10 Apr 2020 13:04:21 +0300 Subject: [PATCH] big cleanup to XTHEME Signed-off-by: Sergey Isakov --- rEFIt_UEFI/Platform/Platform.h | 40 +- rEFIt_UEFI/Platform/Settings.cpp | 1328 +----------------------- rEFIt_UEFI/entry_scan/common.cpp | 119 +-- rEFIt_UEFI/entry_scan/entry_scan.h | 16 +- rEFIt_UEFI/entry_scan/legacy.cpp | 120 +-- rEFIt_UEFI/entry_scan/loader.cpp | 183 +--- rEFIt_UEFI/entry_scan/securemenu.cpp | 22 +- rEFIt_UEFI/entry_scan/tool.cpp | 74 +- rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp | 1029 +----------------- rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h | 51 - rEFIt_UEFI/gui/menu_items/menu_items.h | 55 +- rEFIt_UEFI/libeg/VectorGraphics.cpp | 534 +--------- rEFIt_UEFI/libeg/VectorGraphics.h | 6 - rEFIt_UEFI/libeg/XImage.cpp | 32 + rEFIt_UEFI/libeg/XPointer.cpp | 7 - rEFIt_UEFI/libeg/XPointer.h | 1 - rEFIt_UEFI/libeg/XTheme.cpp | 27 +- rEFIt_UEFI/libeg/image.cpp | 223 +--- rEFIt_UEFI/libeg/libeg.h | 11 - rEFIt_UEFI/libeg/libegint.h | 8 - rEFIt_UEFI/libeg/libscreen.cpp | 29 +- rEFIt_UEFI/libeg/nanosvg.cpp | 95 +- rEFIt_UEFI/libeg/text.cpp | 353 ------- rEFIt_UEFI/refit/icns.cpp | 427 -------- rEFIt_UEFI/refit/lib.cpp | 75 +- rEFIt_UEFI/refit/lib.h | 128 --- rEFIt_UEFI/refit/main.cpp | 93 -- rEFIt_UEFI/refit/menu.cpp | 883 +--------------- rEFIt_UEFI/refit/menu.h | 33 +- rEFIt_UEFI/refit/screen.cpp | 563 +--------- 30 files changed, 79 insertions(+), 6486 deletions(-) diff --git a/rEFIt_UEFI/Platform/Platform.h b/rEFIt_UEFI/Platform/Platform.h index 25dedaa81..938454e58 100755 --- a/rEFIt_UEFI/Platform/Platform.h +++ b/rEFIt_UEFI/Platform/Platform.h @@ -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; diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 56b4ae882..7fdd3e9f3 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -98,13 +98,6 @@ CONST CHAR16 **RecoveryPlists = NULL; BOOLEAN SetTable132 = FALSE; GUI_ANIME *GuiAnime = NULL; -#if !USE_XTHEME -EG_IMAGE *SelectionImages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; -EG_IMAGE *Buttons[4] = {NULL, NULL, NULL, NULL}; - -INTN row0TileSize = 144; -INTN row1TileSize = 64; -#endif //EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //define in lib.h const INTN BCSMargin = 11; BOOLEAN DayLight; @@ -113,25 +106,12 @@ BOOLEAN DayLight; extern MEM_STRUCTURE gRAM; extern BOOLEAN NeedPMfix; -#if !USE_XTHEME -extern INTN ScrollWidth; -INTN ScrollButtonsHeight = 20; -//extern INTN ScrollButtonsHeight; -INTN ScrollBarDecorationsHeight = 5; -//extern INTN ScrollBarDecorationsHeight; -INTN ScrollScrollDecorationsHeight = 7; -//extern INTN ScrollScrollDecorationsHeight; -#endif //extern INTN OldChosenAudio; /* typedef struct { INTN Timeout; UINTN DisableFlags; -#if !USE_XTHEME - UINTN HideBadges; - UINTN HideUIFlags; -#endif BOOLEAN TextOnly; BOOLEAN Quiet; BOOLEAN LegacyFirst; @@ -143,68 +123,20 @@ 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; - INTN Codepage; - INTN CodepageSize; - float Scale; - float CentreShift; -#endif } REFIT_CONFIG; */ // global configuration with default values REFIT_CONFIG GlobalConfig = { -1, // INTN Timeout; 0, // UINTN DisableFlags; -#if !USE_XTHEME - 0, // UINTN HideBadges; - 0, // UINTN HideUIFlags; -#endif FALSE, // BOOLEAN TextOnly; TRUE, // BOOLEAN Quiet; FALSE, // BOOLEAN LegacyFirst; @@ -217,60 +149,16 @@ REFIT_CONFIG GlobalConfig = { FALSE, // BOOLEAN HibernationFixup; FALSE, // BOOLEAN SignatureFixup; -#if !USE_XTHEME - FONT_GRAY, // FONT_TYPE Font; //Welcome should be white - 9, // INTN CharWidth; - 0xFFFFFF80, // UINTN SelectionColor; - NULL, // CHAR16 *FontFileName; - NULL, // CHAR16 *BannerFileName; - NULL, // CHAR16 *SelectionSmallFileName; - NULL, // CHAR16 *SelectionBigFileName; - NULL, // CHAR16 *SelectionIndicatorName; - NULL, // CHAR16 *DefaultSelection; -#endif NULL, // CHAR16 *Theme; NULL, // CHAR16 *ScreenResolution; 0, // INTN ConsoleMode; FALSE, // BOOLEAN CustomIcons; -#if !USE_XTHEME - NULL, // CHAR16 *BackgroundName; - imNone, // SCALING BackgroundScale; - 0, // UINTN BackgroundSharp; - FALSE, // BOOLEAN BackgroundDark; - FALSE, // BOOLEAN SelectionOnTop; - FALSE, // BOOLEAN BootCampStyle; - 0, // INTN BadgeOffsetX; - 0, // INTN BadgeOffsetY; - 4, // INTN BadgeScale; - 0xFFFF, // INTN ThemeDesignWidth; - 0xFFFF, // INTN ThemeDesignHeight; - 0xFFFF, // INTN BannerPosX; - 0xFFFF, // INTN BannerPosY; - 0, // INTN BannerEdgeHorizontal; - 0, // INTN BannerEdgeVertical; - 0, // INTN BannerNudgeX; - 0, // INTN BannerNudgeY; - FALSE, // BOOLEAN VerticalLayout; - FALSE, // BOOLEAN NonSelectedGrey; - 128, // INTN MainEntriesSize; - 8, // INTN TileXSpace; - 24, // INTN TileYSpace; -#endif ICON_FORMAT_DEF, // INTN IconFormat; FALSE, // BOOLEAN NoEarlyProgress; 0, // INT32 Timezone; FALSE, // BOOLEAN ShowOptimus; -#if !USE_XTHEME - FALSE, // BOOLEAN Proportional; - FALSE, // BOOLEAN DarkEmbedded; - FALSE, // BOOLEAN TypeSVG; -#endif 0xC0, // INTN Codepage; 0xC0, // INTN CodepageSize; //extended latin -#if !USE_XTHEME - 1.0f, // float Scale; - 0.0f, // float CentreShift; -#endif }; static struct FIX_CONFIG { const CHAR8* oldName; const CHAR8* newName; UINT32 bitData; } FixesConfig[] = @@ -1014,14 +902,7 @@ CUSTOM_LOADER_ENTRY if (Entry->DriveImagePath) { DuplicateEntry->DriveImagePath = EfiStrDuplicate (Entry->DriveImagePath); } -#if USE_XTHEME DuplicateEntry->BootBgColor = Entry->BootBgColor; -#else - if (Entry->BootBgColor) { - DuplicateEntry->BootBgColor = (__typeof__(DuplicateEntry->BootBgColor))AllocateCopyPool (sizeof(Entry->BootBgColor), Entry->BootBgColor); - } -#endif - DuplicateEntry->Image = Entry->Image; DuplicateEntry->DriveImage = Entry->DriveImage; DuplicateEntry->Hotkey = Entry->Hotkey; @@ -1953,7 +1834,6 @@ FillinCustomEntry ( Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS); } } -#if USE_XTHEME Prop = GetProperty (DictPointer, "Title"); if (Prop != NULL && (Prop->type == kTagTypeString)) { Entry->Title.takeValueFrom(Prop->string); @@ -1994,78 +1874,7 @@ FillinCustomEntry ( FreePool(TmpData); } } -#else - Prop = GetProperty (DictPointer, "Title"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->FullTitle != NULL) { - FreePool (Entry->FullTitle); - Entry->FullTitle = NULL; - } - - if (Entry->Title != NULL) { - FreePool (Entry->Title); - } - - Entry->Title = PoolPrint (L"%a", Prop->string); - } - Prop = GetProperty (DictPointer, "FullTitle"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->FullTitle) { - FreePool (Entry->FullTitle); - } - - Entry->FullTitle = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "Image"); - if (Prop != NULL) { - if (Entry->ImagePath) { - FreePool (Entry->ImagePath); - Entry->ImagePath = NULL; - } - - if (Entry->Image) { - egFreeImage (Entry->Image); - Entry->Image = NULL; - } - - if (Prop->type == kTagTypeString) { - Entry->ImagePath = PoolPrint (L"%a", Prop->string); - } - } else { - UINTN DataLen = 0; - UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen); - if (TmpData) { - Entry->Image = egDecodePNG (TmpData, DataLen, TRUE); - FreePool(TmpData); - } - } - - Prop = GetProperty (DictPointer, "DriveImage"); - if (Prop != NULL) { - if (Entry->DriveImagePath != NULL) { - FreePool (Entry->DriveImagePath); - Entry->DriveImagePath = NULL; - } - - if (Entry->DriveImage != NULL) { - egFreeImage (Entry->DriveImage); - Entry->DriveImage = NULL; - } - - if (Prop->type == kTagTypeString) { - Entry->DriveImagePath = PoolPrint (L"%a", Prop->string); - } - } else { - UINTN DataLen = 0; - UINT8 *TmpData = GetDataSetting (DictPointer, "DriveImageData", &DataLen); - if (TmpData) { - Entry->DriveImage = egDecodePNG (TmpData, DataLen, TRUE); - FreePool(TmpData); - } - } -#endif Prop = GetProperty (DictPointer, "Hotkey"); if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) { Entry->Hotkey = *(Prop->string); @@ -2084,7 +1893,7 @@ FillinCustomEntry ( } else if (AsciiStriCmp (Prop->string, "Theme") == 0) { Entry->CustomBoot = CUSTOM_BOOT_THEME; } else { - CHAR16 *customLogo = PoolPrint (L"%a", Prop->string); + CHAR16 *customLogo = PoolPrint(L"%a", Prop->string); Entry->CustomBoot = CUSTOM_BOOT_USER; if (Entry->CustomLogo != NULL) { egFreeImage (Entry->CustomLogo); @@ -2120,18 +1929,10 @@ FillinCustomEntry ( UINTN Color; Color = AsciiStrHexToUintn (Prop->string); -#if USE_XTHEME Entry->BootBgColor.Red = (Color >> 24) & 0xFF; Entry->BootBgColor.Green = (Color >> 16) & 0xFF; Entry->BootBgColor.Blue = (Color >> 8) & 0xFF; Entry->BootBgColor.Reserved = (Color >> 0) & 0xFF; -#else - Entry->BootBgColor = (__typeof__(Entry->BootBgColor))AllocateZeroPool (sizeof(Entry->BootBgColor)); - Entry->BootBgColor->r = (Color >> 24) & 0xFF; - Entry->BootBgColor->g = (Color >> 16) & 0xFF; - Entry->BootBgColor->b = (Color >> 8) & 0xFF; - Entry->BootBgColor->a = (Color >> 0) & 0xFF; -#endif } // Hidden Property, Values: @@ -2181,7 +1982,6 @@ FillinCustomEntry ( if (Entry->Options.isEmpty() && OSTYPE_IS_WINDOWS(Entry->Type)) { Entry->Options.SPrintf("-s -h"); } -#if USE_XTHEME if (Entry->Title.isEmpty()) { if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) { Entry->Title = L"Recovery"_XSW; @@ -2199,26 +1999,6 @@ FillinCustomEntry ( Entry->DriveImagePath = L"recovery"; } } -#else - - if (Entry->Title == NULL) { - if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) { - Entry->Title = PoolPrint (L"Recovery"); - } else if (OSTYPE_IS_OSX_INSTALLER (Entry->Type)) { - Entry->Title = PoolPrint (L"Install macOS"); - } - } - if ((Entry->Image == NULL) && (Entry->ImagePath == NULL)) { - if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) { - Entry->ImagePath = L"mac"; - } - } - if ((Entry->DriveImage == NULL) && (Entry->DriveImagePath == NULL)) { - if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) { - Entry->DriveImagePath = L"recovery"; - } - } -#endif // OS Specific flags if (OSTYPE_IS_OSX(Entry->Type) || OSTYPE_IS_OSX_RECOVERY (Entry->Type) || OSTYPE_IS_OSX_INSTALLER (Entry->Type)) { @@ -2336,7 +2116,7 @@ FillinCustomEntry ( } return TRUE; } -#if USE_XTHEME + BOOLEAN FillingCustomLegacy ( IN OUT CUSTOM_LEGACY_ENTRY *Entry, @@ -2433,137 +2213,7 @@ FillingCustomLegacy ( Entry->VolumeType = GetVolumeType(DictPointer); return TRUE; } -#else -STATIC -BOOLEAN -FillinCustomLegacy ( - IN OUT CUSTOM_LEGACY_ENTRY *Entry, - TagPtr DictPointer - ) -{ - TagPtr Prop; - if ((Entry == NULL) || (DictPointer == NULL)) { - return FALSE; - } - - Prop = GetProperty (DictPointer, "Disabled"); - if (IsPropertyTrue (Prop)) { - return FALSE; - } - - Prop = GetProperty (DictPointer, "Volume"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->Volume != NULL) { - FreePool (Entry->Volume); - } - - Entry->Volume = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "FullTitle"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->FullTitle) { - FreePool (Entry->FullTitle); - } - - Entry->FullTitle = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "Title"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->Title != NULL) { - FreePool (Entry->Title); - } - - Entry->Title = PoolPrint (L"%a", Prop->string); - } - Prop = GetProperty (DictPointer, "Image"); - if (Prop != NULL) { - if (Entry->ImagePath != NULL) { - FreePool (Entry->ImagePath); - Entry->ImagePath = NULL; - } - - if (Entry->Image != NULL) { - egFreeImage (Entry->Image); - Entry->Image = NULL; - } - - if (Prop->type == kTagTypeString) { - Entry->ImagePath = PoolPrint (L"%a", Prop->string); - } - } else { - UINTN DataLen = 0; - UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen); - if (TmpData) { - Entry->Image = egDecodePNG (TmpData, DataLen, TRUE); - FreePool(TmpData); - } - } - - Prop = GetProperty (DictPointer, "DriveImage"); - if (Prop != NULL) { - if (Entry->DriveImagePath != NULL) { - FreePool (Entry->DriveImagePath); - Entry->DriveImagePath = NULL; - } - - if (Entry->DriveImage != NULL) { - egFreeImage (Entry->DriveImage); - Entry->DriveImage = NULL; - } - - if (Prop->type == kTagTypeString) { - Entry->DriveImagePath = PoolPrint (L"%a", Prop->string); - } - } else { - UINTN DataLen = 0; - UINT8 *TmpData = GetDataSetting (DictPointer, "DriveImageData", &DataLen); - if (TmpData) { - Entry->DriveImage = egDecodePNG (TmpData, DataLen, TRUE); - FreePool(TmpData); - } - } - - Prop = GetProperty (DictPointer, "Hotkey"); - if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) { - Entry->Hotkey = *(Prop->string); - } - - // Hidden Property, Values: - // - No (show the entry) - // - Yes (hide the entry but can be show with F3) - // - Always (always hide the entry) - Prop = GetProperty (DictPointer, "Hidden"); - if (Prop != NULL) { - if ((Prop->type == kTagTypeString) && - (AsciiStriCmp (Prop->string, "Always") == 0)) { - Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED); - } else if (IsPropertyTrue (Prop)) { - Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN); - } else { - Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN); - } - } - - Prop = GetProperty (DictPointer, "Type"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (AsciiStriCmp (Prop->string, "Windows") == 0) { - Entry->Type = OSTYPE_WIN; - } else if (AsciiStriCmp (Prop->string, "Linux") == 0) { - Entry->Type = OSTYPE_LIN; - } else { - Entry->Type = OSTYPE_OTHER; - } - } - - Entry->VolumeType = GetVolumeType(DictPointer); - return TRUE; -} -#endif - -#if USE_XTHEME BOOLEAN FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer) { @@ -2656,118 +2306,7 @@ FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer) return TRUE; } -#else -STATIC -BOOLEAN -FillinCustomTool ( - IN OUT CUSTOM_TOOL_ENTRY *Entry, - TagPtr DictPointer - ) -{ - TagPtr Prop; - if ((Entry == NULL) || (DictPointer == NULL)) { - return FALSE; - } - - Prop = GetProperty (DictPointer, "Disabled"); - if (IsPropertyTrue (Prop)) { - return FALSE; - } - - Prop = GetProperty (DictPointer, "Volume"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->Volume) { - FreePool (Entry->Volume); - } - Entry->Volume = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "Path"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->Path != NULL) { - FreePool (Entry->Path); - } - - Entry->Path = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "Arguments"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { -// if (!Entry->Options.isEmpty()) { -// Entry->Options.setEmpty(); -// } else { -// Entry->Options.SPrintf("%s", Prop->string); -// } - Entry->Options.SPrintf("%s", Prop->string); - } - - Prop = GetProperty (DictPointer, "FullTitle"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->FullTitle != NULL) { - FreePool (Entry->FullTitle); - } - - Entry->FullTitle = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "Title"); - if (Prop != NULL && (Prop->type == kTagTypeString)) { - if (Entry->Title != NULL) { - FreePool (Entry->Title); - } - Entry->Title = PoolPrint (L"%a", Prop->string); - } - - Prop = GetProperty (DictPointer, "Image"); - if (Prop != NULL) { - if (Entry->ImagePath != NULL) { - FreePool (Entry->ImagePath); - Entry->ImagePath = NULL; - } - - if (Entry->Image != NULL) { - egFreeImage (Entry->Image); - Entry->Image = NULL; - } - - if (Prop->type == kTagTypeString) { - Entry->ImagePath = PoolPrint (L"%a", Prop->string); - } - } else { - UINTN DataLen = 0; - UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen); - if (TmpData) { - Entry->Image = egDecodePNG (TmpData, DataLen, TRUE); - } - } - - Prop = GetProperty (DictPointer, "Hotkey"); - if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) { - Entry->Hotkey = *(Prop->string); - } - - // Hidden Property, Values: - // - No (show the entry) - // - Yes (hide the entry but can be show with F3) - // - Always (always hide the entry) - Prop = GetProperty (DictPointer, "Hidden"); - if (Prop != NULL) { - if ((Prop->type == kTagTypeString) && - (AsciiStriCmp (Prop->string, "Always") == 0)) { - Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED); - } else if (IsPropertyTrue (Prop)) { - Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN); - } else { - Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN); - } - } - - Entry->VolumeType = GetVolumeType(DictPointer); - - return TRUE; -} -#endif // EDID reworked by Sherlocks VOID GetEDIDSettings(TagPtr DictPointer) @@ -2786,7 +2325,7 @@ GetEDIDSettings(TagPtr DictPointer) if (Prop != NULL) { gSettings.CustomEDID = GetDataSetting(Dict, "Custom", &j); if ((j % 128) != 0) { - DBG (" Custom EDID has wrong length=%llu\n", j); + DBG (" Custom EDID has wrong length=%llu\n", j); } else { DBG (" Custom EDID is ok\n"); gSettings.CustomEDIDsize = (UINT16)j; @@ -3161,7 +2700,6 @@ GetEarlyUserSettings ( DayLight = (NowHour > 8) && (NowHour < 20); Prop = GetProperty (DictPointer, "Theme"); -#if USE_XTHEME if (Prop != NULL) { if ((Prop->type == kTagTypeString) && Prop->string) { ThemeX.Theme.takeValueFrom(Prop->string); @@ -3206,52 +2744,6 @@ GetEarlyUserSettings ( } } } -#else - //old method to be deleted in future - if (Prop != NULL) { - if ((Prop->type == kTagTypeString) && Prop->string) { - UINTN i; - GlobalConfig.Theme = PoolPrint (L"%a", Prop->string); - DBG ("Default theme: %ls\n", GlobalConfig.Theme); - OldChosenTheme = 0xFFFF; //default for embedded - for (i = 0; i < ThemesNum; i++) { - if (StriCmp(GlobalConfig.Theme, ThemesList[i]) == 0) { - OldChosenTheme = i; - break; - } - } - if ((AsciiStriCmp (Prop->string, "embedded") == 0) || (AsciiStriCmp (Prop->string, "") == 0)) { - Prop = GetProperty (DictPointer, "EmbeddedThemeType"); - if (Prop && (Prop->type == kTagTypeString) && Prop->string) { - if (AsciiStriCmp (Prop->string, "Dark") == 0) { - GlobalConfig.DarkEmbedded = TRUE; - GlobalConfig.Font = FONT_GRAY; - } else if (AsciiStriCmp (Prop->string, "Light") == 0) { - GlobalConfig.DarkEmbedded = FALSE; - GlobalConfig.Font = FONT_ALFA; - } else if (AsciiStriCmp (Prop->string, "DayTime") == 0) { - GlobalConfig.DarkEmbedded = !DayLight; - GlobalConfig.Font = DayLight?FONT_ALFA:FONT_GRAY; - } - } - } - } - } else if (Prop == NULL) { - Prop = GetProperty (DictPointer, "EmbeddedThemeType"); - if (Prop && (Prop->type == kTagTypeString) && Prop->string) { - if (AsciiStriCmp (Prop->string, "Dark") == 0) { - GlobalConfig.DarkEmbedded = TRUE; - GlobalConfig.Font = FONT_GRAY; - } else if (AsciiStriCmp (Prop->string, "Light") == 0) { - GlobalConfig.DarkEmbedded = FALSE; - GlobalConfig.Font = FONT_ALFA; - } else if (AsciiStriCmp (Prop->string, "Daytime") == 0) { - GlobalConfig.DarkEmbedded = !DayLight; - GlobalConfig.Font = DayLight?FONT_ALFA:FONT_GRAY; - } - } - } -#endif Prop = GetProperty (DictPointer, "PlayAsync"); //PlayAsync gSettings.PlayAsync = IsPropertyTrue (Prop); @@ -3504,15 +2996,9 @@ GetEarlyUserSettings ( Entry = (CUSTOM_LEGACY_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_LEGACY_ENTRY)); if (Entry) { // Fill it in -#if USE_XTHEME if (!FillingCustomLegacy(Entry, Dict3) || !AddCustomLegacyEntry (Entry)) { FreePool (Entry); } -#else - if (!FillinCustomLegacy(Entry, Dict3) || !AddCustomLegacyEntry (Entry)) { - FreePool (Entry); - } -#endif } } } @@ -3537,15 +3023,9 @@ GetEarlyUserSettings ( Entry = (CUSTOM_TOOL_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_TOOL_ENTRY)); if (Entry) { // Fill it in -#if USE_XTHEME if (!FillingCustomTool(Entry, Dict3) || !AddCustomToolEntry (Entry)) { FreePool (Entry); } -#else - if (!FillinCustomTool(Entry, Dict3) || !AddCustomToolEntry (Entry)) { - FreePool (Entry); - } -#endif } } } @@ -3967,8 +3447,6 @@ GetListOfThemes () DirIterClose (&DirIter); } -#if USE_XTHEME - EFI_STATUS XTheme::GetThemeTagSettings (void* DictP) { @@ -4367,521 +3845,8 @@ XTheme::GetThemeTagSettings (void* DictP) return EFI_SUCCESS; } -#else -STATIC -EFI_STATUS -GetThemeTagSettings ( - TagPtr DictPointer - ) -{ - TagPtr Dict, Dict2, Dict3; - - //fill default to have an ability change theme - GlobalConfig.BackgroundScale = imCrop; - - if (GlobalConfig.BackgroundName != NULL) { - FreePool (GlobalConfig.BackgroundName); - GlobalConfig.BackgroundName = NULL; - } - - GlobalConfig.BackgroundSharp = 0; - GlobalConfig.BackgroundDark = 0; - - if (GlobalConfig.BannerFileName != NULL) { - FreePool (GlobalConfig.BannerFileName); - GlobalConfig.BannerFileName = NULL; - } - - GlobalConfig.HideBadges = 0; - GlobalConfig.BadgeOffsetX = 0xFFFF; - GlobalConfig.BadgeOffsetY = 0xFFFF; - GlobalConfig.BadgeScale = 8; //default - GlobalConfig.ThemeDesignWidth = 0xFFFF; - GlobalConfig.ThemeDesignHeight = 0xFFFF; - GlobalConfig.BannerEdgeHorizontal = SCREEN_EDGE_LEFT; - GlobalConfig.BannerEdgeVertical = SCREEN_EDGE_TOP; - GlobalConfig.BannerPosX = 0xFFFF; - GlobalConfig.BannerPosY = 0xFFFF; - GlobalConfig.BannerNudgeX = 0; - GlobalConfig.BannerNudgeY = 0; - GlobalConfig.VerticalLayout = FALSE; - GlobalConfig.MainEntriesSize = 128; - GlobalConfig.TileXSpace = 8; - GlobalConfig.TileYSpace = 24; - row0TileSize = 144; - row1TileSize = 64; - LayoutBannerOffset = 64; //default value if not set - LayoutButtonOffset = 0; //default value if not set - LayoutTextOffset = 0; //default value if not set - LayoutAnimMoveForMenuX = 0; //default value if not set - GlobalConfig.HideUIFlags = 0; - GlobalConfig.SelectionColor = 0x80808080; - - if (GlobalConfig.SelectionSmallFileName != NULL) { - FreePool (GlobalConfig.SelectionSmallFileName); - GlobalConfig.SelectionSmallFileName = NULL; - } - - if (GlobalConfig.SelectionBigFileName != NULL) { - FreePool (GlobalConfig.SelectionBigFileName); - GlobalConfig.SelectionBigFileName = NULL; - } - - if (GlobalConfig.SelectionIndicatorName != NULL) { - FreePool (GlobalConfig.SelectionIndicatorName); - GlobalConfig.SelectionIndicatorName = NULL; - } - - GlobalConfig.SelectionOnTop = FALSE; - GlobalConfig.BootCampStyle = FALSE; - ScrollWidth = 16; - ScrollButtonsHeight = 20; - ScrollBarDecorationsHeight = 5; - ScrollScrollDecorationsHeight = 7; - GlobalConfig.Font = FONT_LOAD; - if (GlobalConfig.FontFileName != NULL) { - FreePool (GlobalConfig.FontFileName); - GlobalConfig.FontFileName = NULL; - } - GlobalConfig.CharWidth = 9; - // GlobalConfig.PruneScrollRows = 0; - GuiAnime = NULL; - - if (BigBack != NULL) { - egFreeImage (BigBack); - BigBack = NULL; - } - - if (BackgroundImage != NULL) { - egFreeImage (BackgroundImage); - BackgroundImage = NULL; - } - - if (FontImage != NULL) { - egFreeImage (FontImage); - FontImage = NULL; - } - FreeScrollBar(); - - if (IconFormat != NULL) { - FreePool (IconFormat); - IconFormat = NULL; - } - - GlobalConfig.IconFormat = ICON_FORMAT_DEF; - - // if NULL parameter, quit after setting default values, this is embedded theme - if (DictPointer == NULL) { - return EFI_SUCCESS; - } - - Dict = GetProperty (DictPointer, "BootCampStyle"); - GlobalConfig.BootCampStyle = IsPropertyTrue(Dict); - - Dict = GetProperty (DictPointer, "Background"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Type"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if ((Dict2->string[0] == 'S') || (Dict2->string[0] == 's')) { - GlobalConfig.BackgroundScale = imScale; - } else if ((Dict2->string[0] == 'T') || (Dict2->string[0] == 't')) { - GlobalConfig.BackgroundScale = imTile; - } - } - // } - - Dict2 = GetProperty (Dict, "Path"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - GlobalConfig.BackgroundName = PoolPrint (L"%a", Dict2->string); - } - - Dict2 = GetProperty (Dict, "Sharp"); - GlobalConfig.BackgroundSharp = (INT32)GetPropertyInteger (Dict2, GlobalConfig.BackgroundSharp); - - Dict2 = GetProperty (Dict, "Dark"); - GlobalConfig.BackgroundDark = IsPropertyTrue(Dict2); - } - - Dict = GetProperty (DictPointer, "Banner"); - if (Dict != NULL) { - // retain for legacy themes. - if ((Dict->type == kTagTypeString) && Dict->string) { - GlobalConfig.BannerFileName = PoolPrint (L"%a", Dict->string); - } else { - // for new placement settings - Dict2 = GetProperty (Dict, "Path"); - if (Dict2 != NULL) { - if ((Dict2->type == kTagTypeString) && Dict2->string) { - GlobalConfig.BannerFileName = PoolPrint (L"%a", Dict2->string); - } - } - - Dict2 = GetProperty (Dict, "ScreenEdgeX"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if (AsciiStrCmp (Dict2->string, "left") == 0) { - GlobalConfig.BannerEdgeHorizontal = SCREEN_EDGE_LEFT; - } else if (AsciiStrCmp (Dict2->string, "right") == 0) { - GlobalConfig.BannerEdgeHorizontal = SCREEN_EDGE_RIGHT; - } - } - - Dict2 = GetProperty (Dict, "ScreenEdgeY"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if (AsciiStrCmp (Dict2->string, "top") == 0) { - GlobalConfig.BannerEdgeVertical = SCREEN_EDGE_TOP; - } else if (AsciiStrCmp (Dict2->string, "bottom") == 0) { - GlobalConfig.BannerEdgeVertical = SCREEN_EDGE_BOTTOM; - } - } - - Dict2 = GetProperty (Dict, "DistanceFromScreenEdgeX%"); - GlobalConfig.BannerPosX = (INT32)GetPropertyInteger (Dict2, 0); - - Dict2 = GetProperty (Dict, "DistanceFromScreenEdgeY%"); - GlobalConfig.BannerPosY = (INT32)GetPropertyInteger (Dict2, 0); - - Dict2 = GetProperty (Dict, "NudgeX"); - GlobalConfig.BannerNudgeX = (INT32)GetPropertyInteger (Dict2, 0); - - Dict2 = GetProperty (Dict, "NudgeY"); - GlobalConfig.BannerNudgeY = (INT32)GetPropertyInteger (Dict2, 0); - } - } - - Dict = GetProperty (DictPointer, "Badges"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Swap"); - if (Dict2 != NULL && Dict2->type == kTagTypeTrue) { - GlobalConfig.HideBadges |= HDBADGES_SWAP; - DBG ("OS main and drive as badge\n"); - } - - Dict2 = GetProperty (Dict, "Show"); - if (Dict2 != NULL && Dict2->type == kTagTypeTrue) { - GlobalConfig.HideBadges |= HDBADGES_SHOW; - } - - Dict2 = GetProperty (Dict, "Inline"); - if (Dict2 != NULL && Dict2->type == kTagTypeTrue) { - GlobalConfig.HideBadges |= HDBADGES_INLINE; - } - - // blackosx added X and Y position for badge offset. - Dict2 = GetProperty (Dict, "OffsetX"); - GlobalConfig.BadgeOffsetX = (INTN)GetPropertyInteger (Dict2, GlobalConfig.BadgeOffsetX); - - Dict2 = GetProperty (Dict, "OffsetY"); - GlobalConfig.BadgeOffsetY = (INTN)GetPropertyInteger (Dict2, GlobalConfig.BadgeOffsetY); - - Dict2 = GetProperty (Dict, "Scale"); - GlobalConfig.BadgeScale = (UINTN)GetPropertyInteger (Dict2, GlobalConfig.BadgeScale); - } - - Dict = GetProperty (DictPointer, "Origination"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "DesignWidth"); - GlobalConfig.ThemeDesignWidth = (UINTN)GetPropertyInteger (Dict2, GlobalConfig.ThemeDesignWidth); - - Dict2 = GetProperty (Dict, "DesignHeight"); - GlobalConfig.ThemeDesignHeight = (UINTN)GetPropertyInteger (Dict2, GlobalConfig.ThemeDesignHeight); - } - - Dict = GetProperty (DictPointer, "Layout"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "BannerOffset"); - LayoutBannerOffset = (UINTN)GetPropertyInteger (Dict2, LayoutBannerOffset); - - Dict2 = GetProperty (Dict, "ButtonOffset"); - LayoutButtonOffset = (UINTN)GetPropertyInteger (Dict2, LayoutButtonOffset); - - Dict2 = GetProperty (Dict, "TextOffset"); - LayoutTextOffset = (UINTN)GetPropertyInteger (Dict2, LayoutTextOffset); - - Dict2 = GetProperty (Dict, "AnimAdjustForMenuX"); - LayoutAnimMoveForMenuX = (UINTN)GetPropertyInteger (Dict2, LayoutAnimMoveForMenuX); - - Dict2 = GetProperty (Dict, "Vertical"); - if (Dict2 && Dict2->type == kTagTypeTrue) { - GlobalConfig.VerticalLayout = TRUE; - } - - // GlobalConfig.MainEntriesSize - Dict2 = GetProperty (Dict, "MainEntriesSize"); - GlobalConfig.MainEntriesSize = (INT32)GetPropertyInteger (Dict2, GlobalConfig.MainEntriesSize); - - Dict2 = GetProperty (Dict, "TileXSpace"); - GlobalConfig.TileXSpace = (INT32)GetPropertyInteger (Dict2, GlobalConfig.TileXSpace); - - Dict2 = GetProperty (Dict, "TileYSpace"); - GlobalConfig.TileYSpace = (INT32)GetPropertyInteger (Dict2, GlobalConfig.TileYSpace); - - Dict2 = GetProperty (Dict, "SelectionBigWidth"); - row0TileSize = (INTN)GetPropertyInteger (Dict2, row0TileSize); - - Dict2 = GetProperty (Dict, "SelectionSmallWidth"); - row1TileSize = (INTN)GetPropertyInteger (Dict2, row1TileSize); - - } - - Dict = GetProperty (DictPointer, "Components"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Banner"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_BANNER; - } - - Dict2 = GetProperty (Dict, "Functions"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_FUNCS; - } - - Dict2 = GetProperty (Dict, "Tools"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_TOOLS; - } - - Dict2 = GetProperty (Dict, "Label"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_LABEL; - } - - Dict2 = GetProperty (Dict, "Revision"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_REVISION; - } - - Dict2 = GetProperty (Dict, "Help"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_HELP; - } - - Dict2 = GetProperty (Dict, "MenuTitle"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_MENU_TITLE; - } - - Dict2 = GetProperty (Dict, "MenuTitleImage"); - if (Dict2 && Dict2->type == kTagTypeFalse) { - GlobalConfig.HideUIFlags |= HIDEUI_FLAG_MENU_TITLE_IMAGE; - } - } - - Dict = GetProperty (DictPointer, "Selection"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Color"); - GlobalConfig.SelectionColor = (UINTN)GetPropertyInteger (Dict2, GlobalConfig.SelectionColor); - - Dict2 = GetProperty (Dict, "Small"); - if ( Dict2 && (Dict2->type == kTagTypeString) && Dict2->string) { - GlobalConfig.SelectionSmallFileName = PoolPrint (L"%a", Dict2->string); - } - - Dict2 = GetProperty (Dict, "Big"); - if ( Dict2 && (Dict2->type == kTagTypeString) && Dict2->string) { - GlobalConfig.SelectionBigFileName = PoolPrint (L"%a", Dict2->string); - } - - Dict2 = GetProperty (Dict, "Indicator"); - if ( Dict2 && (Dict2->type == kTagTypeString) && Dict2->string) { - GlobalConfig.SelectionIndicatorName = PoolPrint (L"%a", Dict2->string); - } - - Dict2 = GetProperty (Dict, "OnTop"); - GlobalConfig.SelectionOnTop = IsPropertyTrue (Dict2); - - Dict2 = GetProperty (Dict, "ChangeNonSelectedGrey"); - GlobalConfig.NonSelectedGrey = IsPropertyTrue (Dict2); - } - - Dict = GetProperty (DictPointer, "Scroll"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Width"); - ScrollWidth = (UINTN)GetPropertyInteger (Dict2, ScrollWidth); - - Dict2 = GetProperty (Dict, "Height"); - ScrollButtonsHeight = (UINTN)GetPropertyInteger (Dict2, ScrollButtonsHeight); - - Dict2 = GetProperty (Dict, "BarHeight"); - ScrollBarDecorationsHeight = (UINTN)GetPropertyInteger (Dict2, ScrollBarDecorationsHeight); - - Dict2 = GetProperty (Dict, "ScrollHeight"); - ScrollScrollDecorationsHeight = (UINTN)GetPropertyInteger (Dict2,ScrollScrollDecorationsHeight); - } - - Dict = GetProperty (DictPointer, "Font"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Type"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if ((Dict2->string[0] == 'A') || (Dict2->string[0] == 'B')) { - GlobalConfig.Font = FONT_ALFA; - } else if ((Dict2->string[0] == 'G') || (Dict2->string[0] == 'W')) { - GlobalConfig.Font = FONT_GRAY; - } else if ((Dict2->string[0] == 'L') || (Dict2->string[0] == 'l')) { - GlobalConfig.Font = FONT_LOAD; - } - } - if (GlobalConfig.Font == FONT_LOAD) { - Dict2 = GetProperty (Dict, "Path"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - GlobalConfig.FontFileName = PoolPrint (L"%a", Dict2->string); - } - } - - Dict2 = GetProperty (Dict, "CharWidth"); - GlobalConfig.CharWidth = (UINTN)GetPropertyInteger (Dict2, GlobalConfig.CharWidth); - if (GlobalConfig.CharWidth & 1) { - MsgLog("Warning! Character width %lld should be even!\n", GlobalConfig.CharWidth); - } - - Dict2 = GetProperty (Dict, "Proportional"); - GlobalConfig.Proportional = IsPropertyTrue (Dict2); - } - - Dict = GetProperty (DictPointer, "Anime"); - if (Dict != NULL) { - INTN i, Count = GetTagCount (Dict); - for (i = 0; i < Count; i++) { - GUI_ANIME *Anime; - if (EFI_ERROR (GetElement (Dict, i, &Dict3))) { - continue; - } - - if (Dict3 == NULL) { - break; - } - - Anime = (__typeof__(Anime))AllocateZeroPool (sizeof(GUI_ANIME)); - if (Anime == NULL) { - break; - } - - Dict2 = GetProperty (Dict3, "ID"); - Anime->ID = (UINTN)GetPropertyInteger (Dict2, 1); //default=main screen - - Dict2 = GetProperty (Dict3, "Path"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - Anime->Path = PoolPrint (L"%a", Dict2->string); - } - - Dict2 = GetProperty (Dict3, "Frames"); - Anime->Frames = (UINTN)GetPropertyInteger (Dict2, Anime->Frames); - - Dict2 = GetProperty (Dict3, "FrameTime"); - Anime->FrameTime = (UINTN)GetPropertyInteger (Dict2, Anime->FrameTime); - - Dict2 = GetProperty (Dict3, "ScreenEdgeX"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if (AsciiStrCmp (Dict2->string, "left") == 0) { - Anime->ScreenEdgeHorizontal = SCREEN_EDGE_LEFT; - } else if (AsciiStrCmp (Dict2->string, "right") == 0) { - Anime->ScreenEdgeHorizontal = SCREEN_EDGE_RIGHT; - } - } - - Dict2 = GetProperty (Dict3, "ScreenEdgeY"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if (AsciiStrCmp (Dict2->string, "top") == 0) { - Anime->ScreenEdgeVertical = SCREEN_EDGE_TOP; - } else if (AsciiStrCmp (Dict2->string, "bottom") == 0) { - Anime->ScreenEdgeVertical = SCREEN_EDGE_BOTTOM; - } - } - - //default values are centre - - Dict2 = GetProperty (Dict3, "DistanceFromScreenEdgeX%"); - Anime->FilmX = (INT32)GetPropertyInteger (Dict2, INITVALUE); - - Dict2 = GetProperty (Dict3, "DistanceFromScreenEdgeY%"); - Anime->FilmY = (INT32)GetPropertyInteger (Dict2, INITVALUE); - - Dict2 = GetProperty (Dict3, "NudgeX"); - Anime->NudgeX = (INT32)GetPropertyInteger (Dict2, INITVALUE); - - Dict2 = GetProperty (Dict3, "NudgeY"); - Anime->NudgeY = (INT32)GetPropertyInteger (Dict2, INITVALUE); - - Dict2 = GetProperty (Dict3, "Once"); - Anime->Once = IsPropertyTrue (Dict2); - - // Add the anime to the list - if ((Anime->ID == 0) || (Anime->Path == NULL)) { - FreePool (Anime); - } else if (GuiAnime != NULL) { //second anime or further - if (GuiAnime->ID == Anime->ID) { //why the same anime here? - Anime->Next = GuiAnime->Next; - FreeAnime (GuiAnime); //free double - } else { - GUI_ANIME *Ptr = GuiAnime; - while (Ptr->Next) { - if (Ptr->Next->ID == Anime->ID) { //delete double from list - GUI_ANIME *Next = Ptr->Next; - Ptr->Next = Next->Next; - FreeAnime (Next); - break; - } - Ptr = Ptr->Next; - } - Anime->Next = GuiAnime; - } - GuiAnime = Anime; - } else { - GuiAnime = Anime; //first anime - } - } - } - - // set file defaults in case they were not set - Dict = GetProperty (DictPointer, "Icon"); - if (Dict != NULL) { - Dict2 = GetProperty (Dict, "Format"); - if (Dict2 != NULL && (Dict2->type == kTagTypeString) && Dict2->string) { - if (AsciiStriCmp (Dict2->string, "ICNS") == 0) { - GlobalConfig.IconFormat = ICON_FORMAT_ICNS; - IconFormat = PoolPrint (L"%s", L"icns"); - } else if (AsciiStriCmp (Dict2->string, "PNG") == 0) { - GlobalConfig.IconFormat = ICON_FORMAT_PNG; - IconFormat = PoolPrint (L"%s", L"png"); - } else if (AsciiStriCmp (Dict2->string, "BMP") == 0) { - GlobalConfig.IconFormat = ICON_FORMAT_BMP; - IconFormat = PoolPrint (L"%s", L"bmp"); - }/* else { - GlobalConfig.IconFormat = ICON_FORMAT_DEF; - }*/ - } - } - - if (GlobalConfig.BackgroundName == NULL) { - GlobalConfig.BackgroundName = GetIconsExt(L"background", L"png"); - } - if (GlobalConfig.BannerFileName == NULL) { - GlobalConfig.BannerFileName = GetIconsExt(L"logo", L"png"); - } - if (GlobalConfig.SelectionSmallFileName == NULL) { - GlobalConfig.SelectionSmallFileName = GetIconsExt(L"selection_small", L"png"); - } - if (GlobalConfig.SelectionBigFileName == NULL) { - GlobalConfig.SelectionBigFileName = GetIconsExt(L"selection_big", L"png"); - } - if (GlobalConfig.SelectionIndicatorName == NULL) { - GlobalConfig.SelectionIndicatorName = GetIconsExt(L"selection_indicator", L"png"); - } - if (GlobalConfig.FontFileName == NULL) { - GlobalConfig.FontFileName = GetIconsExt(L"font", L"png"); - } - - return EFI_SUCCESS; -} - -#endif - -#if USE_XTHEME void* XTheme::LoadTheme (const CHAR16 *TestTheme) -#else -TagPtr LoadTheme (const CHAR16 *TestTheme) - -#endif { EFI_STATUS Status = EFI_UNSUPPORTED; TagPtr ThemeDict = NULL; @@ -4913,7 +3878,6 @@ TagPtr LoadTheme (const CHAR16 *TestTheme) if (!EFI_ERROR (Status)) { Status = egLoadFile(ThemeDir, CONFIG_THEME_SVG, (UINT8**)&ThemePtr, &Size); if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) { -#if USE_XTHEME Status = ParseSVGXTheme((const CHAR8*)ThemePtr); if (EFI_ERROR(Status)) { ThemeDict = NULL; @@ -4921,9 +3885,6 @@ TagPtr LoadTheme (const CHAR16 *TestTheme) ThemeDict = (__typeof__(ThemeDict))AllocateZeroPool(sizeof(TagStruct)); ThemeDict->type = kTagTypeNone; } -#else - Status = ParseSVGTheme((const CHAR8*)ThemePtr, &ThemeDict); -#endif if (ThemeDict == NULL) { DBG("svg file %ls not parsed\n", CONFIG_THEME_SVG); } else { @@ -4947,14 +3908,9 @@ TagPtr LoadTheme (const CHAR16 *TestTheme) if (ThemePtr != NULL) { FreePool (ThemePtr); } -#if USE_XTHEME return (void*)ThemeDict; -#else - return ThemeDict; -#endif } -#if USE_XTHEME EFI_STATUS InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time) { @@ -5174,269 +4130,6 @@ finish: return Status; } -#else -EFI_STATUS -InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time) -{ - EFI_STATUS Status = EFI_NOT_FOUND; - UINTN Size = 0; - UINTN i; - TagPtr ThemeDict = NULL; - CHAR8 *ChosenTheme = NULL; - CHAR16 *TestTheme = NULL; - UINTN Rnd; - - DbgHeader("InitTheme"); - GlobalConfig.TypeSVG = FALSE; - GlobalConfig.BootCampStyle = FALSE; - GlobalConfig.Scale = 1.0f; - GlobalConfig.BannerPosX = 0; - GlobalConfig.BannerPosY = 0; - - if (DayLight) { - DBG("use daylight theme\n"); - } else { - DBG("use night theme\n"); - } - - for (i = 0; i < 3; i++) { - // DBG("validate %d face\n", i); - textFace[i].valid = FALSE; - } - // DBG("...done\n"); - NSVGfontChain *fontChain = fontsDB; - while (fontChain) { - NSVGfont *font = fontChain->font; - // DBG("free font %s\n", font->fontFamily); - NSVGfontChain *nextChain = fontChain->next; - if (font) { - nsvg__deleteFont(font); - fontChain->font = NULL; - } - FreePool(fontChain); - fontChain = nextChain; - } - //as all font freed then free the chain - fontsDB = NULL; - - /* - if (mainParser) { - nsvg__deleteParser(mainParser); - DBG("parser deleted\n"); - mainParser = NULL; - } - */ - row0TileSize = 144; - row1TileSize = 64; - if (FontImage != NULL) { - // DBG("free font image\n"); //raster font - egFreeImage (FontImage); - FontImage = NULL; - } - - Rnd = ((Time != NULL) && (ThemesNum != 0)) ? Time->Second % ThemesNum : 0; - - // Free selection images which are not builtin icons - for (i = 0; i < 6; i++) { - // DBG("free selection %d\n", i); - if (SelectionImages[i] != NULL) { - if ((SelectionImages[i] != BuiltinIconTable[BUILTIN_SELECTION_SMALL].Image) && - (SelectionImages[i] != BuiltinIconTable[BUILTIN_SELECTION_BIG].Image)) { - egFreeImage (SelectionImages[i]); - } - SelectionImages[i] = NULL; - } - } - // DBG("...done\n"); - // Free banner which is not builtin icon - if (Banner != NULL) { - if (Banner != BuiltinIconTable[BUILTIN_ICON_BANNER].Image) { - // DBG("free banner\n"); - egFreeImage (Banner); - } - Banner = NULL; - } - // DBG("...done\n"); - //Free buttons images - for (i = 0; i < 4; i++) { - if (Buttons[i] != NULL) { - // DBG("free button %d\n", i); - egFreeImage(Buttons[i]); - Buttons[i] = NULL; - } - } - - // Kill mouse before we invalidate builtin pointer image - // KillMouse(); - //here we have no access to Mouse - - // Invalidate BuiltinIcons - // DBG ("Invalidating BuiltinIcons...\n"); - for (i = 0; i < BUILTIN_ICON_COUNT; i++) { - if (BuiltinIconTable[i].Image != NULL) { - // DBG("free builtin image %d\n", i); - egFreeImage (BuiltinIconTable[i].Image); - BuiltinIconTable[i].Image = NULL; - } - } - // DBG("...done\n"); - while (GuiAnime != NULL) { - GUI_ANIME *NextAnime = GuiAnime->Next; - // DBG("free anime %d\n", GuiAnime->ID); - FreeAnime (GuiAnime); - GuiAnime = NextAnime; - } - // DBG("...done\n"); - GetThemeTagSettings(NULL); - - if (ThemesNum > 0 && - (!GlobalConfig.Theme || StriCmp(GlobalConfig.Theme, L"embedded") != 0)) { - // Try special theme first - if (Time != NULL) { - if ((Time->Month == 12) && ((Time->Day >= 25) && (Time->Day <= 31))) { - TestTheme = PoolPrint (L"christmas"); - } else if ((Time->Month == 1) && ((Time->Day >= 1) && (Time->Day <= 3))) { - TestTheme = PoolPrint (L"newyear"); - } - - if (TestTheme != NULL) { - ThemeDict = LoadTheme (TestTheme); - if (ThemeDict != NULL) { - DBG ("special theme %ls found and %ls parsed\n", TestTheme, CONFIG_THEME_FILENAME); - if (GlobalConfig.Theme) { - FreePool (GlobalConfig.Theme); - } - GlobalConfig.Theme = TestTheme; - } else { // special theme not loaded - DBG ("special theme %ls not found, skipping\n", TestTheme/*, CONFIG_THEME_FILENAME*/); - FreePool (TestTheme); - } - TestTheme = NULL; - } - } - // Try theme from nvram - if (ThemeDict == NULL && UseThemeDefinedInNVRam) { - ChosenTheme = (__typeof__(ChosenTheme))GetNvramVariable(L"Clover.Theme", &gEfiAppleBootGuid, NULL, &Size); - if (ChosenTheme != NULL) { - if (AsciiStrCmp (ChosenTheme, "embedded") == 0) { - goto finish; - } - if (AsciiStrCmp (ChosenTheme, "random") == 0) { - ThemeDict = LoadTheme (ThemesList[Rnd]); - goto finish; - } - - TestTheme = PoolPrint (L"%a", ChosenTheme); - if (TestTheme != NULL) { - ThemeDict = LoadTheme (TestTheme); - if (ThemeDict != NULL) { - DBG ("theme %s defined in NVRAM found and %ls parsed\n", ChosenTheme, CONFIG_THEME_FILENAME); - if (GlobalConfig.Theme != NULL) { - FreePool (GlobalConfig.Theme); - } - GlobalConfig.Theme = TestTheme; - } else { // theme from nvram not loaded - if (GlobalConfig.Theme != NULL) { - DBG ("theme %s chosen from nvram is absent, using theme defined in config: %ls\n", ChosenTheme, GlobalConfig.Theme); - } else { - DBG ("theme %s chosen from nvram is absent, get first theme\n", ChosenTheme); - } - FreePool (TestTheme); - } - TestTheme = NULL; - } - FreePool (ChosenTheme); - ChosenTheme = NULL; - } - } - // Try to get theme from settings - if (ThemeDict == NULL) { - if (GlobalConfig.Theme == NULL) { - if (Time != NULL) { - DBG ("no default theme, get random theme %ls\n", ThemesList[Rnd]); - } else { - DBG ("no default theme, get first theme %ls\n", ThemesList[0]); - } - } else { - if (StriCmp(GlobalConfig.Theme, L"random") == 0) { - ThemeDict = LoadTheme (ThemesList[Rnd]); - } else { - ThemeDict = LoadTheme (GlobalConfig.Theme); - if (ThemeDict == NULL) { - DBG ("GlobalConfig: %ls not found, get embedded theme\n", GlobalConfig.Theme); - FreePool (GlobalConfig.Theme); - GlobalConfig.Theme = NULL; - } - } - } - } - } // ThemesNum>0 - -finish: - if (!ThemeDict) { // No theme could be loaded, use embedded - DBG (" using embedded theme\n"); - GlobalConfig.Theme = NULL; - OldChosenTheme = 0xFFFF; - if (ThemePath != NULL) { - FreePool (ThemePath); - ThemePath = NULL; - } - - if (ThemeDir != NULL) { - ThemeDir->Close (ThemeDir); - ThemeDir = NULL; - } - - GetThemeTagSettings(NULL); - //fill some fields - //GlobalConfig.Timeout = -1; - GlobalConfig.SelectionColor = 0xA0A0A080; - GlobalConfig.Font = FONT_ALFA; //to be inverted later - GlobalConfig.CharWidth = 9; - GlobalConfig.HideBadges = HDBADGES_SHOW; - GlobalConfig.BadgeScale = 16; - Status = StartupSoundPlay(ThemeDir, NULL); - } else { // theme loaded successfully - // read theme settings - if (!GlobalConfig.TypeSVG) { - TagPtr DictPointer = GetProperty(ThemeDict, "Theme"); - if (DictPointer != NULL) { - Status = GetThemeTagSettings(DictPointer); - if (EFI_ERROR (Status)) { - DBG ("Config theme error: %s\n", strerror(Status)); - } - } - } - FreeTag(ThemeDict); - - if (!DayLight) { - Status = StartupSoundPlay(ThemeDir, L"sound_night.wav"); - if (EFI_ERROR(Status)) { - Status = StartupSoundPlay(ThemeDir, L"sound.wav"); - } - } else { - Status = StartupSoundPlay(ThemeDir, L"sound.wav"); - } - - } - for (i = 0; i < ThemesNum; i++) { - if (GlobalConfig.Theme && StriCmp(GlobalConfig.Theme, ThemesList[i]) == 0) { - OldChosenTheme = i; - break; - } - } - if (ChosenTheme != NULL) { - FreePool (ChosenTheme); - } - if (!GlobalConfig.TypeSVG) { - PrepareFont(); - } - - return Status; -} - -#endif - VOID ParseSMBIOSSettings( TagPtr DictPointer @@ -7494,7 +6187,6 @@ GetUserSettings( } else { //DBG("\n ConfigName: %ls n", gSettings.ConfigName); } -#if USE_XTHEME if (gThemeChanged && ThemeX.Theme.notEmpty()) { DictPointer = GetProperty (Dict, "GUI"); if (DictPointer != NULL) { @@ -7506,20 +6198,6 @@ GetUserSettings( } } } -#else - if (gThemeChanged && GlobalConfig.Theme) { - DictPointer = GetProperty (Dict, "GUI"); - if (DictPointer != NULL) { - Prop = GetProperty (DictPointer, "Theme"); - if ((Prop != NULL) && (Prop->type == kTagTypeString) && Prop->string) { - FreePool(GlobalConfig.Theme); - GlobalConfig.Theme = PoolPrint (L"%a", Prop->string); - DBG ("Theme from new config: %ls\n", GlobalConfig.Theme); - } - } - } -#endif - SaveSettings(); } //DBG ("config.plist read and return %s\n", strerror(Status)); diff --git a/rEFIt_UEFI/entry_scan/common.cpp b/rEFIt_UEFI/entry_scan/common.cpp index e91b4e68c..b36651b8b 100644 --- a/rEFIt_UEFI/entry_scan/common.cpp +++ b/rEFIt_UEFI/entry_scan/common.cpp @@ -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; diff --git a/rEFIt_UEFI/entry_scan/entry_scan.h b/rEFIt_UEFI/entry_scan/entry_scan.h index f5c9a2eec..4b8c4d7c5 100644 --- a/rEFIt_UEFI/entry_scan/entry_scan.h +++ b/rEFIt_UEFI/entry_scan/entry_scan.h @@ -46,22 +46,8 @@ extern REFIT_MENU_SCREEN MainMenu; extern XObjArray 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, diff --git a/rEFIt_UEFI/entry_scan/legacy.cpp b/rEFIt_UEFI/entry_scan/legacy.cpp index 7e8356069..31922acec 100644 --- a/rEFIt_UEFI/entry_scan/legacy.cpp +++ b/rEFIt_UEFI/entry_scan/legacy.cpp @@ -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"); diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index 476e9f979..3e99793b9 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -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(); diff --git a/rEFIt_UEFI/entry_scan/securemenu.cpp b/rEFIt_UEFI/entry_scan/securemenu.cpp index 2eeab0530..03853ec64 100644 --- a/rEFIt_UEFI/entry_scan/securemenu.cpp +++ b/rEFIt_UEFI/entry_scan/securemenu.cpp @@ -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) diff --git a/rEFIt_UEFI/entry_scan/tool.cpp b/rEFIt_UEFI/entry_scan/tool.cpp index 0428f108b..c7c328b29 100644 --- a/rEFIt_UEFI/entry_scan/tool.cpp +++ b/rEFIt_UEFI/entry_scan/tool.cpp @@ -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? } diff --git a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp index b144bc6d4..0e863252c 100644 --- a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp +++ b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp @@ -92,14 +92,6 @@ static INTN MaxItemOnScreen = -1; //extern UINT8 gLanMac[4][6]; // their MAC addresses //extern EFI_AUDIO_IO_PROTOCOL *AudioIo; // -////layout must be in XTheme -//#if !USE_XTHEME -//INTN LayoutBannerOffset = 64; -//INTN LayoutButtonOffset = 0; -//INTN LayoutTextOffset = 0; -//INTN LayoutMainMenuHeight = 376; -//INTN LayoutAnimMoveForMenuX = 0; -//#endif // //BOOLEAN SavePreBootLog = FALSE; @@ -139,12 +131,6 @@ BOOLEAN MainAnime = FALSE; ////TODO Scroll variables must be a part of REFIT_SCREEN ////BOOLEAN ScrollEnabled = FALSE; BOOLEAN IsDragging = FALSE; -//#if !USE_XTHEME -//INTN ScrollWidth = 16; -//INTN ScrollButtonsHeight = 20; -//INTN ScrollBarDecorationsHeight = 5; -//INTN ScrollScrollDecorationsHeight = 7; -//#endif INTN ScrollbarYMovement; // // @@ -160,16 +146,6 @@ INTN ScrollbarYMovement; ////#define TILE_YSPACING (24) #define ROW0_SCROLLSIZE (100) // -////EG_IMAGE *SelectionImages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; -////EG_IMAGE *Buttons[4] = {NULL, NULL, NULL, NULL}; -//#if !USE_XTHEME -//static EG_IMAGE *TextBuffer = NULL; -//#endif -// -////EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //non-trasparent -// -////INTN row0TileSize = 144; -////INTN row1TileSize = 64; // static INTN row0Count, row0PosX, row0PosXRunning; static INTN row1Count, row1PosX, row1PosXRunning; @@ -184,102 +160,10 @@ static INTN OldTimeoutTextWidth = 0; static INTN MenuWidth , TimeoutPosY; static INTN EntriesPosX, EntriesPosY; static INTN EntriesWidth, EntriesHeight, EntriesGap; -//#if !USE_XTHEME -//static EG_IMAGE* ScrollbarImage = NULL; -//static EG_IMAGE* ScrollbarBackgroundImage = NULL; -//static EG_IMAGE* UpButtonImage = NULL; -//static EG_IMAGE* DownButtonImage = NULL; -//static EG_IMAGE* BarStartImage = NULL; -//static EG_IMAGE* BarEndImage = NULL; -//static EG_IMAGE* ScrollStartImage = NULL; -//static EG_IMAGE* ScrollEndImage = NULL; -//EG_RECT BarStart; -//EG_RECT BarEnd; -//EG_RECT ScrollStart; -//EG_RECT ScrollEnd; -//EG_RECT ScrollTotal; -//EG_RECT UpButton; -//EG_RECT DownButton; -//EG_RECT ScrollbarBackground; -//EG_RECT Scrollbar; -//EG_RECT ScrollbarOldPointerPlace; -//EG_RECT ScrollbarNewPointerPlace; -//#endif -// -//INPUT_ITEM *InputItems = NULL; -//UINTN InputItemsCount = 0; -// -//INTN OldChosenTheme; -//INTN OldChosenConfig; -//INTN OldChosenDsdt; -//UINTN OldChosenAudio; -//UINT8 DefaultAudioVolume = 70; -////INTN NewChosenTheme; -//#if !USE_XTHEME -//INTN TextStyle; //why global? It will be class SCREEN member -//#endif + BOOLEAN mGuiReady = FALSE; -// -////REFIT_MENU_ITEM_OPTIONS(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) -//REFIT_MENU_ITEM_OPTIONS MenuEntryOptions (L"Options"_XSW, 1, 0, 'O', ActionEnter); -//REFIT_MENU_ITEM_ABOUT MenuEntryAbout (L"About Clover"_XSW, 1, 0, 'A', ActionEnter); -//REFIT_MENU_ITEM_RESET MenuEntryReset (L"Restart Computer"_XSW, 1, 0, 'R', ActionSelect); -//REFIT_MENU_ITEM_SHUTDOWN MenuEntryShutdown(L"Exit Clover"_XSW, 1, 0, 'U', ActionSelect); -//REFIT_MENU_ITEM_RETURN MenuEntryReturn (L"Return"_XSW, 0, 0, 0, ActionEnter); -// -// -//#if USE_XTHEME -//REFIT_MENU_SCREEN MainMenu(1, L"Main Menu"_XSW, L"Automatic boot"_XSW); -//REFIT_MENU_SCREEN AboutMenu(2, L"About"_XSW, L""_XSW); -//REFIT_MENU_SCREEN HelpMenu(3, L"Help"_XSW, L""_XSW); -//#else -//REFIT_MENU_SCREEN MainMenu(1, L"Main Menu", L"Automatic boot"); -//REFIT_MENU_SCREEN AboutMenu(2, L"About", NULL); -//REFIT_MENU_SCREEN HelpMenu(3, L"Help", NULL); -//#endif -// -// -//CONST CHAR16* ArgOptional[NUM_OPT] = { -// L"arch=i386", //0 -// L"arch=x86_64", //1 -// L"-v ", //2 -// L"-f ", //3 -// L"-s ", //4 -// L"-x ", //5 -// L"nv_disable=1", //6 -// L"slide=0", //7 -// L"darkwake=0", //8 -// L"-xcpm", //9 -// L"-gux_no_idle", //10 -// L"-gux_nosleep", //11 -// L"-gux_nomsi", //12 -// L"-gux_defer_usb2", //13 -// L"keepsyms=1", //14 -// L"debug=0x100", //15 -// L"kextlog=0xffff", //16 -// L"-alcoff", //17 -// L"-shikioff", //18 -// L"nvda_drv=1" //19 -//}; - -//UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry); - - - -// -//VOID REFIT_MENU_SCREEN::AddMenuInfo(CONST char *Line) -//{ -// -////DBG("%s, %s : Line=%s\n", __FILE__, __LINE__, XString(Line).c); -// REFIT_INFO_DIALOG *InputBootArgs; -// -// InputBootArgs = new REFIT_INFO_DIALOG; -// InputBootArgs->Title.takeValueFrom(Line); -// InputBootArgs->AtClick = ActionLight; -// AddMenuEntry(InputBootArgs, true); -//} VOID REFIT_MENU_SCREEN::AddMenuInfo_f(CONST char *format, ...) { @@ -296,8 +180,6 @@ VOID REFIT_MENU_SCREEN::AddMenuInfo_f(CONST char *format, ...) AddMenuEntry(InputBootArgs, true); } - - // // Graphics helper functions // @@ -354,7 +236,6 @@ VOID REFIT_MENU_SCREEN::InitScroll(IN INTN ItemCount, IN UINTN MaxCount, ScrollState.LastVisible = ScrollState.FirstVisible + ScrollState.MaxVisible; -#if USE_XTHEME //scroll bar geometry if (!ThemeX.TypeSVG) { UpButton.Width = ThemeX.ScrollWidth; // 16 @@ -376,7 +257,6 @@ VOID REFIT_MENU_SCREEN::InitScroll(IN INTN ItemCount, IN UINTN MaxCount, ScrollStart.Height = 0; // 7 ScrollEnd.Height = 0; } -#endif } @@ -583,51 +463,20 @@ VOID REFIT_MENU_SCREEN::AddMenuEntry(IN REFIT_ABSTRACT_MENU_ENTRY *Entry, bool f // This is supposed to be a destructor ? VOID REFIT_MENU_SCREEN::FreeMenu() { -// INTN i; REFIT_ABSTRACT_MENU_ENTRY *Tentry = NULL; -//TODO - here we must FreePool for a list of Entries, Screens, InputBootArgs +//TODO - here we must Free for a list of Entries, Screens, InputBootArgs if (Entries.size() > 0) { for (UINTN i = 0; i < Entries.size(); i++) { Tentry = &Entries[i]; if (Tentry->SubScreen) { -#if USE_XTHEME -#else - if (Tentry->SubScreen->Title) { - FreePool(Tentry->SubScreen->Title); - Tentry->SubScreen->Title = NULL; - } -#endif // don't free image because of reusing them - // FreeMenu(Tentry->SubScreen); Tentry->SubScreen->FreeMenu(); Tentry->SubScreen = NULL; } -// Title is a XStringW. It'll be destroyed in REFIT_MENU_SCREEN dtor -// if (Tentry->getREFIT_MENU_ITEM_RETURN()) { //can't free constants -// if (Tentry->Title) { -// FreePool(Tentry->Title); -// Tentry->Title = NULL; -// } -// } -// Tentry is an object inserted in a XArray. It'll deleted at Entries.Empty() -// FreePool(Tentry); } Entries.Empty(); -// FreePool(Screen->Entries); -// Screen->Entries = NULL; } -// Infolines will deleted at InfoLines.Empty() -// if (InfoLines.size() > 0) { -// for (UINTN i = 0; i < InfoLines.size(); i++) { -// // TODO: call a user-provided routine for each element here -// FreePool(InfoLines[i]); -// } -// Screen->InfoLines.size() = 0; -// FreePool(Screen->InfoLines); -// Screen->InfoLines = NULL; -// } - InfoLines.Empty(); - + InfoLines.Empty(); } INTN REFIT_MENU_SCREEN::FindMenuShortcutEntry(IN CHAR16 Shortcut) @@ -871,7 +720,6 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT } else { TextStyle = 2; } -#if USE_XTHEME if (ThemeX.TypeSVG) { if (!textFace[TextStyle].valid) { if (textFace[0].valid) { @@ -891,27 +739,6 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT ThemeX.TextHeight = (int)((textFace[TextStyle].size * RowHeightFromTextHeight) * ThemeX.Scale); } } -#else - if (GlobalConfig.TypeSVG) { - if (!textFace[TextStyle].valid) { - if (textFace[0].valid) { - TextStyle = 0; - } else if (textFace[2].valid) { - TextStyle = 2; - } else if (textFace[1].valid) { - TextStyle = 1; - } else { - DBG("no valid text style\n"); - textFace[TextStyle].size = TextHeight - 4; - } - } - if (textFace[TextStyle].valid) { - // TextHeight = (int)((textFace[TextStyle].size + 4) * GlobalConfig.Scale); - //clovy - row height / text size factor - TextHeight = (int)((textFace[TextStyle].size * RowHeightFromTextHeight) * GlobalConfig.Scale); - } - } -#endif //no default - no timeout! if ((*DefaultEntryIndex != -1) && (TimeoutSeconds > 0)) { @@ -945,16 +772,9 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT } if (HaveTimeout) { -#if USE_XTHEME //TimeoutMessage = PoolPrint(L"%s in %d seconds", TimeoutText.data(), TimeoutCountdown); XStringW TOMessage = SWPrintf("%ls in %lld seconds", TimeoutText.wc_str(), TimeoutCountdown); ((*this).*(StyleFunc))(MENU_FUNCTION_PAINT_TIMEOUT, TOMessage.data()); -// FreePool(TimeoutMessage); -#else - CHAR16 *TimeoutMessage = PoolPrint(L"%s in %d seconds", TimeoutText, TimeoutCountdown); - ((*this).*(StyleFunc))(MENU_FUNCTION_PAINT_TIMEOUT, TimeoutMessage); - FreePool(TimeoutMessage); -#endif } if (gEvent) { //for now used at CD eject. @@ -1469,7 +1289,6 @@ VOID REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT */ -#if USE_XTHEME INTN REFIT_MENU_SCREEN::DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) { INTN TextWidth = 0; @@ -1553,15 +1372,10 @@ void REFIT_MENU_SCREEN::EraseTextXY() //used on boot screen { OldTextBufferImage.Draw(OldTextBufferRect.XPos, OldTextBufferRect.YPos); } -#else - - -#endif /** * Helper function to draw text for Boot Camp Style. * @author: Needy */ -#if USE_XTHEME VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) { // check if text was provided. And what else? @@ -1588,11 +1402,7 @@ VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN DrawTextXY(BCSTextX, XPos, YPos, XAlign); } -#else -//remains in menu.cpp -#endif -#if USE_XTHEME VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor) { XImage TextBufferX(UGAWidth-XPos, ThemeX.TextHeight); @@ -1630,10 +1440,6 @@ VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, I SelectionBar.DrawWithoutCompose(XPos, YPos); } -#else - -#endif - VOID REFIT_MENU_SCREEN::SetBar(INTN PosX, INTN UpPosY, INTN DownPosY, IN SCROLL_STATE *State) { // DBG("SetBar <= %d %d %d %d %d\n", UpPosY, DownPosY, State->MaxVisible, State->MaxIndex, State->FirstVisible); @@ -1678,14 +1484,14 @@ VOID REFIT_MENU_SCREEN::SetBar(INTN PosX, INTN UpPosY, INTN DownPosY, IN SCROLL_ ScrollTotal.Height = DownButton.YPos + DownButton.Height - UpButton.YPos; // DBG("ScrollTotal.Height = %d\n", ScrollTotal.Height); //ScrollTotal.Height = 420 } -#if USE_XTHEME + VOID REFIT_MENU_SCREEN::ScrollingBar() { ScrollEnabled = (ScrollState.MaxFirstVisible != 0); if (!ScrollEnabled) { return; } -#if 1 //use compose instead of Draw + //use compose instead of Draw //this is a copy of old algorithm // but we can not use Total and Draw all parts separately assumed they composed on background // it is #else @@ -1710,60 +1516,10 @@ VOID REFIT_MENU_SCREEN::ScrollingBar() Total.Compose(ScrollStart.XPos - ScrollTotal.XPos, ScrollStart.YPos - ScrollTotal.YPos, ThemeX.ScrollStartImage, FALSE); Total.Compose(ScrollEnd.XPos - ScrollTotal.XPos, ScrollEnd.YPos - ScrollTotal.YPos, ThemeX.ScrollEndImage, FALSE); Total.Draw(ScrollTotal.XPos, ScrollTotal.YPos, ThemeX.ScrollWidth / 16.f); //ScrollWidth can be set in theme.plist but usually=16 -#else - for (INTN i = 0; i < ScrollbarBackground.Height; i += ThemeX.ScrollbarBackgroundImage.GetHeight()) { - ThemeX.ScrollbarBackgroundImage.Draw(ScrollbarBackground.XPos - ScrollTotal.XPos, ScrollbarBackground.YPos + i - ScrollTotal.YPos, 1.f); - } - ThemeX.BarStartImage.Draw(BarStart.XPos - ScrollTotal.XPos, BarStart.YPos - ScrollTotal.YPos, 1.f); - ThemeX.BarEndImage.Draw(BarEnd.XPos - ScrollTotal.XPos, BarEnd.YPos - ScrollTotal.YPos, 1.f); - for (INTN i = 0; i < Scrollbar.Height; i += ThemeX.ScrollbarImage.GetHeight()) { - ThemeX.ScrollbarImage.Draw(Scrollbar.XPos - ScrollTotal.XPos, Scrollbar.YPos + i - ScrollTotal.YPos, 1.f); - } - ThemeX.UpButtonImage.Draw(UpButton.XPos - ScrollTotal.XPos, UpButton.YPos - ScrollTotal.YPos, 1.f); - ThemeX.DownButtonImage.Draw(DownButton.XPos - ScrollTotal.XPos, DownButton.YPos - ScrollTotal.YPos, 1.f); - ThemeX.ScrollStartImage.Draw(ScrollStart.XPos - ScrollTotal.XPos, ScrollStart.YPos - ScrollTotal.YPos, 1.f); - ThemeX.ScrollEndImage.Draw(ScrollEnd.XPos - ScrollTotal.XPos, ScrollEnd.YPos - ScrollTotal.YPos, 1.f); -#endif } -#else -VOID REFIT_MENU_SCREEN::ScrollingBar() -{ - EG_IMAGE* Total; -// INTN i; - - ScrollEnabled = (ScrollState.MaxFirstVisible != 0); - if (ScrollEnabled) { - Total = egCreateFilledImage(ScrollTotal.Width, ScrollTotal.Height, TRUE, &MenuBackgroundPixel); - - if (ScrollbarBackgroundImage && ScrollbarBackgroundImage->Height) { - for (INTN i = 0; i < ScrollbarBackground.Height; i+=ScrollbarBackgroundImage->Height) { - egComposeImage(Total, ScrollbarBackgroundImage, ScrollbarBackground.XPos - ScrollTotal.XPos, ScrollbarBackground.YPos + i - ScrollTotal.YPos); - } - } - - egComposeImage(Total, BarStartImage, BarStart.XPos - ScrollTotal.XPos, BarStart.YPos - ScrollTotal.YPos); - egComposeImage(Total, BarEndImage, BarEnd.XPos - ScrollTotal.XPos, BarEnd.YPos - ScrollTotal.YPos); - - if (ScrollbarImage && ScrollbarImage->Height) { - for (INTN i = 0; i < Scrollbar.Height; i+=ScrollbarImage->Height) { - egComposeImage(Total, ScrollbarImage, Scrollbar.XPos - ScrollTotal.XPos, Scrollbar.YPos + i - ScrollTotal.YPos); - } - } - - egComposeImage(Total, UpButtonImage, UpButton.XPos - ScrollTotal.XPos, UpButton.YPos - ScrollTotal.YPos); - egComposeImage(Total, DownButtonImage, DownButton.XPos - ScrollTotal.XPos, DownButton.YPos - ScrollTotal.YPos); - egComposeImage(Total, ScrollStartImage, ScrollStart.XPos - ScrollTotal.XPos, ScrollStart.YPos - ScrollTotal.YPos); - egComposeImage(Total, ScrollEndImage, ScrollEnd.XPos - ScrollTotal.XPos, ScrollEnd.YPos - ScrollTotal.YPos); - - BltImageAlpha(Total, ScrollTotal.XPos, ScrollTotal.YPos, &MenuBackgroundPixel, ScrollWidth); - egFreeImage(Total); - } -} -#endif /** * Graphical menu. */ -#if USE_XTHEME VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText) { INTN Chosen = 0; @@ -2083,369 +1839,10 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa MouseBirth(); } -#else - - -VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText) -{ - INTN i; - INTN j = 0; - INTN ItemWidth = 0; - INTN X, t1, t2; - INTN VisibleHeight = 0; //assume vertical layout - CHAR16 ResultString[TITLE_MAX_LEN]; // assume a title max length of around 128 - INTN PlaceCentre = 0; //(TextHeight / 2) - 7; - INTN PlaceCentre1 = 0; - UINTN OldChosenItem = ~(UINTN)0; - INTN TitleLen = 0; - INTN ScaledWidth = (INTN)(GlobalConfig.CharWidth * GlobalConfig.Scale); -// clovy - INTN ctrlX, ctrlY, ctrlTextX; - - HidePointer(); - - switch (Function) { - - case MENU_FUNCTION_INIT: - egGetScreenSize(&UGAWidth, &UGAHeight); - InitAnime(); - SwitchToGraphicsAndClear(); - - EntriesPosY = ((UGAHeight - (int)(LAYOUT_TOTAL_HEIGHT * GlobalConfig.Scale)) >> 1) + (int)(LayoutBannerOffset * GlobalConfig.Scale) + (TextHeight << 1); - - VisibleHeight = ((UGAHeight - EntriesPosY) / TextHeight) - InfoLines.size() - 2;/* - GlobalConfig.PruneScrollRows; */ - //DBG("MENU_FUNCTION_INIT 1 EntriesPosY=%d VisibleHeight=%d\n", EntriesPosY, VisibleHeight); - if ( Entries[0].getREFIT_INPUT_DIALOG() ) { - REFIT_INPUT_DIALOG& entry = (REFIT_INPUT_DIALOG&)Entries[0]; - if (entry.getREFIT_MENU_SWITCH()) { - if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 3) { - j = (OldChosenTheme == 0xFFFF) ? 0: (OldChosenTheme + 1); - } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 90) { - j = OldChosenConfig; - } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 116) { - j = (OldChosenDsdt == 0xFFFF) ? 0: (OldChosenDsdt + 1); - } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 119) { - j = OldChosenAudio; - } - } - } - InitScroll(Entries.size(), Entries.size(), VisibleHeight, j); - // determine width of the menu - not working - //MenuWidth = 80; // minimum - MenuWidth = (int)(LAYOUT_TEXT_WIDTH * GlobalConfig.Scale); //500 - DrawMenuText(NULL, 0, 0, 0, 0); - - if (TitleImage) { - if (MenuWidth > (INTN)(UGAWidth - (int)(TITLEICON_SPACING * GlobalConfig.Scale) - TitleImage->Width)) { - MenuWidth = UGAWidth - (int)(TITLEICON_SPACING * GlobalConfig.Scale) - TitleImage->Width - 2; - } - EntriesPosX = (UGAWidth - (TitleImage->Width + (int)(TITLEICON_SPACING * GlobalConfig.Scale) + MenuWidth)) >> 1; - //DBG("UGAWIdth=%d TitleImage=%d MenuWidth=%d\n", UGAWidth, - //TitleImage->Width, MenuWidth); - MenuWidth += TitleImage->Width; - } else { - EntriesPosX = (UGAWidth - MenuWidth) >> 1; - } - TimeoutPosY = EntriesPosY + (Entries.size() + 1) * TextHeight; - - // initial painting - egMeasureText(Title, &ItemWidth, NULL); - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE)) { - DrawTextXY(Title, (UGAWidth >> 1), EntriesPosY - TextHeight * 2, X_IS_CENTER); - } - - if (TitleImage) { - INTN FilmXPos = (INTN)(EntriesPosX - (TitleImage->Width + (int)(TITLEICON_SPACING * GlobalConfig.Scale))); - INTN FilmYPos = (INTN)EntriesPosY; - BltImageAlpha(TitleImage, FilmXPos, FilmYPos, &MenuBackgroundPixel, 16); - - // update FilmPlace only if not set by InitAnime - if (FilmPlace.Width == 0 || FilmPlace.Height == 0) { - FilmPlace.XPos = FilmXPos; - FilmPlace.YPos = FilmYPos; - FilmPlace.Width = TitleImage->Width; - FilmPlace.Height = TitleImage->Height; - } - } - - if (InfoLines.size() > 0) { - DrawMenuText(NULL, 0, 0, 0, 0); - for (i = 0; i < (INTN)InfoLines.size(); i++) { - DrawMenuText(InfoLines[i], 0, EntriesPosX, EntriesPosY, 0xFFFF); - EntriesPosY += TextHeight; - } - EntriesPosY += TextHeight; // also add a blank line - } - InitBar(); - - break; - - case MENU_FUNCTION_CLEANUP: - HidePointer(); - break; - - case MENU_FUNCTION_PAINT_ALL: - DrawMenuText(NULL, 0, 0, 0, 0); //should clean every line to avoid artefacts - // DBG("PAINT_ALL: EntriesPosY=%d MaxVisible=%d\n", EntriesPosY, ScrollState.MaxVisible); - // DBG("DownButton.Height=%d TextHeight=%d\n", DownButton.Height, TextHeight); - t2 = EntriesPosY + (ScrollState.MaxVisible + 1) * TextHeight - DownButton.Height; - t1 = EntriesPosX + TextHeight + MenuWidth + (INTN)((TEXT_XMARGIN + 16) * GlobalConfig.Scale); - // DBG("PAINT_ALL: %d %d\n", t1, t2); - SetBar(t1, EntriesPosY, t2, &ScrollState); //823 302 554 - - // blackosx swapped this around so drawing of selection comes before drawing scrollbar. - - for (i = ScrollState.FirstVisible, j = 0; i <= ScrollState.LastVisible; i++, j++) { - REFIT_ABSTRACT_MENU_ENTRY *Entry = &Entries[i]; - TitleLen = StrLen(Entry->Title); - - Entry->Place.XPos = EntriesPosX; - Entry->Place.YPos = EntriesPosY + j * TextHeight; - Entry->Place.Width = TitleLen * ScaledWidth; - Entry->Place.Height = (UINTN)TextHeight; - StrCpyS(ResultString, TITLE_MAX_LEN, Entry->Title); - //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2; - //clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0; - //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2; - PlaceCentre = (INTN)((TextHeight - (INTN)(Buttons[2]->Height)) * GlobalConfig.Scale / 2); - PlaceCentre1 = (INTN)((TextHeight - (INTN)(Buttons[0]->Height)) * GlobalConfig.Scale / 2); -// clovy - ctrlX = EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale); - if (GlobalConfig.TypeSVG) - ctrlX = EntriesPosX; - ctrlTextX = ctrlX + Buttons[0]->Width + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale / 2); - ctrlY = Entry->Place.YPos + PlaceCentre; - - if ( Entry->getREFIT_INPUT_DIALOG() ) { - REFIT_INPUT_DIALOG* inputDialogEntry = Entry->getREFIT_INPUT_DIALOG(); - if (inputDialogEntry->Item->ItemType == BoolValue) { - Entry->Place.Width = StrLen(ResultString) * ScaledWidth; - DrawMenuText(L" ", 0, EntriesPosX, Entry->Place.YPos, 0xFFFF); - DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? (MenuWidth) : 0, -// clovy EntriesPosX + (TextHeight + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale)), - ctrlTextX, - Entry->Place.YPos, 0xFFFF); - BltImageAlpha( (((REFIT_INPUT_DIALOG*)(Entry))->Item->BValue) ? Buttons[3] :Buttons[2], - ctrlX, ctrlY, - &MenuBackgroundPixel, 16); -// DBG("X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale), -// Entry->Place.YPos, Entry->Place.YPos + PlaceCentre); - - } else { - // text input - StrCatS(ResultString, TITLE_MAX_LEN, ((REFIT_INPUT_DIALOG*)(Entry))->Item->SValue); - StrCatS(ResultString, TITLE_MAX_LEN, L" "); - Entry->Place.Width = StrLen(ResultString) * ScaledWidth; - // Slice - suppose to use Row as Cursor in text - DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? MenuWidth : 0, - EntriesPosX, - Entry->Place.YPos, TitleLen + Entry->Row); - } - } else if (Entry->getREFIT_MENU_CHECKBIT()) { - DrawMenuText(L" ", 0, EntriesPosX, Entry->Place.YPos, 0xFFFF); - DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? (MenuWidth) : 0, -// clovy EntriesPosX + (TextHeight + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale)), - ctrlTextX, - Entry->Place.YPos, 0xFFFF); - BltImageAlpha((((REFIT_INPUT_DIALOG*)(Entry))->Item->IValue & Entry->Row) ? Buttons[3] :Buttons[2], - ctrlX, - ctrlY, - &MenuBackgroundPixel, 16); - - } else if (Entry->getREFIT_MENU_SWITCH()) { - if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 3) { - //OldChosenItem = OldChosenTheme; - OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: (OldChosenTheme + 1); - } else if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 90) { - OldChosenItem = OldChosenConfig; - } else if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 116) { - OldChosenItem = (OldChosenDsdt == 0xFFFF) ? 0: (OldChosenDsdt + 1); - } else if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 119) { - OldChosenItem = OldChosenAudio; - } - - DrawMenuText(ResultString, - (i == ScrollState.CurrentSelection) ? MenuWidth : 0, -// clovy EntriesPosX + (TextHeight + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale)), - ctrlTextX, - Entry->Place.YPos, 0xFFFF); - BltImageAlpha((Entry->Row == OldChosenItem) ? Buttons[1] : Buttons[0], - ctrlX, - ctrlY, - &MenuBackgroundPixel, 16); - } else { - //DBG("paint entry %d title=%ls\n", i, Entries[i]->Title); - DrawMenuText(ResultString, - (i == ScrollState.CurrentSelection) ? MenuWidth : 0, - EntriesPosX, Entry->Place.YPos, 0xFFFF); - } - } - - ScrollingBar(); //&ScrollState - inside the class - //MouseBirth(); - break; - - case MENU_FUNCTION_PAINT_SELECTION: - { - // last selection - REFIT_ABSTRACT_MENU_ENTRY *EntryL = &Entries[ScrollState.LastSelection]; - REFIT_ABSTRACT_MENU_ENTRY *EntryC = &Entries[ScrollState.CurrentSelection]; - TitleLen = StrLen(EntryL->Title); - StrCpyS(ResultString, TITLE_MAX_LEN, EntryL->Title); - //clovy//PlaceCentre = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2; - //clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0; - //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2; - PlaceCentre = (INTN)((TextHeight - (INTN)(Buttons[2]->Height)) * GlobalConfig.Scale / 2); - PlaceCentre1 = (INTN)((TextHeight - (INTN)(Buttons[0]->Height)) * GlobalConfig.Scale / 2); - -// clovy - ctrlX = EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale); - if (GlobalConfig.TypeSVG) - ctrlX = EntriesPosX; - ctrlTextX = ctrlX + Buttons[0]->Width + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale / 2); - - // redraw selection cursor - // 1. blackosx swapped this around so drawing of selection comes before drawing scrollbar. - // 2. usr-sse2 - if ( EntryL->getREFIT_INPUT_DIALOG() ) { - REFIT_INPUT_DIALOG* inputDialogEntry = (REFIT_INPUT_DIALOG*)EntryL; - if (inputDialogEntry->Item->ItemType == BoolValue) { - //clovy//DrawMenuText(ResultString, 0, EntriesPosX + (TextHeight + TEXT_XMARGIN), - //clovy// EntryL->Place.YPos, 0xFFFF); - DrawMenuText(ResultString, 0, - ctrlTextX, - EntryL->Place.YPos, 0xFFFF); - BltImageAlpha((inputDialogEntry->Item->BValue)? Buttons[3] : Buttons[2], - ctrlX, - EntryL->Place.YPos + PlaceCentre, - &MenuBackgroundPixel, 16); -// DBG("se:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale), -// EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre); - } else { - StrCatS(ResultString, TITLE_MAX_LEN, ((REFIT_INPUT_DIALOG*)(EntryL))->Item->SValue + - ((REFIT_INPUT_DIALOG*)(EntryL))->Item->LineShift); - StrCatS(ResultString, TITLE_MAX_LEN, L" "); - DrawMenuText(ResultString, 0, EntriesPosX, - EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, - TitleLen + EntryL->Row); - } - } else if (EntryL->getREFIT_MENU_SWITCH()) { - - if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 3) { - OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1; - } else if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 90) { - OldChosenItem = OldChosenConfig; - } else if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 116) { - OldChosenItem = (OldChosenDsdt == 0xFFFF) ? 0: OldChosenDsdt + 1; - } else if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 119) { - OldChosenItem = OldChosenAudio; - } - -// clovy -// DrawMenuText(ResultString, 0, EntriesPosX + (TextHeight + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale)), -// EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF); - DrawMenuText(ResultString, 0, ctrlTextX, - EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF); - BltImageAlpha((EntryL->Row == OldChosenItem) ? Buttons[1] : Buttons[0], - ctrlX, - EntryL->Place.YPos + PlaceCentre1, - &MenuBackgroundPixel, 16); - } else if (EntryL->getREFIT_MENU_CHECKBIT()) { -// clovy -// DrawMenuText(ResultString, 0, EntriesPosX + (TextHeight + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale)), -// EntryL->Place.YPos, 0xFFFF); - DrawMenuText(ResultString, 0, ctrlTextX, - EntryL->Place.YPos, 0xFFFF); - BltImageAlpha((EntryL->getREFIT_MENU_CHECKBIT()->Item->IValue & EntryL->Row) ? Buttons[3] : Buttons[2], - ctrlX, - EntryL->Place.YPos + PlaceCentre, - &MenuBackgroundPixel, 16); -// DBG("ce:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale), -// EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre); - } else { - DrawMenuText(EntryL->Title, 0, EntriesPosX, - EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF); - } - - // current selection - StrCpyS(ResultString, TITLE_MAX_LEN, EntryC->Title); - TitleLen = StrLen(EntryC->Title); - if ( EntryC->getREFIT_MENU_SWITCH() ) { - if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) { - OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1;; - } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 90) { - OldChosenItem = OldChosenConfig; - } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 116) { - OldChosenItem = (OldChosenDsdt == 0xFFFF) ? 0: OldChosenDsdt + 1; - } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 119) { - OldChosenItem = OldChosenAudio; - } - } - - if ( EntryC->getREFIT_INPUT_DIALOG() ) { - REFIT_INPUT_DIALOG* inputDialogEntry = (REFIT_INPUT_DIALOG*)EntryC; - if (inputDialogEntry->Item->ItemType == BoolValue) { - DrawMenuText(ResultString, MenuWidth, - ctrlTextX, - inputDialogEntry->Place.YPos, 0xFFFF); - BltImageAlpha((inputDialogEntry->Item->BValue)? Buttons[3] : Buttons[2], - ctrlX, - inputDialogEntry->Place.YPos + PlaceCentre, - &MenuBackgroundPixel, 16); - } else { - StrCatS(ResultString, TITLE_MAX_LEN, inputDialogEntry->Item->SValue + - inputDialogEntry->Item->LineShift); - StrCatS(ResultString, TITLE_MAX_LEN, L" "); - DrawMenuText(ResultString, MenuWidth, EntriesPosX, - EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight, - TitleLen + inputDialogEntry->Row); - } - } else if (EntryC->getREFIT_MENU_SWITCH()) { - StrCpyS(ResultString, TITLE_MAX_LEN, EntryC->Title); - DrawMenuText(ResultString, MenuWidth, - ctrlTextX, - EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight, - 0xFFFF); - BltImageAlpha((EntryC->Row == OldChosenItem) ? Buttons[1]:Buttons[0], - ctrlX, - EntryC->Place.YPos + PlaceCentre1, - &MenuBackgroundPixel, 16); - } else if (EntryC->getREFIT_MENU_CHECKBIT()) { - DrawMenuText(ResultString, MenuWidth, - ctrlTextX, - EntryC->Place.YPos, 0xFFFF); - BltImageAlpha((EntryC->getREFIT_MENU_CHECKBIT()->Item->IValue & EntryC->Row) ? Buttons[3] :Buttons[2], - ctrlX, - EntryC->Place.YPos + PlaceCentre, - &MenuBackgroundPixel, 16); - }else{ - DrawMenuText(EntryC->Title, MenuWidth, EntriesPosX, - EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight, - 0xFFFF); - } - - ScrollStart.YPos = ScrollbarBackground.YPos + ScrollbarBackground.Height * ScrollState.FirstVisible / (ScrollState.MaxIndex + 1); - Scrollbar.YPos = ScrollStart.YPos + ScrollStart.Height; - ScrollEnd.YPos = Scrollbar.YPos + Scrollbar.Height; // ScrollEnd.Height is already subtracted - ScrollingBar(); //&ScrollState); - - break; - } - - case MENU_FUNCTION_PAINT_TIMEOUT: //ever be here? - X = (UGAWidth - StrLen(ParamText) * ScaledWidth) >> 1; - DrawMenuText(ParamText, 0, X, TimeoutPosY, 0xFFFF); - break; - } - - MouseBirth(); -} -#endif /** * Draw entries for GUI. */ -#if USE_XTHEME VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos) { INTN TextWidth = 0; @@ -2484,45 +1881,6 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos, OldTextWidth = TextWidth; OldRow = Entries[ScrollState.CurrentSelection].Row; } -#else -VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos) -{ - INTN TextWidth; - INTN BadgeDim = (INTN)(BADGE_DIMENSION * GlobalConfig.Scale); - - egMeasureText(Text, &TextWidth, NULL); - - //Clear old text - if (OldTextWidth > TextWidth) { - FillRectAreaOfScreen(OldX, OldY, OldTextWidth, TextHeight, &MenuBackgroundPixel, X_IS_CENTER); - } - - if (!(GlobalConfig.BootCampStyle) - && (GlobalConfig.HideBadges & HDBADGES_INLINE) && (!OldRow) - && (OldTextWidth) && (OldTextWidth != TextWidth)) { - //Clear badge - BltImageAlpha(NULL, (OldX - (OldTextWidth >> 1) - (BadgeDim + 16)), - (OldY - ((BadgeDim - TextHeight) >> 1)), &MenuBackgroundPixel, BadgeDim >> 3); - } - DrawTextXY(Text, XPos, YPos, X_IS_CENTER); - - //show inline badge - if (!(GlobalConfig.BootCampStyle) && - (GlobalConfig.HideBadges & HDBADGES_INLINE) && - (Entries[ScrollState.CurrentSelection].Row == 0)) { - // Display Inline Badge: small icon before the text - BltImageAlpha(Entries[ScrollState.CurrentSelection].Image, - (XPos - (TextWidth >> 1) - (BadgeDim + 16)), - (YPos - ((BadgeDim - TextHeight) >> 1)), &MenuBackgroundPixel, BadgeDim >> 3); - } - - OldX = XPos; - OldY = YPos; - OldTextWidth = TextWidth; - OldRow = Entries[ScrollState.CurrentSelection].Row; -} -#endif - VOID REFIT_MENU_SCREEN::CountItems() { @@ -2542,7 +1900,6 @@ VOID REFIT_MENU_SCREEN::CountItems() } } -#if USE_XTHEME VOID REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align) { INTN Xpos; @@ -2602,13 +1959,6 @@ VOID REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align) // clovy DrawTextXY(Text, Xpos, UGAHeight - 5 - TextHeight, Align); DrawTextXY(Text, Xpos, UGAHeight - (INTN)(ThemeX.TextHeight * 1.5f), Align); } -#else - -#endif - - - -#if USE_XTHEME VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos) { @@ -2880,162 +2230,10 @@ VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 } } -#else -VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 *ParamText) -{ - INTN i; - INTN row0PosYRunning; - INTN VisibleHeight = 0; //assume vertical layout - INTN MessageHeight = 20; - - if (GlobalConfig.TypeSVG && textFace[1].valid) { - MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * GlobalConfig.Scale); - } else { - MessageHeight = (INTN)(TextHeight * RowHeightFromTextHeight * GlobalConfig.Scale); - } - - - switch (Function) { - - case MENU_FUNCTION_INIT: - egGetScreenSize(&UGAWidth, &UGAHeight); - InitAnime(); - SwitchToGraphicsAndClear(); - //BltClearScreen(FALSE); - //adjustable by theme.plist? - EntriesPosY = (int)(LAYOUT_Y_EDGE * GlobalConfig.Scale); - EntriesGap = (int)(GlobalConfig.TileYSpace * GlobalConfig.Scale); - EntriesWidth = GlobalConfig.MainEntriesSize + (int)(16 * GlobalConfig.Scale); - EntriesHeight = GlobalConfig.MainEntriesSize + (int)(16 * GlobalConfig.Scale); - // - VisibleHeight = (UGAHeight - EntriesPosY - (int)(LAYOUT_Y_EDGE * GlobalConfig.Scale) + EntriesGap) / (EntriesHeight + EntriesGap); - EntriesPosX = UGAWidth - EntriesWidth - (int)((BAR_WIDTH + LAYOUT_X_EDGE) * GlobalConfig.Scale); - TimeoutPosY = UGAHeight - (int)(LAYOUT_Y_EDGE * GlobalConfig.Scale) - MessageHeight * 2; //optimus + timeout texts - - CountItems(); - InitScroll(row0Count, Entries.size(), VisibleHeight, 0); - row0PosX = EntriesPosX; - row0PosY = EntriesPosY; - row1PosX = (UGAWidth + EntriesGap - (row1TileSize + (int)(TILE1_XSPACING * GlobalConfig.Scale)) * row1Count) >> 1; - textPosY = TimeoutPosY - (int)(GlobalConfig.TileYSpace * GlobalConfig.Scale) - MessageHeight; //message text - row1PosY = textPosY - row1TileSize - (int)(GlobalConfig.TileYSpace * GlobalConfig.Scale) - LayoutTextOffset; - if (!itemPosX) { - itemPosX = (__typeof__(itemPosX))AllocatePool(sizeof(UINT64) * Entries.size()); - itemPosY = (__typeof__(itemPosY))AllocatePool(sizeof(UINT64) * Entries.size()); - } - row0PosYRunning = row0PosY; - row1PosXRunning = row1PosX; - - // DBG("EntryCount =%d\n", Entries.size()); - for (i = 0; i < (INTN)Entries.size(); i++) { - if (Entries[i].Row == 0) { - itemPosX[i] = row0PosX; - itemPosY[i] = row0PosYRunning; - row0PosYRunning += EntriesHeight + EntriesGap; - } else { - itemPosX[i] = row1PosXRunning; - itemPosY[i] = row1PosY; - row1PosXRunning += row1TileSize + (int)(TILE1_XSPACING* GlobalConfig.Scale); - // DBG("next item in row1 at x=%d\n", row1PosXRunning); - } - } - // initial painting - InitSelection(); - - // Update FilmPlace only if not set by InitAnime - if (FilmPlace.Width == 0 || FilmPlace.Height == 0) { - // CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace)); - FilmPlace = BannerPlace; - } - - InitBar(); - break; - - case MENU_FUNCTION_CLEANUP: - FreePool(itemPosX); - itemPosX = NULL; - FreePool(itemPosY); - itemPosY = NULL; - HidePointer(); - break; - - case MENU_FUNCTION_PAINT_ALL: - SetBar(EntriesPosX + EntriesWidth + (int)(10 * GlobalConfig.Scale), - EntriesPosY, UGAHeight - (int)(LAYOUT_Y_EDGE * GlobalConfig.Scale), &ScrollState); - for (i = 0; i <= ScrollState.MaxIndex; i++) { - if (Entries[i].Row == 0) { - if ((i >= ScrollState.FirstVisible) && (i <= ScrollState.LastVisible)) { - DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0, - itemPosX[i - ScrollState.FirstVisible], itemPosY[i - ScrollState.FirstVisible]); - } - } else { //row1 - DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0, - itemPosX[i], itemPosY[i]); - } - } - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)){ - DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title, - (UGAWidth >> 1), textPosY); - } - - ScrollingBar(); //&ScrollState); - DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT); - DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER); - MouseBirth(); - break; - - case MENU_FUNCTION_PAINT_SELECTION: - HidePointer(); - if (Entries[ScrollState.LastSelection].Row == 0) { - DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE, - itemPosX[ScrollState.LastSelection - ScrollState.FirstVisible], - itemPosY[ScrollState.LastSelection - ScrollState.FirstVisible]); - } else { - DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE, - itemPosX[ScrollState.LastSelection], - itemPosY[ScrollState.LastSelection]); - } - - if (Entries[ScrollState.CurrentSelection].Row == 0) { - DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE, - itemPosX[ScrollState.CurrentSelection - ScrollState.FirstVisible], - itemPosY[ScrollState.CurrentSelection - ScrollState.FirstVisible]); - } else { - DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE, - itemPosX[ScrollState.CurrentSelection], - itemPosY[ScrollState.CurrentSelection]); - } - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title, - (UGAWidth >> 1), textPosY); - } - - ScrollingBar(); //&ScrollState); - DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT); - DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER); - MouseBirth(); - break; - - case MENU_FUNCTION_PAINT_TIMEOUT: - i = (GlobalConfig.HideBadges & HDBADGES_INLINE)?3:1; - HidePointer(); - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)){ - FillRectAreaOfScreen((UGAWidth >> 1), textPosY + MessageHeight * i, - OldTimeoutTextWidth, TextHeight, &MenuBackgroundPixel, X_IS_CENTER); - OldTimeoutTextWidth = DrawTextXY(ParamText, (UGAWidth >> 1), textPosY + MessageHeight * i, X_IS_CENTER); - } - - DrawTextCorner(TEXT_CORNER_REVISION, X_IS_LEFT); - break; - - } -} -#endif /** * Main screen text. */ -#if USE_XTHEME VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText) { EFI_STATUS Status = EFI_SUCCESS; @@ -3243,215 +2441,6 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT } } -#else -VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText) -{ - EFI_STATUS Status = EFI_SUCCESS; - INTN i = 0; - INTN MessageHeight = 0; - // clovy - if (GlobalConfig.TypeSVG && textFace[1].valid) { - MessageHeight = (INTN)(textFace[1].size * RowHeightFromTextHeight * GlobalConfig.Scale); - } else { - MessageHeight = (INTN)(TextHeight * RowHeightFromTextHeight * GlobalConfig.Scale); - } - - switch (Function) { - - case MENU_FUNCTION_INIT: - egGetScreenSize(&UGAWidth, &UGAHeight); - InitAnime(); - SwitchToGraphicsAndClear(); - //BltClearScreen(FALSE); - - EntriesGap = (int)(GlobalConfig.TileXSpace * GlobalConfig.Scale); - EntriesWidth = row0TileSize; - EntriesHeight = GlobalConfig.MainEntriesSize + (int)(16.f * GlobalConfig.Scale); - - MaxItemOnScreen = (UGAWidth - (int)((ROW0_SCROLLSIZE * 2)* GlobalConfig.Scale)) / (EntriesWidth + EntriesGap); //8 - CountItems(); - InitScroll(row0Count, Entries.size(), MaxItemOnScreen, 0); - - row0PosX = EntriesWidth + EntriesGap; - row0PosX = row0PosX * ((MaxItemOnScreen < row0Count)?MaxItemOnScreen:row0Count); - row0PosX = row0PosX - EntriesGap; - row0PosX = UGAWidth - row0PosX; - row0PosX = row0PosX >> 1; - - row0PosY = (int)(((float)UGAHeight - LayoutMainMenuHeight * GlobalConfig.Scale) * 0.5f + - LayoutBannerOffset * GlobalConfig.Scale); - - row1PosX = (UGAWidth + 8 - (row1TileSize + (INTN)(8.0f * GlobalConfig.Scale)) * row1Count) >> 1; - - if (GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - row1PosY = row0PosY + row0TileSize + (INTN)((BCSMargin * 2) * GlobalConfig.Scale) + TextHeight + - (INTN)(INDICATOR_SIZE * GlobalConfig.Scale) + - (INTN)((LayoutButtonOffset + GlobalConfig.TileYSpace) * GlobalConfig.Scale); - } else { - row1PosY = row0PosY + EntriesHeight + - (INTN)((GlobalConfig.TileYSpace + LayoutButtonOffset) * GlobalConfig.Scale); - } - - if (row1Count > 0) { - textPosY = row1PosY + MAX(row1TileSize, MessageHeight) + (INTN)((GlobalConfig.TileYSpace + LayoutTextOffset) * GlobalConfig.Scale); - } else { - textPosY = row1PosY; - } - - if (GlobalConfig.BootCampStyle) { - textPosY = row0PosY + row0TileSize + (INTN)((TEXT_YMARGIN + BCSMargin) * GlobalConfig.Scale); - } - - FunctextPosY = row1PosY + row1TileSize + (INTN)((GlobalConfig.TileYSpace + LayoutTextOffset) * GlobalConfig.Scale); - - if (!itemPosX) { - itemPosX = (__typeof__(itemPosX))AllocatePool(sizeof(UINT64) * Entries.size()); - } - - row0PosXRunning = row0PosX; - row1PosXRunning = row1PosX; - //DBG("EntryCount =%d\n", Entries.size()); - for (i = 0; i < (INTN)Entries.size(); i++) { - if (Entries[i].Row == 0) { - itemPosX[i] = row0PosXRunning; - row0PosXRunning += EntriesWidth + EntriesGap; - } else { - itemPosX[i] = row1PosXRunning; - row1PosXRunning += row1TileSize + (INTN)(TILE1_XSPACING * GlobalConfig.Scale); - //DBG("next item in row1 at x=%d\n", row1PosXRunning); - } - } - // initial painting - InitSelection(); - - // Update FilmPlace only if not set by InitAnime - if (FilmPlace.Width == 0 || FilmPlace.Height == 0) { - CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace)); - } - - //DBG("main menu inited\n"); - break; - - case MENU_FUNCTION_CLEANUP: - FreePool(itemPosX); - itemPosX = NULL; - HidePointer(); - break; - - case MENU_FUNCTION_PAINT_ALL: - - for (i = 0; i <= ScrollState.MaxIndex; i++) { - if (Entries[i].Row == 0) { - if ((i >= ScrollState.FirstVisible) && (i <= ScrollState.LastVisible)) { - DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0, - itemPosX[i - ScrollState.FirstVisible], row0PosY); - // draw static text for the boot options, BootCampStyle - if (GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - INTN textPosX = itemPosX[i - ScrollState.FirstVisible] + (row0TileSize / 2); - FillRectAreaOfScreen(textPosX, textPosY, EntriesWidth + GlobalConfig.TileXSpace, - MessageHeight, &MenuBackgroundPixel, X_IS_CENTER); - // draw the text - DrawBCSText(Entries[i].Title.data(), textPosX, textPosY, X_IS_CENTER); - } - } - } else { - DrawMainMenuEntry(&Entries[i], (i == ScrollState.CurrentSelection)?1:0, - itemPosX[i], row1PosY); - } - } - // clear the text from the second row, required by the BootCampStyle - if ((GlobalConfig.BootCampStyle) && (Entries[ScrollState.LastSelection].Row == 1) - && (Entries[ScrollState.CurrentSelection].Row == 0) && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - FillRectAreaOfScreen((UGAWidth >> 1), FunctextPosY, - // clovy - OldTextWidth, MessageHeight, &MenuBackgroundPixel, X_IS_CENTER); - } - - if ((Entries[ScrollState.LastSelection].Row == 0) && (Entries[ScrollState.CurrentSelection].Row == 1) - && GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title, - (UGAWidth >> 1), FunctextPosY); - } - - // something is wrong with the DrawMainMenuLabel or Entries[ScrollState.CurrentSelection] - // and it's required to create the first selection text from here - // used for all the entries - if (!(GlobalConfig.BootCampStyle) && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title, - (UGAWidth >> 1), textPosY); - } - - DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT); - DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER); - DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT); - Status = MouseBirth(); - if(EFI_ERROR(Status)) { - DBG("can't bear mouse at all! Status=%s\n", strerror(Status)); - } - break; - - case MENU_FUNCTION_PAINT_SELECTION: - HidePointer(); - if (Entries[ScrollState.LastSelection].Row == 0) { - DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE, - itemPosX[ScrollState.LastSelection - ScrollState.FirstVisible], row0PosY); - } else { - DrawMainMenuEntry(&Entries[ScrollState.LastSelection], FALSE, - itemPosX[ScrollState.LastSelection], row1PosY); - } - - if (Entries[ScrollState.CurrentSelection].Row == 0) { - DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE, - itemPosX[ScrollState.CurrentSelection - ScrollState.FirstVisible], row0PosY); - } else { - DrawMainMenuEntry(&Entries[ScrollState.CurrentSelection], TRUE, - itemPosX[ScrollState.CurrentSelection], row1PosY); - } - - // create dynamic text for the second row if BootCampStyle is used - if ((GlobalConfig.BootCampStyle) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) - && Entries[ScrollState.CurrentSelection].Row == 1) { - DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title, - (UGAWidth >> 1), FunctextPosY); - } - - // create dynamic text for all the entries - if ((!(GlobalConfig.BootCampStyle)) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL))) { - DrawMainMenuLabel(Entries[ScrollState.CurrentSelection].Title, - (UGAWidth >> 1), textPosY); - } - - DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT); - DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER); - DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT); - Status = MouseBirth(); - if(EFI_ERROR(Status)) { - DBG("can't bear mouse at sel! Status=%s\n", strerror(Status)); - } - break; - - case MENU_FUNCTION_PAINT_TIMEOUT: - i = (GlobalConfig.HideBadges & HDBADGES_INLINE)?3:1; - HidePointer(); - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)){ - FillRectAreaOfScreen((UGAWidth >> 1), FunctextPosY + MessageHeight * i, - OldTimeoutTextWidth, MessageHeight, &MenuBackgroundPixel, X_IS_CENTER); - OldTimeoutTextWidth = DrawTextXY(ParamText, (UGAWidth >> 1), FunctextPosY + MessageHeight * i, X_IS_CENTER); - } - - DrawTextCorner(TEXT_CORNER_HELP, X_IS_LEFT); - DrawTextCorner(TEXT_CORNER_OPTIMUS, X_IS_CENTER); - DrawTextCorner(TEXT_CORNER_REVISION, X_IS_RIGHT); - Status = MouseBirth(); - if(EFI_ERROR(Status)) { - DBG("can't bear mouse at timeout! Status=%s\n", strerror(Status)); - } - break; - - } -} -#endif - // // user-callable dispatcher functions // @@ -3536,19 +2525,11 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC if (AllowGraphicsMode) { Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle; -#if USE_XTHEME if (ThemeX.VerticalLayout) { MainStyle = &REFIT_MENU_SCREEN::MainMenuVerticalStyle; } else { MainStyle = &REFIT_MENU_SCREEN::MainMenuStyle; } -#else - if (GlobalConfig.VerticalLayout) { - MainStyle = &REFIT_MENU_SCREEN::MainMenuVerticalStyle; - } else { - MainStyle = &REFIT_MENU_SCREEN::MainMenuStyle; - } -#endif } while (!MenuExit) { diff --git a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h index f4d2bf173..2ec1d8551 100644 --- a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h +++ b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h @@ -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 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(); diff --git a/rEFIt_UEFI/gui/menu_items/menu_items.h b/rEFIt_UEFI/gui/menu_items/menu_items.h index 54c8463f3..cd893f486 100644 --- a/rEFIt_UEFI/gui/menu_items/menu_items.h +++ b/rEFIt_UEFI/gui/menu_items/menu_items.h @@ -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; diff --git a/rEFIt_UEFI/libeg/VectorGraphics.cpp b/rEFIt_UEFI/libeg/VectorGraphics.cpp index 992aeb245..bbaf4b013 100755 --- a/rEFIt_UEFI/libeg/VectorGraphics.cpp +++ b/rEFIt_UEFI/libeg/VectorGraphics.cpp @@ -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"); } diff --git a/rEFIt_UEFI/libeg/VectorGraphics.h b/rEFIt_UEFI/libeg/VectorGraphics.h index ceee33eff..e0cf7c8de 100644 --- a/rEFIt_UEFI/libeg/VectorGraphics.h +++ b/rEFIt_UEFI/libeg/VectorGraphics.h @@ -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); diff --git a/rEFIt_UEFI/libeg/XImage.cpp b/rEFIt_UEFI/libeg/XImage.cpp index 5989273f1..a2de344dc 100644 --- a/rEFIt_UEFI/libeg/XImage.cpp +++ b/rEFIt_UEFI/libeg/XImage.cpp @@ -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; +} + diff --git a/rEFIt_UEFI/libeg/XPointer.cpp b/rEFIt_UEFI/libeg/XPointer.cpp index 21fc5b80f..c01961150 100644 --- a/rEFIt_UEFI/libeg/XPointer.cpp +++ b/rEFIt_UEFI/libeg/XPointer.cpp @@ -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; diff --git a/rEFIt_UEFI/libeg/XPointer.h b/rEFIt_UEFI/libeg/XPointer.h index 9427b505c..4a99073e4 100644 --- a/rEFIt_UEFI/libeg/XPointer.h +++ b/rEFIt_UEFI/libeg/XPointer.h @@ -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; } diff --git a/rEFIt_UEFI/libeg/XTheme.cpp b/rEFIt_UEFI/libeg/XTheme.cpp index d8652b3ab..d94a5460d 100644 --- a/rEFIt_UEFI/libeg/XTheme.cpp +++ b/rEFIt_UEFI/libeg/XTheme.cpp @@ -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 + diff --git a/rEFIt_UEFI/libeg/image.cpp b/rEFIt_UEFI/libeg/image.cpp index 36f6b3867..5bfd7239c 100644 --- a/rEFIt_UEFI/libeg/image.cpp +++ b/rEFIt_UEFI/libeg/image.cpp @@ -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; diff --git a/rEFIt_UEFI/libeg/libeg.h b/rEFIt_UEFI/libeg/libeg.h index 4221b5cad..183f99233 100755 --- a/rEFIt_UEFI/libeg/libeg.h +++ b/rEFIt_UEFI/libeg/libeg.h @@ -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 diff --git a/rEFIt_UEFI/libeg/libegint.h b/rEFIt_UEFI/libeg/libegint.h index dfe83bcce..448eb8a52 100644 --- a/rEFIt_UEFI/libeg/libegint.h +++ b/rEFIt_UEFI/libeg/libegint.h @@ -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__ */ diff --git a/rEFIt_UEFI/libeg/libscreen.cpp b/rEFIt_UEFI/libeg/libscreen.cpp index 73ea84274..f982ea3f3 100644 --- a/rEFIt_UEFI/libeg/libscreen.cpp +++ b/rEFIt_UEFI/libeg/libscreen.cpp @@ -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, diff --git a/rEFIt_UEFI/libeg/nanosvg.cpp b/rEFIt_UEFI/libeg/nanosvg.cpp index 9c79864ce..062824692 100644 --- a/rEFIt_UEFI/libeg/nanosvg.cpp +++ b/rEFIt_UEFI/libeg/nanosvg.cpp @@ -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); diff --git a/rEFIt_UEFI/libeg/text.cpp b/rEFIt_UEFI/libeg/text.cpp index 35ba90804..33e88325b 100644 --- a/rEFIt_UEFI/libeg/text.cpp +++ b/rEFIt_UEFI/libeg/text.cpp @@ -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 */ diff --git a/rEFIt_UEFI/refit/icns.cpp b/rEFIt_UEFI/refit/icns.cpp index 8c01941b9..ee1393d89 100644 --- a/rEFIt_UEFI/refit/icns.cpp +++ b/rEFIt_UEFI/refit/icns.cpp @@ -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 diff --git a/rEFIt_UEFI/refit/lib.cpp b/rEFIt_UEFI/refit/lib.cpp index 8383d80cc..2a11dedb3 100644 --- a/rEFIt_UEFI/refit/lib.cpp +++ b/rEFIt_UEFI/refit/lib.cpp @@ -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 // diff --git a/rEFIt_UEFI/refit/lib.h b/rEFIt_UEFI/refit/lib.h index 68ebdd4ed..8480459b2 100644 --- a/rEFIt_UEFI/refit/lib.h +++ b/rEFIt_UEFI/refit/lib.h @@ -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 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); diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 72373576c..9469b7c72 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -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 - } } diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 03bb29fea..26ac26f09 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -72,42 +72,15 @@ //#define LSTR(s) L##s -// scrolling definitions -//static INTN MaxItemOnScreen = -1; -//#if USE_XTHEME -//REFIT_MENU_SCREEN OptionMenu(4, L"Options"_XSW, L""_XSW); -//#else REFIT_MENU_SCREEN OptionMenu(4, L"Options"_XSW, L""_XSW); -//#endif -// -//extern REFIT_MENU_ITEM_RETURN MenuEntryReturn; -//extern UINTN ThemesNum; -//extern CONST CHAR16 *ThemesList[]; -//extern UINTN ConfigsNum; -//extern CHAR16 *ConfigsList[]; -//extern UINTN DsdtsNum; -//extern CHAR16 *DsdtsList[]; -//extern UINTN AudioNum; -//extern HDA_OUTPUTS AudioList[20]; extern CONST CHAR8 *AudioOutputNames[]; -//extern CHAR8 NonDetected[]; + #include "../Platform/string.h" -//extern BOOLEAN GetLegacyLanAddress; -//extern UINT8 gLanMac[4][6]; // their MAC addresses -//extern EFI_AUDIO_IO_PROTOCOL *AudioIo; -// -////layout must be in XTheme -//#if !USE_XTHEME -//INTN LayoutBannerOffset = 64; -//INTN LayoutButtonOffset = 0; -//INTN LayoutTextOffset = 0; + INTN LayoutMainMenuHeight = 376; INTN LayoutAnimMoveForMenuX = 0; -//#endif -// -//BOOLEAN SavePreBootLog = FALSE; // //#define SCROLL_LINE_UP (0) //#define SCROLL_LINE_DOWN (1) @@ -142,96 +115,6 @@ INTN LayoutAnimMoveForMenuX = 0; // //BOOLEAN MainAnime = FALSE; // -////TODO Scroll variables must be a part of REFIT_SCREEN -////BOOLEAN ScrollEnabled = FALSE; -//BOOLEAN IsDragging = FALSE; -//#if !USE_XTHEME -INTN ScrollWidth = 16; -//INTN ScrollButtonsHeight = 20; -//INTN ScrollBarDecorationsHeight = 5; -//INTN ScrollScrollDecorationsHeight = 7; -//#endif -//INTN ScrollbarYMovement; -// -// -////#define TextHeight (FONT_CELL_HEIGHT + TEXT_YMARGIN * 2) -// -//// clovy - set row height based on text size -//#define RowHeightFromTextHeight (1.35f) -// -////TODO spacing must be a part of layout in XTheme -//#define TITLEICON_SPACING (16) -////#define ROW0__TILESIZE (144) -////#define ROW1_TILESIZE (64) -//#define TILE1_XSPACING (8) -////#define TILE_YSPACING (24) -//#define ROW0_SCROLLSIZE (100) -// -////EG_IMAGE *SelectionImages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; -////EG_IMAGE *Buttons[4] = {NULL, NULL, NULL, NULL}; -#if !USE_XTHEME -static EG_IMAGE *TextBuffer = NULL; -#endif -// -////EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //non-trasparent -// -////INTN row0TileSize = 144; -////INTN row1TileSize = 64; -// -//static INTN row0Count, row0PosX, row0PosXRunning; -//static INTN row1Count, row1PosX, row1PosXRunning; -//static INTN *itemPosX = NULL; -//static INTN *itemPosY = NULL; -#if !USE_XTHEME -static INTN row0PosY /*, row1PosY, textPosY, FunctextPosY*/; -#endif -////static EG_IMAGE* MainImage; -//static INTN OldX = 0, OldY = 0; -//static INTN OldTextWidth = 0; -//static UINTN OldRow = 0; -//static INTN OldTimeoutTextWidth = 0; -//static INTN MenuWidth, TimeoutPosY; -//static INTN EntriesPosX, EntriesPosY; -//static INTN EntriesWidth, EntriesHeight, EntriesGap; -#if !USE_XTHEME -EG_IMAGE* ScrollbarImage = NULL; -EG_IMAGE* ScrollbarBackgroundImage = NULL; -EG_IMAGE* UpButtonImage = NULL; -EG_IMAGE* DownButtonImage = NULL; -EG_IMAGE* BarStartImage = NULL; -EG_IMAGE* BarEndImage = NULL; -EG_IMAGE* ScrollStartImage = NULL; -EG_IMAGE* ScrollEndImage = NULL; -EG_RECT BarStart; -EG_RECT BarEnd; -EG_RECT ScrollStart; -EG_RECT ScrollEnd; -EG_RECT ScrollTotal; -EG_RECT UpButton; -EG_RECT DownButton; -EG_RECT ScrollbarBackground; -EG_RECT Scrollbar; -EG_RECT ScrollbarOldPointerPlace; -EG_RECT ScrollbarNewPointerPlace; -#endif -// -//INPUT_ITEM *InputItems = NULL; -//UINTN InputItemsCount = 0; -// -//INTN OldChosenTheme; -//INTN OldChosenConfig; -//INTN OldChosenDsdt; -//UINTN OldChosenAudio; -//UINT8 DefaultAudioVolume = 70; -////INTN NewChosenTheme; -//#if !USE_XTHEME -//INTN TextStyle; //why global? It will be class SCREEN member -//#endif -////BOOLEAN mGuiReady = FALSE; -// - - -//REFIT_MENU_ITEM_OPTIONS(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) REFIT_MENU_ITEM_OPTIONS MenuEntryOptions (L"Options"_XSW, 1, 0, 'O', ActionEnter); REFIT_MENU_ITEM_ABOUT MenuEntryAbout (L"About Clover"_XSW, 1, 0, 'A', ActionEnter); REFIT_MENU_ITEM_RESET MenuEntryReset (L"Restart Computer"_XSW, 1, 0, 'R', ActionSelect); @@ -239,15 +122,9 @@ REFIT_MENU_ITEM_SHUTDOWN MenuEntryShutdown(L"Exit Clover"_XSW, 1, 0, 'U', A REFIT_MENU_ITEM_RETURN MenuEntryReturn (L"Return"_XSW, 0, 0, 0, ActionEnter); -#if USE_XTHEME REFIT_MENU_SCREEN MainMenu(1, L"Main Menu"_XSW, L"Automatic boot"_XSW); REFIT_MENU_SCREEN AboutMenu(2, L"About"_XSW, L""_XSW); REFIT_MENU_SCREEN HelpMenu(3, L"Help"_XSW, L""_XSW); -#else -REFIT_MENU_SCREEN MainMenu(1, L"Main Menu", L"Automatic boot"); -REFIT_MENU_SCREEN AboutMenu(2, L"About", NULL); -REFIT_MENU_SCREEN HelpMenu(3, L"Help", NULL); -#endif // input - tsc @@ -785,7 +662,6 @@ VOID ApplyInputs(VOID) } i++; //3 if (InputItems[i].Valid) { -#if USE_XTHEME if (GlobalConfig.Theme) { FreePool(GlobalConfig.Theme); } @@ -793,22 +669,7 @@ VOID ApplyInputs(VOID) GlobalConfig.Theme = PoolPrint(L"embedded"); } else { GlobalConfig.Theme = PoolPrint(L"%s", ThemesList[OldChosenTheme]); - //ThemeX.DarkEmbedded = FALSE; Don't know what to do - //ThemeX.Font = FONT_ALFA; } - // GlobalConfig.Theme = EfiStrDuplicate(ThemeX.Theme.wc_str()); -#else - if (GlobalConfig.Theme) { - FreePool(GlobalConfig.Theme); - } - if (OldChosenTheme == 0xFFFF) { - GlobalConfig.Theme = PoolPrint(L"embedded"); - } else { - GlobalConfig.Theme = PoolPrint(L"%s", ThemesList[OldChosenTheme]); - GlobalConfig.DarkEmbedded = FALSE; - GlobalConfig.Font = FONT_ALFA; - } -#endif //will change theme after ESC gThemeChanged = TRUE; @@ -1360,19 +1221,11 @@ VOID ApplyInputs(VOID) VOID AboutRefit(VOID) { -#if USE_XTHEME if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { AboutMenu.TitleImage = ThemeX.GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT); } else { AboutMenu.TitleImage.setEmpty(); } -#else - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { - AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - } else { - AboutMenu.TitleImage = NULL; - } -#endif if (AboutMenu.Entries.size() == 0) { // AboutMenu.AddMenuInfo_f(("Clover Version 5.0")); @@ -1430,19 +1283,11 @@ VOID AboutRefit(VOID) VOID HelpRefit(VOID) { -#if USE_XTHEME if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { HelpMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_HELP); } else { HelpMenu.TitleImage.setEmpty(); } -#else - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { - HelpMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_HELP); - } else { - HelpMenu.TitleImage = NULL; - } -#endif if (HelpMenu.Entries.size() == 0) { switch (gLanguage) { @@ -1822,648 +1667,21 @@ VOID HelpRefit(VOID) [2] checkbox [3] checkbox_checked */ -#if !USE_XTHEME -VOID InitSelection(VOID) -{ - - if (!AllowGraphicsMode) - return; - SelectionBackgroundPixel.r = (GlobalConfig.SelectionColor >> 24) & 0xFF; - SelectionBackgroundPixel.g = (GlobalConfig.SelectionColor >> 16) & 0xFF; - SelectionBackgroundPixel.b = (GlobalConfig.SelectionColor >> 8) & 0xFF; - SelectionBackgroundPixel.a = (GlobalConfig.SelectionColor >> 0) & 0xFF; - - if (SelectionImages[0] != NULL) { - return; - } - // load small selection image - if (GlobalConfig.SelectionSmallFileName != NULL){ - SelectionImages[2] = egLoadImage(ThemeDir, GlobalConfig.SelectionSmallFileName, FALSE); - } - if (SelectionImages[2] == NULL){ - SelectionImages[2] = BuiltinIcon(BUILTIN_SELECTION_SMALL); - SelectionImages[2]->HasAlpha = FALSE; // support transparensy for selection icons - CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); - } - SelectionImages[2] = egEnsureImageSize(SelectionImages[2], - row1TileSize, row1TileSize, &MenuBackgroundPixel); - if (SelectionImages[2] == NULL) { - return; - } - // load big selection image - if (!GlobalConfig.TypeSVG && GlobalConfig.SelectionBigFileName != NULL) { - SelectionImages[0] = egLoadImage(ThemeDir, GlobalConfig.SelectionBigFileName, FALSE); - SelectionImages[0] = egEnsureImageSize(SelectionImages[0], - row0TileSize, row0TileSize, - &MenuBackgroundPixel); - } - if (SelectionImages[0] == NULL) { - // calculate big selection image from small one - SelectionImages[0] = BuiltinIcon(BUILTIN_SELECTION_BIG); - SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons - CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); - if (SelectionImages[0] == NULL) { - egFreeImage(SelectionImages[2]); - SelectionImages[2] = NULL; - return; - } - if (GlobalConfig.SelectionOnTop) { - SelectionImages[0]->HasAlpha = TRUE; - SelectionImages[2]->HasAlpha = TRUE; - } - } - - // BootCampStyle indicator image - if (GlobalConfig.BootCampStyle) { - // load indicator selection image - if (GlobalConfig.SelectionIndicatorName != NULL) { - SelectionImages[4] = egLoadImage(ThemeDir, GlobalConfig.SelectionIndicatorName, TRUE); - } - if (!SelectionImages[4]) { - SelectionImages[4] = egDecodePNG(ACCESS_EMB_DATA(emb_selection_indicator), ACCESS_EMB_SIZE(emb_selection_indicator), TRUE); - - } - INTN ScaledIndicatorSize = (INTN)(INDICATOR_SIZE * GlobalConfig.Scale); - SelectionImages[4] = egEnsureImageSize(SelectionImages[4], ScaledIndicatorSize, ScaledIndicatorSize, &MenuBackgroundPixel); - if (!SelectionImages[4]) { - SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize, - TRUE, &StdBackgroundPixel); - - } - SelectionImages[5] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize, - TRUE, &MenuBackgroundPixel); - } - - /* - Button & radio, or any other next icons with builtin icon as fallback should synced to: - - BUILTIN_ICON_* in lib.h - - BuiltinIconTable in icns.c - - Data in egemb_icons.h / scroll_images.h - */ - - // Radio buttons - //it was a nonsense egLoadImage is just inluded into egLoadIcon. - // will be corrected with XTheme support - //the procedure loadIcon should also check embedded icons - Buttons[0] = egLoadImage(ThemeDir, GetIconsExt(L"radio_button", L"png"), TRUE); //memory leak - Buttons[1] = egLoadImage(ThemeDir, GetIconsExt(L"radio_button_selected", L"png"), TRUE); - if (!Buttons[0]) { - Buttons[0] = egLoadIcon(ThemeDir, L"radio_button.png", 48); - } - if (!Buttons[0]) { - Buttons[0] = egDecodePNG(ACCESS_EMB_DATA(emb_radio_button), ACCESS_EMB_SIZE(emb_radio_button), TRUE); - } - if (!Buttons[1]) { - Buttons[1] = egLoadIcon(ThemeDir, L"radio_button_selected.png", 48); - } - - if (!Buttons[1]) { - Buttons[1] = egDecodePNG(ACCESS_EMB_DATA(emb_radio_button_selected), ACCESS_EMB_SIZE(emb_radio_button_selected), TRUE); - } - - // Checkbox - Buttons[2] = egLoadImage(ThemeDir, GetIconsExt(L"checkbox", L"png"), TRUE); - Buttons[3] = egLoadImage(ThemeDir, GetIconsExt(L"checkbox_checked", L"png"), TRUE); - if (!Buttons[2]) { -// DBG("egLoadIcon checkbox\n"); - Buttons[2] = egLoadIcon(ThemeDir, L"checkbox.png", 48); - } - if (!Buttons[3]) { -// DBG("egLoadIcon checkbox_checked\n"); - Buttons[3] = egLoadIcon(ThemeDir, L"checkbox_checked.png", 48); - } - - if (!Buttons[2]) { -// DBG("embedded checkbox\n"); - Buttons[2] = egDecodePNG(ACCESS_EMB_DATA(emb_checkbox), ACCESS_EMB_SIZE(emb_checkbox), TRUE); - } - - if (!Buttons[3]) { -// DBG("embedded checkbox_checked\n"); - Buttons[3] = egDecodePNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked), TRUE); - } - // non-selected background images - //totally wrong - if (GlobalConfig.SelectionBigFileName != NULL) { - SelectionImages[1] = egCreateFilledImage(row0TileSize, row0TileSize, - TRUE, &MenuBackgroundPixel); - SelectionImages[3] = egCreateFilledImage(row1TileSize, row1TileSize, - TRUE, &MenuBackgroundPixel); - } else { // using embedded theme (this is an assumption but a better check is required) - EG_PIXEL BackgroundPixel; - if (GlobalConfig.DarkEmbedded || GlobalConfig.TypeSVG) { - BackgroundPixel = DarkEmbeddedBackgroundPixel; - BackgroundPixel.a = 0x00; - } else { - BackgroundPixel = StdBackgroundPixel; - BackgroundPixel.a = 0xff; - } - if (GlobalConfig.DarkEmbedded) { //nonsense then equal else - SelectionImages[1] = egCreateFilledImage(row0TileSize, row0TileSize, - TRUE, &BackgroundPixel); - SelectionImages[3] = egCreateFilledImage(row1TileSize, row1TileSize, - TRUE, &BackgroundPixel); - - } else { - SelectionImages[1] = egCreateFilledImage(row0TileSize, row0TileSize, - TRUE, &BackgroundPixel); //&StdBackgroundPixel); - SelectionImages[3] = egCreateFilledImage(row1TileSize, row1TileSize, - TRUE, &BackgroundPixel); - } - } -// DBG("selections inited\n"); -} -#endif // // Scrolling functions // #define CONSTRAIN_MIN(Variable, MinValue) if (Variable < MinValue) Variable = MinValue #define CONSTRAIN_MAX(Variable, MaxValue) if (Variable > MaxValue) Variable = MaxValue -#if !USE_XTHEME -INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) -{ - INTN TextWidth = 0; - INTN XText = 0; - INTN Height; - INTN TextXYStyle = 1; - EG_IMAGE *TextBufferXY = NULL; - - if (!Text) { - return 0; - } - if (!textFace[1].valid) { - if (textFace[2].valid) { - TextXYStyle = 2; - } else { - TextXYStyle = 0; - } - } - - egMeasureText(Text, &TextWidth, NULL); - - if (XAlign == X_IS_LEFT) { - TextWidth = UGAWidth - XPos - 1; - XText = XPos; - } - - if (GlobalConfig.TypeSVG) { - TextWidth += TextHeight * 2; //give more place for buffer - if (!textFace[TextXYStyle].valid) { - DBG("no vaid text face for message!\n"); - Height = TextHeight; - } else { - Height = (int)(textFace[TextXYStyle].size * RowHeightFromTextHeight * GlobalConfig.Scale); - } - } else { - Height = TextHeight; - } - - TextBufferXY = egCreateFilledImage(TextWidth, Height, TRUE, &MenuBackgroundPixel); - - // render the text - TextWidth = egRenderText(Text, TextBufferXY, 0, 0, 0xFFFF, TextXYStyle); - - if (XAlign != X_IS_LEFT) { - // shift 64 is prohibited - XText = XPos - (TextWidth >> XAlign); //X_IS_CENTER = 1 - } -// DBG("draw text %ls\n", Text); -// DBG("pos=%d width=%d xtext=%d Height=%d Y=%d\n", XPos, TextWidth, XText, Height, YPos); - BltImageAlpha(TextBufferXY, XText, YPos, &MenuBackgroundPixel, 16); - egFreeImage(TextBufferXY); - - return TextWidth; -} -#endif -/** - * Helper function to draw text for Boot Camp Style. - * @author: Needy - */ - -#if USE_XTHEME - -#else -VOID DrawMenuText(IN CONST CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor) -{ - //use Text=null to reinit the buffer - if (!Text) { - if (TextBuffer) { - egFreeImage(TextBuffer); - TextBuffer = NULL; - } - return; - } - - if (TextBuffer && (TextBuffer->Height != TextHeight)) { - egFreeImage(TextBuffer); - TextBuffer = NULL; - } - - if (TextBuffer == NULL) { - TextBuffer = egCreateImage(UGAWidth-XPos, TextHeight, TRUE); - } - - if (Cursor != 0xFFFF) { - egFillImage(TextBuffer, &MenuBackgroundPixel); - } else { - egFillImage(TextBuffer, &InputBackgroundPixel); - } - - - if (SelectedWidth > 0) { - // draw selection bar background - egFillImageArea(TextBuffer, 0, 0, (INTN)SelectedWidth, TextHeight, - &SelectionBackgroundPixel); - } - - // render the text - if (GlobalConfig.TypeSVG) { - //clovy - text veltically centred on Height - egRenderText(Text, TextBuffer, 0, - (INTN)((TextHeight - (textFace[TextStyle].size * GlobalConfig.Scale)) / 2), - Cursor, TextStyle); - } else { - egRenderText(Text, TextBuffer, TEXT_XMARGIN, TEXT_YMARGIN, Cursor, TextStyle); - } - BltImageAlpha(TextBuffer, (INTN)XPos, (INTN)YPos, &MenuBackgroundPixel, 16); -} - -#endif - -#if !USE_XTHEME -VOID FreeScrollBar(VOID) -{ - if (ScrollbarBackgroundImage) { - egFreeImage(ScrollbarBackgroundImage); - ScrollbarBackgroundImage = NULL; - } - if (BarStartImage) { - egFreeImage(BarStartImage); - BarStartImage = NULL; - } - if (BarEndImage) { - egFreeImage(BarEndImage); - BarEndImage = NULL; - } - if (ScrollbarImage) { - egFreeImage(ScrollbarImage); - ScrollbarImage = NULL; - } - if (ScrollStartImage) { - egFreeImage(ScrollStartImage); - ScrollStartImage = NULL; - } - if (ScrollEndImage) { - egFreeImage(ScrollEndImage); - ScrollEndImage = NULL; - } - if (UpButtonImage) { - egFreeImage(UpButtonImage); - UpButtonImage = NULL; - } - if (DownButtonImage) { - egFreeImage(DownButtonImage); - DownButtonImage = NULL; - } -} - - -VOID InitBar(VOID) -{ - if (ThemeDir) { - if (!ScrollbarBackgroundImage) { - ScrollbarBackgroundImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\bar_fill", L"png"), FALSE); - } - if (!BarStartImage) { - BarStartImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\bar_start", L"png"), TRUE); - } - if (!BarEndImage) { - BarEndImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\bar_end", L"png"), TRUE); - } - if (!ScrollbarImage) { - ScrollbarImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\scroll_fill", L"png"), FALSE); - } - if (!ScrollStartImage) { - ScrollStartImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\scroll_start", L"png"), TRUE); - } - if (!ScrollEndImage) { - ScrollEndImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\scroll_end", L"png"), TRUE); - } - if (!UpButtonImage) { - UpButtonImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\up_button", L"png"), TRUE); - } - if (!DownButtonImage) { - DownButtonImage = egLoadImage(ThemeDir, GetIconsExt(L"scrollbar\\down_button", L"png"), TRUE); - } - } - - if (!BarStartImage && !GlobalConfig.TypeSVG) { - BarStartImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_bar_start), ACCESS_EMB_SIZE(emb_scroll_bar_start), TRUE); - } - if (!BarEndImage && !GlobalConfig.TypeSVG) { - BarEndImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_bar_end), ACCESS_EMB_SIZE(emb_scroll_bar_end), TRUE); - } - if (!ScrollbarBackgroundImage) { - if (GlobalConfig.TypeSVG) { - ScrollbarBackgroundImage = egLoadIcon(ThemeDir, L"scrollbar-background.png", 48); - } - if (!ScrollbarBackgroundImage) { - ScrollbarBackgroundImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_bar_fill), ACCESS_EMB_SIZE(emb_scroll_bar_fill), TRUE); - } - } - if (!ScrollbarImage) { - if (GlobalConfig.TypeSVG) { - ScrollbarImage = egLoadIcon(ThemeDir, L"scrollbar-holder.png", 48); - } - if (!ScrollbarImage) { - ScrollbarImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_scroll_fill), ACCESS_EMB_SIZE(emb_scroll_scroll_fill), TRUE); - } - } - if (!ScrollStartImage && !GlobalConfig.TypeSVG) { - ScrollStartImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_scroll_start), ACCESS_EMB_SIZE(emb_scroll_scroll_start), TRUE); - } - if (!ScrollEndImage && !GlobalConfig.TypeSVG) { - ScrollEndImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_scroll_end), ACCESS_EMB_SIZE(emb_scroll_scroll_end), TRUE); - } - if (!UpButtonImage && !GlobalConfig.TypeSVG) { - UpButtonImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_up_button), ACCESS_EMB_SIZE(emb_scroll_up_button), TRUE); - } - if (!DownButtonImage && !GlobalConfig.TypeSVG) { - DownButtonImage = egDecodePNG(ACCESS_EMB_DATA(emb_scroll_down_button), ACCESS_EMB_SIZE(emb_scroll_down_button), TRUE); - } - if (!GlobalConfig.TypeSVG) { - UpButton.Width = ScrollWidth; // 16 - UpButton.Height = ScrollButtonsHeight; // 20 - DownButton.Width = UpButton.Width; - DownButton.Height = ScrollButtonsHeight; - BarStart.Height = ScrollBarDecorationsHeight; // 5 - BarEnd.Height = ScrollBarDecorationsHeight; - ScrollStart.Height = ScrollScrollDecorationsHeight; // 7 - ScrollEnd.Height = ScrollScrollDecorationsHeight; - - } else { - UpButton.Width = ScrollWidth; // 16 - UpButton.Height = 0; // 20 - DownButton.Width = UpButton.Width; - DownButton.Height = 0; - BarStart.Height = ScrollBarDecorationsHeight; // 5 - BarEnd.Height = ScrollBarDecorationsHeight; - ScrollStart.Height = 0; // 7 - ScrollEnd.Height = 0; - - } -} -#endif - -/** - * Draw entries for GUI. - */ -#if USE_XTHEME - -#else -VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos) -{ - EG_IMAGE* MainImage = NULL; - EG_IMAGE* BadgeImage = NULL; - bool NewImageCreated = false; - INTN Scale = GlobalConfig.MainEntriesSize >> 3; //usually it is 128>>3 == 16. if 256>>3 == 32 - - if (Entry->Row == 0 && Entry->getDriveImage() && !(GlobalConfig.HideBadges & HDBADGES_SWAP)) { - MainImage = Entry->getDriveImage(); - } else { - MainImage = Entry->Image; - } - //this should be inited by the Theme - if (!MainImage) { - if (!IsEmbeddedTheme()) { - MainImage = egLoadIcon(ThemeDir, GetIconsExt(L"icons\\os_mac", L"icns"), Scale << 3); - } - if (!MainImage) { - MainImage = DummyImage(Scale << 3); - } - if (MainImage) { - NewImageCreated = true; - } - } - // DBG("Entry title=%ls; Width=%d\n", Entry->Title, MainImage->Width); - - if (GlobalConfig.TypeSVG) { - Scale = 16 * (selected ? 1 : -1); - } else { - Scale = ((Entry->Row == 0) ? (Scale * (selected ? 1 : -1)): 16) ; - } - - if (Entry->Row == 0) { - BadgeImage = Entry->getBadgeImage(); - } //else null - - if (GlobalConfig.SelectionOnTop) { - SelectionImages[0]->HasAlpha = TRUE; - SelectionImages[2]->HasAlpha = TRUE; - //MainImage->HasAlpha = TRUE; - BltImageCompositeBadge(MainImage, - SelectionImages[((Entry->Row == 0) ? 0 : 2) + (selected ? 0 : 1)], - BadgeImage, - XPos, YPos, Scale); - } else { - BltImageCompositeBadge(SelectionImages[((Entry->Row == 0) ? 0 : 2) + (selected ? 0 : 1)], - MainImage, - BadgeImage, - XPos, YPos, Scale); - } - // draw BCS indicator - // Needy: if Labels (Titles) are hidden there is no point to draw the indicator - if (GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { - SelectionImages[4]->HasAlpha = TRUE; - - // indicator is for row 0, main entries, only - if (Entry->Row == 0) { - BltImageAlpha(SelectionImages[4 + (selected ? 0 : 1)], - XPos + (row0TileSize / 2) - (INTN)(INDICATOR_SIZE * 0.5f * GlobalConfig.Scale), - row0PosY + row0TileSize + TextHeight + (INTN)((BCSMargin * 2) * GlobalConfig.Scale), - &MenuBackgroundPixel, Scale); - } - } - - Entry->Place.XPos = XPos; - Entry->Place.YPos = YPos; - Entry->Place.Width = MainImage->Width; - Entry->Place.Height = MainImage->Height; - //we can't free MainImage because it may be new image or it may be a link to entry image - // a workaround - if (NewImageCreated) { - egFreeImage(MainImage); - } -} -#endif - -/** - * Helper function to draw text for Boot Camp Style. - * @author: Needy - */ -#if !USE_XTHEME -VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) -{ - // check if text was provided - if (!Text) { - return; - } - - INTN TextLen = StrLen(Text); - - // number of chars to be drawn on the screen - INTN MaxTextLen = 13; - INTN EllipsisLen = 2; - - CHAR16 *BCSText = NULL; - - // more space, more characters - if (GlobalConfig.TileXSpace >= 25 && GlobalConfig.TileXSpace < 30) { - MaxTextLen = 14; - } else if (GlobalConfig.TileXSpace >= 30 && GlobalConfig.TileXSpace < 35) { - MaxTextLen = 15; - } else if (GlobalConfig.TileXSpace >= 35 && GlobalConfig.TileXSpace < 40) { - MaxTextLen = 16; - } else if (GlobalConfig.TileXSpace >= 40 && GlobalConfig.TileXSpace < 45) { - MaxTextLen = 17; - } else if (GlobalConfig.TileXSpace >= 45 && GlobalConfig.TileXSpace < 50) { - MaxTextLen = 18; - } else if (GlobalConfig.TileXSpace >= 50) { - MaxTextLen = 19; - } - - MaxTextLen += EllipsisLen; - - // if the text exceeds the given limit - if (TextLen > MaxTextLen) { - BCSText = (__typeof__(BCSText))AllocatePool((sizeof(CHAR16) * MaxTextLen) + 1); - - // error check, not enough memory - if (!BCSText) { - return; - } - - // copy the permited amound of chars minus the ellipsis - StrnCpyS(BCSText, (MaxTextLen - EllipsisLen) + 1, Text, MaxTextLen - EllipsisLen); - BCSText[MaxTextLen - EllipsisLen] = '\0'; - - // add ellipsis - StrnCatS(BCSText, MaxTextLen + 1, L"..", EllipsisLen); - // redundant, used for safety measures - BCSText[MaxTextLen] = '\0'; - DrawTextXY(BCSText, XPos, YPos, XAlign); - FreePool(BCSText); - } else { - // draw full text - DrawTextXY(Text, XPos, YPos, XAlign); - } -} -#endif - -//the purpose of the procedure is restore Background in rect -//XAlign is always centre, Color is the Backgrounf fill -#if USE_XTHEME - -#else -VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color, IN UINT8 XAlign) -{ - EG_IMAGE *TmpBuffer = NULL; - INTN X = XPos - (Width >> XAlign); - - if (!Width || !Height) return; - - TmpBuffer = egCreateImage(Width, Height, FALSE); - if (!BackgroundImage) { - egFillImage(TmpBuffer, Color); - } else { - egRawCopy(TmpBuffer->PixelData, - BackgroundImage->PixelData + YPos * BackgroundImage->Width + X, - Width, Height, - TmpBuffer->Width, - BackgroundImage->Width); - } - BltImage(TmpBuffer, X, YPos); - egFreeImage(TmpBuffer); -} -#endif - - -#if USE_XTHEME - -#else -VOID DrawTextCorner(UINTN TextC, UINT8 Align) -{ - INTN Xpos; - CHAR16 *Text = NULL; - - if ( - // HIDEUI_ALL - included - ((TextC == TEXT_CORNER_REVISION) && ((GlobalConfig.HideUIFlags & HIDEUI_FLAG_REVISION) != 0)) || - ((TextC == TEXT_CORNER_HELP) && ((GlobalConfig.HideUIFlags & HIDEUI_FLAG_HELP) != 0)) || - ((TextC == TEXT_CORNER_OPTIMUS) && (GlobalConfig.ShowOptimus == FALSE)) - ) { - return; - } - - switch (TextC) { - case TEXT_CORNER_REVISION: - // Display Clover boot volume - if (SelfVolume->VolLabel && SelfVolume->VolLabel[0] != L'#') { - Text = PoolPrint(L"%s, booted from %s", gFirmwareRevision, SelfVolume->VolLabel); - } - if ( !Text ) { - Text = PoolPrint(L"%s", gFirmwareRevision, SelfVolume->VolName); - } - break; - case TEXT_CORNER_HELP: - Text = PoolPrint(L"F1:Help"); - break; - case TEXT_CORNER_OPTIMUS: - if (gGraphics[0].Vendor != Intel) { - Text = PoolPrint(L"Discrete"); - } else { - Text = PoolPrint(L"Intel"); - } - // Text = (NGFX == 2)?L"Intel":L"Discrete"; - break; - default: - return; - } - - switch (Align) { - case X_IS_LEFT: - Xpos = (INTN)(TextHeight * 0.75f); - break; - case X_IS_RIGHT: - Xpos = UGAWidth - (INTN)(TextHeight * 0.7f);//2 - break; - case X_IS_CENTER: - Xpos = UGAWidth >> 1; - break; - default: - if ( Text ) FreePool(Text); - return; - } - // DBG("draw text %ls at (%d, %d)\n", Text, Xpos, UGAHeight - 5 - TextHeight), - // clovy DrawTextXY(Text, Xpos, UGAHeight - 5 - TextHeight, Align); - DrawTextXY(Text, Xpos, UGAHeight - (INTN)(TextHeight * 1.5f), Align); - if ( Text ) FreePool(Text); -} -#endif // // user-callable dispatcher functions // -REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title) +REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *CTitle) { - if ( Title ) Entry->Title.takeValueFrom(Title); + if ( CTitle ) Entry->Title.takeValueFrom(CTitle); else Entry->Title.setEmpty(); -// if (Title) { -// } else { -// Entry->Title = (__typeof__(Entry->Title))AllocateZeroPool(128); -// } Entry->Image = OptionMenu.TitleImage; Entry->AtClick = AtClick; @@ -2481,30 +1699,19 @@ REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MEN REFIT_MENU_ITEM_OPTIONS* newREFIT_MENU_ITEM_OPTIONS(REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title) { - //create entry -// *Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof. REFIT_MENU_ITEM_OPTIONS* Entry = new REFIT_MENU_ITEM_OPTIONS(); return NewEntry_(Entry, SubScreen, AtClick, ID, Title)->getREFIT_MENU_ITEM_OPTIONS(); // (*Entry)->Tag = TAG_OPTIONS; } -// -//VOID NewLoaderEntry(LOADER_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title) -//{ -// //create entry -//// *Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof. -// *Entry = new LOADER_ENTRY(); -// NewEntry_(*Entry, SubScreen, AtClick, ID, Title); // cast ok because super class -//} VOID ModifyTitles(REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry) { if (ChosenEntry->SubScreen->ID == SCREEN_DSDT) { -// snwprintf((CHAR16*)ChosenEntry->Title, 128, "DSDT fix mask [0x%08X]->", gSettings.FixDsdt); // TODO jief : cast to fix ChosenEntry->Title.SWPrintf("DSDT fix mask [0x%08x]->", gSettings.FixDsdt); // TODO jief : cast to fix //MsgLog("@ESC: %ls\n", (*ChosenEntry)->Title); } else if (ChosenEntry->SubScreen->ID == SCREEN_CSR) { // CSR -// snwprintf((CHAR16*)ChosenEntry->Title, 128, "System Integrity Protection [0x%04X]->", gSettings.CsrActiveConfig); // TODO jief : cast to fix +// TODO jief : cast to fix ChosenEntry->Title.SWPrintf("System Integrity Protection [0x%04x]->", gSettings.CsrActiveConfig); // TODO jief : cast to fix // check for the right booter flag to allow the application // of the new System Integrity Protection configuration. @@ -2513,10 +1720,8 @@ VOID ModifyTitles(REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry) } } else if (ChosenEntry->SubScreen->ID == SCREEN_BLC) { -// snwprintf((CHAR16*)ChosenEntry->Title, 128, "boot_args->flags [0x%04X]->", gSettings.BooterConfig); // TODO jief : cast to fix ChosenEntry->Title.SWPrintf("boot_args->flags [0x%04x]->", gSettings.BooterConfig); // TODO jief : cast to fix } else if (ChosenEntry->SubScreen->ID == SCREEN_DSM) { -// snwprintf((CHAR16*)ChosenEntry->Title, 128, "Drop OEM _DSM [0x%04X]->", dropDSM); // TODO jief : cast to fix ChosenEntry->Title.SWPrintf("Drop OEM _DSM [0x%04x]->", dropDSM); // TODO jief : cast to fix } } @@ -3545,15 +2750,8 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry) INTN SubEntryIndex = -1; //value -1 means old position to remember INTN NextEntryIndex = -1; - // REFIT_INPUT_DIALOG* InputBootArgs; -#if USE_XTHEME BOOLEAN OldFontStyle = ThemeX.Proportional; ThemeX.Proportional = FALSE; //temporary disable proportional -#else - BOOLEAN OldFontStyle = GlobalConfig.Proportional; - GlobalConfig.Proportional = FALSE; //temporary disable proportional -#endif - if (AllowGraphicsMode) { Style = &REFIT_MENU_SCREEN::GraphicsMenuStyle; @@ -3561,19 +2759,11 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry) // remember, if you extended this menu then change procedures // FillInputs and ApplyInputs -#if USE_XTHEME if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { OptionMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS); } else { OptionMenu.TitleImage.setEmpty(); } -#else - if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { - OptionMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_OPTIONS); - } else { - OptionMenu.TitleImage = NULL; - } -#endif gThemeOptionsChanged = FALSE; @@ -3651,70 +2841,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry) } // if MENU_EXIT_ENTER } //exit: -#if USE_XTHEME ThemeX.Proportional = OldFontStyle; -#else - GlobalConfig.Proportional = OldFontStyle; -#endif - ApplyInputs(); } - -//UINT32 EncodeOptions(CONST CHAR16 *Options) -//{ -// UINT32 OptionsBits = 0; -// INTN Index; -// if (!Options) { -// return 0; -// } -// for (Index = 0; Index < NUM_OPT; Index++) { -// if (StrStr(Options, ArgOptional[Index])) { -// OptionsBits |= (1 << Index); -// if (Index == 1) { -// OptionsBits &= ~1; -// } -// } -// } -// return OptionsBits; -//} -// -//VOID DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry) -//{ -// //set checked option -// INTN Index; -// if (!Entry) { -// return; -// } -// for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON -// if (gSettings.OptionsBits & (1 << Index)) { -// Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, ArgOptional[Index]); -// } -// } -// //remove unchecked options -// for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON -// if ((gSettings.OptionsBits & (1 << Index)) == 0) { -// Entry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, ArgOptional[Index]); -// } -// } -// -// if (Entry->getLOADER_ENTRY()) { -// LOADER_ENTRY* loaderEntry = Entry->getLOADER_ENTRY(); -// // Only for non-legacy entries, as LEGACY_ENTRY doesn't have OSVersion -// if (gSettings.OptionsBits & OPT_NVWEBON) { -// if (AsciiOSVersionToUint64(loaderEntry->OSVersion) >= AsciiOSVersionToUint64("10.12")) { -// gSettings.NvidiaWeb = TRUE; -// } else { -// Entry->LoadOptions = AddLoadOption(loaderEntry->LoadOptions, ArgOptional[INX_NVWEBON]); -// } -// } -// if ((gSettings.OptionsBits & OPT_NVWEBON) == 0) { -// if (AsciiOSVersionToUint64(loaderEntry->OSVersion) >= AsciiOSVersionToUint64("10.12")) { -// gSettings.NvidiaWeb = FALSE; -// } else { -// Entry->LoadOptions = RemoveLoadOption(loaderEntry->LoadOptions, ArgOptional[INX_NVWEBON]); -// } -// } -// } -//} -// diff --git a/rEFIt_UEFI/refit/menu.h b/rEFIt_UEFI/refit/menu.h index 34a3daaca..88844a3ea 100644 --- a/rEFIt_UEFI/refit/menu.h +++ b/rEFIt_UEFI/refit/menu.h @@ -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 diff --git a/rEFIt_UEFI/refit/screen.cpp b/rEFIt_UEFI/refit/screen.cpp index c0d8b34b4..778e3fe8a 100644 --- a/rEFIt_UEFI/refit/screen.cpp +++ b/rEFIt_UEFI/refit/screen.cpp @@ -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;