mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
fix vector theme appearance
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
parent
a28edd4a35
commit
2a731df6e4
@ -15,7 +15,7 @@ BackgroundSharp="0x80"
|
||||
Badges="swap show"
|
||||
BadgeOffsetX="0x0"
|
||||
BadgeOffsetY="0xA"
|
||||
BadgeScale="0x06"
|
||||
BadgeScale="0x08"
|
||||
CharWidth="14"
|
||||
VerticalLayout="1"
|
||||
|
||||
|
Before Width: | Height: | Size: 349 KiB After Width: | Height: | Size: 349 KiB |
@ -1981,7 +1981,7 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
}
|
||||
INTN CompWidth = (Entry->Row == 0) ? ThemeX.row0TileSize : ThemeX.row1TileSize;
|
||||
INTN CompHeight = CompWidth;
|
||||
// DBG("Entry title=%ls; Width=%d\n", Entry->Title, MainImage->Width);
|
||||
DBG("Entry title=%ls; MainWidth=%lld\n", Entry->Title.wc_str(), MainImage.GetWidth());
|
||||
float fScale;
|
||||
if (ThemeX.TypeSVG) {
|
||||
fScale = (selected ? 1.f : -1.f);
|
||||
@ -1991,9 +1991,15 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
|
||||
if (Entry->Row == 0) {
|
||||
BadgeImage = Entry->getBadgeImage();
|
||||
DBG(" BadgeWidth=%lld\n", BadgeImage->GetWidth());
|
||||
} //else null
|
||||
|
||||
XImage TopImage = ThemeX.SelectionImages[((Entry->Row == 0) ? 0 : 2) + (selected ? 0 : 1)];
|
||||
DBG(" SelectionWidth=%lld\n", TopImage.GetWidth());
|
||||
if (TopImage.GetWidth() > CompWidth) {
|
||||
CompWidth = TopImage.GetWidth();
|
||||
CompHeight = CompWidth;
|
||||
}
|
||||
XImage Back(CompWidth, CompHeight);
|
||||
// Back.GetArea(XPos, YPos, 0, 0); // this is background at this place
|
||||
Back.CopyRect(ThemeX.Background, XPos, YPos);
|
||||
@ -2003,52 +2009,64 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
INTN OffsetY = (CompHeight - MainImage.GetHeight()) / 2;
|
||||
OffsetY = (OffsetY > 0) ? OffsetY: 0;
|
||||
|
||||
INTN OffsetTX = (CompWidth - TopImage.GetWidth()) / 2;
|
||||
OffsetTX = (OffsetTX > 0) ? OffsetTX: 0;
|
||||
INTN OffsetTY = (CompHeight - TopImage.GetHeight()) / 2;
|
||||
OffsetTY = (OffsetTY > 0) ? OffsetTY: 0;
|
||||
|
||||
DBG(" Comp=[%lld,%lld], offset=[%lld,%lld]\n", CompWidth, CompHeight, OffsetX, OffsetY);
|
||||
|
||||
if(ThemeX.SelectionOnTop) {
|
||||
//place main image in centre. It may be OS or Drive
|
||||
Back.Compose(OffsetX, OffsetY, MainImage, false);
|
||||
} else {
|
||||
Back.Compose(0, 0, TopImage, false); //selection first
|
||||
Back.Compose(OffsetTX, OffsetTY, TopImage, false); //selection first
|
||||
Back.Compose(OffsetX, OffsetY, MainImage, false);
|
||||
}
|
||||
// DBG("compose size=%lld\n", CompWidth);
|
||||
//the badge is already scaled?
|
||||
// DBG("check Badge size=%lld offset=%lld\n", BadgeImage->GetWidth(), ThemeX.BadgeOffsetX);
|
||||
// place the badge image
|
||||
if (BadgeImage &&
|
||||
((INTN)BadgeImage->GetWidth() + 8) < CompWidth &&
|
||||
((INTN)BadgeImage->GetHeight() + 8) < CompHeight) {
|
||||
|
||||
// Check for user badge x offset from theme.plist
|
||||
if (ThemeX.BadgeOffsetX != 0xFFFF) {
|
||||
// Check if value is between 0 and ( width of the main icon - width of badge )
|
||||
if (ThemeX.BadgeOffsetX < 0 || ThemeX.BadgeOffsetX > (CompWidth - (INTN)BadgeImage->GetWidth())) {
|
||||
DBG("User offset X %lld is out of range\n", ThemeX.BadgeOffsetX);
|
||||
ThemeX.BadgeOffsetX = CompWidth - 8 - BadgeImage->GetWidth();
|
||||
DBG(" corrected to default %lld\n", ThemeX.BadgeOffsetX);
|
||||
float fBadgeScale = ThemeX.BadgeScale/16.f;
|
||||
if (BadgeImage && !BadgeImage->isEmpty()) {
|
||||
INTN BadgeWidth = (INTN)(BadgeImage->GetWidth() * fBadgeScale);
|
||||
INTN BadgeHeight = (INTN)(BadgeImage->GetHeight() * fBadgeScale);
|
||||
|
||||
if ((BadgeWidth + 8) < CompWidth && (BadgeHeight + 8) < CompHeight) {
|
||||
|
||||
// Check for user badge x offset from theme.plist
|
||||
if (ThemeX.BadgeOffsetX != 0xFFFF) {
|
||||
// Check if value is between 0 and ( width of the main icon - width of badge )
|
||||
// if (ThemeX.BadgeOffsetX < 0 || ThemeX.BadgeOffsetX > (CompWidth - BadgeWidth)) {
|
||||
// DBG("User offset X %lld is out of range\n", ThemeX.BadgeOffsetX);
|
||||
// ThemeX.BadgeOffsetX = CompWidth - 8 - BadgeWidth;
|
||||
// DBG(" corrected to default %lld\n", ThemeX.BadgeOffsetX);
|
||||
// }
|
||||
OffsetX += ThemeX.BadgeOffsetX;
|
||||
} else {
|
||||
// Set default position
|
||||
OffsetX += CompWidth - 8 - BadgeWidth;
|
||||
}
|
||||
OffsetX += ThemeX.BadgeOffsetX;
|
||||
} else {
|
||||
// Set default position
|
||||
OffsetX += CompWidth - 8 - BadgeImage->GetWidth();
|
||||
}
|
||||
// Check for user badge y offset from theme.plist
|
||||
if (ThemeX.BadgeOffsetY != 0xFFFF) {
|
||||
// Check if value is between 0 and ( height of the main icon - height of badge )
|
||||
if (ThemeX.BadgeOffsetY < 0 || ThemeX.BadgeOffsetY > (CompHeight - (INTN)BadgeImage->GetHeight())) {
|
||||
DBG("User offset Y %lld is out of range\n",ThemeX.BadgeOffsetY);
|
||||
ThemeX.BadgeOffsetY = CompHeight - 8 - BadgeImage->GetHeight();
|
||||
DBG(" corrected to default %lld\n", ThemeX.BadgeOffsetY);
|
||||
// Check for user badge y offset from theme.plist
|
||||
if (ThemeX.BadgeOffsetY != 0xFFFF) {
|
||||
// Check if value is between 0 and ( height of the main icon - height of badge )
|
||||
if (ThemeX.BadgeOffsetY < 0 || ThemeX.BadgeOffsetY > (CompHeight - BadgeHeight)) {
|
||||
DBG("User offset Y %lld is out of range\n",ThemeX.BadgeOffsetY);
|
||||
// ThemeX.BadgeOffsetY = CompHeight - 8 - BadgeHeight;
|
||||
DBG(" corrected to default %lld\n", ThemeX.BadgeOffsetY);
|
||||
}
|
||||
OffsetY += ThemeX.BadgeOffsetY;
|
||||
} else {
|
||||
// Set default position
|
||||
OffsetY += CompHeight - 8 - BadgeHeight;
|
||||
}
|
||||
OffsetY += ThemeX.BadgeOffsetY;
|
||||
} else {
|
||||
// Set default position
|
||||
OffsetY += CompHeight - 8 - BadgeImage->GetHeight();
|
||||
DBG(" badge offset=[%lld,%lld]\n", OffsetX, OffsetY);
|
||||
Back.Compose(OffsetX, OffsetY, *BadgeImage, false, fBadgeScale);
|
||||
}
|
||||
Back.Compose(OffsetX, OffsetY, *BadgeImage, false);
|
||||
}
|
||||
|
||||
if(ThemeX.SelectionOnTop) {
|
||||
Back.Compose(0, 0, TopImage, false); //selection at the top
|
||||
Back.Compose(OffsetTX, OffsetTY, TopImage, false); //selection at the top
|
||||
}
|
||||
Back.DrawWithoutCompose(XPos, YPos);
|
||||
|
||||
|
@ -209,10 +209,11 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString& IconNameX, XImage* Imag
|
||||
// DBG("begin rasterize %s\n", IconNameX.c_str());
|
||||
float tx = 0.f, ty = 0.f;
|
||||
if ((Id != BUILTIN_ICON_BACKGROUND) &&
|
||||
(Id != BUILTIN_ICON_ANIME) &&
|
||||
IconNameX.ExistIn("Banner")) {
|
||||
(Id != BUILTIN_ICON_ANIME) /*&&
|
||||
IconNameX.ExistIn("Banner")*/) {
|
||||
float realWidth = (bounds[2] - bounds[0]) * Scale;
|
||||
float realHeight = (bounds[3] - bounds[1]) * Scale;
|
||||
DBG("icon=%s width=%f realwidth=%f\n", IconNameX.c_str(), Width, realWidth);
|
||||
tx = (Width - realWidth) * 0.5f;
|
||||
ty = (Height - realHeight) * 0.5f;
|
||||
}
|
||||
@ -619,7 +620,7 @@ VOID testSVG()
|
||||
Scale = (ScaleX > ScaleY)?ScaleY:ScaleX;
|
||||
float tx = 0; //-SVGimage->realBounds[0] * Scale;
|
||||
float ty = 0; //-SVGimage->realBounds[1] * Scale;
|
||||
DBG("timing rasterize start tx=%f ty=%f\n", tx, ty);
|
||||
DBG("timing rasterize start tx=%f ty=%f\n", tx, ty); //the aim is measure duration
|
||||
nsvgRasterize(rast, SVGimage, tx,ty,Scale,Scale, (UINT8*)NewImage.GetPixelPtr(0,0), (int)Width, (int)Height, (int)Width*4);
|
||||
DBG("timing rasterize end\n");
|
||||
NewImage.Draw((UGAWidth - Width) / 2,
|
||||
|
@ -238,7 +238,7 @@ void XImage::CopyScaled(const XImage& Image, float scale)
|
||||
* Lowest means final image is opaque
|
||||
* else transparency will be multiplied
|
||||
*/
|
||||
void XImage::Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest)
|
||||
void XImage::Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest, float topScale)
|
||||
{
|
||||
EG_RECT OutPlace;
|
||||
OutPlace.XPos = PosX;
|
||||
@ -251,7 +251,7 @@ void XImage::Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest)
|
||||
Area.YPos = 0;
|
||||
Area.Width = TopImage.GetWidth();
|
||||
Area.Height = TopImage.GetHeight();
|
||||
Compose(OutPlace, Area, TopImage, Lowest, 0.f);
|
||||
Compose(OutPlace, Area, TopImage, Lowest, topScale);
|
||||
}
|
||||
// TopScale is for scaling TopImage. = 0.f means no scale or = 1.f
|
||||
// InPlace is a place in TopImage before scaling
|
||||
|
@ -84,11 +84,11 @@ public:
|
||||
void FillArea(const EG_PIXEL* Color, EG_RECT& Rect);
|
||||
void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, EG_RECT& Rect);
|
||||
void Copy(XImage* Image);
|
||||
void CopyScaled(const XImage& Image, float scale);
|
||||
void CopyScaled(const XImage& Image, float scale = 0.f);
|
||||
void CopyRect(const XImage& Image, INTN X, INTN Y);
|
||||
void CopyRect(const XImage& Image, const EG_RECT& OwnPlace, const EG_RECT& InputRect);
|
||||
void Compose(const EG_RECT& OwnPlace, const EG_RECT& InputRect, const XImage& TopImage, bool Lowest, float TopScale = 0.f);
|
||||
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we often can Back.Draw(...) + Top.Draw(...)
|
||||
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest, float topScale = 0); //instead of compose we often can Back.Draw(...) + Top.Draw(...)
|
||||
void FlipRB();
|
||||
EFI_STATUS FromPNG(const UINT8 * Data, UINTN Lenght);
|
||||
EFI_STATUS ToPNG(UINT8** Data, UINTN& OutSize);
|
||||
|
Loading…
Reference in New Issue
Block a user