move types declarations

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-26 20:00:53 +03:00
parent 9b85ac2a5b
commit a65aa874a2
10 changed files with 243 additions and 199 deletions

View File

@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "LegacyBiosThunk.h" #include "LegacyBiosThunk.h"
#include <posix.h> #include <posix.h>
#include "BootLog.h" // for DebugLog #include "BootLog.h" // for DebugLog
#include "Platform.h"
#include "../refit/screen.h" // just for PauseForKey #include "../refit/screen.h" // just for PauseForKey
#ifndef DEBUG_ALL #ifndef DEBUG_ALL

View File

@ -2889,7 +2889,7 @@ GetEarlyUserSettings (
if (Prop != NULL) { if (Prop != NULL) {
if ((Prop->type == kTagTypeString) && Prop->string) { if ((Prop->type == kTagTypeString) && Prop->string) {
ThemeX.Theme.takeValueFrom(Prop->string); ThemeX.Theme.takeValueFrom(Prop->string);
DBG ("Default theme: %ls\n", ThemeX.Theme); DBG ("Default theme: %ls\n", ThemeX.Theme.data());
OldChosenTheme = 0xFFFF; //default for embedded OldChosenTheme = 0xFFFF; //default for embedded
for (UINTN i = 0; i < ThemesNum; i++) { for (UINTN i = 0; i < ThemesNum; i++) {
//now comparison is case sensitive //now comparison is case sensitive
@ -4649,7 +4649,7 @@ GetThemeTagSettings (
#endif #endif
TagPtr TagPtr
LoadTheme (CHAR16 *TestTheme) LoadTheme (const CHAR16 *TestTheme)
{ {
EFI_STATUS Status = EFI_UNSUPPORTED; EFI_STATUS Status = EFI_UNSUPPORTED;
TagPtr ThemeDict = NULL; TagPtr ThemeDict = NULL;

View File

@ -147,7 +147,12 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
if (Image) { if (Image) {
Entry->Image.FromEGImage(Image); Entry->Image.FromEGImage(Image);
} else { } else {
Entry->Image = ThemeX.GetIcon(Volume->LegacyOS->IconName); UINTN Size = StrLen(Volume->LegacyOS->IconName) + 1;
CHAR8 *IconName = (__typeof__(IconName))AllocateZeroPool(Size);
UnicodeStrToAsciiStrS(Volume->LegacyOS->IconName, IconName, Size - 1);
Entry->Image = ThemeX.GetIcon(IconName);
FreePool(IconName);
} }
#else #else
if (Image) { if (Image) {

View File

@ -57,6 +57,7 @@
class REFIT_MENU_ENTRY_ITEM_ABSTRACT; class REFIT_MENU_ENTRY_ITEM_ABSTRACT;
class REFIT_MENU_ENTRY; class REFIT_MENU_ENTRY;
class REFIT_ABSTRACT_MENU_ENTRY;
typedef VOID (REFIT_MENU_SCREEN::*MENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText); typedef VOID (REFIT_MENU_SCREEN::*MENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText);

View File

@ -111,7 +111,7 @@ EFI_STATUS ParseSVGXIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float S
if ((strstr(IconName, "selection_big") != NULL) && (!ThemeX.SelectionOnTop)) { if ((strstr(IconName, "selection_big") != NULL) && (!ThemeX.SelectionOnTop)) {
ThemeX.MainEntriesSize = (int)(IconImage->width * Scale); //xxx ThemeX.MainEntriesSize = (int)(IconImage->width * Scale); //xxx
ThemeX.row0TileSize = ThemeX.MainEntriesSize + (int)(16.f * Scale); ThemeX.row0TileSize = ThemeX.MainEntriesSize + (int)(16.f * Scale);
DBG("main entry size = %d\n", ThemeX.MainEntriesSize); DBG("main entry size = %lld\n", ThemeX.MainEntriesSize);
} }
if ((strstr(IconName, "selection_small") != NULL) && (!ThemeX.SelectionOnTop)) { if ((strstr(IconName, "selection_small") != NULL) && (!ThemeX.SelectionOnTop)) {
ThemeX.row1TileSize = (int)(IconImage->width * Scale); ThemeX.row1TileSize = (int)(IconImage->width * Scale);
@ -189,7 +189,7 @@ EFI_STATUS ParseSVGXIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float S
if ((Id == BUILTIN_ICON_BANNER) && (strstr(IconName, "Banner") != NULL)) { if ((Id == BUILTIN_ICON_BANNER) && (strstr(IconName, "Banner") != NULL)) {
ThemeX.BannerPosX = (int)(bounds[0] * Scale - ThemeX.CentreShift); ThemeX.BannerPosX = (int)(bounds[0] * Scale - ThemeX.CentreShift);
ThemeX.BannerPosY = (int)(bounds[1] * Scale); ThemeX.BannerPosY = (int)(bounds[1] * Scale);
DBG("Banner position at parse [%d,%d]\n", ThemeX.BannerPosX, ThemeX.BannerPosY); DBG("Banner position at parse [%lld,%lld]\n", ThemeX.BannerPosX, ThemeX.BannerPosY);
} }
float Height = IconImage->height * Scale; float Height = IconImage->height * Scale;
@ -638,7 +638,7 @@ EFI_STATUS ParseSVGXTheme(CONST CHAR8* buffer, TagPtr * dict)
// must be svg view-box // must be svg view-box
float vbx = mainParser->viewWidth; float vbx = mainParser->viewWidth;
float vby = mainParser->viewHeight; float vby = mainParser->viewHeight;
DBG("Theme view-bounds: w=%d h=%d units=%s\n", (int)vbx, (int)vby, "px"); DBG("Theme view-bounds: w=%f h=%f units=px\n", vbx, vby);
if (vby > 1.0f) { if (vby > 1.0f) {
SVGimage->height = vby; SVGimage->height = vby;
} }
@ -646,7 +646,7 @@ EFI_STATUS ParseSVGXTheme(CONST CHAR8* buffer, TagPtr * dict)
SVGimage->height = 768.f; //default height SVGimage->height = 768.f; //default height
} }
float Scale = UGAHeight / SVGimage->height; float Scale = UGAHeight / SVGimage->height;
DBG("using scale %ls\n", Scale); DBG("using scale %f\n", Scale);
ThemeX.Scale = Scale; ThemeX.Scale = Scale;
ThemeX.CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f; ThemeX.CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f;
@ -836,7 +836,7 @@ INTN renderSVGtext(XImage& TextBufferXY, INTN posX, INTN posY, INTN textType, XS
} }
float fH = fontSVG->bbox[3] - fontSVG->bbox[1]; //1250 float fH = fontSVG->bbox[3] - fontSVG->bbox[1]; //1250
if (fH == 0.f) { if (fH == 0.f) {
DBG("wrong font: %ls\n", fontSVG->unitsPerEm); DBG("wrong font: %f\n", fontSVG->unitsPerEm);
DumpFloat2("Font bbox", fontSVG->bbox, 4); DumpFloat2("Font bbox", fontSVG->bbox, 4);
fH = fontSVG->unitsPerEm?fontSVG->unitsPerEm:1000.0f; //1000 fH = fontSVG->unitsPerEm?fontSVG->unitsPerEm:1000.0f; //1000
} }

View File

@ -2,6 +2,7 @@
#include "XImage.h" #include "XImage.h"
//#include "../refit/IO.h" //#include "../refit/IO.h"
#include "libeg.h"
class REFIT_MENU_SCREEN; class REFIT_MENU_SCREEN;
class XImage; class XImage;

View File

@ -5,8 +5,9 @@
#include "../cpp_foundation/XObjArray.h" #include "../cpp_foundation/XObjArray.h"
#include "../cpp_foundation/XString.h" #include "../cpp_foundation/XString.h"
#include "libeg.h" #include "libeg.h"
#include "XImage.h"
#include "nanosvg.h" #include "nanosvg.h"
#include "XImage.h"
#define INDICATOR_SIZE (52) #define INDICATOR_SIZE (52)

View File

@ -149,7 +149,6 @@ typedef enum {
imScale, imScale,
imCrop, imCrop,
imTile imTile
} SCALING; } SCALING;
typedef enum { typedef enum {
@ -158,6 +157,212 @@ typedef enum {
FONT_LOAD FONT_LOAD
} FONT_TYPE; } FONT_TYPE;
typedef enum {
NoEvents,
Move,
LeftClick,
RightClick,
DoubleClick,
ScrollClick,
ScrollDown,
ScrollUp,
LeftMouseDown,
RightMouseDown,
MouseMove
} MOUSE_EVENT;
typedef enum {
ActionNone = 0,
ActionHelp,
ActionSelect,
ActionEnter,
ActionDeselect,
ActionDestroy,
ActionOptions,
ActionDetails,
ActionFinish,
ActionScrollDown,
ActionScrollUp,
ActionMoveScrollbar,
ActionPageDown,
ActionPageUp,
ActionLight
} ACTION;
typedef struct {
INTN CurrentSelection, LastSelection;
INTN MaxScroll, MaxIndex;
INTN FirstVisible, LastVisible, MaxVisible, MaxFirstVisible;
BOOLEAN IsScrolling, PaintAll, PaintSelection;
} SCROLL_STATE;
typedef enum {
BoolValue,
Decimal,
Hex,
ASString,
UNIString,
RadioSwitch,
CheckBit,
} ITEM_TYPE;
typedef struct {
ITEM_TYPE ItemType; //string, value, boolean
BOOLEAN Valid;
BOOLEAN BValue;
UINT8 Pad8;
UINT32 IValue;
// UINT64 UValue;
// CHAR8* AValue;
CHAR16* SValue; // Max Size (see below) so the field can be edit by the GUI
UINTN LineShift;
} INPUT_ITEM;
typedef struct {
EFI_STATUS LastStatus;
EFI_FILE *DirHandle;
BOOLEAN CloseDirHandle;
EFI_FILE_INFO *LastFileInfo;
} REFIT_DIR_ITER;
typedef struct {
UINT8 Flags;
UINT8 StartCHS[3];
UINT8 Type;
UINT8 EndCHS[3];
UINT32 StartLBA;
UINT32 Size;
} MBR_PARTITION_INFO;
typedef struct {
UINT8 Type;
CONST CHAR16 *IconName;
CONST CHAR16 *Name;
} LEGACY_OS;
typedef struct {
EFI_DEVICE_PATH *DevicePath;
EFI_HANDLE DeviceHandle;
EFI_FILE *RootDir;
CONST CHAR16 *DevicePathString;
CONST CHAR16 *VolName;
CONST CHAR16 *VolLabel;
UINT8 DiskKind;
LEGACY_OS *LegacyOS;
BOOLEAN Hidden;
UINT8 BootType;
BOOLEAN IsAppleLegacy;
BOOLEAN HasBootCode;
BOOLEAN IsMbrPartition;
UINTN MbrPartitionIndex;
EFI_BLOCK_IO *BlockIO;
UINT64 BlockIOOffset;
EFI_BLOCK_IO *WholeDiskBlockIO;
EFI_DEVICE_PATH *WholeDiskDevicePath;
EFI_HANDLE WholeDiskDeviceHandle;
MBR_PARTITION_INFO *MbrPartitionTable;
UINT32 DriveCRC32;
EFI_GUID RootUUID; //for recovery it is UUID of parent partition
UINT64 SleepImageOffset;
} REFIT_VOLUME;
typedef struct KEXT_PATCH KEXT_PATCH;
struct KEXT_PATCH
{
CHAR8 *Name;
CHAR8 *Label;
BOOLEAN IsPlistPatch;
CHAR8 align[7];
INT64 DataLen;
UINT8 *Data;
UINT8 *Patch;
UINT8 *MaskFind;
UINT8 *MaskReplace;
CHAR8 *MatchOS;
CHAR8 *MatchBuild;
INPUT_ITEM MenuItem;
};
typedef struct {
CHAR8 *Label;
INTN DataLen;
UINT8 *Data;
UINT8 *Patch;
UINT8 *MaskFind;
UINT8 *MaskReplace;
INTN Count;
CHAR8 *MatchOS;
CHAR8 *MatchBuild;
INPUT_ITEM MenuItem;
} KERNEL_PATCH;
typedef struct KERNEL_AND_KEXT_PATCHES
{
BOOLEAN KPDebug;
BOOLEAN KPKernelCpu;
BOOLEAN KPKernelLapic;
BOOLEAN KPKernelXCPM;
BOOLEAN KPKernelPm;
BOOLEAN KPAppleIntelCPUPM;
BOOLEAN KPAppleRTC;
BOOLEAN KPDELLSMBIOS; // Dell SMBIOS patch
BOOLEAN KPPanicNoKextDump;
UINT8 pad[3];
UINT32 FakeCPUID;
// UINT32 align0;
CHAR16 *KPATIConnectorsController;
#if defined(MDE_CPU_IA32)
UINT32 align1;
#endif
UINT8 *KPATIConnectorsData;
#if defined(MDE_CPU_IA32)
UINT32 align2;
#endif
UINTN KPATIConnectorsDataLen;
#if defined(MDE_CPU_IA32)
UINT32 align3;
#endif
UINT8 *KPATIConnectorsPatch;
#if defined(MDE_CPU_IA32)
UINT32 align4;
#endif
INT32 NrKexts;
UINT32 align40;
KEXT_PATCH *KextPatches; //zzzz
#if defined(MDE_CPU_IA32)
UINT32 align5;
#endif
INT32 NrForceKexts;
UINT32 align50;
CHAR16 **ForceKexts;
#if defined(MDE_CPU_IA32)
UINT32 align6;
#endif
INT32 NrKernels;
KERNEL_PATCH *KernelPatches;
INT32 NrBoots;
KERNEL_PATCH *BootPatches;
} KERNEL_AND_KEXT_PATCHES;
typedef enum {
AlignNo,
AlignLeft,
AlignRight,
AlignCenter,
AlignUp,
AlignDown
} ALIGNMENT;
/* This should be compatible with EFI_UGA_PIXEL */ /* This should be compatible with EFI_UGA_PIXEL */
typedef struct { typedef struct {
UINT8 b, g, r, a; UINT8 b, g, r, a;
@ -184,6 +389,20 @@ typedef struct {
BOOLEAN HasAlpha; //moved here to avoid alignment issue BOOLEAN HasAlpha; //moved here to avoid alignment issue
} EG_IMAGE; } EG_IMAGE;
typedef struct GUI_ANIME GUI_ANIME;
struct GUI_ANIME {
UINTN ID;
CHAR16 *Path;
UINTN Frames;
UINTN FrameTime;
INTN FilmX, FilmY; //relative
INTN ScreenEdgeHorizontal;
INTN ScreenEdgeVertical;
INTN NudgeX, NudgeY;
BOOLEAN Once;
GUI_ANIME *Next;
};
#ifdef __cplusplus #ifdef __cplusplus
class EG_RECT { class EG_RECT {
public: public:

View File

@ -92,21 +92,6 @@ extern EFI_RUNTIME_SERVICES* gRT;
// lib module // lib module
// //
typedef struct {
EFI_STATUS LastStatus;
EFI_FILE *DirHandle;
BOOLEAN CloseDirHandle;
EFI_FILE_INFO *LastFileInfo;
} REFIT_DIR_ITER;
typedef struct {
UINT8 Flags;
UINT8 StartCHS[3];
UINT8 Type;
UINT8 EndCHS[3];
UINT32 StartLBA;
UINT32 Size;
} MBR_PARTITION_INFO;
#define DISK_KIND_INTERNAL (0) #define DISK_KIND_INTERNAL (0)
#define DISK_KIND_EXTERNAL (1) #define DISK_KIND_EXTERNAL (1)
@ -204,49 +189,8 @@ OSTYPE_COMPARE_IMP(OSTYPE_IS_LINUX, type1, type2) || OSTYPE_COMPARE_IMP(OSTYPE_I
#define IS_EXTENDED_PART_TYPE(type) ((type) == 0x05 || (type) == 0x0f || (type) == 0x85) #define IS_EXTENDED_PART_TYPE(type) ((type) == 0x05 || (type) == 0x0f || (type) == 0x85)
typedef struct {
UINT8 Type;
CONST CHAR16 *IconName;
CONST CHAR16 *Name;
} LEGACY_OS;
typedef struct {
EFI_DEVICE_PATH *DevicePath;
EFI_HANDLE DeviceHandle;
EFI_FILE *RootDir;
CONST CHAR16 *DevicePathString;
CONST CHAR16 *VolName;
CONST CHAR16 *VolLabel;
UINT8 DiskKind;
LEGACY_OS *LegacyOS;
BOOLEAN Hidden;
UINT8 BootType;
BOOLEAN IsAppleLegacy;
BOOLEAN HasBootCode;
BOOLEAN IsMbrPartition;
UINTN MbrPartitionIndex;
EFI_BLOCK_IO *BlockIO;
UINT64 BlockIOOffset;
EFI_BLOCK_IO *WholeDiskBlockIO;
EFI_DEVICE_PATH *WholeDiskDevicePath;
EFI_HANDLE WholeDiskDeviceHandle;
MBR_PARTITION_INFO *MbrPartitionTable;
UINT32 DriveCRC32;
EFI_GUID RootUUID; //for recovery it is UUID of parent partition
UINT64 SleepImageOffset;
} REFIT_VOLUME;
typedef enum {
AlignNo,
AlignLeft,
AlignRight,
AlignCenter,
AlignUp,
AlignDown
} ALIGNMENT;
//mouse types //mouse types
/*
typedef enum { typedef enum {
NoEvents, NoEvents,
Move, Move,
@ -260,7 +204,7 @@ typedef enum {
RightMouseDown, RightMouseDown,
MouseMove MouseMove
} MOUSE_EVENT; } MOUSE_EVENT;
*/
typedef struct _pointers { typedef struct _pointers {
EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol; EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
EG_IMAGE *Pointer; EG_IMAGE *Pointer;
@ -276,57 +220,11 @@ typedef struct _pointers {
} POINTERS; } POINTERS;
//GUI types //GUI types
typedef enum {
BoolValue,
Decimal,
Hex,
ASString,
UNIString,
RadioSwitch,
CheckBit,
} ITEM_TYPE;
typedef struct {
ITEM_TYPE ItemType; //string, value, boolean
BOOLEAN Valid;
BOOLEAN BValue;
UINT8 Pad8;
UINT32 IValue;
// UINT64 UValue;
// CHAR8* AValue;
CHAR16* SValue; // Max Size (see below) so the field can be edit by the GUI
UINTN LineShift;
} INPUT_ITEM;
// Allow for 255 unicode characters + 2 byte unicode null terminator. // Allow for 255 unicode characters + 2 byte unicode null terminator.
#define SVALUE_MAX_SIZE 512 #define SVALUE_MAX_SIZE 512
typedef enum {
ActionNone = 0,
ActionHelp,
ActionSelect,
ActionEnter,
ActionDeselect,
ActionDestroy,
ActionOptions,
ActionDetails,
ActionFinish,
ActionScrollDown,
ActionScrollUp,
ActionMoveScrollbar,
ActionPageDown,
ActionPageUp,
ActionLight
} ACTION;
typedef struct {
INTN CurrentSelection, LastSelection;
INTN MaxScroll, MaxIndex;
INTN FirstVisible, LastVisible, MaxVisible, MaxFirstVisible;
BOOLEAN IsScrolling, PaintAll, PaintSelection;
} SCROLL_STATE;
//extern BOOLEAN ScrollEnabled; //extern BOOLEAN ScrollEnabled;
extern EG_RECT UpButton; extern EG_RECT UpButton;
extern EG_RECT DownButton; extern EG_RECT DownButton;
@ -477,96 +375,13 @@ typedef struct {
} REFIT_CONFIG; } REFIT_CONFIG;
// types // types
typedef struct KEXT_PATCH KEXT_PATCH;
struct KEXT_PATCH
{
CHAR8 *Name;
CHAR8 *Label;
BOOLEAN IsPlistPatch;
CHAR8 align[7];
INT64 DataLen;
UINT8 *Data;
UINT8 *Patch;
UINT8 *MaskFind;
UINT8 *MaskReplace;
CHAR8 *MatchOS;
CHAR8 *MatchBuild;
INPUT_ITEM MenuItem;
};
typedef struct {
CHAR8 *Label;
INTN DataLen;
UINT8 *Data;
UINT8 *Patch;
UINT8 *MaskFind;
UINT8 *MaskReplace;
INTN Count;
CHAR8 *MatchOS;
CHAR8 *MatchBuild;
INPUT_ITEM MenuItem;
} KERNEL_PATCH;
typedef struct KERNEL_AND_KEXT_PATCHES
{
BOOLEAN KPDebug;
BOOLEAN KPKernelCpu;
BOOLEAN KPKernelLapic;
BOOLEAN KPKernelXCPM;
BOOLEAN KPKernelPm;
BOOLEAN KPAppleIntelCPUPM;
BOOLEAN KPAppleRTC;
BOOLEAN KPDELLSMBIOS; // Dell SMBIOS patch
BOOLEAN KPPanicNoKextDump;
UINT8 pad[3];
UINT32 FakeCPUID;
// UINT32 align0;
CHAR16 *KPATIConnectorsController;
#if defined(MDE_CPU_IA32)
UINT32 align1;
#endif
UINT8 *KPATIConnectorsData;
#if defined(MDE_CPU_IA32)
UINT32 align2;
#endif
UINTN KPATIConnectorsDataLen;
#if defined(MDE_CPU_IA32)
UINT32 align3;
#endif
UINT8 *KPATIConnectorsPatch;
#if defined(MDE_CPU_IA32)
UINT32 align4;
#endif
INT32 NrKexts;
UINT32 align40;
KEXT_PATCH *KextPatches; //zzzz
#if defined(MDE_CPU_IA32)
UINT32 align5;
#endif
INT32 NrForceKexts;
UINT32 align50;
CHAR16 **ForceKexts;
#if defined(MDE_CPU_IA32)
UINT32 align6;
#endif
INT32 NrKernels;
KERNEL_PATCH *KernelPatches;
INT32 NrBoots;
KERNEL_PATCH *BootPatches;
} KERNEL_AND_KEXT_PATCHES;
#define ANIME_INFINITE ((UINTN)-1) #define ANIME_INFINITE ((UINTN)-1)
//some unreal values //some unreal values
#define SCREEN_EDGE_LEFT 50000 #define SCREEN_EDGE_LEFT 50000
#define SCREEN_EDGE_TOP 60000 #define SCREEN_EDGE_TOP 60000
#define SCREEN_EDGE_RIGHT 70000 #define SCREEN_EDGE_RIGHT 70000
#define SCREEN_EDGE_BOTTOM 80000 #define SCREEN_EDGE_BOTTOM 80000
/*
typedef struct GUI_ANIME GUI_ANIME; typedef struct GUI_ANIME GUI_ANIME;
struct GUI_ANIME { struct GUI_ANIME {
UINTN ID; UINTN ID;
@ -580,7 +395,7 @@ struct GUI_ANIME {
BOOLEAN Once; BOOLEAN Once;
GUI_ANIME *Next; GUI_ANIME *Next;
}; };
*/
extern EFI_HANDLE SelfImageHandle; extern EFI_HANDLE SelfImageHandle;
extern EFI_HANDLE SelfDeviceHandle; extern EFI_HANDLE SelfDeviceHandle;
extern EFI_LOADED_IMAGE *SelfLoadedImage; extern EFI_LOADED_IMAGE *SelfLoadedImage;

View File

@ -1,4 +1,5 @@
#include "../gui/menu_items/menu_items.h" #include "../gui/menu_items/menu_items.h"
#include "../libeg/libeg.h"
VOID InitScreen(IN BOOLEAN SetMaxResolution); VOID InitScreen(IN BOOLEAN SetMaxResolution);
VOID SetupScreen(VOID); VOID SetupScreen(VOID);