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-04-13 21:01:40 +02:00
|
|
|
#include "XCinema.h"
|
2020-03-26 18:00:53 +01:00
|
|
|
|
2020-04-23 13:36:35 +02:00
|
|
|
extern const INTN IconsNamesSize;
|
2020-03-18 07:39:11 +01:00
|
|
|
#define INDICATOR_SIZE (52)
|
|
|
|
|
2020-05-16 21:30:29 +02:00
|
|
|
class XIcon
|
2020-03-13 14:34:36 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
INTN Id; //for example BUILTIN_ICON_POINTER
|
2020-04-30 08:03:56 +02:00
|
|
|
XString8 Name; //for example "os_moja", "vol_internal"
|
2020-03-13 14:34:36 +01:00
|
|
|
XImage Image;
|
2020-03-18 07:39:11 +01:00
|
|
|
XImage ImageNight;
|
2020-04-18 08:39:47 +02:00
|
|
|
bool Native;
|
2020-05-14 09:03:06 +02:00
|
|
|
void *ImageSVG; //NSVGimage*
|
|
|
|
void *ImageSVGnight;
|
2020-05-16 21:30:29 +02:00
|
|
|
protected:
|
|
|
|
bool Empty;
|
|
|
|
public:
|
|
|
|
XIcon(): Id(0), Name(), Image(), ImageNight(), Native(false), ImageSVG(nullptr), ImageSVGnight(nullptr), Empty(true)
|
2020-05-15 10:17:06 +02:00
|
|
|
{};
|
2020-05-16 21:30:29 +02:00
|
|
|
XIcon(INTN Id, bool Embedded = false);
|
|
|
|
~XIcon();
|
|
|
|
|
|
|
|
bool isEmpty() const { return Empty; }
|
|
|
|
void setFilled() { Empty = false; }
|
|
|
|
void setEmpty() { Empty = true; }
|
|
|
|
|
|
|
|
EFI_STATUS LoadXImage(EFI_FILE *Dir, const XStringW& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);
|
|
|
|
EFI_STATUS LoadXImage(EFI_FILE *Dir, const wchar_t* LIconName);
|
|
|
|
EFI_STATUS LoadXImage(EFI_FILE *Dir, const char* IconName);
|
2020-03-13 14:34:36 +01:00
|
|
|
|
2020-04-02 21:27:10 +02:00
|
|
|
// Default are not valid, as usual. We delete them. If needed, proper ones can be created
|
2020-05-15 10:17:06 +02:00
|
|
|
// Icon(const Icon&) = delete;
|
2020-05-16 21:30:29 +02:00
|
|
|
XIcon& operator=(const XIcon&); // = delete;
|
2020-04-05 23:14:27 +02:00
|
|
|
void GetEmbedded();
|
2020-05-16 21:30:29 +02:00
|
|
|
const XImage& GetBest(bool night) const;
|
2020-03-13 14:34:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class XTheme
|
|
|
|
{
|
|
|
|
public:
|
2020-05-16 21:30:29 +02:00
|
|
|
XObjArray<XIcon> Icons;
|
2020-03-17 20:43:58 +01:00
|
|
|
EFI_FILE *ThemeDir;
|
2020-03-13 14:34:36 +01:00
|
|
|
|
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-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
|
|
|
|
const XIcon& GetIcon(INTN Id); //get by id
|
|
|
|
const XIcon& GetIconAlt(INTN Id, INTN Alt); //if id not found
|
|
|
|
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-04-08 12:04:54 +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-04-03 22:00:42 +02:00
|
|
|
EFI_STATUS GetThemeTagSettings(void* 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-04-03 22:00:42 +02:00
|
|
|
void* LoadTheme(const CHAR16 *TestTheme); //return TagPtr 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-20 18:48:19 +01:00
|
|
|
void Init();
|
|
|
|
XTheme(); //default constructor
|
2020-03-13 14:34:36 +01:00
|
|
|
~XTheme();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
//internal layout variables instead of globals in menu.cpp
|
|
|
|
|
|
|
|
};
|
2020-03-16 20:47:02 +01:00
|
|
|
#endif
|