mirror of
https://github.com/reactos/reactos.git
synced 2024-06-09 22:15:23 +00:00
[FREELDR:UI] Cleanup for the ProgressBar functions.
- Remove duplicated code from directui.c and use the one from TUI instead, with the latter properly #ifdef'ed for _M_ARM. - Fix their title color. - Add SAL annotations.
This commit is contained in:
parent
a9994eab45
commit
d749b45e2a
|
@ -94,8 +94,24 @@ VOID UiUpdateDateTime(VOID); // Updates th
|
|||
VOID UiInfoBox(PCSTR MessageText); // Displays a info box on the screen
|
||||
VOID UiMessageBox(PCSTR Format, ...); // Displays a message box on the screen with an ok button
|
||||
VOID UiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources
|
||||
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
|
||||
VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
UiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
UiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
// Displays all the message boxes in a given section.
|
||||
VOID
|
||||
|
|
|
@ -16,8 +16,24 @@
|
|||
|
||||
VOID MiniTuiDrawBackdrop(VOID);
|
||||
VOID MiniTuiDrawStatusText(PCSTR StatusText);
|
||||
VOID MiniTuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText);
|
||||
VOID MiniTuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText);
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
MiniTuiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
MiniTuiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
|
@ -53,8 +53,25 @@ VOID NoUiDrawStatusText(PCSTR StatusText);
|
|||
VOID NoUiUpdateDateTime(VOID);
|
||||
VOID NoUiMessageBox(PCSTR MessageText);
|
||||
VOID NoUiMessageBoxCritical(PCSTR MessageText);
|
||||
VOID NoUiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText);
|
||||
VOID NoUiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText);
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
NoUiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
NoUiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
BOOLEAN NoUiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
|
||||
UCHAR NoUiTextToColor(PCSTR ColorText);
|
||||
UCHAR NoUiTextToFillStyle(PCSTR FillStyleText);
|
||||
|
|
|
@ -75,8 +75,25 @@ VOID TuiSaveScreen(PUCHAR Buffer); // Saves the sc
|
|||
VOID TuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save
|
||||
VOID TuiMessageBox(PCSTR MessageText); // Displays a message box on the screen with an ok button
|
||||
VOID TuiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources
|
||||
VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
|
||||
VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
TuiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
/* Draws the progress bar showing nPos percent filled */
|
||||
VOID
|
||||
TuiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText);
|
||||
|
||||
BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
|
||||
UCHAR TuiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value
|
||||
UCHAR TuiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
|
||||
|
|
|
@ -109,51 +109,25 @@ UiMessageBoxCritical(IN PCSTR MessageText)
|
|||
}
|
||||
|
||||
VOID
|
||||
UiDrawProgressBarCenter(IN ULONG Position,
|
||||
IN ULONG Range,
|
||||
IN PCHAR ProgressText)
|
||||
UiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
ULONG Left, Top, Right, Bottom, Width, Height;
|
||||
|
||||
/* Build the coordinates and sizes */
|
||||
Height = 2;
|
||||
Width = UiScreenWidth;
|
||||
Left = 0;
|
||||
Right = (Left + Width) - 1;
|
||||
Top = UiScreenHeight - Height - 4;
|
||||
Bottom = Top + Height + 1;
|
||||
|
||||
/* Draw the progress bar */
|
||||
UiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
|
||||
MiniTuiDrawProgressBarCenter(Position, Range, ProgressText);
|
||||
}
|
||||
|
||||
VOID
|
||||
UiDrawProgressBar(IN ULONG Left,
|
||||
IN ULONG Top,
|
||||
IN ULONG Right,
|
||||
IN ULONG Bottom,
|
||||
IN ULONG Position,
|
||||
IN ULONG Range,
|
||||
IN PCHAR ProgressText)
|
||||
UiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
ULONG i, ProgressBarWidth;
|
||||
|
||||
/* Calculate the width of the bar proper */
|
||||
ProgressBarWidth = (Right - Left) - 3;
|
||||
|
||||
/* First make sure the progress bar text fits */
|
||||
UiTruncateStringEllipsis(ProgressText, ProgressBarWidth - 4);
|
||||
if (Position > Range) Position = Range;
|
||||
|
||||
/* Draw the "Loading..." text */
|
||||
UiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, ProgressText, ATTR(7, 0));
|
||||
|
||||
/* Draw the percent complete */
|
||||
for (i = 0; i < (Position * ProgressBarWidth) / Range; i++)
|
||||
{
|
||||
/* Use the fill character */
|
||||
UiDrawText(Left + 2 + i, Top + 2, "\xDB", ATTR(UiTextColor, UiMenuBgColor));
|
||||
}
|
||||
MiniTuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
* Hervé Poussineau
|
||||
*/
|
||||
|
||||
#ifndef _M_ARM
|
||||
#include <freeldr.h>
|
||||
|
||||
#ifndef _M_ARM
|
||||
|
||||
VOID MiniTuiDrawBackdrop(VOID)
|
||||
{
|
||||
/* Fill in a black background */
|
||||
|
@ -24,7 +25,13 @@ VOID MiniTuiDrawStatusText(PCSTR StatusText)
|
|||
/* Minimal UI doesn't have a status bar */
|
||||
}
|
||||
|
||||
VOID MiniTuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
#endif // _M_ARM
|
||||
|
||||
VOID
|
||||
MiniTuiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
ULONG Left, Top, Right, Bottom, Width, Height;
|
||||
|
||||
|
@ -40,18 +47,30 @@ VOID MiniTuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressTex
|
|||
MiniTuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
|
||||
}
|
||||
|
||||
VOID MiniTuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
MiniTuiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
ULONG i;
|
||||
ULONG ProgressBarWidth = (Right - Left) - 3;
|
||||
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);
|
||||
|
||||
/* Clip the position */
|
||||
if (Position > Range)
|
||||
Position = Range;
|
||||
|
||||
/* Draw the "Loading..." text */
|
||||
TuiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, ProgressText, ATTR(COLOR_GRAY, COLOR_BLACK));
|
||||
TuiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, ProgressText, ATTR(UiTextColor, UiMenuBgColor));
|
||||
|
||||
/* Draw the percent complete */
|
||||
for (i = 0; i < (Position * ProgressBarWidth) / Range; i++)
|
||||
|
@ -60,10 +79,14 @@ VOID MiniTuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UL
|
|||
TuiDrawText(Left + 2 + i, Top + 2, "\xDB", ATTR(UiTextColor, UiMenuBgColor));
|
||||
}
|
||||
|
||||
#ifndef _M_ARM
|
||||
TuiUpdateDateTime();
|
||||
VideoCopyOffScreenBufferToVRAM();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _M_ARM
|
||||
|
||||
VOID
|
||||
MiniTuiDrawMenu(PUI_MENU_INFO MenuInfo)
|
||||
{
|
||||
|
|
|
@ -100,11 +100,23 @@ VOID NoUiMessageBoxCritical(PCSTR MessageText)
|
|||
MachConsGetCh();
|
||||
}
|
||||
|
||||
VOID NoUiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
NoUiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
}
|
||||
|
||||
VOID NoUiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
NoUiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -683,29 +683,46 @@ VOID TuiMessageBoxCritical(PCSTR MessageText)
|
|||
}
|
||||
}
|
||||
|
||||
VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
TuiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
ULONG Left, Top, Right, Bottom;
|
||||
ULONG Width = 50; // Allow for 50 "bars"
|
||||
ULONG Height = 2;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Draw the progress bar */
|
||||
TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
|
||||
}
|
||||
|
||||
VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
TuiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
ULONG i;
|
||||
ULONG ProgressBarWidth = (Right - Left) - 3;
|
||||
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);
|
||||
|
||||
/* Clip the position */
|
||||
if (Position > Range)
|
||||
Position = Range;
|
||||
|
||||
|
@ -728,8 +745,10 @@ VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG
|
|||
TuiDrawText(Left + 2 + i, Top + 2, "\xB2", ATTR(UiTextColor, UiMenuBgColor));
|
||||
}
|
||||
|
||||
#ifndef _M_ARM
|
||||
TuiUpdateDateTime();
|
||||
VideoCopyOffScreenBufferToVRAM();
|
||||
#endif
|
||||
}
|
||||
|
||||
UCHAR TuiTextToColor(PCSTR ColorText)
|
||||
|
|
|
@ -369,12 +369,24 @@ UCHAR UiTextToFillStyle(PCSTR FillStyleText)
|
|||
return UiVtbl.TextToFillStyle(FillStyleText);
|
||||
}
|
||||
|
||||
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
UiDrawProgressBarCenter(
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
UiVtbl.DrawProgressBarCenter(Position, Range, ProgressText);
|
||||
}
|
||||
|
||||
VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
|
||||
VOID
|
||||
UiDrawProgressBar(
|
||||
_In_ ULONG Left,
|
||||
_In_ ULONG Top,
|
||||
_In_ ULONG Right,
|
||||
_In_ ULONG Bottom,
|
||||
_In_ ULONG Position,
|
||||
_In_ ULONG Range,
|
||||
_Inout_z_ PSTR ProgressText)
|
||||
{
|
||||
UiVtbl.DrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue