mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
some advance in xtheme support
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
629baca0ee
commit
9ec0c457f5
@ -326,7 +326,19 @@ STATIC void CreateInfoLines(IN CONST CHAR16 *Message, OUT XStringWArray* Informa
|
||||
|
||||
extern REFIT_MENU_ITEM_RETURN MenuEntryReturn;
|
||||
|
||||
//STATIC REFIT_MENU_ENTRY *AlertMessageEntries[] = { &MenuEntryReturn };
|
||||
|
||||
// it is not good to use Options menu style for messages and one line dialogs
|
||||
// it can be a semitransparent rectangular at the screen centre as it was in Clover v1.0
|
||||
#if USE_XTHEME
|
||||
STATIC REFIT_MENU_SCREEN AlertMessageMenu(0, XStringW(), XStringW(), &MenuEntryReturn, NULL);
|
||||
VOID AlertMessage(IN XStringW& Title, IN XStringW& Message)
|
||||
{
|
||||
CreateInfoLines(Message.data(), &AlertMessageMenu.InfoLines);
|
||||
AlertMessageMenu.Title = Title;
|
||||
AlertMessageMenu.RunMenu(NULL);
|
||||
AlertMessageMenu.InfoLines.Empty();
|
||||
}
|
||||
#else
|
||||
STATIC REFIT_MENU_SCREEN AlertMessageMenu(0, NULL, NULL, &MenuEntryReturn, NULL);
|
||||
|
||||
// Display an alert message
|
||||
@ -351,6 +363,7 @@ VOID AlertMessage(IN CONST CHAR16 *Title, IN CONST CHAR16 *Message)
|
||||
// }
|
||||
AlertMessageMenu.InfoLines.Empty();
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TAG_YES 1
|
||||
#define TAG_NO 2
|
||||
@ -360,8 +373,11 @@ STATIC REFIT_SIMPLE_MENU_ENTRY_TAG YesMessageEntry = { XStringWP(L"Yes"), TAG_
|
||||
STATIC REFIT_SIMPLE_MENU_ENTRY_TAG NoMessageEntry = { XStringWP(L"No"), TAG_NO, ActionEnter };
|
||||
|
||||
//REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
|
||||
#if USE_XTHEME
|
||||
STATIC REFIT_MENU_SCREEN YesNoMessageMenu(0, XStringW(), XStringW(), &YesMessageEntry, &NoMessageEntry);
|
||||
#else
|
||||
STATIC REFIT_MENU_SCREEN YesNoMessageMenu(0, NULL, NULL, &YesMessageEntry, &NoMessageEntry);
|
||||
|
||||
#endif
|
||||
// Display a yes/no prompt
|
||||
BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CONST CHAR16 *Message)
|
||||
{
|
||||
@ -411,8 +427,11 @@ BOOLEAN AskUserForFilePathFromDir(IN CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Vo
|
||||
//STATIC REFIT_MENU_SCREEN InitialMenu = {0, L"Please Select File...", NULL, 0, NULL,
|
||||
// 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
|
||||
// { 0, 0, 0, 0 }, NULL};
|
||||
#if USE_XTHEME
|
||||
STATIC REFIT_MENU_SCREEN InitialMenu(0, XStringWP(L"Please Select File..."), XStringW());
|
||||
#else
|
||||
STATIC REFIT_MENU_SCREEN InitialMenu(0, L"Please Select File...", NULL);
|
||||
|
||||
#endif
|
||||
// Ask user for file path from volumes menu
|
||||
BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **Result)
|
||||
{
|
||||
|
@ -109,9 +109,15 @@ STATIC REFIT_MENU_ENTRY QueryEntry[] = {
|
||||
{ L"Insert authentication into database", SECURE_BOOT_POLICY_INSERT, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },
|
||||
};
|
||||
STATIC REFIT_MENU_ENTRY *QueryEntries[] = { QueryEntry, QueryEntry + 1, QueryEntry + 2 };
|
||||
#if USE_XTHEME
|
||||
STATIC REFIT_MENU_SCREEN QueryUserMenu = { 0, XStringWP(L"Secure Boot Authentication"), XStringWP(), 3, NULL, 2, QueryEntries,
|
||||
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
|
||||
/* FILM_CENTRE, FILM_CENTRE,*/ { 0, 0, 0, 0 }, NULL };
|
||||
#else
|
||||
STATIC REFIT_MENU_SCREEN QueryUserMenu = { 0, L"Secure Boot Authentication", NULL, 3, NULL, 2, QueryEntries,
|
||||
0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
|
||||
/* FILM_CENTRE, FILM_CENTRE,*/ { 0, 0, 0, 0 }, NULL };
|
||||
#endif
|
||||
|
||||
// Query the secure boot user what to do with image
|
||||
UINTN QuerySecureBootUser(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||
|
@ -70,14 +70,19 @@ public:
|
||||
XStringW Title;
|
||||
XImage TitleImage;
|
||||
#else
|
||||
CONST CHAR16 *Title; //Title is not const, but *Title is. It will be better to make it XStringW
|
||||
CONST CHAR16 *Title; //Title is not const, but *Title is. It will be better to make it XStringW
|
||||
EG_IMAGE *TitleImage;
|
||||
#endif
|
||||
XStringWArray InfoLines;
|
||||
XObjArray<REFIT_ABSTRACT_MENU_ENTRY> Entries;
|
||||
INTN TimeoutSeconds;
|
||||
#if USE_XTHEME
|
||||
XStringW TimeoutText;
|
||||
XStringW ThemeName;
|
||||
#else
|
||||
CONST CHAR16 *TimeoutText;
|
||||
CONST CHAR16 *Theme;
|
||||
#endif
|
||||
BOOLEAN AnimeRun;
|
||||
BOOLEAN Once;
|
||||
UINT64 LastDraw;
|
||||
@ -108,15 +113,34 @@ public:
|
||||
EG_RECT ScrollbarNewPointerPlace;
|
||||
*/
|
||||
|
||||
|
||||
#if USE_XTHEME
|
||||
REFIT_MENU_SCREEN()
|
||||
: ID(0), Title(0), TitleImage(0),
|
||||
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
|
||||
: ID(0), Title(), TitleImage(),
|
||||
TimeoutSeconds(0), TimeoutText(), ThemeName(), AnimeRun(0),
|
||||
Once(0), LastDraw(0), CurrentFrame(0),
|
||||
Frames(0), FrameTime(0),
|
||||
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
{};
|
||||
#else
|
||||
REFIT_MENU_SCREEN()
|
||||
: ID(0), Title(0), TitleImage(0),
|
||||
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
|
||||
Once(0), LastDraw(0), CurrentFrame(0),
|
||||
Frames(0), FrameTime(0),
|
||||
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
||||
#if USE_XTHEME
|
||||
REFIT_MENU_SCREEN(UINTN ID, XStringW& Title, XStringW& TimeoutText)
|
||||
: ID(ID), Title(Title), TitleImage(),
|
||||
TimeoutSeconds(0), TimeoutText(TimeoutText), ThemeName(), AnimeRun(0),
|
||||
Once(0), LastDraw(0), CurrentFrame(0),
|
||||
Frames(0), FrameTime(0),
|
||||
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
{};
|
||||
#else
|
||||
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText)
|
||||
: ID(ID), Title(Title), TitleImage(0),
|
||||
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
|
||||
@ -124,6 +148,20 @@ public:
|
||||
Frames(0), FrameTime(0),
|
||||
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
{};
|
||||
#endif
|
||||
|
||||
#if USE_XTHEME
|
||||
REFIT_MENU_SCREEN(UINTN ID, XStringW& Title, XStringW& TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
|
||||
: ID(ID), Title(Title), TitleImage(),
|
||||
TimeoutSeconds(0), TimeoutText(TimeoutText), ThemeName(), AnimeRun(0),
|
||||
Once(0), LastDraw(0), CurrentFrame(0),
|
||||
Frames(0), FrameTime(0),
|
||||
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
{
|
||||
Entries.AddReference(entry1, false);
|
||||
Entries.AddReference(entry2, false);
|
||||
};
|
||||
#else
|
||||
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
|
||||
: ID(ID), Title(Title), TitleImage(0),
|
||||
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
|
||||
@ -131,9 +169,10 @@ public:
|
||||
Frames(0), FrameTime(0),
|
||||
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
{
|
||||
Entries.AddReference(entry1, false);
|
||||
Entries.AddReference(entry2, false);
|
||||
Entries.AddReference(entry1, false);
|
||||
Entries.AddReference(entry2, false);
|
||||
};
|
||||
#endif
|
||||
|
||||
//Scroll functions
|
||||
VOID InitScroll(IN INTN ItemCount, IN UINTN MaxCount,
|
||||
|
@ -746,10 +746,14 @@ VOID RenderSVGfont(NSVGfont *fontSVG, UINT32 color)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// it is not draw, it is render and mainly used in egRenderText
|
||||
// which is used in icns.cpp as an icon rplacement if no image found, looks like not used
|
||||
// in menu.cpp 3 places
|
||||
//textType = 0-help 1-message 2-menu 3-test
|
||||
//return text width in pixels
|
||||
#if USE_XTHEME
|
||||
INTN drawSVGtext(XImage& TextBufferXY, INTN posX, INTN posY, INTN textType, XString& string, UINTN Cursor)
|
||||
INTN renderSVGtext(XImage& TextBufferXY, INTN posX, INTN posY, INTN textType, XString& string, UINTN Cursor)
|
||||
{
|
||||
INTN Width;
|
||||
UINTN i;
|
||||
@ -774,7 +778,7 @@ INTN drawSVGtext(XImage& TextBufferXY, INTN posX, INTN posY, INTN textType, XStr
|
||||
float Scale, sy;
|
||||
float x, y;
|
||||
if (!fontSVG) {
|
||||
DBG("no font for drawSVGtext\n");
|
||||
DBG("no font for renderSVGtext\n");
|
||||
return 0;
|
||||
}
|
||||
p = nsvg__createParser();
|
||||
@ -836,7 +840,7 @@ INTN drawSVGtext(XImage& TextBufferXY, INTN posX, INTN posY, INTN textType, XStr
|
||||
|
||||
}
|
||||
#else
|
||||
INTN drawSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* string, UINTN Cursor)
|
||||
INTN renderSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* string, UINTN Cursor)
|
||||
{
|
||||
INTN Width;
|
||||
UINTN i;
|
||||
@ -861,7 +865,7 @@ INTN drawSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CO
|
||||
float Scale, sy;
|
||||
float x, y;
|
||||
if (!fontSVG) {
|
||||
DBG("no font for drawSVGtext\n");
|
||||
DBG("no font for renderSVGtext\n");
|
||||
return 0;
|
||||
}
|
||||
if (!TextBufferXY) {
|
||||
@ -908,7 +912,7 @@ INTN drawSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CO
|
||||
y = (float)posY + fontSVG->bbox[1] * Scale;
|
||||
p->isText = TRUE;
|
||||
|
||||
//DBG("drawSVGtext -> Enter. Text=%a\n", XString(string).c);
|
||||
//DBG("renderSVGtext -> Enter. Text=%a\n", XString(string).c);
|
||||
for (i=0; i < len; i++) {
|
||||
CHAR16 letter = string[i];
|
||||
|
||||
@ -1066,7 +1070,11 @@ VOID testSVG()
|
||||
Height = 80;
|
||||
Width = UGAWidth-200;
|
||||
DBG("create test textbuffer\n");
|
||||
#if USE_XTHEME
|
||||
XImage TextBufferXY(Width, Height);
|
||||
#else
|
||||
EG_IMAGE* TextBufferXY = egCreateFilledImage(Width, Height, TRUE, &MenuBackgroundPixel);
|
||||
#endif
|
||||
Status = egLoadFile(SelfRootDir, L"Font.svg", &FileData, &FileDataLength);
|
||||
DBG("test Font.svg loaded status=%r\n", Status);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
@ -1082,14 +1090,23 @@ VOID testSVG()
|
||||
// DBG("font parsed family=%a\n", p->font->fontFamily);
|
||||
FreePool(FileData);
|
||||
// Scale = Height / fontSVG->unitsPerEm;
|
||||
drawSVGtext(TextBufferXY, 0, 0, 3, XStringW().takeValueFrom("Clover Кловер"), 1);
|
||||
#if USE_XTHEME
|
||||
renderSVGtext(TextBufferXY, 0, 0, 3, XString("Clover Кловер"), 1);
|
||||
#else
|
||||
renderSVGtext(TextBufferXY, 0, 0, 3, L"Clover Кловер", 1);
|
||||
#endif
|
||||
// DBG("text ready to blit\n");
|
||||
#if USE_XTHEME
|
||||
TextBufferXY.Draw((UGAWidth - Width) / 2,
|
||||
(UGAHeight - Height) / 2, 1.f);
|
||||
#else
|
||||
BltImageAlpha(TextBufferXY,
|
||||
(UGAWidth - Width) / 2,
|
||||
(UGAHeight - Height) / 2,
|
||||
&MenuBackgroundPixel,
|
||||
16);
|
||||
egFreeImage(TextBufferXY);
|
||||
#endif
|
||||
// nsvg__deleteParser(p);
|
||||
// DBG("draw finished\n");
|
||||
}
|
||||
|
@ -37,6 +37,8 @@
|
||||
#ifndef __LIBEG_LIBEG_H__
|
||||
#define __LIBEG_LIBEG_H__
|
||||
|
||||
#define USE_XTHEME 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -140,11 +142,6 @@ extern "C" {
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#define USE_XTHEME 0
|
||||
#if USE_XTHEME
|
||||
extern XTheme ThemeX; //global variable defined in lib.cpp
|
||||
#endif
|
||||
|
||||
/* types */
|
||||
|
||||
typedef enum {
|
||||
@ -292,7 +289,6 @@ VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY,
|
||||
|
||||
EFI_STATUS egScreenShot(VOID);
|
||||
|
||||
INTN drawSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* text, UINTN Cursor);
|
||||
VOID testSVG(VOID);
|
||||
|
||||
#endif /* __LIBEG_LIBEG_H__ */
|
||||
|
@ -181,6 +181,12 @@ EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
||||
|
||||
//VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength);
|
||||
|
||||
#if USE_XTHEME
|
||||
INTN renderSVGtext(XImage& TextBufferXY, INTN posX, INTN posY, INTN textType, XString& string, UINTN Cursor);
|
||||
#else
|
||||
INTN renderSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* text, UINTN Cursor);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* __LIBEG_LIBEGINT_H__ */
|
||||
|
@ -267,7 +267,11 @@ INTN egRenderText(IN CONST CHAR16 *Text, IN OUT EG_IMAGE *CompImage,
|
||||
INTN ScaledWidth = (INTN)(GlobalConfig.CharWidth * GlobalConfig.Scale);
|
||||
|
||||
if (GlobalConfig.TypeSVG) {
|
||||
return drawSVGtext(CompImage, PosX, PosY, textType, Text, Cursor);
|
||||
#if USE_XTHEME
|
||||
return renderSVGtext(XImage(CompImage), PosX, PosY, textType, XString(Text), Cursor);
|
||||
#else
|
||||
return renderSVGtext(CompImage, PosX, PosY, textType, Text, Cursor);
|
||||
#endif
|
||||
}
|
||||
|
||||
// clip the text
|
||||
|
@ -55,8 +55,6 @@
|
||||
https://www.chromium.org/chromium-os
|
||||
*/
|
||||
|
||||
#define ADVLOG 1
|
||||
|
||||
// Experimental <--
|
||||
|
||||
#include "../libeg/libeg.h"
|
||||
@ -64,6 +62,11 @@
|
||||
#include "../cpp_foundation/XObjArray.h"
|
||||
#include "../cpp_foundation/XStringWArray.h"
|
||||
#include "../cpp_foundation/XStringW.h"
|
||||
#if USE_XTHEME
|
||||
#include "../libeg/XTheme.h"
|
||||
extern XTheme ThemeX; //global variable defined in lib.cpp
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define REFIT_DEBUG (2)
|
||||
|
Loading…
Reference in New Issue
Block a user