mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-23 16:17:40 +01:00
Menu width fixes, proportional font fixes, other menu tweaks
This commit is contained in:
parent
fce06f6035
commit
cf41491adc
@ -754,9 +754,9 @@ VOID LOADER_ENTRY::KernelCPUIDPatch(UINT8* kernelData)
|
||||
BOOLEAN LOADER_ENTRY::KernelPatchPm(VOID *kernelData)
|
||||
{
|
||||
DBG_RT("Patching kernel power management...\n");
|
||||
#if NEW_PM
|
||||
UINT8 *Kernel = (UINT8 *)kernelData;
|
||||
|
||||
#if NEW_PM
|
||||
//Slice
|
||||
//1. procedure xcpm_idle
|
||||
// wrmsr 0xe2 twice
|
||||
|
@ -156,7 +156,6 @@ static INTN OldTextWidth = 0;
|
||||
static UINTN OldRow = 0;
|
||||
static INTN OldTimeoutTextWidth = 0;
|
||||
static INTN MenuWidth , TimeoutPosY;
|
||||
static INTN MenuMaxPosX = 0;
|
||||
static UINTN MenuMaxTextLen = 0;
|
||||
static INTN EntriesPosX, EntriesPosY;
|
||||
static INTN EntriesWidth, EntriesHeight, EntriesGap;
|
||||
@ -534,6 +533,12 @@ UINTN REFIT_MENU_SCREEN::InputDialog(IN MENU_STYLE_FUNC StyleFunc)
|
||||
because it works.
|
||||
*/
|
||||
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
|
||||
#if DBG_INPUTDIALOG
|
||||
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)
|
||||
{
|
||||
INTN MaxWidth;
|
||||
if (MenuMaxPosX > XPos && MenuMaxPosX < UGAWidth) {
|
||||
MaxWidth = MenuMaxPosX - XPos;
|
||||
if (MenuWidth + XPos <= UGAWidth) {
|
||||
MaxWidth = MenuWidth;
|
||||
} else {
|
||||
MaxWidth = UGAWidth - XPos;
|
||||
}
|
||||
|
||||
XImage TextBufferX(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;
|
||||
|
||||
// set maximum allowed X-Position for menu content (this is ctrlTextX + MenuWidth)
|
||||
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)
|
||||
// set maximum allowed text length for menu content (this is applicable only for non-svg and non-proportional)
|
||||
MenuMaxTextLen = (UINTN)(MenuWidth / ScaledWidth);
|
||||
|
||||
// initial painting
|
||||
@ -1709,12 +1713,15 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
|
||||
ctrlTextX,
|
||||
Entry->Place.YPos, 0xFFFF);
|
||||
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 {
|
||||
// text input
|
||||
ResultString += ((REFIT_INPUT_DIALOG*)(Entry))->Item->SValue;
|
||||
ResultString += inputDialogEntry->Item->SValue;
|
||||
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
|
||||
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? MenuWidth : 0,
|
||||
EntriesPosX,
|
||||
@ -1792,7 +1799,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
|
||||
EntryL->Place.YPos, 0xFFFF);
|
||||
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 += (inputDialogEntry->Item->SValue + inputDialogEntry->Item->LineShift);
|
||||
ResultString += L" ";
|
||||
DrawMenuText(ResultString, 0, EntriesPosX,
|
||||
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" ";
|
||||
DrawMenuText(ResultString, MenuWidth, EntriesPosX,
|
||||
EntriesPosY + (ScrollState.CurrentSelection - ScrollState.FirstVisible) * ThemeX.TextHeight,
|
||||
TitleLen + inputDialogEntry->Row);
|
||||
TitleLen + EntryC->Row);
|
||||
}
|
||||
} else if (EntryC->getREFIT_MENU_SWITCH()) { //radio
|
||||
DrawMenuText(ResultString, MenuWidth,
|
||||
|
@ -274,7 +274,6 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
|
||||
textScale = 1.f;
|
||||
}
|
||||
INTN CharScaledWidth = (INTN)(CharWidth * textScale);
|
||||
INTN FontScaledWidth = (INTN)(FontWidth * textScale); //FontWidth should be scaled as well?
|
||||
// clip the text
|
||||
// TextLength = StrLenInWChar(Text.wc_str()); //it must be UTF16 length
|
||||
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
|
||||
}
|
||||
|
||||
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);
|
||||
FontPixel = FontImage.GetPixel(0,0);
|
||||
UINT16 c0 = 0x20;
|
||||
INTN RealWidth = CharScaledWidth;
|
||||
INTN Shift = (FontScaledWidth - CharScaledWidth) / 2;
|
||||
INTN Shift = (FontWidth - CharWidth) * textScale / 2;
|
||||
if (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
|
||||
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);
|
||||
for (UINTN i = 0; i < TextLength && c0 != 0; i++) {
|
||||
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 (c >= 0x410 && c < 0x450) {
|
||||
//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) {
|
||||
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 {
|
||||
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
|
||||
//RightSpace will not be scaled
|
||||
// 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
|
||||
if (PosX + RealWidth > CompImage.GetWidth()) {
|
||||
DBG("no more place for character\n");
|
||||
|
@ -138,17 +138,18 @@ VOID FillInputs(BOOLEAN New)
|
||||
if (New) {
|
||||
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
|
||||
if (New) {
|
||||
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
|
||||
if (New) {
|
||||
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++].IValue = 3;
|
||||
@ -380,7 +381,7 @@ VOID FillInputs(BOOLEAN New)
|
||||
|
||||
InputItems[InputItemsCount].ItemType = Decimal; //70
|
||||
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);
|
||||
InputItems[InputItemsCount].ItemType = Decimal; //71
|
||||
|
Loading…
Reference in New Issue
Block a user