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 <posix.h>
#include "BootLog.h" // for DebugLog
#include "Platform.h"
#include "../refit/screen.h" // just for PauseForKey
#ifndef DEBUG_ALL

View File

@ -2889,7 +2889,7 @@ GetEarlyUserSettings (
if (Prop != NULL) {
if ((Prop->type == kTagTypeString) && 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
for (UINTN i = 0; i < ThemesNum; i++) {
//now comparison is case sensitive
@ -4649,7 +4649,7 @@ GetThemeTagSettings (
#endif
TagPtr
LoadTheme (CHAR16 *TestTheme)
LoadTheme (const CHAR16 *TestTheme)
{
EFI_STATUS Status = EFI_UNSUPPORTED;
TagPtr ThemeDict = NULL;

View File

@ -147,7 +147,12 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
if (Image) {
Entry->Image.FromEGImage(Image);
} 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
if (Image) {

View File

@ -57,6 +57,7 @@
class REFIT_MENU_ENTRY_ITEM_ABSTRACT;
class REFIT_MENU_ENTRY;
class REFIT_ABSTRACT_MENU_ENTRY;
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)) {
ThemeX.MainEntriesSize = (int)(IconImage->width * Scale); //xxx
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)) {
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)) {
ThemeX.BannerPosX = (int)(bounds[0] * Scale - ThemeX.CentreShift);
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;
@ -638,7 +638,7 @@ EFI_STATUS ParseSVGXTheme(CONST CHAR8* buffer, TagPtr * dict)
// 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");
DBG("Theme view-bounds: w=%f h=%f units=px\n", vbx, vby);
if (vby > 1.0f) {
SVGimage->height = vby;
}
@ -646,7 +646,7 @@ EFI_STATUS ParseSVGXTheme(CONST CHAR8* buffer, TagPtr * dict)
SVGimage->height = 768.f; //default height
}
float Scale = UGAHeight / SVGimage->height;
DBG("using scale %ls\n", Scale);
DBG("using scale %f\n", Scale);
ThemeX.Scale = Scale;
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
if (fH == 0.f) {
DBG("wrong font: %ls\n", fontSVG->unitsPerEm);
DBG("wrong font: %f\n", fontSVG->unitsPerEm);
DumpFloat2("Font bbox", fontSVG->bbox, 4);
fH = fontSVG->unitsPerEm?fontSVG->unitsPerEm:1000.0f; //1000
}

View File

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

View File

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

View File

@ -149,7 +149,6 @@ typedef enum {
imScale,
imCrop,
imTile
} SCALING;
typedef enum {
@ -158,6 +157,212 @@ typedef enum {
FONT_LOAD
} 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 */
typedef struct {
UINT8 b, g, r, a;
@ -184,6 +389,20 @@ typedef struct {
BOOLEAN HasAlpha; //moved here to avoid alignment issue
} 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
class EG_RECT {
public:

View File

@ -92,21 +92,6 @@ extern EFI_RUNTIME_SERVICES* gRT;
// 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_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)
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
/*
typedef enum {
NoEvents,
Move,
@ -260,7 +204,7 @@ typedef enum {
RightMouseDown,
MouseMove
} MOUSE_EVENT;
*/
typedef struct _pointers {
EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
EG_IMAGE *Pointer;
@ -276,57 +220,11 @@ typedef struct _pointers {
} POINTERS;
//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.
#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 EG_RECT UpButton;
extern EG_RECT DownButton;
@ -477,96 +375,13 @@ typedef struct {
} REFIT_CONFIG;
// 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)
//some unreal values
#define SCREEN_EDGE_LEFT 50000
#define SCREEN_EDGE_TOP 60000
#define SCREEN_EDGE_RIGHT 70000
#define SCREEN_EDGE_BOTTOM 80000
/*
typedef struct GUI_ANIME GUI_ANIME;
struct GUI_ANIME {
UINTN ID;
@ -580,7 +395,7 @@ struct GUI_ANIME {
BOOLEAN Once;
GUI_ANIME *Next;
};
*/
extern EFI_HANDLE SelfImageHandle;
extern EFI_HANDLE SelfDeviceHandle;
extern EFI_LOADED_IMAGE *SelfLoadedImage;

View File

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