use embedded logo, drive image priorities changed

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-10 22:29:51 +03:00
parent 6039faefa2
commit ba80bb4f4d
2 changed files with 31 additions and 2 deletions

View File

@ -338,6 +338,27 @@ const XImage& XTheme::GetIcon(INTN Id)
return NullIcon; //such Id is not found in the database
}
const XImage& XTheme::GetIconAlt(INTN Id, INTN Alt)
{
for (size_t i = 0; i < Icons.size(); i++)
{
if (Icons[i].Id == Id)
{
if (!Daylight && !Icons[i].ImageNight.isEmpty()) {
return Icons[i].ImageNight;
}
//if daylight or night icon absent
if (!Icons[i].Image.isEmpty()) {
return Icons[i].Image;
}
//if daylight or night icon absent
return GetIcon(Alt); //including NullIcon
}
}
return NullIcon; //such Id is not found in the database
}
const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
{
return LoadOSIcon(XString().takeValueFrom(OSIconName));
@ -407,6 +428,13 @@ void XTheme::FillByEmbedded()
Background.Fill(StdBackgroundPixel);
}
BigBack.setEmpty();
if (Daylight) {
Banner.FromPNG(ACCESS_EMB_DATA(emb_logo), emb_logo_size);
} else {
Banner.FromPNG(ACCESS_EMB_DATA(emb_dark_logo), emb_dark_logo_size);
}
//and buttons
Buttons[0].FromPNG(ACCESS_EMB_DATA(emb_radio_button), ACCESS_EMB_SIZE(emb_radio_button));
Buttons[1].FromPNG(ACCESS_EMB_DATA(emb_radio_button_selected), ACCESS_EMB_SIZE(emb_radio_button_selected));
@ -707,14 +735,14 @@ void XTheme::FillByDir() //assume ThemeDir is defined by InitTheme() procedure
if (EFI_ERROR(Status) &&
(i >= BUILTIN_ICON_VOL_INTERNAL_HFS) &&
(i <= BUILTIN_ICON_VOL_INTERNAL_REC)) {
NewIcon->Image = GetIcon(BUILTIN_ICON_VOL_INTERNAL); //copy existing
NewIcon->Image = GetIconAlt(i, BUILTIN_ICON_VOL_INTERNAL); //copy existing
}
Status = NewIcon->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i]));
if (EFI_ERROR(Status) &&
(i >= BUILTIN_ICON_VOL_INTERNAL_HFS) &&
(i <= BUILTIN_ICON_VOL_INTERNAL_REC)) {
NewIcon->ImageNight = GetIcon(BUILTIN_ICON_VOL_INTERNAL); //copy existing
NewIcon->ImageNight = GetIconAlt(i, BUILTIN_ICON_VOL_INTERNAL); //copy existing
}
Icons.AddReference(NewIcon, true);
}

View File

@ -124,6 +124,7 @@ public:
// const XImage& GetIcon(const CHAR16* Name);
const XImage& GetIcon(const XString& Name); //get by name
const XImage& GetIcon(INTN Id); //get by id
const XImage& GetIconAlt(INTN Id, INTN Alt); //if id not found
const XImage& LoadOSIcon(const CHAR16* OSIconName); //TODO make XString provider
const XImage& LoadOSIcon(const XString& Full);