clean place under buttons

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-04 20:02:30 +03:00
parent 314acac5ab
commit 26795329fe
4 changed files with 30 additions and 45 deletions

View File

@ -207,7 +207,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(void *parser, INTN Id, const XString& IconNameX
XImage NewImage(iWidth, iHeight); //empty
if (IconImage->shapes == NULL) {
*Image = NewImage;
DBG("return empty with status=%s\n", strerror(Status));
// DBG("return empty with status=%s\n", strerror(Status));
return Status;
}
@ -289,7 +289,7 @@ EFI_STATUS ParseSVGIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float Sc
if ((strstr(IconName, "selection_big") != NULL) && (!GlobalConfig.SelectionOnTop)) {
GlobalConfig.MainEntriesSize = (int)(IconImage->width * Scale); //xxx
row0TileSize = GlobalConfig.MainEntriesSize + (int)(16.f * Scale);
DBG("main entry size = %lld\n", GlobalConfig.MainEntriesSize);
DBG("main entry size = %lld\n", GlobalConfig.MainEntriesSize);
}
if ((strstr(IconName, "selection_small") != NULL) && (!GlobalConfig.SelectionOnTop)) {
row1TileSize = (int)(IconImage->width * Scale);

View File

@ -531,7 +531,8 @@ void XImage::Draw(INTN x, INTN y, float scale, bool Opaque)
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);
Background.DrawWithoutCompose(x, y);
#if 0
// prepare protocols
EFI_STATUS Status;
EFI_GUID UgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;
@ -556,6 +557,15 @@ void XImage::Draw(INTN x, INTN y, float scale, bool Opaque)
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Background.GetPixelPtr(0, 0), EfiUgaBltBufferToVideo,
0, 0, x, y, AreaWidth, AreaHeight, AreaWidth*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
#endif
}
void XImage::DrawOnBack(INTN XPos, INTN YPos, const XImage& Plate)
{
XImage BackLayer(Width, Height);
BackLayer.CopyRect(Plate, XPos, YPos); //assume Plate is big enough [XPos+Width, YPos+Height]
BackLayer.Compose(0, 0, *this, true);
BackLayer.DrawWithoutCompose(XPos, YPos);
}
/*

View File

@ -100,6 +100,7 @@ public:
void Draw(INTN x, INTN y, float scale); //can accept 0 scale as 1.f
void Draw(INTN x, INTN y);
void DrawWithoutCompose(INTN x, INTN y, UINTN width = 0, UINTN height = 0);
void DrawOnBack(INTN x, INTN y, const XImage& Plate);
//I changed the name because LoadImage is too widely used
// will be used instead of old egLoadImage
EFI_STATUS LoadXImage(EFI_FILE *Dir, const XStringW& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);

View File

@ -3246,7 +3246,7 @@ INTN REFIT_MENU_SCREEN::DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INT
// DBG("draw text %ls\n", Text);
// DBG("pos=%d width=%d xtext=%d Height=%d Y=%d\n", XPos, TextWidth, XText, Height, YPos);
TextBufferXY.Draw(XText, YPos, 0, false);
TextBufferXY.DrawOnBack(XText, YPos, ThemeX.Background);
// TextBufferXY.DrawWithoutCompose(XText, YPos);
return TextWidth2;
}
@ -3872,11 +3872,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
Entry->Place.YPos = EntriesPosY + j * TextHeight;
Entry->Place.Width = TitleLen * ScaledWidth;
Entry->Place.Height = (UINTN)TextHeight;
//StrCpyS(ResultString, TITLE_MAX_LEN, Entry->Title.data());
ResultString = Entry->Title; //create a copy to modify later
//clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2;
//clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0;
//clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2;
PlaceCentre = (INTN)((TextHeight - (INTN)(ThemeX.Buttons[2].GetHeight())) * ThemeX.Scale / 2);
PlaceCentre1 = (INTN)((TextHeight - (INTN)(ThemeX.Buttons[0].GetHeight())) * ThemeX.Scale / 2);
// clovy
@ -3892,21 +3888,14 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
if (inputDialogEntry->Item && inputDialogEntry->Item->ItemType == BoolValue) {
Entry->Place.Width = ResultString.length() * ScaledWidth;
//possible artefacts
// DrawMenuText(XStringWP(L" "), 0, EntriesPosX, Entry->Place.YPos, 0xFFFF);
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? (MenuWidth) : 0,
ctrlTextX,
Entry->Place.YPos, 0xFFFF);
ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->BValue)?3:2].Draw(ctrlX, ctrlY);
// DBG("X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale),
// Entry->Place.YPos, Entry->Place.YPos + PlaceCentre);
ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->BValue)?3:2].DrawOnBack(ctrlX, ctrlY, ThemeX.Background);
} else {
// text input
ResultString += ((REFIT_INPUT_DIALOG*)(Entry))->Item->SValue;
ResultString += L" ";
// StrCatS(ResultString, TITLE_MAX_LEN, ((REFIT_INPUT_DIALOG*)(Entry))->Item->SValue);
// StrCatS(ResultString, TITLE_MAX_LEN, L" ");
Entry->Place.Width = ResultString.length() * ScaledWidth;
// Slice - suppose to use Row as Cursor in text
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? MenuWidth : 0,
@ -3914,12 +3903,11 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
Entry->Place.YPos, TitleLen + Entry->Row);
}
} else if (Entry->getREFIT_MENU_CHECKBIT()) {
// DrawMenuText(XStringW().takeValueFrom(" "), 0, EntriesPosX, Entry->Place.YPos, 0xFFFF); //clean the place
ThemeX.FillRectAreaOfScreen(ctrlTextX, Entry->Place.YPos, MenuWidth, TextHeight);
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? (MenuWidth) : 0,
ctrlTextX,
Entry->Place.YPos, 0xFFFF);
ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->IValue & Entry->Row)?3:2].Draw(ctrlX, ctrlY);
ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->IValue & Entry->Row)?3:2].DrawOnBack(ctrlX, ctrlY, ThemeX.Background);
} else if (Entry->getREFIT_MENU_SWITCH()) {
if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 3) {
//OldChosenItem = OldChosenTheme;
@ -3937,7 +3925,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// clovy EntriesPosX + (TextHeight + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale)),
ctrlTextX,
Entry->Place.YPos, 0xFFFF);
ThemeX.Buttons[(Entry->Row == OldChosenItem)?1:0].Draw(ctrlX, ctrlY);
ThemeX.Buttons[(Entry->Row == OldChosenItem)?1:0].DrawOnBack(ctrlX, ctrlY, ThemeX.Background);
} else {
//DBG("paint entry %d title=%ls\n", i, Entries[i]->Title);
DrawMenuText(ResultString,
@ -3957,7 +3945,6 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
REFIT_ABSTRACT_MENU_ENTRY *EntryC = &Entries[ScrollState.CurrentSelection];
TitleLen = EntryL->Title.length();
ResultString = EntryL->Title;
// StrCpyS(ResultString, TITLE_MAX_LEN, EntryL->Title);
//clovy//PlaceCentre = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2;
//clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0;
//clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2;
@ -3980,16 +3967,10 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
DrawMenuText(ResultString, 0,
ctrlTextX,
EntryL->Place.YPos, 0xFFFF);
ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre);
// DBG("se:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale),
// EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre);
ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].DrawOnBack(ctrlX, EntryL->Place.YPos + PlaceCentre, ThemeX.Background);
} else {
ResultString += (((REFIT_INPUT_DIALOG*)(EntryL))->Item->SValue + ((REFIT_INPUT_DIALOG*)(EntryL))->Item->LineShift);
ResultString += L" ";
// StrCatS(ResultString, TITLE_MAX_LEN, ((REFIT_INPUT_DIALOG*)(EntryL))->Item->SValue +
// ((REFIT_INPUT_DIALOG*)(EntryL))->Item->LineShift);
// StrCatS(ResultString, TITLE_MAX_LEN, L" ");
DrawMenuText(ResultString, 0, EntriesPosX,
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight,
TitleLen + EntryL->Row);
@ -4009,15 +3990,12 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// clovy
DrawMenuText(ResultString, 0, ctrlTextX,
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF);
ThemeX.Buttons[(EntryL->Row == OldChosenItem)?1:0].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre1);
ThemeX.Buttons[(EntryL->Row == OldChosenItem)?1:0].DrawOnBack(ctrlX, EntryL->Place.YPos + PlaceCentre1, ThemeX.Background);
} else if (EntryL->getREFIT_MENU_CHECKBIT()) {
// clovy
DrawMenuText(ResultString, 0, ctrlTextX,
EntryL->Place.YPos, 0xFFFF);
ThemeX.Buttons[(EntryL->getREFIT_MENU_CHECKBIT()->Item->IValue & EntryL->Row) ?3:2].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre);
// DBG("ce:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale),
// EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre);
ThemeX.Buttons[(EntryL->getREFIT_MENU_CHECKBIT()->Item->IValue & EntryL->Row) ?3:2].DrawOnBack(ctrlX, EntryL->Place.YPos + PlaceCentre, ThemeX.Background);
} else {
DrawMenuText(EntryL->Title, 0, EntriesPosX,
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF);
@ -4025,7 +4003,6 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// current selection
ResultString = EntryC->Title;
// StrCpyS(ResultString, TITLE_MAX_LEN, EntryC->Title);
TitleLen = EntryC->Title.length();
if ( EntryC->getREFIT_MENU_SWITCH() ) {
if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) {
@ -4045,14 +4022,11 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
DrawMenuText(ResultString, MenuWidth,
ctrlTextX,
inputDialogEntry->Place.YPos, 0xFFFF);
ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].Draw(ctrlX, inputDialogEntry->Place.YPos + PlaceCentre);
ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].DrawOnBack(ctrlX, inputDialogEntry->Place.YPos + PlaceCentre, ThemeX.Background);
} else {
ResultString += (inputDialogEntry->Item->SValue +
inputDialogEntry->Item->LineShift);
ResultString += L" ";
// StrCatS(ResultString, TITLE_MAX_LEN, inputDialogEntry->Item->SValue +
// inputDialogEntry->Item->LineShift);
// StrCatS(ResultString, TITLE_MAX_LEN, L" ");
DrawMenuText(ResultString, MenuWidth, EntriesPosX,
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight,
TitleLen + inputDialogEntry->Row);
@ -4062,12 +4036,12 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
ctrlTextX,
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight,
0xFFFF);
ThemeX.Buttons[(EntryC->Row == OldChosenItem)?1:0].Draw(ctrlX, EntryC->Place.YPos + PlaceCentre1);
ThemeX.Buttons[(EntryC->Row == OldChosenItem)?1:0].DrawOnBack(ctrlX, EntryC->Place.YPos + PlaceCentre1, ThemeX.Background);
} else if (EntryC->getREFIT_MENU_CHECKBIT()) {
DrawMenuText(ResultString, MenuWidth,
ctrlTextX,
EntryC->Place.YPos, 0xFFFF);
ThemeX.Buttons[(EntryC->getREFIT_MENU_CHECKBIT()->Item->IValue & EntryC->Row)?3:2].Draw(ctrlX, EntryC->Place.YPos + PlaceCentre);
ThemeX.Buttons[(EntryC->getREFIT_MENU_CHECKBIT()->Item->IValue & EntryC->Row)?3:2].DrawOnBack(ctrlX, EntryC->Place.YPos + PlaceCentre, ThemeX.Background);
}else{
DrawMenuText(EntryC->Title, MenuWidth, EntriesPosX,
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight,
@ -4783,7 +4757,7 @@ VOID REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align)
{
INTN Xpos;
// CHAR16 *Text = NULL;
XStringW Text;
XString Text;
if (
// HIDEUI_ALL - included
@ -4799,20 +4773,20 @@ VOID REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align)
// Display Clover boot volume
if (SelfVolume->VolLabel && SelfVolume->VolLabel[0] != L'#') {
// Text = PoolPrint(L"%s, booted from %s", gFirmwareRevision, SelfVolume->VolLabel);
Text = XStringW() + gFirmwareRevision + L", booted from " + SelfVolume->VolLabel;
Text = XString() + gFirmwareRevision + ", booted from " + SelfVolume->VolLabel;
}
if (Text.isEmpty()) {
Text = XStringW() + gFirmwareRevision + L" " + SelfVolume->VolName;
Text = XString() + gFirmwareRevision + " " + SelfVolume->VolName;
}
break;
case TEXT_CORNER_HELP:
Text = XStringW() + L"F1:Help";
Text = XString() + "F1:Help";
break;
case TEXT_CORNER_OPTIMUS:
if (gGraphics[0].Vendor != Intel) {
Text = XStringW() + L"Discrete";
Text = XString() + "Discrete";
} else {
Text = XStringW() + L"Intel";
Text = XString() + "Intel";
}
// Text = (NGFX == 2)?L"Intel":L"Discrete";
break;