2020-03-12 10:47:59 +01:00
|
|
|
#if !defined(__XTHEME_H__)
|
2020-03-13 14:34:36 +01:00
|
|
|
#define __XTHEME_H__
|
|
|
|
|
2020-03-12 10:47:59 +01:00
|
|
|
#include "../cpp_foundation/XObjArray.h"
|
2020-03-16 12:15:25 +01:00
|
|
|
#include "../cpp_foundation/XString.h"
|
2020-03-13 14:34:36 +01:00
|
|
|
#include "libeg.h"
|
2020-03-26 21:32:31 +01:00
|
|
|
//#include "nanosvg.h"
|
2020-03-26 18:00:53 +01:00
|
|
|
#include "XImage.h"
|
2020-08-11 14:43:53 +02:00
|
|
|
#include "XIcon.h"
|
2020-04-13 21:01:40 +02:00
|
|
|
#include "XCinema.h"
|
2020-10-03 19:02:31 +02:00
|
|
|
#include "Self.h"
|
2020-03-26 18:00:53 +01:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
class TagDict;
|
|
|
|
|
2020-08-19 14:50:26 +02:00
|
|
|
class TagStruct;
|
|
|
|
|
2020-03-18 07:39:11 +01:00
|
|
|
#define INDICATOR_SIZE (52)
|
|
|
|
|
2020-03-13 14:34:36 +01:00
|
|
|
class XTheme
|
|
|
|
{
|
|
|
|
public:
|
2020-05-16 21:30:29 +02:00
|
|
|
XObjArray<XIcon> Icons;
|
2020-10-03 19:02:31 +02:00
|
|
|
protected:
|
2020-10-20 09:55:46 +02:00
|
|
|
XStringW m_ThemePath = NullXStringW;
|
2020-03-17 20:43:58 +01:00
|
|
|
EFI_FILE *ThemeDir;
|
2020-03-13 14:34:36 +01:00
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
public:
|
|
|
|
void openThemeDir() {
|
|
|
|
if ( ThemeDir != NULL ) ThemeDir->Close(ThemeDir);
|
|
|
|
/*Status = */self.getCloverDir().Open(&self.getCloverDir(), &ThemeDir, m_ThemePath.wc_str(), EFI_FILE_MODE_READ, 0);
|
|
|
|
}
|
|
|
|
void closeThemeDir() {
|
|
|
|
if ( ThemeDir != NULL ) ThemeDir->Close(ThemeDir);
|
|
|
|
ThemeDir = NULL;
|
|
|
|
}
|
|
|
|
// const XStringW& getThemePath() { return m_ThemePath; }
|
|
|
|
// void setThemePath(const XStringW& aThemePath) {
|
|
|
|
// m_ThemePath = aThemePath;
|
|
|
|
// closeThemeDir();
|
|
|
|
// openThemeDir();
|
|
|
|
// }
|
|
|
|
const EFI_FILE& getThemeDir() {
|
|
|
|
return *ThemeDir;
|
|
|
|
}
|
|
|
|
bool IsEmbeddedTheme(void)
|
|
|
|
{
|
|
|
|
if (embedded) {
|
|
|
|
ThemeDir = NULL;
|
|
|
|
}
|
|
|
|
return ThemeDir == NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
2020-03-27 17:50:17 +01:00
|
|
|
// UINTN DisableFlags;
|
2020-03-12 10:47:59 +01:00
|
|
|
UINTN HideBadges;
|
|
|
|
UINTN HideUIFlags;
|
2020-03-27 20:47:06 +01:00
|
|
|
// BOOLEAN TextOnly;
|
2020-03-12 10:47:59 +01:00
|
|
|
FONT_TYPE Font;
|
|
|
|
INTN CharWidth;
|
|
|
|
UINTN SelectionColor;
|
|
|
|
XStringW FontFileName;
|
|
|
|
XStringW Theme;
|
|
|
|
XStringW BannerFileName;
|
|
|
|
XStringW SelectionSmallFileName;
|
|
|
|
XStringW SelectionBigFileName;
|
|
|
|
XStringW SelectionIndicatorName;
|
|
|
|
XStringW DefaultSelection;
|
|
|
|
XStringW BackgroundName;
|
|
|
|
SCALING BackgroundScale;
|
2020-03-26 15:24:20 +01:00
|
|
|
INTN BackgroundSharp;
|
2020-03-12 10:47:59 +01:00
|
|
|
BOOLEAN BackgroundDark;
|
2020-03-27 17:50:17 +01:00
|
|
|
// BOOLEAN CustomIcons;
|
2020-03-12 10:47:59 +01:00
|
|
|
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;
|
2020-03-12 15:00:36 +01:00
|
|
|
// INTN IconFormat;
|
2020-03-12 10:47:59 +01:00
|
|
|
BOOLEAN Proportional;
|
2020-03-27 17:50:17 +01:00
|
|
|
// BOOLEAN ShowOptimus;
|
2020-03-29 18:17:27 +02:00
|
|
|
BOOLEAN embedded;
|
2020-03-12 10:47:59 +01:00
|
|
|
BOOLEAN DarkEmbedded;
|
|
|
|
BOOLEAN TypeSVG;
|
2020-04-08 11:45:36 +02:00
|
|
|
// INTN Codepage; //no! it is global settings
|
|
|
|
// INTN CodepageSize;
|
2020-03-12 10:47:59 +01:00
|
|
|
float Scale;
|
2020-03-13 14:34:36 +01:00
|
|
|
float CentreShift;
|
2020-03-20 18:48:19 +01:00
|
|
|
INTN row0TileSize;
|
|
|
|
INTN row1TileSize;
|
2020-04-04 05:46:41 +02:00
|
|
|
INTN BanHeight;
|
2020-03-20 18:48:19 +01:00
|
|
|
INTN LayoutHeight; //it was 376 before
|
2020-03-26 15:24:20 +01:00
|
|
|
INTN LayoutBannerOffset;
|
|
|
|
INTN LayoutButtonOffset;
|
|
|
|
INTN LayoutTextOffset;
|
|
|
|
INTN LayoutAnimMoveForMenuX;
|
2020-04-02 16:03:58 +02:00
|
|
|
INTN ScrollWidth;
|
|
|
|
INTN ScrollButtonsHeight;
|
|
|
|
INTN ScrollBarDecorationsHeight;
|
|
|
|
INTN ScrollScrollDecorationsHeight;
|
|
|
|
|
2020-03-26 15:24:20 +01:00
|
|
|
|
2020-04-07 21:48:36 +02:00
|
|
|
INTN FontWidth;
|
|
|
|
INTN FontHeight;
|
|
|
|
INTN TextHeight;
|
|
|
|
|
2020-03-20 18:48:19 +01:00
|
|
|
BOOLEAN Daylight;
|
2020-03-13 14:34:36 +01:00
|
|
|
|
|
|
|
XImage Background; //Background and Banner will not be in array as they live own life
|
2020-03-17 05:25:38 +01:00
|
|
|
XImage BigBack; //it size is not equal to screen size will be scaled or cropped
|
|
|
|
XImage Banner; //same as logo in the array, make a link?
|
2020-03-20 18:48:19 +01:00
|
|
|
XImage SelectionImages[6];
|
2020-03-23 15:51:20 +01:00
|
|
|
XImage Buttons[4];
|
2020-03-20 18:48:19 +01:00
|
|
|
XImage ScrollbarBackgroundImage;
|
|
|
|
XImage BarStartImage;
|
|
|
|
XImage BarEndImage;
|
|
|
|
XImage ScrollbarImage;
|
|
|
|
XImage ScrollStartImage;
|
|
|
|
XImage ScrollEndImage;
|
|
|
|
XImage UpButtonImage;
|
|
|
|
XImage DownButtonImage;
|
2020-03-13 14:34:36 +01:00
|
|
|
|
2020-04-07 21:48:36 +02:00
|
|
|
XImage FontImage;
|
|
|
|
|
2020-04-04 05:46:41 +02:00
|
|
|
EG_RECT BannerPlace;
|
2020-04-16 06:45:53 +02:00
|
|
|
|
2020-04-13 21:01:40 +02:00
|
|
|
XCinema Cinema;
|
2020-04-16 06:45:53 +02:00
|
|
|
|
2020-04-14 18:52:13 +02:00
|
|
|
void *SVGParser;
|
2020-08-11 14:43:53 +02:00
|
|
|
|
|
|
|
void Init();
|
|
|
|
XTheme(); //default constructor
|
|
|
|
XTheme(const XTheme&) = delete;
|
|
|
|
XTheme& operator=(const XTheme&) = delete;
|
|
|
|
|
|
|
|
~XTheme();
|
|
|
|
|
|
|
|
|
2020-03-17 05:25:38 +01:00
|
|
|
//fill the theme
|
2020-04-05 14:25:39 +02:00
|
|
|
// const XImage& GetIcon(const char* Name);
|
|
|
|
// const XImage& GetIcon(const CHAR16* Name);
|
2020-05-16 21:30:29 +02:00
|
|
|
const XIcon& GetIcon(const XString8& Name); //get by name
|
2020-05-23 13:16:02 +02:00
|
|
|
XIcon* GetIconP(const XString8& Name);
|
2020-05-16 21:30:29 +02:00
|
|
|
const XIcon& GetIcon(INTN Id); //get by id
|
2020-05-23 13:16:02 +02:00
|
|
|
XIcon* GetIconP(INTN Id); //not const
|
|
|
|
XIcon& GetIconAlt(INTN Id, INTN Alt); //if id not found
|
2020-05-16 21:30:29 +02:00
|
|
|
const XIcon& LoadOSIcon(const CHAR16* OSIconName); //TODO make XString provider
|
|
|
|
const XIcon& LoadOSIcon(const XString8& Full);
|
2020-04-18 08:39:47 +02:00
|
|
|
bool CheckNative(INTN Id);
|
2020-05-16 21:30:29 +02:00
|
|
|
|
2020-04-07 21:48:36 +02:00
|
|
|
//fonts
|
|
|
|
void LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols);
|
|
|
|
void PrepareFont();
|
2020-04-22 01:27:01 +02:00
|
|
|
INTN GetEmpty(const XImage& Buffer, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& FirstPixel, INTN MaxWidth, INTN Start, INTN Step);
|
2020-04-07 21:48:36 +02:00
|
|
|
INTN RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
|
2020-04-15 23:04:33 +02:00
|
|
|
IN INTN PosX, IN INTN PosY, IN UINTN Cursor, INTN textType, float textScale = 0.f);
|
2020-04-08 11:45:36 +02:00
|
|
|
//overload for UTF8 text
|
2020-04-30 08:03:56 +02:00
|
|
|
INTN RenderText(IN const XString8& Text, OUT XImage* CompImage_ptr,
|
2020-04-15 23:04:33 +02:00
|
|
|
IN INTN PosX, IN INTN PosY, IN UINTN Cursor, INTN textType, float textScale = 0.f);
|
2020-10-03 19:02:31 +02:00
|
|
|
void MeasureText(IN const XStringW& Text, OUT INTN *Width, OUT INTN *Height);
|
2020-04-07 21:48:36 +02:00
|
|
|
|
|
|
|
|
2020-05-16 21:30:29 +02:00
|
|
|
// void AddIcon(XIcon& NewIcon); //return EFI_STATUS?
|
2020-03-16 12:15:25 +01:00
|
|
|
void FillByEmbedded();
|
2020-03-21 12:43:45 +01:00
|
|
|
void FillByDir();
|
2020-08-25 17:35:19 +02:00
|
|
|
EFI_STATUS GetThemeTagSettings(const TagDict* DictPointer);
|
2020-03-26 21:32:31 +01:00
|
|
|
void parseTheme(void* p, const char** dict); //in nano project
|
2020-04-06 11:15:36 +02:00
|
|
|
EFI_STATUS ParseSVGXTheme(const CHAR8* buffer); // in VectorTheme
|
2020-05-14 09:03:06 +02:00
|
|
|
EFI_STATUS ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image, void **SVGIcon);
|
2020-08-25 17:35:19 +02:00
|
|
|
TagDict* LoadTheme(const XStringW& TestTheme); //return TagStruct* why?
|
2020-04-14 18:52:13 +02:00
|
|
|
EFI_STATUS LoadSvgFrame(INTN i, OUT XImage* XFrame); // for animation
|
2020-03-17 05:25:38 +01:00
|
|
|
|
|
|
|
//screen operations
|
|
|
|
void ClearScreen();
|
2020-03-17 20:43:58 +01:00
|
|
|
void FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height);
|
2020-04-05 16:04:39 +02:00
|
|
|
// void InitSelection();
|
2020-03-20 18:48:19 +01:00
|
|
|
void InitBar();
|
2020-03-16 12:15:25 +01:00
|
|
|
|
2020-03-13 14:34:36 +01:00
|
|
|
protected:
|
|
|
|
//internal layout variables instead of globals in menu.cpp
|
|
|
|
|
|
|
|
};
|
2020-03-16 20:47:02 +01:00
|
|
|
#endif
|