repair text menu

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-02 11:44:42 +03:00
parent 0c6dc2f45e
commit 0dacc1df4c

View File

@ -3369,13 +3369,14 @@ VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN
VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor) VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor)
{ {
XImage TextBufferX(UGAWidth-XPos, TextHeight); XImage TextBufferX(UGAWidth-XPos, TextHeight);
XImage SelectionBar(UGAWidth-XPos, TextHeight);
/*
if (Cursor == 0xFFFF) { //InfoLine = 0xFFFF if (Cursor == 0xFFFF) { //InfoLine = 0xFFFF
TextBufferX.Fill(MenuBackgroundPixel); TextBufferX.Fill(MenuBackgroundPixel);
} else { } else {
TextBufferX.Fill(InputBackgroundPixel); TextBufferX.Fill(InputBackgroundPixel);
} }
*/
if (SelectedWidth > 0) { if (SelectedWidth > 0) {
// fill selection bar background // fill selection bar background
@ -3383,8 +3384,11 @@ VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, I
TextRect.Width = SelectedWidth; TextRect.Width = SelectedWidth;
TextRect.Height = TextHeight; TextRect.Height = TextHeight;
TextBufferX.FillArea(SelectionBackgroundPixel, TextRect); TextBufferX.FillArea(SelectionBackgroundPixel, TextRect);
// SelectionBar.Fill(SelectionBackgroundPixel);
} }
SelectionBar.CopyRect(ThemeX.Background, XPos, YPos);
// SelectionBar.DrawWithoutCompose(XPos, YPos);
// TextBufferX.Compose(0, 0, ThemeX.Background, true);
// render the text // render the text
if (ThemeX.TypeSVG) { if (ThemeX.TypeSVG) {
//clovy - text vertically centred on Height //clovy - text vertically centred on Height
@ -3394,7 +3398,9 @@ VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, I
} else { } else {
egRenderText(Text, &TextBufferX, TEXT_XMARGIN, TEXT_YMARGIN, Cursor, TextStyle); egRenderText(Text, &TextBufferX, TEXT_XMARGIN, TEXT_YMARGIN, Cursor, TextStyle);
} }
TextBufferX.Draw((INTN)XPos, (INTN)YPos); SelectionBar.Compose(0, 0, TextBufferX, true);
// TextBufferX.DrawWithoutCompose(XPos, YPos);
SelectionBar.DrawWithoutCompose(XPos, YPos);
} }
#else #else
@ -3721,6 +3727,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
switch (Function) { switch (Function) {
case MENU_FUNCTION_INIT: case MENU_FUNCTION_INIT:
{
egGetScreenSize(&UGAWidth, &UGAHeight); egGetScreenSize(&UGAWidth, &UGAHeight);
InitAnime(); InitAnime();
SwitchToGraphicsAndClear(); SwitchToGraphicsAndClear();
@ -3747,7 +3754,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// determine width of the menu - not working // determine width of the menu - not working
//MenuWidth = 80; // minimum //MenuWidth = 80; // minimum
MenuWidth = (int)(LAYOUT_TEXT_WIDTH * ThemeX.Scale); //500 MenuWidth = (int)(LAYOUT_TEXT_WIDTH * ThemeX.Scale); //500
// DrawMenuText(NULL, 0, 0, 0, 0);
if (!TitleImage.isEmpty()) { if (!TitleImage.isEmpty()) {
if (MenuWidth > (INTN)(UGAWidth - (int)(TITLEICON_SPACING * ThemeX.Scale) - TitleImage.GetWidth())) { if (MenuWidth > (INTN)(UGAWidth - (int)(TITLEICON_SPACING * ThemeX.Scale) - TitleImage.GetWidth())) {
@ -3795,13 +3802,13 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
ThemeX.InitBar(); ThemeX.InitBar();
break; break;
}
case MENU_FUNCTION_CLEANUP: case MENU_FUNCTION_CLEANUP:
HidePointer(); HidePointer();
break; break;
case MENU_FUNCTION_PAINT_ALL: case MENU_FUNCTION_PAINT_ALL:
// DrawMenuText(NULL, 0, 0, 0, 0); //should clean every line to avoid artefacts {
// DBG("PAINT_ALL: EntriesPosY=%lld MaxVisible=%lld\n", EntriesPosY, ScrollState.MaxVisible); // DBG("PAINT_ALL: EntriesPosY=%lld MaxVisible=%lld\n", EntriesPosY, ScrollState.MaxVisible);
// DBG("DownButton.Height=%lld TextHeight=%lld\n", DownButton.Height, TextHeight); // DBG("DownButton.Height=%lld TextHeight=%lld\n", DownButton.Height, TextHeight);
t2 = EntriesPosY + (ScrollState.MaxVisible + 1) * TextHeight - DownButton.Height; t2 = EntriesPosY + (ScrollState.MaxVisible + 1) * TextHeight - DownButton.Height;
@ -3820,7 +3827,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
Entry->Place.Width = TitleLen * ScaledWidth; Entry->Place.Width = TitleLen * ScaledWidth;
Entry->Place.Height = (UINTN)TextHeight; Entry->Place.Height = (UINTN)TextHeight;
//StrCpyS(ResultString, TITLE_MAX_LEN, Entry->Title.data()); //StrCpyS(ResultString, TITLE_MAX_LEN, Entry->Title.data());
ResultString = Entry->Title; ResultString = Entry->Title; //create a copy to modify later
//clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2; //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2;
//clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0; //clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0;
//clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2; //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2;
@ -3896,14 +3903,14 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
ScrollingBar(); //&ScrollState - inside the class ScrollingBar(); //&ScrollState - inside the class
//MouseBirth(); //MouseBirth();
break; break;
}
case MENU_FUNCTION_PAINT_SELECTION: case MENU_FUNCTION_PAINT_SELECTION:
{ {
// last selection // last selection
REFIT_ABSTRACT_MENU_ENTRY *EntryL = &Entries[ScrollState.LastSelection]; REFIT_ABSTRACT_MENU_ENTRY *EntryL = &Entries[ScrollState.LastSelection];
REFIT_ABSTRACT_MENU_ENTRY *EntryC = &Entries[ScrollState.CurrentSelection]; REFIT_ABSTRACT_MENU_ENTRY *EntryC = &Entries[ScrollState.CurrentSelection];
TitleLen = StrLen(EntryL->Title); TitleLen = EntryL->Title.length();
ResultString.takeValueFrom(EntryL->Title); ResultString = EntryL->Title;
// StrCpyS(ResultString, TITLE_MAX_LEN, EntryL->Title); // StrCpyS(ResultString, TITLE_MAX_LEN, EntryL->Title);
//clovy//PlaceCentre = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2; //clovy//PlaceCentre = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2;
//clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0; //clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0;
@ -3922,7 +3929,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// 2. usr-sse2 // 2. usr-sse2
if ( EntryL->getREFIT_INPUT_DIALOG() ) { if ( EntryL->getREFIT_INPUT_DIALOG() ) {
REFIT_INPUT_DIALOG* inputDialogEntry = (REFIT_INPUT_DIALOG*)EntryL; REFIT_INPUT_DIALOG* inputDialogEntry = (REFIT_INPUT_DIALOG*)EntryL;
if (inputDialogEntry->Item->ItemType == BoolValue) { if (inputDialogEntry->Item->ItemType == BoolValue) { //this is checkbox
//clovy //clovy
DrawMenuText(ResultString, 0, DrawMenuText(ResultString, 0,
ctrlTextX, ctrlTextX,
@ -3941,7 +3948,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight,
TitleLen + EntryL->Row); TitleLen + EntryL->Row);
} }
} else if (EntryL->getREFIT_MENU_SWITCH()) { } else if (EntryL->getREFIT_MENU_SWITCH()) { //radio buttons 0,1
if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 3) { if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 3) {
OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1; OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1;
@ -3956,7 +3963,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// clovy // clovy
DrawMenuText(ResultString, 0, ctrlTextX, DrawMenuText(ResultString, 0, ctrlTextX,
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF); EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF);
ThemeX.Buttons[(EntryL->Row == OldChosenItem)?3:2].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre1); ThemeX.Buttons[(EntryL->Row == OldChosenItem)?1:0].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre1);
} else if (EntryL->getREFIT_MENU_CHECKBIT()) { } else if (EntryL->getREFIT_MENU_CHECKBIT()) {
// clovy // clovy
DrawMenuText(ResultString, 0, ctrlTextX, DrawMenuText(ResultString, 0, ctrlTextX,
@ -3966,16 +3973,14 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
// DBG("ce:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale), // DBG("ce:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale),
// EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre); // EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre);
} else { } else {
XStringW TitleX; DrawMenuText(EntryL->Title, 0, EntriesPosX,
TitleX.takeValueFrom(EntryL->Title);
DrawMenuText(TitleX, 0, EntriesPosX,
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF); EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * TextHeight, 0xFFFF);
} }
// current selection // current selection
ResultString.takeValueFrom(EntryC->Title); ResultString = EntryC->Title;
// StrCpyS(ResultString, TITLE_MAX_LEN, EntryC->Title); // StrCpyS(ResultString, TITLE_MAX_LEN, EntryC->Title);
TitleLen = StrLen(EntryC->Title); TitleLen = EntryC->Title.length();
if ( EntryC->getREFIT_MENU_SWITCH() ) { if ( EntryC->getREFIT_MENU_SWITCH() ) {
if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) { if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) {
OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1;; OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1;;
@ -3990,7 +3995,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
if ( EntryC->getREFIT_INPUT_DIALOG() ) { if ( EntryC->getREFIT_INPUT_DIALOG() ) {
REFIT_INPUT_DIALOG* inputDialogEntry = (REFIT_INPUT_DIALOG*)EntryC; REFIT_INPUT_DIALOG* inputDialogEntry = (REFIT_INPUT_DIALOG*)EntryC;
if (inputDialogEntry->Item->ItemType == BoolValue) { if (inputDialogEntry->Item->ItemType == BoolValue) { //checkbox
DrawMenuText(ResultString, MenuWidth, DrawMenuText(ResultString, MenuWidth,
ctrlTextX, ctrlTextX,
inputDialogEntry->Place.YPos, 0xFFFF); inputDialogEntry->Place.YPos, 0xFFFF);
@ -4006,10 +4011,8 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight, EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight,
TitleLen + inputDialogEntry->Row); TitleLen + inputDialogEntry->Row);
} }
} else if (EntryC->getREFIT_MENU_SWITCH()) { } else if (EntryC->getREFIT_MENU_SWITCH()) { //radio
ResultString.takeValueFrom(EntryC->Title); DrawMenuText(EntryC->Title, MenuWidth,
// StrCpyS(ResultString, TITLE_MAX_LEN, EntryC->Title);
DrawMenuText(ResultString, MenuWidth,
ctrlTextX, ctrlTextX,
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight, EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight,
0xFFFF); 0xFFFF);
@ -4020,8 +4023,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
EntryC->Place.YPos, 0xFFFF); 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].Draw(ctrlX, EntryC->Place.YPos + PlaceCentre);
}else{ }else{
ResultString.takeValueFrom(EntryC->Title); DrawMenuText(EntryC->Title, MenuWidth, EntriesPosX,
DrawMenuText(ResultString, MenuWidth, EntriesPosX,
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight, EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * TextHeight,
0xFFFF); 0xFFFF);
} }
@ -4034,7 +4036,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
break; break;
} }
case MENU_FUNCTION_PAINT_TIMEOUT: //ever be here? case MENU_FUNCTION_PAINT_TIMEOUT: //ParamText should be XStringW
ResultString.takeValueFrom(ParamText); ResultString.takeValueFrom(ParamText);
INTN X = (UGAWidth - StrLen(ParamText) * ScaledWidth) >> 1; INTN X = (UGAWidth - StrLen(ParamText) * ScaledWidth) >> 1;
DrawMenuText(ResultString, 0, X, TimeoutPosY, 0xFFFF); DrawMenuText(ResultString, 0, X, TimeoutPosY, 0xFFFF);