mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-02-23 02:11:54 +01:00
advance xtheme invention
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
81286c08b1
commit
d79dcb5f9e
@ -2189,7 +2189,7 @@ ParseXML (
|
||||
UINT32 bufSize
|
||||
);
|
||||
|
||||
EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize);
|
||||
EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict);
|
||||
//VOID RenderSVGfont(NSVGfont *fontSVG);
|
||||
|
||||
TagPtr
|
||||
|
@ -4172,7 +4172,7 @@ LoadTheme (CHAR16 *TestTheme)
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = egLoadFile(ThemeDir, CONFIG_THEME_SVG, (UINT8**)&ThemePtr, &Size);
|
||||
if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) {
|
||||
Status = ParseSVGTheme((const CHAR8*)ThemePtr, &ThemeDict, 0);
|
||||
Status = ParseSVGTheme((const CHAR8*)ThemePtr, &ThemeDict);
|
||||
if (EFI_ERROR(Status)) {
|
||||
ThemeDict = NULL;
|
||||
}
|
||||
@ -4222,6 +4222,8 @@ InitTheme(
|
||||
GlobalConfig.TypeSVG = FALSE;
|
||||
GlobalConfig.BootCampStyle = FALSE;
|
||||
GlobalConfig.Scale = 1.0f;
|
||||
GlobalConfig.BannerPosX = 0;
|
||||
GlobalConfig.BannerPosY = 0;
|
||||
|
||||
if (DayLight) {
|
||||
DBG("use daylight theme\n");
|
||||
|
@ -5,6 +5,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define TEST_MATH 0
|
||||
#define TEST_SVG_IMAGE 1
|
||||
#define TEST_SIZEOF 0
|
||||
#define TEST_FONT 0
|
||||
#define TEST_DITHER 0
|
||||
#define USE_XTHEME 0
|
||||
|
||||
|
||||
#include "nanosvg.h"
|
||||
#include "FloatLib.h"
|
||||
@ -24,11 +31,11 @@
|
||||
#define DBG(...) DebugLog(DEBUG_VEC, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define TEST_MATH 0
|
||||
#define TEST_SVG_IMAGE 1
|
||||
#define TEST_SIZEOF 0
|
||||
#define TEST_FONT 0
|
||||
#define TEST_DITHER 0
|
||||
#if USE_XTHEME
|
||||
#include "XTheme.h"
|
||||
XTheme Theme; //later this definition will be global
|
||||
#endif
|
||||
|
||||
|
||||
#define NSVG_RGB(r, g, b) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16))
|
||||
//#define NSVG_RGBA(r, g, b, a) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16) | ((unsigned int)a << 24))
|
||||
@ -51,6 +58,13 @@ extern BOOLEAN DayLight;
|
||||
textFaces textFace[4]; //0-help 1-message 2-menu 3-test
|
||||
NSVGparser *mainParser = NULL; //it must be global variable
|
||||
|
||||
#if USE_XTHEME
|
||||
EFI_STATUS ParseSVGXIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float Scale, XImage& Image)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
EFI_STATUS ParseSVGIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float Scale, EG_IMAGE **Image)
|
||||
{
|
||||
@ -226,7 +240,7 @@ EFI_STATUS ParseSVGIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float Sc
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize)
|
||||
EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
NSVGimage *SVGimage;
|
||||
@ -421,7 +435,7 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize)
|
||||
GlobalConfig.MainEntriesSize = (INTN)(128.f * Scale);
|
||||
}
|
||||
DBG("parsing theme finish\n");
|
||||
#if 1 //dump fonts
|
||||
#if 0 //dump fonts
|
||||
{
|
||||
NSVGfont *fontSVG = NULL;
|
||||
NSVGfontChain *fontChain = fontsDB;
|
||||
@ -441,6 +455,60 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
#if USE_XTHEME
|
||||
EFI_STATUS ParseSVGXTheme(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=%a\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 %s\n", PoolPrintFloat(Scale));
|
||||
Theme.Scale = Scale;
|
||||
Theme.CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f;
|
||||
|
||||
if (mainParser->font) {
|
||||
DBG("theme contains font-family=%a\n", mainParser->font->fontFamily);
|
||||
}
|
||||
|
||||
Theme.Background = XImage(UGAWidth, UGAHeight);
|
||||
if (!Theme.BigBack.isEmpty()) {
|
||||
Theme.BigBack.setEmpty:
|
||||
}
|
||||
Status = EFI_NOT_FOUND;
|
||||
if (!DayLight) {
|
||||
Status = ParseSVGXIcon(mainParser, BUILTIN_ICON_BACKGROUND, "Background_night", Scale, &Theme.BigBack);
|
||||
}
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = ParseSVGXIcon(mainParser, BUILTIN_ICON_BACKGROUND, "Background", Scale, &Theme.BigBack);
|
||||
}
|
||||
DBG("background parsed\n");
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
EG_IMAGE * LoadSvgFrame(INTN i)
|
||||
{
|
||||
EG_IMAGE *Frame = NULL;
|
||||
|
@ -1,30 +1,30 @@
|
||||
#if !defined(__XTHEME_H__)
|
||||
#define __XTHEME_H__
|
||||
|
||||
#define __XTHEME_H__
|
||||
|
||||
#include "../cpp_foundation/XToolsCommon.h"
|
||||
#include "../cpp_foundation/XObjArray.h"
|
||||
#include "../cpp_foundation/XStringW.h"
|
||||
#include "libeg.h"
|
||||
#include "XImage.h"
|
||||
|
||||
class Icon
|
||||
{
|
||||
public:
|
||||
INTN Id; //for example BUILTIN_ICON_POINTER
|
||||
XStringW Name; //for example "os_moja", "vol_internal"
|
||||
XImage ImageNight;
|
||||
XImage Image;
|
||||
|
||||
Icon();
|
||||
~Icon();
|
||||
|
||||
};
|
||||
|
||||
class XTheme
|
||||
{
|
||||
public:
|
||||
XObjArray<Icon> Icons;
|
||||
|
||||
#include "libeg.h"
|
||||
#include "XImage.h"
|
||||
|
||||
class Icon
|
||||
{
|
||||
public:
|
||||
INTN Id; //for example BUILTIN_ICON_POINTER
|
||||
XStringW Name; //for example "os_moja", "vol_internal"
|
||||
XImage ImageNight;
|
||||
XImage Image;
|
||||
|
||||
Icon();
|
||||
~Icon();
|
||||
|
||||
};
|
||||
|
||||
class XTheme
|
||||
{
|
||||
public:
|
||||
XObjArray<Icon> Icons;
|
||||
|
||||
UINTN DisableFlags;
|
||||
UINTN HideBadges;
|
||||
UINTN HideUIFlags;
|
||||
@ -70,21 +70,22 @@ public:
|
||||
INTN Codepage;
|
||||
INTN CodepageSize;
|
||||
float Scale;
|
||||
float CentreShift;
|
||||
|
||||
XImage Background; //Background and Banner will not be in array as they live own life
|
||||
XImage Banner;
|
||||
|
||||
XImage& GetIcon(XStringW& Name, BOOLEAN Night); //get by name
|
||||
XImage& GetIcon(INTN Id, BOOLEAN Night); //get by id
|
||||
|
||||
void AddIcon(Icon& NewIcon); //return EFI_STATUS?
|
||||
|
||||
XTheme(); //default constructor
|
||||
~XTheme();
|
||||
|
||||
protected:
|
||||
//internal layout variables instead of globals in menu.cpp
|
||||
|
||||
};
|
||||
float CentreShift;
|
||||
|
||||
XImage Background; //Background and Banner will not be in array as they live own life
|
||||
XImage BigBack; //not sure is needed
|
||||
XImage Banner;
|
||||
|
||||
XImage& GetIcon(XStringW& Name, BOOLEAN Night); //get by name
|
||||
XImage& GetIcon(INTN Id, BOOLEAN Night); //get by id
|
||||
|
||||
void AddIcon(Icon& NewIcon); //return EFI_STATUS?
|
||||
|
||||
XTheme(); //default constructor
|
||||
~XTheme();
|
||||
|
||||
protected:
|
||||
//internal layout variables instead of globals in menu.cpp
|
||||
|
||||
};
|
||||
#endif
|
@ -2023,9 +2023,12 @@ static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
|
||||
if (strstr(value, "italic") != NULL) {
|
||||
DBG("it is italic\n");
|
||||
attr->fontFace->fontStyle = 'i';
|
||||
} else if (strstr(value, "bold") != NULL) {
|
||||
} else if (strstr(value, "bold") != NULL) {
|
||||
DBG("it is bold\n");
|
||||
attr->fontFace->fontStyle = 'b';
|
||||
} else if (strstr(value, "light") != NULL) {
|
||||
DBG("it is light\n");
|
||||
attr->fontFace->fontStyle = 'l';
|
||||
} else {
|
||||
DBG("it is other\n");
|
||||
attr->fontFace->fontStyle = 'n';
|
||||
@ -2765,6 +2768,8 @@ static void nsvg__parseTextSpan(NSVGparser* p, const char** dict)
|
||||
text->fontStyle = 'i';
|
||||
} else if (strstr(dict[i+1], "bold") != NULL) {
|
||||
text->fontStyle = 'b';
|
||||
} else if (strstr(dict[i + 1], "light") != NULL) {
|
||||
text->fontStyle = 'l';
|
||||
} else {
|
||||
text->fontStyle = 'n';
|
||||
}
|
||||
@ -3606,8 +3611,10 @@ static void nsvg__parseFontFace(NSVGparser* p, const char** dict)
|
||||
font->fontStyle = 'i';
|
||||
} else if (strstr(dict[i+1], "bold") != NULL) {
|
||||
font->fontStyle = 'b';
|
||||
} else if (strstr(dict[i + 1], "light") != NULL) {
|
||||
font->fontStyle = 'l';
|
||||
} else {
|
||||
font->fontStyle = 'n';
|
||||
font->fontStyle = 'n'; //normal
|
||||
}
|
||||
}
|
||||
else if (strcmp(dict[i], "units-per-em") == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user