https://git.reactos.org/?p=reactos.git;a=commitdiff;h=910124736612450b61164…
commit 910124736612450b611643f8e416f16cdd61e076
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Jan 6 23:58:22 2022 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Feb 6 17:52:44 2022 +0100
[FREELDR:UI] Couple of fixes for the ProgressBar functions.
- Fix box size calculations.
- MiniTUI: Distinguish Vista+ vs. NTLDR style progress bar.
---
boot/freeldr/freeldr/ui/minitui.c | 38 +++++++++++++++++++++++--------
boot/freeldr/freeldr/ui/tui.c | 48 +++++++++++++++++++++++++--------------
2 files changed, 59 insertions(+), 27 deletions(-)
diff --git a/boot/freeldr/freeldr/ui/minitui.c b/boot/freeldr/freeldr/ui/minitui.c
index cc967f9b753..95bb0b0eb1f 100644
--- a/boot/freeldr/freeldr/ui/minitui.c
+++ b/boot/freeldr/freeldr/ui/minitui.c
@@ -9,6 +9,10 @@
#include <freeldr.h>
+/* NTLDR or Vista+ BOOTMGR progress-bar style */
+// #define NTLDR_PROGRESSBAR
+// #define BTMGR_PROGRESSBAR /* Default style */
+
#ifndef _M_ARM
VOID MiniTuiDrawBackdrop(VOID)
@@ -36,12 +40,19 @@ MiniTuiDrawProgressBarCenter(
ULONG Left, Top, Right, Bottom, Width, Height;
/* Build the coordinates and sizes */
+#ifdef NTLDR_PROGRESSBAR
Height = 2;
- Width = UiScreenWidth;
+ Width = UiScreenWidth;
Left = 0;
- Right = (Left + Width) - 1;
- Top = UiScreenHeight - Height - 4;
- Bottom = Top + Height + 1;
+ Top = UiScreenHeight - Height - 2;
+#else // BTMGR_PROGRESSBAR
+ Height = 3;
+ Width = UiScreenWidth - 4;
+ Left = 2;
+ Top = UiScreenHeight - Height - 3;
+#endif
+ Right = Left + Width - 1;
+ Bottom = Top + Height - 1;
/* Draw the progress bar */
MiniTuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
@@ -60,23 +71,30 @@ MiniTuiDrawProgressBar(
ULONG ProgressBarWidth, i;
/* Calculate the width of the bar proper */
- ProgressBarWidth = (Right - Left) - 3;
-
- /* First make sure the progress bar text fits */
- UiTruncateStringEllipsis(ProgressText, ProgressBarWidth - 4);
+ ProgressBarWidth = Right - Left + 1;
/* Clip the position */
if (Position > Range)
Position = Range;
+ /* First make sure the progress bar text fits */
+ UiTruncateStringEllipsis(ProgressText, ProgressBarWidth);
+
/* Draw the "Loading..." text */
- TuiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, ProgressText,
ATTR(UiTextColor, UiMenuBgColor));
+ TuiDrawCenteredText(Left, Top, Right,
+#ifdef NTLDR_PROGRESSBAR
+ Bottom - 1,
+#else // BTMGR_PROGRESSBAR
+ Bottom - 2, // One empty line between text and bar.
+#endif
+ ProgressText, ATTR(UiTextColor, UiMenuBgColor));
/* Draw the percent complete */
for (i = 0; i < (Position * ProgressBarWidth) / Range; i++)
{
/* Use the fill character */
- TuiDrawText(Left + 2 + i, Top + 2, "\xDB", ATTR(UiTextColor,
UiMenuBgColor));
+ TuiDrawText(Left + i, Bottom,
+ "\xDB", ATTR(UiTextColor, UiMenuBgColor));
}
#ifndef _M_ARM
diff --git a/boot/freeldr/freeldr/ui/tui.c b/boot/freeldr/freeldr/ui/tui.c
index 9da79931b94..821d7b399ba 100644
--- a/boot/freeldr/freeldr/ui/tui.c
+++ b/boot/freeldr/freeldr/ui/tui.c
@@ -689,16 +689,21 @@ TuiDrawProgressBarCenter(
_In_ ULONG Range,
_Inout_z_ PSTR ProgressText)
{
- ULONG Left, Top, Right, Bottom;
- ULONG Width = 50; // Allow for 50 "bars"
- ULONG Height = 2;
+ ULONG Left, Top, Right, Bottom, Width, Height;
/* Build the coordinates and sizes */
- Left = (UiScreenWidth - Width - 4) / 2;
- Right = Left + Width + 3;
- Top = (UiScreenHeight - Height - 2) / 2;
- Top += 2;
- Bottom = Top + Height + 1;
+ Height = 2;
+ Width = 50; // Allow for 50 "bars"
+ Left = (UiScreenWidth - Width) / 2;
+ Top = (UiScreenHeight - Height + 4) / 2;
+ Right = Left + Width - 1;
+ Bottom = Top + Height - 1;
+
+ /* Inflate to include the box margins */
+ Left -= 2;
+ Right += 2;
+ Top -= 1;
+ Bottom += 1;
/* Draw the progress bar */
TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
@@ -716,33 +721,42 @@ TuiDrawProgressBar(
{
ULONG ProgressBarWidth, i;
- /* Calculate the width of the bar proper */
- ProgressBarWidth = (Right - Left) - 3;
+ /* Draw the box */
+ TuiDrawBox(Left, Top, Right, Bottom, VERT, HORZ, TRUE, TRUE, ATTR(UiMenuFgColor,
UiMenuBgColor));
- /* First make sure the progress bar text fits */
- UiTruncateStringEllipsis(ProgressText, ProgressBarWidth - 4);
+ /* Exclude the box margins */
+ Left += 2;
+ Right -= 2;
+ Top += 1;
+ Bottom -= 1;
+
+ /* Calculate the width of the bar proper */
+ ProgressBarWidth = Right - Left + 1;
/* Clip the position */
if (Position > Range)
Position = Range;
- /* Draw the box */
- TuiDrawBox(Left, Top, Right, Bottom, VERT, HORZ, TRUE, TRUE, ATTR(UiMenuFgColor,
UiMenuBgColor));
+ /* First make sure the progress bar text fits */
+ UiTruncateStringEllipsis(ProgressText, ProgressBarWidth);
/* Draw the "Loading..." text */
- TuiDrawCenteredText(Left + 2, Top + 2, Right - 2, Top + 2, ProgressText,
ATTR(UiTextColor, UiMenuBgColor));
+ TuiDrawCenteredText(Left, Top, Right, Bottom - 1,
+ ProgressText, ATTR(UiTextColor, UiMenuBgColor));
/* Draw the percent complete */
for (i = 0; i < (Position * ProgressBarWidth) / Range; i++)
{
/* Use the fill character */
- TuiDrawText(Left + 2 + i, Top + 2, "\xDB", ATTR(UiTextColor,
UiMenuBgColor));
+ TuiDrawText(Left + i, Bottom,
+ "\xDB", ATTR(UiTextColor, UiMenuBgColor));
}
/* Draw the shadow */
for (; i < ProgressBarWidth; i++)
{
- TuiDrawText(Left + 2 + i, Top + 2, "\xB2", ATTR(UiTextColor,
UiMenuBgColor));
+ TuiDrawText(Left + i, Bottom,
+ "\xB2", ATTR(UiTextColor, UiMenuBgColor));
}
#ifndef _M_ARM