Correct theme Daylight, DarkEmbedded, some other theme issues

This commit is contained in:
asava 2020-04-16 14:04:24 +03:00
parent ea2cb13808
commit f86e36a7e5
7 changed files with 55 additions and 42 deletions

View File

@ -121,7 +121,6 @@ BOOLEAN SetTable132 = FALSE;
//EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //define in lib.h //EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //define in lib.h
const INTN BCSMargin = 11; const INTN BCSMargin = 11;
BOOLEAN DayLight;
// //
DRIVERS_FLAGS gDriversFlags; //the initializer is not needed for global variables DRIVERS_FLAGS gDriversFlags; //the initializer is not needed for global variables
@ -190,7 +189,7 @@ REFIT_CONFIG GlobalConfig = {
FALSE, // BOOLEAN CustomIcons; FALSE, // BOOLEAN CustomIcons;
ICON_FORMAT_DEF, // INTN IconFormat; ICON_FORMAT_DEF, // INTN IconFormat;
FALSE, // BOOLEAN NoEarlyProgress; FALSE, // BOOLEAN NoEarlyProgress;
0, // INT32 Timezone; 0xFF, // INT32 Timezone; / 0xFF - not set
FALSE, // BOOLEAN ShowOptimus; FALSE, // BOOLEAN ShowOptimus;
0xC0, // INTN Codepage; 0xC0, // INTN Codepage;
0xC0, // INTN CodepageSize; //extended latin 0xC0, // INTN CodepageSize; //extended latin
@ -2668,7 +2667,7 @@ GetEarlyUserSettings (
INT32 NowHour = Now.Hour + GlobalConfig.Timezone; INT32 NowHour = Now.Hour + GlobalConfig.Timezone;
if (NowHour < 0 ) NowHour += 24; if (NowHour < 0 ) NowHour += 24;
if (NowHour >= 24 ) NowHour -= 24; if (NowHour >= 24 ) NowHour -= 24;
DayLight = (NowHour > 8) && (NowHour < 20); ThemeX.Daylight = (NowHour > 8) && (NowHour < 20);
Prop = GetProperty (DictPointer, "Theme"); Prop = GetProperty (DictPointer, "Theme");
if (Prop != NULL) { if (Prop != NULL) {
@ -2694,8 +2693,8 @@ GetEarlyUserSettings (
ThemeX.DarkEmbedded = FALSE; ThemeX.DarkEmbedded = FALSE;
ThemeX.Font = FONT_ALFA; ThemeX.Font = FONT_ALFA;
} else if (AsciiStriCmp (Prop->string, "DayTime") == 0) { } else if (AsciiStriCmp (Prop->string, "DayTime") == 0) {
ThemeX.DarkEmbedded = !DayLight; ThemeX.DarkEmbedded = !ThemeX.Daylight;
ThemeX.Font = DayLight?FONT_ALFA:FONT_GRAY; ThemeX.Font = ThemeX.Daylight?FONT_ALFA:FONT_GRAY;
} }
} }
} }
@ -2710,8 +2709,8 @@ GetEarlyUserSettings (
ThemeX.DarkEmbedded = FALSE; ThemeX.DarkEmbedded = FALSE;
ThemeX.Font = FONT_ALFA; ThemeX.Font = FONT_ALFA;
} else if (AsciiStriCmp (Prop->string, "Daytime") == 0) { } else if (AsciiStriCmp (Prop->string, "Daytime") == 0) {
ThemeX.DarkEmbedded = !DayLight; ThemeX.DarkEmbedded = !ThemeX.Daylight;
ThemeX.Font = DayLight?FONT_ALFA:FONT_GRAY; ThemeX.Font = ThemeX.Daylight?FONT_ALFA:FONT_GRAY;
} }
} }
} }
@ -3861,16 +3860,27 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
CHAR8 *ChosenTheme = NULL; CHAR8 *ChosenTheme = NULL;
CHAR16 *TestTheme = NULL; CHAR16 *TestTheme = NULL;
UINTN Rnd; UINTN Rnd;
EFI_TIME Now;
DbgHeader("InitXTheme");
ThemeX.Init(); //initialize Daylight when we know timezone
if (GlobalConfig.Timezone != 0xFF) { // 0xFF:default=timezone not set
if (DayLight) { gRT->GetTime(&Now, NULL);
DBG("use daylight theme\n"); INT32 NowHour = Now.Hour + GlobalConfig.Timezone;
if (NowHour < 0 ) NowHour += 24;
if (NowHour >= 24 ) NowHour -= 24;
ThemeX.Daylight = (NowHour > 8) && (NowHour < 20);
} else {
ThemeX.Daylight = TRUE; // when timezone is not set
}
if (ThemeX.Daylight) {
DBG("use Daylight theme\n");
} else { } else {
DBG("use night theme\n"); DBG("use night theme\n");
} }
DbgHeader("InitXTheme");
ThemeX.Init();
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
// DBG("validate %d face\n", i); // DBG("validate %d face\n", i);
textFace[i].valid = FALSE; textFace[i].valid = FALSE;
@ -3996,7 +4006,13 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
finish: finish:
if (!ThemeDict) { // No theme could be loaded, use embedded if (!ThemeDict) { // No theme could be loaded, use embedded
DBG (" using embedded theme\n"); DBG (" using embedded theme\n");
ThemeX.Init(); if (ThemeX.DarkEmbedded) { // when using embedded, set Daylight according to darkembedded
ThemeX.Daylight = FALSE;
} else {
ThemeX.Daylight = TRUE;
}
ThemeX.FillByEmbedded();
OldChosenTheme = 0xFFFF; OldChosenTheme = 0xFFFF;
if (ThemePath != NULL) { if (ThemePath != NULL) {
FreePool (ThemePath); FreePool (ThemePath);
@ -4030,7 +4046,7 @@ finish:
} }
FreeTag(ThemeDict); FreeTag(ThemeDict);
if (!DayLight) { if (!ThemeX.Daylight) {
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound_night.wav"); Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound_night.wav");
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound.wav"); Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound.wav");

View File

@ -34,7 +34,6 @@
#include "Settings.h" #include "Settings.h"
#include "Nvram.h" #include "Nvram.h"
extern BOOLEAN DayLight;
extern UINTN AudioNum; extern UINTN AudioNum;
extern HDA_OUTPUTS AudioList[20]; extern HDA_OUTPUTS AudioList[20];
extern UINT8 EmbeddedSound[]; extern UINT8 EmbeddedSound[];

View File

@ -49,8 +49,6 @@ extern void DumpFloat2 (CONST char* s, float* t, int N);
extern UINTN NumFrames; extern UINTN NumFrames;
extern UINTN FrameTime; extern UINTN FrameTime;
extern BOOLEAN DayLight;
textFaces textFace[4]; //0-help 1-message 2-menu 3-test, far future it will be infinite list with id textFaces textFace[4]; //0-help 1-message 2-menu 3-test, far future it will be infinite list with id
@ -272,7 +270,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
BigBack.setEmpty(); BigBack.setEmpty();
} }
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
if (!DayLight) { if (!ThemeX.Daylight) {
Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background_night"_XS, &BigBack); Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background_night"_XS, &BigBack);
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
@ -282,7 +280,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
// --- Make Banner // --- Make Banner
Banner.setEmpty(); //for the case of theme switch Banner.setEmpty(); //for the case of theme switch
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
if (!DayLight) { if (!ThemeX.Daylight) {
Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner_night"_XS, &Banner); Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner_night"_XS, &Banner);
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
@ -327,7 +325,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
//selection for bootcamp style //selection for bootcamp style
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
if (!DayLight) { if (!ThemeX.Daylight) {
Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator_night"_XS, &SelectionImages[4]); Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator_night"_XS, &SelectionImages[4]);
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {

View File

@ -220,8 +220,8 @@ void XTheme::Init()
SelectionColor = 0x80808080; SelectionColor = 0x80808080;
SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
FontFileName.setEmpty(); FontFileName.setEmpty();
Theme.takeValueFrom("embedded"); // Theme.takeValueFrom("embedded");
embedded = true; embedded = false;
BannerFileName.setEmpty(); BannerFileName.setEmpty();
SelectionSmallFileName.setEmpty(); SelectionSmallFileName.setEmpty();
SelectionBigFileName.setEmpty(); SelectionBigFileName.setEmpty();
@ -254,13 +254,13 @@ void XTheme::Init()
// IconFormat = ICON_FORMAT_DEF; // IconFormat = ICON_FORMAT_DEF;
Proportional = FALSE; Proportional = FALSE;
// ShowOptimus = FALSE; // ShowOptimus = FALSE;
DarkEmbedded = FALSE; //looks like redundant, we always check Night or Daylight // DarkEmbedded = FALSE; //looks like redundant, we always check Night or Daylight
TypeSVG = FALSE; TypeSVG = FALSE;
// Codepage = 0xC0; //this is for PNG theme // Codepage = 0xC0; //this is for PNG theme
// CodepageSize = 0xC0; // INTN CodepageSize; //extended latin // CodepageSize = 0xC0; // INTN CodepageSize; //extended latin
Scale = 1.0f; Scale = 1.0f;
CentreShift = 0.0f; CentreShift = 0.0f;
Daylight = true; // Daylight = true;
LayoutHeight = 376; LayoutHeight = 376;
LayoutBannerOffset = 64; //default value if not set LayoutBannerOffset = 64; //default value if not set
LayoutButtonOffset = 0; //default value if not set LayoutButtonOffset = 0; //default value if not set
@ -419,23 +419,25 @@ const XImage& XTheme::LoadOSIcon(const XString& Full)
void XTheme::FillByEmbedded() void XTheme::FillByEmbedded()
{ {
embedded = true;
Theme.takeValueFrom("embedded");
SelectionColor = 0xA0A0A080;
SelectionBackgroundPixel = { 0xa0, 0xa0, 0xa0, 0x80 };
Icons.Empty(); Icons.Empty();
for (INTN i = 0; i < BUILTIN_ICON_COUNT; ++i) { //this is embedded icon count for (INTN i = 0; i < BUILTIN_ICON_COUNT; ++i) { //this is embedded icon count
Icon* NewIcon = new Icon(i, true); Icon* NewIcon = new Icon(i, true);
Icons.AddReference(NewIcon, true); Icons.AddReference(NewIcon, true);
} }
Background = XImage(UGAWidth, UGAHeight);
if (DarkEmbedded) {
Background.Fill(DarkEmbeddedBackgroundPixel);
} else {
Background.Fill(StdBackgroundPixel);
}
BigBack.setEmpty(); BigBack.setEmpty();
Background = XImage(UGAWidth, UGAHeight);
if (Daylight) { if (Daylight) {
Background.Fill(StdBackgroundPixel);
Banner.FromPNG(ACCESS_EMB_DATA(emb_logo), emb_logo_size); Banner.FromPNG(ACCESS_EMB_DATA(emb_logo), emb_logo_size);
} else { } else {
Background.Fill(DarkEmbeddedBackgroundPixel);
Banner.FromPNG(ACCESS_EMB_DATA(emb_dark_logo), emb_dark_logo_size); Banner.FromPNG(ACCESS_EMB_DATA(emb_dark_logo), emb_dark_logo_size);
} }

View File

@ -106,8 +106,6 @@ int nsvg__shapesBound(NSVGshape *shapes, float* bounds);
void takeXformBounds(NSVGshape *shape, float *xform, float *bounds); void takeXformBounds(NSVGshape *shape, float *xform, float *bounds);
void nsvg__deleteShapes(NSVGshape* shape); void nsvg__deleteShapes(NSVGshape* shape);
extern BOOLEAN DayLight;
void DumpFloat2 (CONST char* s, float* t, int N) void DumpFloat2 (CONST char* s, float* t, int N)
{ {
#if DEBUG_SVG #if DEBUG_SVG
@ -2917,8 +2915,8 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
DBG("set message->font=%s color=%X size=%f as in MessageRow\n", fontSVG->fontFamily, text->fontColor, text->fontSize); DBG("set message->font=%s color=%X size=%f as in MessageRow\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
} }
break; break;
} else if (!DayLight && strcmp(group->id, "MessageRow_night") == 0) { } else if (!ThemeX.Daylight && strcmp(group->id, "MessageRow_night") == 0) {
//replace daylight settings //replace ThemeX.Daylight settings
p->font = fontSVG; p->font = fontSVG;
p->fontSize = text->fontSize; p->fontSize = text->fontSize;
p->fontColor = text->fontColor; p->fontColor = text->fontColor;
@ -2937,7 +2935,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
DBG("set menu->font=%s color=%X size=%f as in MenuRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize); DBG("set menu->font=%s color=%X size=%f as in MenuRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
} }
break; break;
} else if (!DayLight && strcmp(group->id, "MenuRows_night") == 0) { } else if (!ThemeX.Daylight && strcmp(group->id, "MenuRows_night") == 0) {
textFace[2].font = fontSVG; textFace[2].font = fontSVG;
textFace[2].size = (INTN)text->fontSize; textFace[2].size = (INTN)text->fontSize;
textFace[2].color = text->fontColor; textFace[2].color = text->fontColor;
@ -2952,7 +2950,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
DBG("set help->font=%s color=%X size=%f as in HelpRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize); DBG("set help->font=%s color=%X size=%f as in HelpRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
} }
break; break;
} else if (!DayLight && strstr(group->id, "HelpRows_night") != NULL) { } else if (!ThemeX.Daylight && strstr(group->id, "HelpRows_night") != NULL) {
textFace[0].font = fontSVG; textFace[0].font = fontSVG;
textFace[0].size = (INTN)text->fontSize; textFace[0].size = (INTN)text->fontSize;
textFace[0].color = text->fontColor; textFace[0].color = text->fontColor;
@ -3518,12 +3516,12 @@ void XTheme::parseTheme(void* parser, const char** dict)
BadgeScale = getIntegerDict(dict[i + 1]); BadgeScale = getIntegerDict(dict[i + 1]);
} else if (strcmp(dict[i], "SelectionColor") == 0) { } else if (strcmp(dict[i], "SelectionColor") == 0) {
Color = getIntegerDict(dict[i + 1]); Color = getIntegerDict(dict[i + 1]);
if (DayLight) { if (ThemeX.Daylight) {
SelectionColor = Color; SelectionColor = Color;
} }
} else if (strcmp(dict[i], "SelectionColor_night") == 0) { } else if (strcmp(dict[i], "SelectionColor_night") == 0) {
found = TRUE; found = TRUE;
if (!DayLight) { if (!ThemeX.Daylight) {
SelectionColor = getIntegerDict(dict[i + 1]); SelectionColor = getIntegerDict(dict[i + 1]);
} }
} else if (strcmp(dict[i], "VerticalLayout") == 0) { } else if (strcmp(dict[i], "VerticalLayout") == 0) {

View File

@ -158,7 +158,8 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
(PixelPtr->Red == FirstPixel.Red) (PixelPtr->Red == FirstPixel.Red)
) { ) {
PixelPtr->Reserved = 0; //if a pixel has same color as first pixel then it will be transparent PixelPtr->Reserved = 0; //if a pixel has same color as first pixel then it will be transparent
} else if (ThemeX.DarkEmbedded) { //} else if (ThemeX.DarkEmbedded) {
} else if (!ThemeX.Daylight) {
*PixelPtr = SemiWhitePixel; //special case to change a text to semi white, not blue pixels *PixelPtr = SemiWhitePixel; //special case to change a text to semi white, not blue pixels
} }
FontPtr[Ypos + x] = *PixelPtr++; //not (x, YPos) !!! FontPtr[Ypos + x] = *PixelPtr++; //not (x, YPos) !!!

View File

@ -2163,7 +2163,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GetListOfConfigs(); GetListOfConfigs();
} }
ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings // ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
if (gConfigDict[i]) { if (gConfigDict[i]) {
@ -2418,7 +2418,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
gThemeNeedInit = FALSE; gThemeNeedInit = FALSE;
} else if (gThemeChanged) { } else if (gThemeChanged) {
DBG("change theme\n"); DBG("change theme\n");
ThemeX.FillByEmbedded();
InitTheme(FALSE, NULL); InitTheme(FALSE, NULL);
OptionMenu.FreeMenu(); OptionMenu.FreeMenu();
} }