2020-03-13 09:44:45 +01:00
|
|
|
/*
|
|
|
|
* a class to keep definitions for all theme settings
|
|
|
|
*/
|
2020-03-17 20:43:58 +01:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <Protocol/GraphicsOutput.h>
|
|
|
|
}
|
|
|
|
|
2020-03-16 12:15:25 +01:00
|
|
|
#include "libegint.h"
|
2020-03-18 07:39:11 +01:00
|
|
|
#include "../refit/screen.h"
|
2020-04-01 14:57:32 +02:00
|
|
|
#include "../refit/lib.h"
|
2020-03-18 07:39:11 +01:00
|
|
|
|
2020-03-13 09:44:45 +01:00
|
|
|
#include "XTheme.h"
|
|
|
|
|
2020-03-31 16:25:07 +02:00
|
|
|
#ifndef DEBUG_ALL
|
|
|
|
#define DEBUG_XTHEME 1
|
|
|
|
#else
|
|
|
|
#define DEBUG_XTHEME DEBUG_ALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_XTHEME == 0
|
|
|
|
#define DBG(...)
|
|
|
|
#else
|
|
|
|
#define DBG(...) DebugLog(DEBUG_XTHEME, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2020-03-16 12:15:25 +01:00
|
|
|
CONST CHAR8* IconsNames[] = {
|
|
|
|
"func_about",
|
|
|
|
"func_options",
|
|
|
|
"func_clover",
|
|
|
|
"func_secureboot",
|
|
|
|
"func_secureboot_config",
|
|
|
|
"func_reset",
|
|
|
|
"func_shutdown",
|
|
|
|
"func_help",
|
|
|
|
"tool_shell", //8
|
|
|
|
"tool_part",
|
|
|
|
"tool_rescue",
|
|
|
|
"pointer",//11
|
|
|
|
"vol_internal",
|
|
|
|
"vol_external",
|
|
|
|
"vol_optical",
|
|
|
|
"vol_firewire",
|
|
|
|
"vol_clover" ,
|
2020-04-23 13:36:35 +02:00
|
|
|
"vol_internal_hfs" , //17
|
2020-03-16 12:15:25 +01:00
|
|
|
"vol_internal_apfs",
|
|
|
|
"vol_internal_ntfs",
|
|
|
|
"vol_internal_ext3" ,
|
|
|
|
"vol_recovery",//21
|
2020-03-28 19:34:23 +01:00
|
|
|
// not used? will be skipped while theme parsing
|
2020-03-16 12:15:25 +01:00
|
|
|
"logo",
|
|
|
|
"selection_small",
|
2020-03-18 15:11:56 +01:00
|
|
|
"selection_big", //BUILTIN_SELECTION_BIG=24 we keep this numeration
|
2020-03-16 12:15:25 +01:00
|
|
|
//os icons
|
|
|
|
"os_mac", //0 + 25
|
|
|
|
"os_tiger",
|
|
|
|
"os_leo",
|
|
|
|
"os_snow",
|
|
|
|
"os_lion",
|
|
|
|
"os_cougar",
|
|
|
|
"os_mav",
|
|
|
|
"os_yos",
|
2020-04-23 13:36:35 +02:00
|
|
|
"os_cap", //33
|
2020-03-16 12:15:25 +01:00
|
|
|
"os_sierra",
|
|
|
|
"os_hsierra",
|
2020-04-23 13:36:35 +02:00
|
|
|
"os_moja", //36
|
|
|
|
"os_cata", //37 //there is no reserve for 10.16, next oses should be added to the end of the list
|
|
|
|
"os_linux", //13 + 25 = 38
|
2020-03-16 12:15:25 +01:00
|
|
|
"os_ubuntu",
|
|
|
|
"os_suse",
|
2020-04-23 13:36:35 +02:00
|
|
|
"os_freebsd", //16+25 = 41
|
2020-03-16 12:15:25 +01:00
|
|
|
"os_freedos",
|
|
|
|
"os_win",
|
|
|
|
"os_vista",
|
2020-04-23 13:36:35 +02:00
|
|
|
"radio_button", //20+25 = 45
|
2020-03-16 12:15:25 +01:00
|
|
|
"radio_button_selected",
|
2020-04-23 13:36:35 +02:00
|
|
|
"checkbox", //22+25 = 47
|
2020-03-16 12:15:25 +01:00
|
|
|
"checkbox_checked",
|
2020-03-29 07:42:33 +02:00
|
|
|
"scrollbar_background", //24 - present here for SVG theme but should be done more common way
|
|
|
|
"scrollbar_holder",
|
2020-04-25 22:14:53 +02:00
|
|
|
"os_unknown", //51 == ICON_OTHER_OS
|
|
|
|
"os_clover", //52 == ICON_CLOVER
|
2020-04-24 18:24:34 +02:00
|
|
|
//other oses will be added below
|
2020-03-29 07:42:33 +02:00
|
|
|
""
|
2020-03-16 12:15:25 +01:00
|
|
|
};
|
2020-04-23 13:36:35 +02:00
|
|
|
const INTN IconsNamesSize = sizeof(IconsNames) / sizeof(IconsNames[0]);
|
2020-03-16 12:15:25 +01:00
|
|
|
|
2020-04-06 11:15:36 +02:00
|
|
|
//icons class
|
|
|
|
//if ImageNight is not set then Image should be used
|
|
|
|
#define DEC_BUILTIN_ICON(id, ico) { \
|
|
|
|
Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEC_BUILTIN_ICON2(id, ico, dark) { \
|
|
|
|
Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico)); \
|
|
|
|
ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
|
|
|
|
}
|
|
|
|
|
2020-04-16 13:42:14 +02:00
|
|
|
Icon::Icon(INTN Index, bool TakeEmbedded) : Image(), ImageNight()
|
2020-04-06 11:15:36 +02:00
|
|
|
{
|
|
|
|
Id = Index;
|
|
|
|
Name.setEmpty();
|
2020-04-18 08:39:47 +02:00
|
|
|
Native = false;
|
2020-04-23 13:36:35 +02:00
|
|
|
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index < IconsNamesSize) { //full table
|
2020-04-06 11:15:36 +02:00
|
|
|
Name.takeValueFrom(IconsNames[Index]);
|
|
|
|
}
|
|
|
|
if (TakeEmbedded) {
|
|
|
|
GetEmbedded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Icon::GetEmbedded()
|
|
|
|
{
|
|
|
|
switch (Id) {
|
|
|
|
case BUILTIN_ICON_FUNC_ABOUT:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_ABOUT, emb_func_about, emb_dark_func_about)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_OPTIONS:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_OPTIONS, emb_func_options, emb_dark_func_options)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_CLOVER:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_CLOVER, emb_func_clover, emb_dark_func_clover)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_SECURE_BOOT:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_SECURE_BOOT, emb_func_secureboot, emb_dark_func_secureboot)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG, emb_func_secureboot_config, emb_dark_func_secureboot_config)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_RESET:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_RESET, emb_func_reset, emb_dark_func_reset)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_EXIT:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_EXIT, emb_func_exit, emb_dark_func_exit)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_FUNC_HELP:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_HELP, emb_func_help, emb_dark_func_help)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_TOOL_SHELL:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_TOOL_SHELL, emb_func_shell, emb_dark_func_shell)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_BANNER:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_ICON_BANNER, emb_logo, emb_dark_logo)
|
|
|
|
break;
|
|
|
|
case BUILTIN_SELECTION_SMALL:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_SELECTION_SMALL, emb_selection_small, emb_dark_selection_small)
|
|
|
|
break;
|
|
|
|
case BUILTIN_SELECTION_BIG:
|
|
|
|
DEC_BUILTIN_ICON2(BUILTIN_SELECTION_BIG, emb_selection_big, emb_dark_selection_big)
|
|
|
|
break;
|
|
|
|
//next icons have no dark image
|
|
|
|
case BUILTIN_ICON_POINTER:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_POINTER, emb_pointer)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_INTERNAL:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL, emb_vol_internal)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_EXTERNAL:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_EXTERNAL, emb_vol_external)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_OPTICAL:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_OPTICAL, emb_vol_optical)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_BOOTER:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_BOOTER, emb_vol_internal_booter)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_INTERNAL_HFS:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_HFS, emb_vol_internal_hfs)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_INTERNAL_APFS:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_APFS, emb_vol_internal_apfs)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_INTERNAL_NTFS:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_NTFS, emb_vol_internal_ntfs)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_INTERNAL_EXT3:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_EXT3, emb_vol_internal_ext)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_VOL_INTERNAL_REC:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_REC, emb_vol_internal_recovery)
|
|
|
|
break;
|
|
|
|
case BUILTIN_RADIO_BUTTON:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_RADIO_BUTTON, emb_radio_button)
|
|
|
|
break;
|
|
|
|
case BUILTIN_RADIO_BUTTON_SELECTED:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_RADIO_BUTTON_SELECTED, emb_radio_button_selected)
|
|
|
|
break;
|
|
|
|
case BUILTIN_CHECKBOX:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX, emb_checkbox)
|
|
|
|
break;
|
|
|
|
case BUILTIN_CHECKBOX_CHECKED:
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX_CHECKED, emb_checkbox_checked)
|
|
|
|
break;
|
|
|
|
case BUILTIN_ICON_SELECTION:
|
|
|
|
Name.takeValueFrom("selection_indicator");
|
|
|
|
DEC_BUILTIN_ICON(BUILTIN_ICON_SELECTION, emb_selection_indicator)
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Image.setEmpty(); //done by ctor?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//something to do else?
|
|
|
|
}
|
|
|
|
|
2020-03-13 09:44:45 +01:00
|
|
|
Icon::~Icon() {}
|
|
|
|
|
2020-04-06 11:15:36 +02:00
|
|
|
//xtheme class
|
2020-03-16 12:15:25 +01:00
|
|
|
XTheme::XTheme() {
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
XTheme::~XTheme() {
|
|
|
|
//nothing todo?
|
|
|
|
}
|
|
|
|
|
|
|
|
void XTheme::Init()
|
2020-03-13 09:44:45 +01:00
|
|
|
{
|
2020-03-27 17:50:17 +01:00
|
|
|
// DisableFlags = 0;
|
2020-03-12 15:00:36 +01:00
|
|
|
HideBadges = 0;
|
|
|
|
HideUIFlags = 0;
|
2020-03-27 20:47:06 +01:00
|
|
|
// TextOnly = FALSE;
|
2020-03-12 15:00:36 +01:00
|
|
|
Font = FONT_GRAY; // FONT_TYPE
|
|
|
|
CharWidth = 9;
|
2020-04-06 11:15:36 +02:00
|
|
|
SelectionColor = 0x80808080;
|
2020-04-15 22:12:43 +02:00
|
|
|
SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
|
2020-03-12 15:00:36 +01:00
|
|
|
FontFileName.setEmpty();
|
2020-04-16 13:04:24 +02:00
|
|
|
// Theme.takeValueFrom("embedded");
|
|
|
|
embedded = false;
|
2020-03-12 15:00:36 +01:00
|
|
|
BannerFileName.setEmpty();
|
|
|
|
SelectionSmallFileName.setEmpty();
|
|
|
|
SelectionBigFileName.setEmpty();
|
|
|
|
SelectionIndicatorName.setEmpty();
|
|
|
|
DefaultSelection.setEmpty();
|
|
|
|
BackgroundName.setEmpty();
|
|
|
|
BackgroundScale = imNone; // SCALING
|
|
|
|
BackgroundSharp = 0;
|
|
|
|
BackgroundDark = FALSE; //TODO should be set to true if Night theme
|
2020-03-27 17:50:17 +01:00
|
|
|
// CustomIcons = FALSE; //TODO don't know how to handle with SVG theme
|
2020-03-12 15:00:36 +01:00
|
|
|
SelectionOnTop = FALSE;
|
|
|
|
BootCampStyle = FALSE;
|
2020-04-08 09:32:26 +02:00
|
|
|
BadgeOffsetX = 0xFFFF; //default offset
|
|
|
|
BadgeOffsetY = 0xFFFF;
|
2020-03-12 15:00:36 +01:00
|
|
|
BadgeScale = 4; // TODO now we have float scale = BadgeScale/16
|
|
|
|
ThemeDesignWidth = 0xFFFF;
|
|
|
|
ThemeDesignHeight = 0xFFFF;
|
2020-04-14 18:52:13 +02:00
|
|
|
BannerPosX = 0xFFFF; // the value out of range [0,1000] means default
|
2020-03-12 15:00:36 +01:00
|
|
|
BannerPosY = 0xFFFF;
|
|
|
|
BannerEdgeHorizontal = 0;
|
|
|
|
BannerEdgeVertical = 0;
|
|
|
|
BannerNudgeX = 0;
|
|
|
|
BannerNudgeY = 0;
|
2020-04-15 22:12:43 +02:00
|
|
|
BanHeight = 0;
|
2020-03-12 15:00:36 +01:00
|
|
|
VerticalLayout = FALSE;
|
2020-04-21 17:57:47 +02:00
|
|
|
NonSelectedGrey = FALSE;
|
2020-03-12 15:00:36 +01:00
|
|
|
MainEntriesSize = 128;
|
|
|
|
TileXSpace = 8;
|
|
|
|
TileYSpace = 24;
|
|
|
|
// IconFormat = ICON_FORMAT_DEF;
|
|
|
|
Proportional = FALSE;
|
2020-03-27 17:50:17 +01:00
|
|
|
// ShowOptimus = FALSE;
|
2020-04-16 13:04:24 +02:00
|
|
|
// DarkEmbedded = FALSE; //looks like redundant, we always check Night or Daylight
|
2020-03-12 15:00:36 +01:00
|
|
|
TypeSVG = FALSE;
|
2020-04-08 11:45:36 +02:00
|
|
|
// Codepage = 0xC0; //this is for PNG theme
|
|
|
|
// CodepageSize = 0xC0; // INTN CodepageSize; //extended latin
|
2020-03-12 15:00:36 +01:00
|
|
|
Scale = 1.0f;
|
2020-03-13 09:44:45 +01:00
|
|
|
CentreShift = 0.0f;
|
2020-04-16 13:04:24 +02:00
|
|
|
// Daylight = true;
|
2020-03-20 18:48:19 +01:00
|
|
|
LayoutHeight = 376;
|
2020-03-26 15:24:20 +01:00
|
|
|
LayoutBannerOffset = 64; //default value if not set
|
|
|
|
LayoutButtonOffset = 0; //default value if not set
|
|
|
|
LayoutTextOffset = 0; //default value if not set
|
|
|
|
LayoutAnimMoveForMenuX = 0; //default value if not set
|
|
|
|
|
|
|
|
row0TileSize = 144;
|
|
|
|
row1TileSize = 64;
|
2020-04-07 21:48:36 +02:00
|
|
|
|
|
|
|
FontWidth = 9;
|
|
|
|
FontHeight = 18;
|
|
|
|
TextHeight = 19;
|
2020-04-15 18:30:39 +02:00
|
|
|
|
|
|
|
Cinema.setEmpty();
|
2020-03-13 09:44:45 +01:00
|
|
|
}
|
|
|
|
|
2020-03-29 07:42:33 +02:00
|
|
|
/*
|
|
|
|
* what if the icon is not found or name is wrong?
|
|
|
|
* probably it whould return Empty image
|
|
|
|
* Image.isEmpty() == true
|
|
|
|
*/
|
2020-04-05 14:25:39 +02:00
|
|
|
//const XImage& XTheme::GetIcon(const char* Name)
|
|
|
|
//{
|
|
|
|
// return GetIcon(XString().takeValueFrom(Name));
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//const XImage& XTheme::GetIcon(const CHAR16* Name)
|
|
|
|
//{
|
|
|
|
// return GetIcon(XString().takeValueFrom(Name));
|
|
|
|
//}
|
2020-03-30 17:31:52 +02:00
|
|
|
|
2020-03-29 12:19:05 +02:00
|
|
|
static XImage NullIcon;
|
2020-04-05 17:54:10 +02:00
|
|
|
static XImage DummyIcon;
|
2020-03-29 12:19:05 +02:00
|
|
|
|
2020-04-30 08:03:56 +02:00
|
|
|
const XImage& XTheme::GetIcon(const XString8& Name)
|
2020-03-13 09:44:45 +01:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < Icons.size(); i++)
|
|
|
|
{
|
2020-03-29 07:42:33 +02:00
|
|
|
if (Icons[i].Name == Name) //night icon has same name as daylight icon
|
2020-03-13 09:44:45 +01:00
|
|
|
{
|
2020-04-06 11:15:36 +02:00
|
|
|
return GetIcon(Icons[i].Id);
|
2020-03-13 09:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-06 11:15:36 +02:00
|
|
|
return NullIcon; //if name is not found
|
2020-03-13 09:44:45 +01:00
|
|
|
}
|
|
|
|
|
2020-04-18 08:39:47 +02:00
|
|
|
bool XTheme::CheckNative(INTN Id)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < Icons.size(); i++)
|
|
|
|
{
|
|
|
|
if (Icons[i].Id == Id)
|
|
|
|
{
|
|
|
|
return Icons[i].Native;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-21 20:41:35 +02:00
|
|
|
const XImage& XTheme::GetIcon(INTN Id)
|
2020-03-13 09:44:45 +01:00
|
|
|
{
|
2020-04-21 20:41:35 +02:00
|
|
|
return GetIconAlt(Id, -1);
|
2020-03-13 09:44:45 +01:00
|
|
|
}
|
2020-04-05 17:54:10 +02:00
|
|
|
|
2020-04-18 08:39:47 +02:00
|
|
|
/*
|
2020-04-21 20:41:35 +02:00
|
|
|
* Get Icon with this ID=id, for example VOL_INTERNAL_HFS
|
|
|
|
* if not found then search for ID=Alt with Native attribute set, for example VOL_INTERNAL
|
|
|
|
* if not found then check embedded with ID=Id
|
2020-04-18 08:39:47 +02:00
|
|
|
* if not found then check embedded with ID=Alt
|
|
|
|
*/
|
2020-04-21 20:41:35 +02:00
|
|
|
const XImage& XTheme::GetIconAlt(INTN Id, INTN Alt) //if not found then take embedded
|
2020-04-10 21:29:51 +02:00
|
|
|
{
|
2020-04-21 20:41:35 +02:00
|
|
|
INTN IdFound = -1;
|
|
|
|
INTN AltFound = -1;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < Icons.size() && (IdFound < 0 || (Alt >= 0 && AltFound < 0)); i++) {
|
|
|
|
if (Icons[i].Id == Id) {
|
|
|
|
IdFound = i;
|
|
|
|
}
|
|
|
|
if (Icons[i].Id == Alt) {
|
|
|
|
AltFound = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if icon is empty, try to fill it with alternative
|
|
|
|
if (IdFound >= 0 && Icons[IdFound].Image.isEmpty()) {
|
|
|
|
// check for native ID=Alt, if Alt was specified
|
|
|
|
if (Alt >= 0 && AltFound >= 0 && Icons[AltFound].Native && !Icons[AltFound].Image.isEmpty()) {
|
|
|
|
// using Alt icon
|
|
|
|
Icons[IdFound].Image = Icons[AltFound].Image;
|
|
|
|
Icons[IdFound].ImageNight = Icons[AltFound].ImageNight;
|
|
|
|
} else {
|
|
|
|
// check for embedded with ID=Id
|
|
|
|
Icon *NewIcon = new Icon(Id, true);
|
|
|
|
if (NewIcon->Image.isEmpty()) {
|
|
|
|
// check for embedded with ID=Alt
|
|
|
|
NewIcon = new Icon(Alt, true);
|
2020-04-10 21:29:51 +02:00
|
|
|
}
|
2020-04-21 20:41:35 +02:00
|
|
|
if (!NewIcon->Image.isEmpty()) {
|
|
|
|
// using Embedded icon
|
|
|
|
Icons[IdFound].Image = NewIcon->Image;
|
|
|
|
Icons[IdFound].ImageNight = NewIcon->ImageNight;
|
2020-04-18 08:39:47 +02:00
|
|
|
}
|
2020-04-10 21:29:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 20:41:35 +02:00
|
|
|
if (IdFound >= 0 && !Icons[IdFound].Image.isEmpty()) {
|
|
|
|
// icon not empty, return it
|
|
|
|
if (!Daylight && !Icons[IdFound].ImageNight.isEmpty()) {
|
2020-04-23 10:07:05 +02:00
|
|
|
DBG("got night icon %lld name{%s}\n", Id, IconsNames[IdFound]);
|
2020-04-21 20:41:35 +02:00
|
|
|
return Icons[IdFound].ImageNight;
|
|
|
|
}
|
|
|
|
//if daylight or night icon absent
|
2020-04-23 10:07:05 +02:00
|
|
|
DBG("got day icon %lld name{%s}\n", Id, IconsNames[IdFound]);
|
2020-04-21 20:41:35 +02:00
|
|
|
return Icons[IdFound].Image;
|
|
|
|
}
|
|
|
|
return NullIcon; //such Id is not found in the database
|
2020-04-10 21:29:51 +02:00
|
|
|
}
|
|
|
|
|
2020-04-05 17:54:10 +02:00
|
|
|
const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
|
2020-04-06 11:15:36 +02:00
|
|
|
{
|
2020-04-30 08:03:56 +02:00
|
|
|
return LoadOSIcon(XString8().takeValueFrom(OSIconName));
|
2020-04-06 11:15:36 +02:00
|
|
|
}
|
|
|
|
|
2020-04-30 08:03:56 +02:00
|
|
|
const XImage& XTheme::LoadOSIcon(const XString8& Full)
|
2020-04-05 17:54:10 +02:00
|
|
|
{
|
|
|
|
// input value can be L"win", L"ubuntu,linux", L"moja,mac" set by GetOSIconName (OSVersion)
|
2020-04-30 08:03:56 +02:00
|
|
|
XString8 First;
|
|
|
|
XString8 Second;
|
|
|
|
XString8 Third;
|
2020-04-05 17:54:10 +02:00
|
|
|
const XImage *ReturnImage;
|
2020-04-23 22:43:35 +02:00
|
|
|
UINTN Comma = Full.indexOf(',');
|
2020-04-23 15:20:48 +02:00
|
|
|
UINTN Size = Full.length();
|
2020-04-28 22:42:53 +02:00
|
|
|
DBG("IconName=%s comma=%lld size=%lld\n", Full.c_str(), Comma, Size);
|
2020-04-05 17:54:10 +02:00
|
|
|
if (Comma != MAX_XSIZE) { //Comma
|
2020-04-30 08:22:26 +02:00
|
|
|
First = "os_"_XS8 + Full.subString(0, Comma);
|
2020-04-05 17:54:10 +02:00
|
|
|
ReturnImage = &GetIcon(First);
|
2020-04-28 22:42:53 +02:00
|
|
|
DBG(" first=%s\n", First.c_str());
|
2020-04-05 17:54:10 +02:00
|
|
|
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
|
|
|
//else search second name
|
2020-04-30 08:22:26 +02:00
|
|
|
Second = "os_"_XS8 + Full.subString(Comma + 1, Size - Comma - 1);
|
2020-04-09 05:32:57 +02:00
|
|
|
//moreover names can be triple L"chrome,grub,linux"
|
2020-04-23 22:43:35 +02:00
|
|
|
UINTN SecondComma = Second.indexOf(',');
|
2020-04-09 05:32:57 +02:00
|
|
|
if (Comma == MAX_XSIZE) {
|
|
|
|
ReturnImage = &GetIcon(Second);
|
|
|
|
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
|
|
|
} else {
|
2020-04-23 22:43:35 +02:00
|
|
|
First = Second.subString(0, SecondComma);
|
2020-04-09 05:32:57 +02:00
|
|
|
ReturnImage = &GetIcon(First);
|
|
|
|
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
2020-04-30 08:22:26 +02:00
|
|
|
Third = "os_"_XS8 + Second.subString(SecondComma + 1, Size - SecondComma - 1);
|
2020-04-09 05:32:57 +02:00
|
|
|
ReturnImage = &GetIcon(Third);
|
|
|
|
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
|
|
|
}
|
2020-04-28 22:42:53 +02:00
|
|
|
DBG(" Second=%s\n", Second.c_str());
|
2020-04-05 17:54:10 +02:00
|
|
|
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
|
|
|
} else {
|
2020-04-30 08:22:26 +02:00
|
|
|
ReturnImage = &GetIcon("os_"_XS8 + Full);
|
2020-04-28 22:42:53 +02:00
|
|
|
DBG(" Full=%s\n", Full.c_str());
|
2020-04-05 17:54:10 +02:00
|
|
|
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
|
|
|
}
|
|
|
|
// else something
|
|
|
|
if (DummyIcon.isEmpty()) //initialize once per session
|
|
|
|
DummyIcon.DummyImage(MainEntriesSize);
|
|
|
|
return DummyIcon;
|
|
|
|
}
|
2020-04-02 21:27:10 +02:00
|
|
|
//
|
|
|
|
//void XTheme::AddIcon(Icon& NewIcon)
|
|
|
|
//{
|
|
|
|
// Icons.AddCopy(NewIcon);
|
|
|
|
//}
|
2020-03-16 12:15:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
void XTheme::FillByEmbedded()
|
2020-03-17 20:43:58 +01:00
|
|
|
{
|
2020-04-16 13:04:24 +02:00
|
|
|
embedded = true;
|
|
|
|
Theme.takeValueFrom("embedded");
|
|
|
|
SelectionColor = 0xA0A0A080;
|
|
|
|
SelectionBackgroundPixel = { 0xa0, 0xa0, 0xa0, 0x80 };
|
|
|
|
|
2020-04-02 21:27:10 +02:00
|
|
|
Icons.Empty();
|
2020-04-05 16:04:39 +02:00
|
|
|
for (INTN i = 0; i < BUILTIN_ICON_COUNT; ++i) { //this is embedded icon count
|
2020-04-05 23:14:27 +02:00
|
|
|
Icon* NewIcon = new Icon(i, true);
|
2020-04-02 21:27:10 +02:00
|
|
|
Icons.AddReference(NewIcon, true);
|
2020-03-19 19:35:58 +01:00
|
|
|
}
|
2020-04-10 16:35:24 +02:00
|
|
|
|
|
|
|
BigBack.setEmpty();
|
2020-04-16 13:04:24 +02:00
|
|
|
Background = XImage(UGAWidth, UGAHeight);
|
2020-04-10 21:29:51 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-04-05 16:04:39 +02:00
|
|
|
//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));
|
|
|
|
Buttons[2].FromPNG(ACCESS_EMB_DATA(emb_checkbox), ACCESS_EMB_SIZE(emb_checkbox));
|
|
|
|
Buttons[3].FromPNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked));
|
|
|
|
|
|
|
|
if (Daylight) {
|
|
|
|
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_selection_big), ACCESS_EMB_SIZE(emb_selection_big));
|
|
|
|
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_selection_small), ACCESS_EMB_SIZE(emb_selection_small));
|
|
|
|
} else {
|
|
|
|
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_big), ACCESS_EMB_SIZE(emb_dark_selection_big));
|
|
|
|
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_small), ACCESS_EMB_SIZE(emb_dark_selection_small));
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectionImages[4].FromPNG(ACCESS_EMB_DATA(emb_selection_indicator), ACCESS_EMB_SIZE(emb_selection_indicator));
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void XTheme::ClearScreen() //and restore background and banner
|
|
|
|
{
|
2020-04-12 20:53:27 +02:00
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FirstBannerPixel = MenuBackgroundPixel;
|
2020-03-17 20:43:58 +01:00
|
|
|
if (BanHeight < 2) {
|
|
|
|
BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1);
|
|
|
|
}
|
2020-04-11 22:08:03 +02:00
|
|
|
// egClearScreen(&MenuBackgroundPixel); //not needed
|
2020-03-17 20:43:58 +01:00
|
|
|
if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) {
|
|
|
|
//Banner image prepared before
|
|
|
|
if (!Banner.isEmpty()) {
|
2020-04-12 20:53:27 +02:00
|
|
|
FirstBannerPixel = Banner.GetPixel(0,0);
|
|
|
|
|
2020-03-18 07:39:11 +01:00
|
|
|
BannerPlace.Width = Banner.GetWidth();
|
|
|
|
BannerPlace.Height = (BanHeight >= Banner.GetHeight()) ? Banner.GetHeight() : BanHeight;
|
2020-03-17 20:43:58 +01:00
|
|
|
BannerPlace.XPos = BannerPosX;
|
|
|
|
BannerPlace.YPos = BannerPosY;
|
|
|
|
if (!TypeSVG) {
|
|
|
|
// Check if new style placement value was used for banner in theme.plist
|
|
|
|
|
|
|
|
if ((BannerPosX >=0 && BannerPosX <=1000) && (BannerPosY >=0 && BannerPosY <=1000)) {
|
|
|
|
// Check if screen size being used is different from theme origination size.
|
|
|
|
// If yes, then recalculate the placement % value.
|
|
|
|
// This is necessary because screen can be a different size, but banner is not scaled.
|
|
|
|
BannerPlace.XPos = HybridRepositioning(BannerEdgeHorizontal, BannerPosX, BannerPlace.Width, UGAWidth, ThemeDesignWidth );
|
|
|
|
BannerPlace.YPos = HybridRepositioning(BannerEdgeVertical, BannerPosY, BannerPlace.Height, UGAHeight, ThemeDesignHeight);
|
|
|
|
// Check if banner is required to be nudged.
|
2020-03-18 07:39:11 +01:00
|
|
|
BannerPlace.XPos = CalculateNudgePosition(BannerPlace.XPos, BannerNudgeX, Banner.GetWidth(), UGAWidth);
|
|
|
|
BannerPlace.YPos = CalculateNudgePosition(BannerPlace.YPos, BannerNudgeY, Banner.GetHeight(), UGAHeight);
|
2020-03-17 20:43:58 +01:00
|
|
|
// DBG("banner position new style\n");
|
|
|
|
} else {
|
|
|
|
// Use rEFIt default (no placement values speicifed)
|
2020-04-18 21:11:50 +02:00
|
|
|
BannerPlace.XPos = (UGAWidth >= Banner.GetWidth() ) ? (UGAWidth - Banner.GetWidth() ) >> 1 : 0;
|
|
|
|
BannerPlace.YPos = (BanHeight >= Banner.GetHeight()) ? (BanHeight - Banner.GetHeight()) : 0;
|
2020-03-17 20:43:58 +01:00
|
|
|
// DBG("banner position old style\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 18:30:39 +02:00
|
|
|
DBG("BannerPlace at Clear Screen [%lld,%lld]\n", BannerPlace.XPos, BannerPlace.YPos);
|
2020-03-17 20:43:58 +01:00
|
|
|
//Then prepare Background from BigBack
|
2020-04-20 02:55:35 +02:00
|
|
|
if (Background.GetWidth() != UGAWidth || Background.GetHeight() != UGAHeight) { // should we type UGAWidth and UGAHeight as UINTN to avoid cast ?
|
|
|
|
// Resolution changed or empty background
|
2020-03-17 20:43:58 +01:00
|
|
|
Background = XImage(UGAWidth, UGAHeight);
|
|
|
|
}
|
2020-04-03 22:00:42 +02:00
|
|
|
// now we are sure Background has UGA sizes
|
2020-04-12 20:53:27 +02:00
|
|
|
float BigScale;
|
|
|
|
float BigScaleY;
|
2020-03-17 20:43:58 +01:00
|
|
|
if (!BigBack.isEmpty()) {
|
|
|
|
switch (BackgroundScale) {
|
|
|
|
case imScale:
|
2020-04-12 20:53:27 +02:00
|
|
|
// DBG("back copy scaled\n");
|
|
|
|
// Background.setSizeInPixels(UGAWidth, UGAHeight); //anyway set
|
|
|
|
BigScale = (float)UGAWidth/BigBack.GetWidth();
|
|
|
|
BigScaleY = (float)UGAHeight/BigBack.GetHeight();
|
|
|
|
Background.CopyScaled(BigBack, MAX(BigScale, BigScaleY));
|
2020-03-17 20:43:58 +01:00
|
|
|
break;
|
|
|
|
case imCrop:
|
2020-03-18 07:39:11 +01:00
|
|
|
{
|
2020-03-17 20:43:58 +01:00
|
|
|
INTN x = UGAWidth - BigBack.GetWidth();
|
|
|
|
INTN x1, x2, y1, y2;
|
|
|
|
if (x >= 0) {
|
|
|
|
x1 = x >> 1;
|
|
|
|
x2 = 0;
|
|
|
|
x = BigBack.GetWidth();
|
|
|
|
} else {
|
|
|
|
x1 = 0;
|
|
|
|
x2 = (-x) >> 1;
|
|
|
|
x = UGAWidth;
|
|
|
|
}
|
|
|
|
INTN y = UGAHeight - BigBack.GetHeight();
|
|
|
|
if (y >= 0) {
|
|
|
|
y1 = y >> 1;
|
|
|
|
y2 = 0;
|
|
|
|
y = BigBack.GetHeight();
|
|
|
|
} else {
|
|
|
|
y1 = 0;
|
|
|
|
y2 = (-y) >> 1;
|
|
|
|
y = UGAHeight;
|
|
|
|
}
|
2020-04-03 22:00:42 +02:00
|
|
|
const EG_RECT BackRect = EG_RECT(x1, y1, x, y);
|
|
|
|
const EG_RECT BigRect = EG_RECT(x2, y2, x, y);
|
2020-03-17 20:43:58 +01:00
|
|
|
//the function can be in XImage class
|
2020-04-03 22:00:42 +02:00
|
|
|
// egRawCopy((EG_PIXEL*)Background.GetPixelPtr(x1, y1),
|
|
|
|
// (EG_PIXEL*)BigBack.GetPixelPtr(x2, y2),
|
|
|
|
// x, y, Background.GetWidth(), BigBack.GetWidth());
|
2020-03-31 16:25:07 +02:00
|
|
|
// DBG("crop to x,y: %lld, %lld\n", x, y);
|
2020-04-03 22:00:42 +02:00
|
|
|
Background.CopyRect(BigBack, BackRect, BigRect);
|
2020-04-01 14:57:32 +02:00
|
|
|
// DBG("back copy cropped\n");
|
2020-03-17 20:43:58 +01:00
|
|
|
break;
|
2020-03-18 07:39:11 +01:00
|
|
|
}
|
2020-03-17 20:43:58 +01:00
|
|
|
case imTile:
|
2020-03-18 07:39:11 +01:00
|
|
|
{
|
|
|
|
INTN x = (BigBack.GetWidth() * ((UGAWidth - 1) / BigBack.GetWidth() + 1) - UGAWidth) >> 1;
|
|
|
|
INTN y = (BigBack.GetHeight() * ((UGAHeight - 1) / BigBack.GetHeight() + 1) - UGAHeight) >> 1;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* p1 = Background.GetPixelPtr(0, 0);
|
|
|
|
for (INTN j = 0; j < UGAHeight; j++) {
|
|
|
|
for (INTN i = 0; i < UGAWidth; i++) {
|
2020-03-17 20:43:58 +01:00
|
|
|
*p1++ = BigBack.GetPixel((i + x) % BigBack.GetWidth(), (j + y) % BigBack.GetHeight());
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 14:57:32 +02:00
|
|
|
// DBG("back copy tiled\n");
|
2020-03-17 20:43:58 +01:00
|
|
|
break;
|
2020-03-18 07:39:11 +01:00
|
|
|
}
|
2020-03-17 20:43:58 +01:00
|
|
|
case imNone:
|
|
|
|
default:
|
|
|
|
// already scaled
|
2020-03-31 14:35:04 +02:00
|
|
|
Background = BigBack;
|
2020-04-01 14:57:32 +02:00
|
|
|
// DBG("back copy equal\n");
|
2020-03-17 20:43:58 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-04-20 02:55:35 +02:00
|
|
|
} else {
|
|
|
|
// no background loaded, fill by default
|
|
|
|
if (!embedded) {
|
|
|
|
BlueBackgroundPixel = FirstBannerPixel;
|
|
|
|
} else if (Daylight) {
|
|
|
|
// embedded light
|
|
|
|
BlueBackgroundPixel = StdBackgroundPixel;
|
|
|
|
} else {
|
|
|
|
// embedded dark
|
|
|
|
BlueBackgroundPixel = DarkEmbeddedBackgroundPixel;
|
|
|
|
}
|
|
|
|
Background.Fill(BlueBackgroundPixel); //blue opaque. May be better to set black opaque?
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
2020-04-03 22:00:42 +02:00
|
|
|
//join Banner and Background for menu drawing
|
|
|
|
if (!Banner.isEmpty()) {
|
|
|
|
Background.Compose(BannerPlace.XPos, BannerPlace.YPos, Banner, true);
|
|
|
|
}
|
2020-04-01 16:59:58 +02:00
|
|
|
Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight);
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
|
|
|
|
2020-04-05 16:04:39 +02:00
|
|
|
#if 0
|
2020-03-29 07:42:33 +02:00
|
|
|
void XTheme::InitSelection() //for PNG theme
|
2020-03-17 20:43:58 +01:00
|
|
|
{
|
2020-03-19 19:35:58 +01:00
|
|
|
EFI_STATUS Status;
|
2020-03-17 20:43:58 +01:00
|
|
|
if (!AllowGraphicsMode)
|
|
|
|
return;
|
2020-03-19 19:35:58 +01:00
|
|
|
//used to fill TextBuffer if selected
|
2020-04-01 14:57:32 +02:00
|
|
|
SelectionBackgroundPixel.Red = (SelectionColor >> 24) & 0xFF;
|
|
|
|
SelectionBackgroundPixel.Green = (SelectionColor >> 16) & 0xFF;
|
|
|
|
SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF;
|
|
|
|
SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF;
|
2020-03-17 20:43:58 +01:00
|
|
|
|
2020-03-19 19:35:58 +01:00
|
|
|
if (!SelectionImages[0].isEmpty()) { //already presents
|
2020-03-17 20:43:58 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-03-18 15:11:56 +01:00
|
|
|
|
2020-04-01 19:07:57 +02:00
|
|
|
if (TypeSVG) {
|
|
|
|
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL);
|
|
|
|
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG);
|
|
|
|
if (SelectionImages[0].isEmpty()) {
|
|
|
|
SelectionImages[0] = SelectionImages[2]; //use same selection if OnTop for example
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// load small selection image
|
|
|
|
if (SelectionImages[2].isEmpty()){
|
|
|
|
SelectionImages[2].LoadXImage(ThemeDir, SelectionSmallFileName);
|
|
|
|
}
|
|
|
|
if (SelectionImages[2].isEmpty()){
|
|
|
|
// SelectionImages[2] = BuiltinIcon(BUILTIN_SELECTION_SMALL);
|
|
|
|
// SelectionImages[2]->HasAlpha = FALSE; // support transparensy for selection icons
|
|
|
|
if (Daylight) {
|
|
|
|
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_selection_small), ACCESS_EMB_SIZE(emb_selection_small));
|
|
|
|
} else {
|
|
|
|
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_small), ACCESS_EMB_SIZE(emb_dark_selection_small));
|
|
|
|
}
|
|
|
|
// CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); //why???
|
|
|
|
}
|
|
|
|
//cut or extend the image by Compose
|
|
|
|
/* SelectionImages[2] = egEnsureImageSize(SelectionImages[2],
|
|
|
|
row1TileSize, row1TileSize, &MenuBackgroundPixel);
|
|
|
|
if (SelectionImages[2] == NULL) {
|
|
|
|
return;
|
|
|
|
} */
|
|
|
|
|
|
|
|
// load big selection image
|
|
|
|
if (SelectionImages[0].isEmpty()) {
|
|
|
|
SelectionImages[0].LoadXImage(ThemeDir, SelectionBigFileName);
|
|
|
|
// SelectionImages[0].EnsureImageSize(row0TileSize, row0TileSize, &MenuBackgroundPixel);
|
2020-03-18 10:07:34 +01:00
|
|
|
}
|
2020-03-18 07:39:11 +01:00
|
|
|
if (SelectionImages[0].isEmpty()) {
|
2020-04-01 19:07:57 +02:00
|
|
|
// calculate big selection image from small one
|
|
|
|
// SelectionImages[0] = BuiltinIcon(BUILTIN_SELECTION_BIG);
|
|
|
|
if (Daylight) {
|
|
|
|
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_selection_big), ACCESS_EMB_SIZE(emb_selection_big));
|
|
|
|
} else {
|
|
|
|
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_big), ACCESS_EMB_SIZE(emb_dark_selection_big));
|
|
|
|
}
|
|
|
|
// SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons
|
|
|
|
//CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
BlueBackgroundPixel = StdBackgroundPixel;
|
|
|
|
if (SelectionImages[0].isEmpty()) {
|
|
|
|
SelectionImages[2].setEmpty();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if (SelectionOnTop) {
|
|
|
|
// SelectionImages[0]->HasAlpha = TRUE; // TODO ?
|
|
|
|
// SelectionImages[2]->HasAlpha = TRUE;
|
|
|
|
// }
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// BootCampStyle indicator image
|
2020-03-18 10:07:34 +01:00
|
|
|
if (BootCampStyle) {
|
2020-03-17 20:43:58 +01:00
|
|
|
// load indicator selection image
|
2020-03-29 07:42:33 +02:00
|
|
|
if (!TypeSVG && SelectionImages[4].isEmpty()) {
|
2020-03-19 19:35:58 +01:00
|
|
|
SelectionImages[4].LoadXImage(ThemeDir, SelectionIndicatorName);
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
2020-04-01 19:07:57 +02:00
|
|
|
if (SelectionImages[4].isEmpty()) {
|
|
|
|
SelectionImages[4].FromPNG(ACCESS_EMB_DATA(emb_selection_indicator), ACCESS_EMB_SIZE(emb_selection_indicator));
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
2020-03-18 10:07:34 +01:00
|
|
|
INTN ScaledIndicatorSize = (INTN)(INDICATOR_SIZE * Scale);
|
2020-04-01 19:07:57 +02:00
|
|
|
SelectionImages[4].EnsureImageSize(ScaledIndicatorSize, ScaledIndicatorSize, MenuBackgroundPixel);
|
2020-03-18 07:39:11 +01:00
|
|
|
if (SelectionImages[4].isEmpty()) {
|
2020-03-18 10:07:34 +01:00
|
|
|
// SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
|
|
|
|
// TRUE, &StdBackgroundPixel);
|
|
|
|
SelectionImages[4] = XImage(ScaledIndicatorSize, ScaledIndicatorSize);
|
2020-04-01 14:57:32 +02:00
|
|
|
SelectionImages[4].Fill(StdBackgroundPixel);
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
2020-03-18 10:07:34 +01:00
|
|
|
SelectionImages[5] = XImage(ScaledIndicatorSize, ScaledIndicatorSize);
|
2020-04-01 14:57:32 +02:00
|
|
|
SelectionImages[5].Fill(MenuBackgroundPixel);
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Button & radio, or any other next icons with builtin icon as fallback should synced to:
|
|
|
|
- BUILTIN_ICON_* in lib.h
|
|
|
|
- BuiltinIconTable in icns.c
|
|
|
|
- Data in egemb_icons.h / scroll_images.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Radio buttons
|
|
|
|
//it was a nonsense egLoadImage is just inluded into egLoadIcon.
|
|
|
|
// will be corrected with XTheme support
|
|
|
|
//the procedure loadIcon should also check embedded icons
|
2020-03-19 19:35:58 +01:00
|
|
|
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_radio_button_selected)
|
|
|
|
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_radio_button)
|
|
|
|
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_checkbox)
|
|
|
|
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_checkbox_checked)
|
2020-03-20 18:48:19 +01:00
|
|
|
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_dark_font_data)
|
2020-03-19 19:35:58 +01:00
|
|
|
|
2020-04-01 19:07:57 +02:00
|
|
|
if (!TypeSVG) { //SVG theme already parsed buttons
|
|
|
|
Status = Buttons[0].LoadXImage(ThemeDir, "radio_button");
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Buttons[0].FromPNG(ACCESS_EMB_DATA(emb_radio_button), ACCESS_EMB_SIZE(emb_radio_button));
|
|
|
|
}
|
|
|
|
Status = Buttons[1].LoadXImage(ThemeDir, "radio_button_selected");
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Buttons[1].FromPNG(ACCESS_EMB_DATA(emb_radio_button_selected), ACCESS_EMB_SIZE(emb_radio_button_selected));
|
|
|
|
}
|
|
|
|
Status = Buttons[2].LoadXImage(ThemeDir, "checkbox");
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Buttons[2].FromPNG(ACCESS_EMB_DATA(emb_checkbox), ACCESS_EMB_SIZE(emb_checkbox));
|
|
|
|
}
|
|
|
|
Status = Buttons[3].LoadXImage(ThemeDir, "checkbox_checked");
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Buttons[3].FromPNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked));
|
|
|
|
}
|
|
|
|
} else {
|
2020-04-03 22:00:42 +02:00
|
|
|
//SVG theme already parsed all icons
|
2020-04-30 08:22:26 +02:00
|
|
|
Buttons[0] = GetIcon("radio_button"_XS8);
|
|
|
|
Buttons[1] = GetIcon("radio_button_selected"_XS8);
|
|
|
|
Buttons[2] = GetIcon("checkbox"_XS8);
|
|
|
|
Buttons[3] = GetIcon("checkbox_checked"_XS8);
|
2020-03-19 19:35:58 +01:00
|
|
|
}
|
2020-03-18 10:07:34 +01:00
|
|
|
|
2020-03-17 20:43:58 +01:00
|
|
|
// non-selected background images
|
2020-03-18 10:07:34 +01:00
|
|
|
|
2020-03-21 12:43:45 +01:00
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff };
|
2020-04-04 05:46:41 +02:00
|
|
|
if (TypeSVG || !SelectionBigFileName.isEmpty()) {
|
2020-03-18 10:07:34 +01:00
|
|
|
BackgroundPixel = { 0x00, 0x00, 0x00, 0x00 };
|
2020-04-04 05:46:41 +02:00
|
|
|
} else if (DarkEmbedded) {
|
|
|
|
BackgroundPixel = { 0x33, 0x33, 0x33, 0x00 }; //nonsense. Will be a sense if semi-transparent
|
2020-04-01 19:07:57 +02:00
|
|
|
} else { //for example embedded daylight
|
2020-03-18 10:07:34 +01:00
|
|
|
BackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff };
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
2020-04-01 19:07:57 +02:00
|
|
|
|
2020-03-18 10:07:34 +01:00
|
|
|
SelectionImages[1] = XImage(row0TileSize, row0TileSize);
|
2020-03-21 12:43:45 +01:00
|
|
|
SelectionImages[1].Fill(BackgroundPixel);
|
2020-03-18 10:07:34 +01:00
|
|
|
SelectionImages[3] = XImage(row1TileSize, row1TileSize);
|
2020-03-21 12:43:45 +01:00
|
|
|
SelectionImages[3].Fill(BackgroundPixel);
|
2020-03-18 10:07:34 +01:00
|
|
|
|
2020-03-17 20:43:58 +01:00
|
|
|
}
|
2020-04-05 16:04:39 +02:00
|
|
|
#endif
|
2020-03-19 19:35:58 +01:00
|
|
|
//use this only for PNG theme
|
2020-03-18 15:11:56 +01:00
|
|
|
void XTheme::FillByDir() //assume ThemeDir is defined by InitTheme() procedure
|
|
|
|
{
|
2020-04-06 11:15:36 +02:00
|
|
|
EFI_STATUS Status;
|
2020-04-02 21:27:10 +02:00
|
|
|
Icons.Empty();
|
2020-04-23 13:36:35 +02:00
|
|
|
for (INTN i = 0; i < IconsNamesSize; ++i) { //scan full table
|
2020-04-21 20:41:35 +02:00
|
|
|
Status = EFI_NOT_FOUND;
|
2020-04-05 23:14:27 +02:00
|
|
|
Icon* NewIcon = new Icon(i); //initialize without embedded
|
2020-04-21 20:41:35 +02:00
|
|
|
switch (i) {
|
|
|
|
case BUILTIN_SELECTION_SMALL:
|
|
|
|
Status = NewIcon->Image.LoadXImage(ThemeDir, SelectionSmallFileName);
|
|
|
|
break;
|
|
|
|
case BUILTIN_SELECTION_BIG:
|
|
|
|
Status = NewIcon->Image.LoadXImage(ThemeDir, SelectionBigFileName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Status = NewIcon->Image.LoadXImage(ThemeDir, IconsNames[i]);
|
|
|
|
}
|
2020-04-18 08:39:47 +02:00
|
|
|
NewIcon->Native = !EFI_ERROR(Status);
|
2020-04-21 20:41:35 +02:00
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
NewIcon->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i]));
|
2020-04-06 11:15:36 +02:00
|
|
|
}
|
2020-04-21 20:41:35 +02:00
|
|
|
Icons.AddReference(NewIcon, true);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
if (i >= BUILTIN_ICON_VOL_INTERNAL_HFS && i <= BUILTIN_ICON_VOL_INTERNAL_REC) {
|
|
|
|
// call to GetIconAlt will get alternate/embedded into Icon if missing
|
|
|
|
GetIconAlt(i, BUILTIN_ICON_VOL_INTERNAL);
|
|
|
|
} else if (i == BUILTIN_SELECTION_BIG) {
|
|
|
|
GetIconAlt(i, BUILTIN_SELECTION_SMALL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (BootCampStyle) {
|
|
|
|
Icon *NewIcon = new Icon(BUILTIN_ICON_SELECTION);
|
|
|
|
// load indicator selection image
|
|
|
|
Status = NewIcon->Image.LoadXImage(ThemeDir, SelectionIndicatorName);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Status = NewIcon->Image.LoadXImage(ThemeDir, "selection_indicator");
|
2020-04-06 11:15:36 +02:00
|
|
|
}
|
2020-04-02 21:27:10 +02:00
|
|
|
Icons.AddReference(NewIcon, true);
|
2020-03-18 15:11:56 +01:00
|
|
|
}
|
2020-03-19 19:35:58 +01:00
|
|
|
|
2020-04-05 16:04:39 +02:00
|
|
|
SelectionBackgroundPixel.Red = (SelectionColor >> 24) & 0xFF;
|
|
|
|
SelectionBackgroundPixel.Green = (SelectionColor >> 16) & 0xFF;
|
|
|
|
SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF;
|
|
|
|
SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF;
|
|
|
|
|
2020-04-21 20:41:35 +02:00
|
|
|
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL);
|
|
|
|
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG);
|
2020-04-05 16:04:39 +02:00
|
|
|
if (BootCampStyle) {
|
2020-04-21 20:41:35 +02:00
|
|
|
SelectionImages[4] = GetIcon(BUILTIN_ICON_SELECTION);
|
2020-04-05 16:04:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//and buttons
|
|
|
|
Buttons[0] = GetIcon(BUILTIN_RADIO_BUTTON);
|
|
|
|
Buttons[1] = GetIcon(BUILTIN_RADIO_BUTTON_SELECTED);
|
|
|
|
Buttons[2] = GetIcon(BUILTIN_CHECKBOX);
|
|
|
|
Buttons[3] = GetIcon(BUILTIN_CHECKBOX_CHECKED);
|
2020-03-19 19:35:58 +01:00
|
|
|
|
2020-03-20 18:48:19 +01:00
|
|
|
//load banner and background
|
2020-03-19 19:35:58 +01:00
|
|
|
Banner.LoadXImage(ThemeDir, BannerFileName);
|
2020-04-06 11:15:36 +02:00
|
|
|
Status = BigBack.LoadXImage(ThemeDir, BackgroundName);
|
|
|
|
if (EFI_ERROR(Status) && !Banner.isEmpty()) {
|
|
|
|
//take first pixel from banner
|
|
|
|
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& firstPixel = Banner.GetPixel(0,0);
|
|
|
|
BigBack.setSizeInPixels(UGAWidth, UGAHeight);
|
|
|
|
BigBack.Fill(firstPixel);
|
|
|
|
}
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void XTheme::InitBar()
|
|
|
|
{
|
|
|
|
if (!TypeSVG) {
|
|
|
|
ScrollbarBackgroundImage.LoadXImage(ThemeDir, "scrollbar\\bar_fill");
|
|
|
|
BarStartImage.LoadXImage(ThemeDir, "scrollbar\\bar_start");
|
|
|
|
BarEndImage.LoadXImage(ThemeDir, "scrollbar\\bar_end");
|
|
|
|
ScrollbarImage.LoadXImage(ThemeDir, "scrollbar\\scroll_fill");
|
|
|
|
ScrollStartImage.LoadXImage(ThemeDir, "scrollbar\\scroll_start");
|
|
|
|
ScrollEndImage.LoadXImage(ThemeDir, "scrollbar\\scroll_end");
|
|
|
|
UpButtonImage.LoadXImage(ThemeDir, "scrollbar\\up_button");
|
|
|
|
DownButtonImage.LoadXImage(ThemeDir, "scrollbar\\down_button");
|
2020-05-04 18:05:29 +02:00
|
|
|
} else {
|
|
|
|
ScrollbarBackgroundImage.setEmpty();
|
|
|
|
BarStartImage.setEmpty();
|
|
|
|
BarEndImage.setEmpty();
|
|
|
|
ScrollbarImage.setEmpty();
|
|
|
|
ScrollStartImage.setEmpty();
|
|
|
|
ScrollEndImage.setEmpty();
|
|
|
|
UpButtonImage.setEmpty();
|
|
|
|
DownButtonImage.setEmpty();
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
2020-03-19 19:35:58 +01:00
|
|
|
|
2020-03-20 18:48:19 +01:00
|
|
|
//some help with embedded scroll
|
|
|
|
if (BarStartImage.isEmpty() && !TypeSVG) {
|
|
|
|
BarStartImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_bar_start), ACCESS_EMB_SIZE(emb_scroll_bar_start));
|
|
|
|
}
|
|
|
|
if (BarEndImage.isEmpty() && !TypeSVG) {
|
|
|
|
BarEndImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_bar_end), ACCESS_EMB_SIZE(emb_scroll_bar_end));
|
|
|
|
}
|
|
|
|
if (ScrollbarBackgroundImage.isEmpty()) {
|
|
|
|
if (TypeSVG) {
|
|
|
|
//return OSIconsTable[i].image;
|
2020-04-30 08:22:26 +02:00
|
|
|
ScrollbarBackgroundImage = GetIcon("scrollbar_background"_XS8);
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
if (ScrollbarBackgroundImage.isEmpty()) {
|
|
|
|
ScrollbarBackgroundImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_bar_fill), ACCESS_EMB_SIZE(emb_scroll_bar_fill));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ScrollbarImage.isEmpty()) {
|
|
|
|
if (TypeSVG) {
|
2020-04-30 08:22:26 +02:00
|
|
|
ScrollbarImage = GetIcon("scrollbar_holder"_XS8); //"_night" is already accounting
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
if (ScrollbarImage.isEmpty()) {
|
|
|
|
ScrollbarImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_scroll_fill), ACCESS_EMB_SIZE(emb_scroll_scroll_fill));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ScrollStartImage.isEmpty()) {
|
|
|
|
if (TypeSVG) {
|
2020-04-30 08:22:26 +02:00
|
|
|
ScrollStartImage = GetIcon("scrollbar_start"_XS8);
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
if (ScrollStartImage.isEmpty()) {
|
|
|
|
ScrollStartImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_scroll_start), ACCESS_EMB_SIZE(emb_scroll_scroll_start));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ScrollEndImage.isEmpty()) {
|
|
|
|
if (TypeSVG) {
|
2020-04-30 08:22:26 +02:00
|
|
|
ScrollEndImage = GetIcon("scrollbar_end"_XS8);
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
if (ScrollEndImage.isEmpty()) {
|
|
|
|
ScrollEndImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_scroll_end), ACCESS_EMB_SIZE(emb_scroll_scroll_end));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (UpButtonImage.isEmpty()) {
|
|
|
|
if (TypeSVG) {
|
2020-04-30 08:22:26 +02:00
|
|
|
UpButtonImage = GetIcon("scrollbar_up_button"_XS8);
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
UpButtonImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_up_button), ACCESS_EMB_SIZE(emb_scroll_up_button));
|
|
|
|
}
|
|
|
|
if (DownButtonImage.isEmpty()) {
|
|
|
|
if (TypeSVG) {
|
2020-04-30 08:22:26 +02:00
|
|
|
DownButtonImage = GetIcon("scrollbar_down_button"_XS8);
|
2020-03-20 18:48:19 +01:00
|
|
|
}
|
|
|
|
if (DownButtonImage.isEmpty()) {
|
|
|
|
DownButtonImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_down_button), ACCESS_EMB_SIZE(emb_scroll_down_button));
|
|
|
|
}
|
|
|
|
}
|
2020-03-18 15:11:56 +01:00
|
|
|
}
|
2020-03-20 18:48:19 +01:00
|
|
|
|
2020-04-05 05:44:27 +02:00
|
|
|
//the purpose of the procedure is restore Background in rect
|
|
|
|
//XAlign is always centre, Color is the Backgrounf fill
|
|
|
|
//TODO replace by some existing procedure
|
|
|
|
VOID XTheme::FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height)
|
|
|
|
{
|
|
|
|
// TmpBuffer.CopyScaled(Background, 1.f);
|
|
|
|
INTN X = XPos - (Width >> 1); //X_IS_CENTRE
|
2020-04-09 20:04:35 +02:00
|
|
|
if (X < 0) {
|
|
|
|
X = 0;
|
|
|
|
}
|
|
|
|
if (X + Width > UGAWidth) {
|
2020-04-18 11:46:52 +02:00
|
|
|
Width = (X > UGAWidth) ? 0 : (UGAWidth - X);
|
2020-04-09 20:04:35 +02:00
|
|
|
}
|
|
|
|
if (YPos + Height > UGAHeight) {
|
2020-04-18 11:46:52 +02:00
|
|
|
Height = (YPos > UGAHeight) ? 0 : (UGAHeight - YPos);
|
2020-04-09 20:04:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
XImage TmpBuffer(Width, Height);
|
2020-04-05 05:44:27 +02:00
|
|
|
TmpBuffer.CopyRect(Background, X, YPos); //a part of BackGround image
|
|
|
|
TmpBuffer.DrawWithoutCompose(X, YPos);
|
|
|
|
// TmpBuffer.Draw(X, YPos, 0, true);
|
|
|
|
}
|
|
|
|
|
2020-04-10 12:04:21 +02:00
|
|
|
|
2020-03-29 15:44:08 +02:00
|
|
|
|
2020-03-20 18:48:19 +01:00
|
|
|
|