Menu width fixes, proportional font fixes, other menu tweaks

This commit is contained in:
asava 2020-05-05 02:52:00 +03:00
parent fce06f6035
commit cf41491adc
4 changed files with 31 additions and 23 deletions

View File

@ -754,9 +754,9 @@ VOID LOADER_ENTRY::KernelCPUIDPatch(UINT8* kernelData)
BOOLEAN LOADER_ENTRY::KernelPatchPm(VOID *kernelData) BOOLEAN LOADER_ENTRY::KernelPatchPm(VOID *kernelData)
{ {
DBG_RT("Patching kernel power management...\n"); DBG_RT("Patching kernel power management...\n");
#if NEW_PM
UINT8 *Kernel = (UINT8 *)kernelData; UINT8 *Kernel = (UINT8 *)kernelData;
#if NEW_PM
//Slice //Slice
//1. procedure xcpm_idle //1. procedure xcpm_idle
// wrmsr 0xe2 twice // wrmsr 0xe2 twice

View File

@ -156,7 +156,6 @@ static INTN OldTextWidth = 0;
static UINTN OldRow = 0; static UINTN OldRow = 0;
static INTN OldTimeoutTextWidth = 0; static INTN OldTimeoutTextWidth = 0;
static INTN MenuWidth , TimeoutPosY; static INTN MenuWidth , TimeoutPosY;
static INTN MenuMaxPosX = 0;
static UINTN MenuMaxTextLen = 0; static UINTN MenuMaxTextLen = 0;
static INTN EntriesPosX, EntriesPosY; static INTN EntriesPosX, EntriesPosY;
static INTN EntriesWidth, EntriesHeight, EntriesGap; static INTN EntriesWidth, EntriesHeight, EntriesGap;
@ -534,6 +533,12 @@ UINTN REFIT_MENU_SCREEN::InputDialog(IN MENU_STYLE_FUNC StyleFunc)
because it works. because it works.
*/ */
UINTN LineSize = 38; UINTN LineSize = 38;
// make sure that LineSize is not too big
UINTN MaxPossibleLineSize = (MenuWidth - selectedEntry.Place.Width) / (INTN)(ThemeX.CharWidth * ThemeX.Scale) - 1;
if (!ThemeX.TypeSVG && !ThemeX.Proportional && LineSize > MaxPossibleLineSize) {
LineSize = MaxPossibleLineSize;
}
#define DBG_INPUTDIALOG 0 #define DBG_INPUTDIALOG 0
#if DBG_INPUTDIALOG #if DBG_INPUTDIALOG
UINTN Iteration = 0; UINTN Iteration = 0;
@ -1435,11 +1440,12 @@ VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN
VOID REFIT_MENU_SCREEN::DrawMenuText(IN const XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor) VOID REFIT_MENU_SCREEN::DrawMenuText(IN const XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor)
{ {
INTN MaxWidth; INTN MaxWidth;
if (MenuMaxPosX > XPos && MenuMaxPosX < UGAWidth) { if (MenuWidth + XPos <= UGAWidth) {
MaxWidth = MenuMaxPosX - XPos; MaxWidth = MenuWidth;
} else { } else {
MaxWidth = UGAWidth - XPos; MaxWidth = UGAWidth - XPos;
} }
XImage TextBufferX(MaxWidth, ThemeX.TextHeight); XImage TextBufferX(MaxWidth, ThemeX.TextHeight);
XImage SelectionBar(MaxWidth, ThemeX.TextHeight); XImage SelectionBar(MaxWidth, ThemeX.TextHeight);
@ -1618,9 +1624,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
} }
TimeoutPosY = EntriesPosY + (Entries.size() + 1) * ThemeX.TextHeight; TimeoutPosY = EntriesPosY + (Entries.size() + 1) * ThemeX.TextHeight;
// set maximum allowed X-Position for menu content (this is ctrlTextX + MenuWidth) // set maximum allowed text length for menu content (this is applicable only for non-svg and non-proportional)
MenuMaxPosX = EntriesPosX + (ThemeX.TypeSVG ? 0 : (INTN)(TEXT_XMARGIN * ThemeX.Scale)) + ThemeX.Buttons[0].GetWidth() + (INTN)(TEXT_XMARGIN * ThemeX.Scale / 2) + MenuWidth;
// set maximum allowed text length for menu content (this is applicable only for non-svg)
MenuMaxTextLen = (UINTN)(MenuWidth / ScaledWidth); MenuMaxTextLen = (UINTN)(MenuWidth / ScaledWidth);
// initial painting // initial painting
@ -1709,12 +1713,15 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
ctrlTextX, ctrlTextX,
Entry->Place.YPos, 0xFFFF); Entry->Place.YPos, 0xFFFF);
ThemeX.FillRectAreaOfScreen((ctrlTextX + ctrlX) >> 1, Entry->Place.YPos, ctrlTextX - ctrlX, ThemeX.TextHeight); ThemeX.FillRectAreaOfScreen((ctrlTextX + ctrlX) >> 1, Entry->Place.YPos, ctrlTextX - ctrlX, ThemeX.TextHeight);
ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->BValue)?3:2].DrawOnBack(ctrlX, ctrlY, ThemeX.Background); ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].DrawOnBack(ctrlX, ctrlY, ThemeX.Background);
} else { } else {
// text input // text input
ResultString += ((REFIT_INPUT_DIALOG*)(Entry))->Item->SValue; ResultString += inputDialogEntry->Item->SValue;
ResultString += L" "; ResultString += L" ";
Entry->Place.Width = ResultString.length() * ScaledWidth; // set cursor to beginning if it is outside of screen
if (!ThemeX.TypeSVG && !ThemeX.Proportional && (TitleLen + (INTN)Entry->Row) * ScaledWidth > MenuWidth) {
Entry->Row = 0;
}
// Slice - suppose to use Row as Cursor in text // Slice - suppose to use Row as Cursor in text
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? MenuWidth : 0, DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? MenuWidth : 0,
EntriesPosX, EntriesPosX,
@ -1792,7 +1799,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
EntryL->Place.YPos, 0xFFFF); EntryL->Place.YPos, 0xFFFF);
ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].DrawOnBack(ctrlX, EntryL->Place.YPos + PlaceCentre, ThemeX.Background); ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].DrawOnBack(ctrlX, EntryL->Place.YPos + PlaceCentre, ThemeX.Background);
} else { } else {
ResultString += (((REFIT_INPUT_DIALOG*)(EntryL))->Item->SValue + ((REFIT_INPUT_DIALOG*)(EntryL))->Item->LineShift); ResultString += (inputDialogEntry->Item->SValue + inputDialogEntry->Item->LineShift);
ResultString += L" "; ResultString += L" ";
DrawMenuText(ResultString, 0, EntriesPosX, DrawMenuText(ResultString, 0, EntriesPosX,
EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * ThemeX.TextHeight, EntriesPosY + (ScrollState.LastSelection - ScrollState.FirstVisible) * ThemeX.TextHeight,
@ -1855,7 +1862,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
ResultString += L" "; ResultString += L" ";
DrawMenuText(ResultString, MenuWidth, EntriesPosX, DrawMenuText(ResultString, MenuWidth, EntriesPosX,
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * ThemeX.TextHeight, EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * ThemeX.TextHeight,
TitleLen + inputDialogEntry->Row); TitleLen + EntryC->Row);
} }
} else if (EntryC->getREFIT_MENU_SWITCH()) { //radio } else if (EntryC->getREFIT_MENU_SWITCH()) { //radio
DrawMenuText(ResultString, MenuWidth, DrawMenuText(ResultString, MenuWidth,

View File

@ -274,7 +274,6 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
textScale = 1.f; textScale = 1.f;
} }
INTN CharScaledWidth = (INTN)(CharWidth * textScale); INTN CharScaledWidth = (INTN)(CharWidth * textScale);
INTN FontScaledWidth = (INTN)(FontWidth * textScale); //FontWidth should be scaled as well?
// clip the text // clip the text
// TextLength = StrLenInWChar(Text.wc_str()); //it must be UTF16 length // TextLength = StrLenInWChar(Text.wc_str()); //it must be UTF16 length
TextLength = StrLen(Text.wc_str()); TextLength = StrLen(Text.wc_str());
@ -283,16 +282,16 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
PrepareFont(); //at the boot screen there is embedded font PrepareFont(); //at the boot screen there is embedded font
} }
DBG("TextLength =%lld PosX=%lld PosY=%lld\n", TextLength, PosX, PosY); DBG("TextLength =%lld PosX=%lld PosY=%lld\n", TextLength, PosX, PosY);
FirstPixel = CompImage.GetPixel(0,0); FirstPixel = CompImage.GetPixel(0,0);
FontPixel = FontImage.GetPixel(0,0); FontPixel = FontImage.GetPixel(0,0);
UINT16 c0 = 0x20; UINT16 c0 = 0x20;
INTN RealWidth = CharScaledWidth; INTN RealWidth = CharScaledWidth;
INTN Shift = (FontScaledWidth - CharScaledWidth) / 2; INTN Shift = (FontWidth - CharWidth) * textScale / 2;
if (Shift < 0) { if (Shift < 0) {
Shift = 0; Shift = 0;
} }
DBG("FontWidth=%lld, CharWidth=%lld\n", FontWidth, RealWidth); DBG("FontWidth=%lld, CharWidth=%lld\n", FontWidth, RealWidth);
EG_RECT Area; //area is scaled EG_RECT Area; //area is scaled
Area.YPos = PosY; // not sure Area.YPos = PosY; // not sure
@ -304,7 +303,7 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
DBG("codepage=%llx, asciiPage=%x\n", GlobalConfig.Codepage, AsciiPageSize); DBG("codepage=%llx, asciiPage=%x\n", GlobalConfig.Codepage, AsciiPageSize);
for (UINTN i = 0; i < TextLength && c0 != 0; i++) { for (UINTN i = 0; i < TextLength && c0 != 0; i++) {
UINT16 c = Text.wc_str()[i]; //including UTF8 -> UTF16 conversion UINT16 c = Text.wc_str()[i]; //including UTF8 -> UTF16 conversion
DBG("initial char to render 0x%hx\n", c); //good DBG("initial char to render 0x%hx\n", c); //good
if (gLanguage != korean) { //russian Codepage = 0x410 if (gLanguage != korean) { //russian Codepage = 0x410
if (c >= 0x410 && c < 0x450) { if (c >= 0x410 && c < 0x450) {
//we have russian raster fonts with chars at 0xC0 //we have russian raster fonts with chars at 0xC0
@ -329,7 +328,8 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
if (RightSpace >= FontWidth) { if (RightSpace >= FontWidth) {
RightSpace = 0; //empty place for invisible characters RightSpace = 0; //empty place for invisible characters
} }
RealWidth = CharScaledWidth - (int)(RightSpace * textScale); //a part of char //RealWidth = CharScaledWidth - (int)(RightSpace * textScale); //a part of char
RealWidth = (FontWidth - RightSpace) * textScale; //a part of char
} }
} else { } else {
LeftSpace = 2; LeftSpace = 2;
@ -338,7 +338,7 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
LeftSpace = (int)(LeftSpace * textScale); //was not scaled yet LeftSpace = (int)(LeftSpace * textScale); //was not scaled yet
//RightSpace will not be scaled //RightSpace will not be scaled
// RealWidth are scaled now // RealWidth are scaled now
DBG(" RealWidth = %lld LeftSpace = %lld RightSpace = %lld\n", RealWidth, LeftSpace, RightSpace); DBG(" RealWidth = %lld LeftSpace = %lld RightSpace = %lld\n", RealWidth, LeftSpace, RightSpace);
c0 = c; //remember old value c0 = c; //remember old value
if (PosX + RealWidth > CompImage.GetWidth()) { if (PosX + RealWidth > CompImage.GetWidth()) {
DBG("no more place for character\n"); DBG("no more place for character\n");

View File

@ -138,17 +138,18 @@ VOID FillInputs(BOOLEAN New)
if (New) { if (New) {
InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(SVALUE_MAX_SIZE); InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(SVALUE_MAX_SIZE);
} }
snwprintf(InputItems[InputItemsCount++].SValue, SVALUE_MAX_SIZE, "%s ", gSettings.BootArgs); // no need for extra space here, it is added by ApplyInputs()
snwprintf(InputItems[InputItemsCount++].SValue, SVALUE_MAX_SIZE, "%s", gSettings.BootArgs);
InputItems[InputItemsCount].ItemType = UNIString; //1 InputItems[InputItemsCount].ItemType = UNIString; //1
if (New) { if (New) {
InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(32); InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(32);
} }
snwprintf(InputItems[InputItemsCount++].SValue, 32, "%ls", gSettings.DsdtName); // 1-> 2 snwprintf(InputItems[InputItemsCount++].SValue, 32, "%ls", gSettings.DsdtName); // 1-> 2
InputItems[InputItemsCount].ItemType = UNIString; //2 InputItems[InputItemsCount].ItemType = UNIString; //2
if (New) { if (New) {
InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(63); InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(63);
} }
snwprintf(InputItems[InputItemsCount++].SValue, 63, "%ls", gSettings.BlockKexts); snwprintf(InputItems[InputItemsCount++].SValue, 63, "%ls", gSettings.BlockKexts);
InputItems[InputItemsCount].ItemType = RadioSwitch; //3 - Themes chooser InputItems[InputItemsCount].ItemType = RadioSwitch; //3 - Themes chooser
InputItems[InputItemsCount++].IValue = 3; InputItems[InputItemsCount++].IValue = 3;
@ -380,7 +381,7 @@ VOID FillInputs(BOOLEAN New)
InputItems[InputItemsCount].ItemType = Decimal; //70 InputItems[InputItemsCount].ItemType = Decimal; //70
if (New) { if (New) {
InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(8); InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(12);
} }
snwprintf(InputItems[InputItemsCount++].SValue, 8, "%02lld", gSettings.PointerSpeed); snwprintf(InputItems[InputItemsCount++].SValue, 8, "%02lld", gSettings.PointerSpeed);
InputItems[InputItemsCount].ItemType = Decimal; //71 InputItems[InputItemsCount].ItemType = Decimal; //71