eliminate mouse edge effect

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-31 15:35:04 +03:00
parent 8b806cf4e7
commit 0c62865b22
7 changed files with 49 additions and 39 deletions

View File

@ -135,13 +135,13 @@ typedef struct {
INTN CharWidth;
UINTN SelectionColor;
CHAR16 *FontFileName;
CHAR16 *Theme;
CHAR16 *BannerFileName;
CHAR16 *SelectionSmallFileName;
CHAR16 *SelectionBigFileName;
CHAR16 *SelectionIndicatorName;
CHAR16 *DefaultSelection;
#endif
CHAR16 *Theme;
CHAR16 *ScreenResolution;
INTN ConsoleMode;
BOOLEAN CustomIcons;
@ -209,13 +209,13 @@ REFIT_CONFIG GlobalConfig = {
9, // INTN CharWidth;
0xFFFFFF80, // UINTN SelectionColor;
NULL, // CHAR16 *FontFileName;
NULL, // CHAR16 *Theme;
NULL, // CHAR16 *BannerFileName;
NULL, // CHAR16 *SelectionSmallFileName;
NULL, // CHAR16 *SelectionBigFileName;
NULL, // CHAR16 *SelectionIndicatorName;
NULL, // CHAR16 *DefaultSelection;
#endif
NULL, // CHAR16 *Theme;
NULL, // CHAR16 *ScreenResolution;
0, // INTN ConsoleMode;
FALSE, // BOOLEAN CustomIcons;
@ -2971,11 +2971,12 @@ GetEarlyUserSettings (
if (Prop != NULL) {
if ((Prop->type == kTagTypeString) && Prop->string) {
ThemeX.Theme.takeValueFrom(Prop->string);
DBG ("Default theme: %ls\n", ThemeX.Theme.data());
GlobalConfig.Theme = PoolPrint (L"%a", Prop->string);
DBG ("Default theme: %ls\n", GlobalConfig.Theme);
OldChosenTheme = 0xFFFF; //default for embedded
for (UINTN i = 0; i < ThemesNum; i++) {
//now comparison is case sensitive
if (StriCmp(ThemeX.Theme.data(), ThemesList[i]) == 0) {
if (StriCmp(GlobalConfig.Theme, ThemesList[i]) == 0) {
OldChosenTheme = i;
break;
}
@ -3831,7 +3832,7 @@ XTheme::GetThemeTagSettings (void* DictP)
// if NULL parameter, quit after setting default values, this is embedded theme
if (DictPointer == NULL) {
if (DictP == NULL) {
return EFI_SUCCESS;
}
@ -4869,7 +4870,8 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
// DBG("...done\n");
ThemeX.GetThemeTagSettings(NULL);
if (ThemesNum > 0) {
if (ThemesNum > 0 &&
(!GlobalConfig.Theme || StriCmp(GlobalConfig.Theme, L"embedded") != 0)) {
// Try special theme first
if (Time != NULL) {
if ((Time->Month == 12) && ((Time->Day >= 25) && (Time->Day <= 31))) {
@ -4924,19 +4926,24 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
}
// Try to get theme from settings
if (ThemeDict == NULL) {
if (ThemeX.Theme.isEmpty()) {
if (!GlobalConfig.Theme) {
if (Time != NULL) {
DBG ("no default theme, get random theme %ls\n", ThemesList[Rnd]);
} else {
DBG ("no default theme, get first theme %ls\n", ThemesList[0]);
}
} else {
if (StriCmp(ThemeX.Theme.data(), L"random") == 0) {
ThemeDict = LoadTheme (ThemesList[Rnd]);
} else {
ThemeDict = LoadTheme (ThemeX.Theme.data());
DBG ("no default theme, get first theme %ls\n", ThemesList[0]);
ThemeDict = LoadTheme (ThemesList[0]);
}
} else {
if (StriCmp(GlobalConfig.Theme, L"random") == 0) {
ThemeDict = LoadTheme (ThemesList[Rnd]);
} else {
ThemeDict = LoadTheme (GlobalConfig.Theme);
if (ThemeDict == NULL) {
DBG ("GlobalConfig: %ls not found, get embedded theme\n", ThemeX.Theme.data());
DBG ("GlobalConfig: %ls not found, get embedded theme\n", GlobalConfig.Theme);
} else {
DBG("chosen theme %ls\n", GlobalConfig.Theme);
ThemeX.Theme.takeValueFrom(GlobalConfig.Theme);
}
}
}
@ -4958,7 +4965,7 @@ finish:
ThemeDir = NULL;
}
ThemeX.GetThemeTagSettings(NULL);
// ThemeX.GetThemeTagSettings(NULL); already done
//fill some fields
ThemeX.Font = FONT_ALFA; //to be inverted later. At start we have FONT_GRAY
ThemeX.embedded = true;
@ -5001,10 +5008,7 @@ finish:
#else
EFI_STATUS
InitTheme(
BOOLEAN UseThemeDefinedInNVRam,
EFI_TIME *Time
)
InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
{
EFI_STATUS Status = EFI_NOT_FOUND;
UINTN Size = 0;
@ -7325,7 +7329,8 @@ GetUserSettings(
if (DictPointer != NULL) {
Prop = GetProperty (DictPointer, "Theme");
if ((Prop != NULL) && (Prop->type == kTagTypeString) && Prop->string) {
ThemeX.Theme.takeValueFrom(Prop->string);
// ThemeX.Theme.takeValueFrom(Prop->string);
GlobalConfig.Theme = PoolPrint (L"%a", Prop->string);
DBG ("Theme from new config: %ls\n", ThemeX.Theme.data());
}
}

View File

@ -501,10 +501,10 @@ void XImage::Draw(INTN x, INTN y, float scale, bool Opaque)
XImage Top(*this, scale); //can accept 0 as scale
XImage Background(Width, Height);
Background.GetArea(x, y, Width, Height);
Background.Compose(0, 0, Top, Opaque);
UINTN AreaWidth = (x + Width > (UINTN)UGAWidth) ? (UGAWidth - x) : Width;
UINTN AreaHeight = (y + Height > (UINTN)UGAHeight) ? (UGAHeight - y) : Height;
Background.GetArea(x, y, AreaWidth, AreaHeight); //it will resize the Background image
Background.Compose(0, 0, Top, Opaque);
// prepare protocols
EFI_STATUS Status;
@ -524,11 +524,11 @@ void XImage::Draw(INTN x, INTN y, float scale, bool Opaque)
if (GraphicsOutput != NULL) {
GraphicsOutput->Blt(GraphicsOutput, Background.GetPixelPtr(0, 0),
EfiBltBufferToVideo,
0, 0, x, y, AreaWidth, AreaHeight, GetWidth()*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
0, 0, x, y, AreaWidth, AreaHeight, AreaWidth*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Background.GetPixelPtr(0, 0), EfiUgaBltBufferToVideo,
0, 0, x, y, AreaWidth, AreaHeight, GetWidth()*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
0, 0, x, y, AreaWidth, AreaHeight, AreaWidth*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
}

View File

@ -116,7 +116,11 @@ VOID XPointer::Draw()
oldPlace = newPlace;
// CopyMem(&oldPlace, &newPlace, sizeof(EG_RECT)); //can we use oldPlace = newPlace; ?
// take background image for later to restore background
oldImage.GetArea(newPlace);
newPlace.Width = PointerImage->GetWidth();
newPlace.Height = PointerImage->GetHeight();
oldImage.GetArea(newPlace); //GetArea will resize oldImage, so correct newPlace
newPlace.Width = oldImage.GetWidth();
newPlace.Height = oldImage.GetHeight();
PointerImage->Draw(newPlace.XPos, newPlace.YPos); //zero means no scale
}

View File

@ -431,10 +431,11 @@ void XTheme::ClearScreen() //and restore background and banner
case imNone:
default:
// already scaled
Background = BigBack;
break;
}
}
Background.Draw(0, 0);
Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight);
//then draw banner
if (!Banner.isEmpty()) {
Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale);

View File

@ -328,13 +328,13 @@ typedef struct {
INTN CharWidth;
UINTN SelectionColor;
CHAR16 *FontFileName;
CHAR16 *Theme;
CHAR16 *BannerFileName;
CHAR16 *SelectionSmallFileName;
CHAR16 *SelectionBigFileName;
CHAR16 *SelectionIndicatorName;
CHAR16 *DefaultSelection;
#endif
CHAR16 *Theme;
CHAR16 *ScreenResolution;
INTN ConsoleMode;
BOOLEAN CustomIcons;

View File

@ -2255,12 +2255,13 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GetListOfConfigs();
}
#if USE_XTHEME
ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings
#endif
for (i=0; i<2; i++) {
if (gConfigDict[i]) {
/* Status = */GetEarlyUserSettings(SelfRootDir, gConfigDict[i]);
// if (EFI_ERROR(Status)) {
// DBG("Error in Early settings%d: %s\n", i, strerror(Status));
// }
GetEarlyUserSettings(SelfRootDir, gConfigDict[i]);
}
}
@ -2273,9 +2274,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
#endif // ENABLE_SECURE_BOOT
MainMenu.TimeoutSeconds = GlobalConfig.Timeout >= 0 ? GlobalConfig.Timeout : 0;
#if USE_XTHEME
ThemeX.FillByEmbedded();
#endif
//DBG("LoadDrivers() start\n");
LoadDrivers();
//DBG("LoadDrivers() end\n");

View File

@ -3773,11 +3773,11 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
case MENU_FUNCTION_PAINT_ALL:
// DrawMenuText(NULL, 0, 0, 0, 0); //should clean every line to avoid artefacts
// DBG("PAINT_ALL: EntriesPosY=%d MaxVisible=%d\n", EntriesPosY, ScrollState.MaxVisible);
// DBG("DownButton.Height=%d TextHeight=%d\n", DownButton.Height, TextHeight);
DBG("PAINT_ALL: EntriesPosY=%lld MaxVisible=%lld\n", EntriesPosY, ScrollState.MaxVisible);
DBG("DownButton.Height=%lld TextHeight=%lld\n", DownButton.Height, TextHeight);
t2 = EntriesPosY + (ScrollState.MaxVisible + 1) * TextHeight - DownButton.Height;
t1 = EntriesPosX + TextHeight + MenuWidth + (INTN)((TEXT_XMARGIN + 16) * ThemeX.Scale);
// DBG("PAINT_ALL: %d %d\n", t1, t2);
DBG("PAINT_ALL: %lld %lld\n", t1, t2);
SetBar(t1, EntriesPosY, t2, &ScrollState); //823 302 554
// blackosx swapped this around so drawing of selection comes before drawing scrollbar.
@ -6873,9 +6873,11 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
gSettings.OptionsBits = EncodeOptions(TmpArgs);
// DBG("main OptionsBits = 0x%X\n", gSettings.OptionsBits);
if ( MainChosenEntry->getLOADER_ENTRY() ) gSettings.OptionsBits |= EncodeOptions(MainChosenEntry->getLOADER_ENTRY()->LoadOptions);
if (MainChosenEntry->getLOADER_ENTRY())
gSettings.OptionsBits |= EncodeOptions(MainChosenEntry->getLOADER_ENTRY()->LoadOptions);
// DBG("add OptionsBits = 0x%X\n", gSettings.OptionsBits);
if ( MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM() ) DecodeOptions(MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM());
if (MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM())
DecodeOptions(MainChosenEntry->getREFIT_MENU_ITEM_BOOTNUM());
// DBG(" enter menu with LoadOptions: %ls\n", ((LOADER_ENTRY*)MainChosenEntry)->LoadOptions);
if (MainChosenEntry->getLOADER_ENTRY()) {
// Only for non-legacy entries, as LEGACY_ENTRY doesn't have Flags