[FREELDR:UI] Isolate TuiDrawBox() top/bottom horizontal lines drawing into their own helpers.

This commit is contained in:
Hermès Bélusca-Maïto 2022-02-20 02:46:23 +01:00
parent 622a90522d
commit ee32f9b86e
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 112 additions and 31 deletions

View file

@ -40,7 +40,37 @@ VOID TuiUnInitialize(VOID); // Un-initiali
VOID TuiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); // Draws a box around the area specified
/* Draws a box around the area specified */
VOID
TuiDrawBox(
_In_ ULONG Left,
_In_ ULONG Top,
_In_ ULONG Right,
_In_ ULONG Bottom,
_In_ UCHAR VertStyle,
_In_ UCHAR HorzStyle,
_In_ BOOLEAN Fill,
_In_ BOOLEAN Shadow,
_In_ UCHAR Attr);
VOID
TuiDrawBoxTopLine(
_In_ ULONG Left,
_In_ ULONG Top,
_In_ ULONG Right,
_In_ UCHAR VertStyle,
_In_ UCHAR HorzStyle,
_In_ UCHAR Attr);
VOID
TuiDrawBoxBottomLine(
_In_ ULONG Left,
_In_ ULONG Bottom,
_In_ ULONG Right,
_In_ UCHAR VertStyle,
_In_ UCHAR HorzStyle,
_In_ UCHAR Attr);
/* Draws text at coordinates specified */
VOID

View file

@ -397,26 +397,29 @@ VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
* DrawBox()
* This function assumes coordinates are zero-based
*/
VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
VOID
TuiDrawBoxTopLine(
_In_ ULONG Left,
_In_ ULONG Top,
_In_ ULONG Right,
_In_ UCHAR VertStyle,
_In_ UCHAR HorzStyle,
_In_ UCHAR Attr)
{
UCHAR ULCorner, URCorner, LLCorner, LRCorner;
UCHAR ULCorner, URCorner;
// Calculate the corner values
/* Calculate the corner values */
if (HorzStyle == HORZ)
{
if (VertStyle == VERT)
{
ULCorner = UL;
URCorner = UR;
LLCorner = LL;
LRCorner = LR;
}
else // VertStyle == D_VERT
{
ULCorner = VD_UL;
URCorner = VD_UR;
LLCorner = VD_LL;
LRCorner = VD_LR;
}
}
else // HorzStyle == D_HORZ
@ -425,44 +428,92 @@ VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyl
{
ULCorner = HD_UL;
URCorner = HD_UR;
LLCorner = HD_LL;
LRCorner = HD_LR;
}
else // VertStyle == D_VERT
{
ULCorner = D_UL;
URCorner = D_UR;
}
}
TuiFillArea(Left, Top, Left, Top, ULCorner, Attr);
TuiFillArea(Left+1, Top, Right-1, Top, HorzStyle, Attr);
TuiFillArea(Right, Top, Right, Top, URCorner, Attr);
}
VOID
TuiDrawBoxBottomLine(
_In_ ULONG Left,
_In_ ULONG Bottom,
_In_ ULONG Right,
_In_ UCHAR VertStyle,
_In_ UCHAR HorzStyle,
_In_ UCHAR Attr)
{
UCHAR LLCorner, LRCorner;
/* Calculate the corner values */
if (HorzStyle == HORZ)
{
if (VertStyle == VERT)
{
LLCorner = LL;
LRCorner = LR;
}
else // VertStyle == D_VERT
{
LLCorner = VD_LL;
LRCorner = VD_LR;
}
}
else // HorzStyle == D_HORZ
{
if (VertStyle == VERT)
{
LLCorner = HD_LL;
LRCorner = HD_LR;
}
else // VertStyle == D_VERT
{
LLCorner = D_LL;
LRCorner = D_LR;
}
}
// Fill in box background
if (Fill)
{
TuiFillArea(Left, Top, Right, Bottom, ' ', Attr);
}
// Fill in corners
TuiFillArea(Left, Top, Left, Top, ULCorner, Attr);
TuiFillArea(Right, Top, Right, Top, URCorner, Attr);
TuiFillArea(Left, Bottom, Left, Bottom, LLCorner, Attr);
TuiFillArea(Right, Bottom, Right, Bottom, LRCorner, Attr);
// Fill in left line
TuiFillArea(Left, Top+1, Left, Bottom-1, VertStyle, Attr);
// Fill in top line
TuiFillArea(Left+1, Top, Right-1, Top, HorzStyle, Attr);
// Fill in right line
TuiFillArea(Right, Top+1, Right, Bottom-1, VertStyle, Attr);
// Fill in bottom line
TuiFillArea(Left+1, Bottom, Right-1, Bottom, HorzStyle, Attr);
TuiFillArea(Right, Bottom, Right, Bottom, LRCorner, Attr);
}
// Draw the shadow
VOID
TuiDrawBox(
_In_ ULONG Left,
_In_ ULONG Top,
_In_ ULONG Right,
_In_ ULONG Bottom,
_In_ UCHAR VertStyle,
_In_ UCHAR HorzStyle,
_In_ BOOLEAN Fill,
_In_ BOOLEAN Shadow,
_In_ UCHAR Attr)
{
/* Fill in the box background */
if (Fill)
TuiFillArea(Left, Top, Right, Bottom, ' ', Attr);
/* Fill in the top horizontal line */
TuiDrawBoxTopLine(Left, Top, Right, VertStyle, HorzStyle, Attr);
/* Fill in the vertical left and right lines */
TuiFillArea(Left, Top+1, Left, Bottom-1, VertStyle, Attr);
TuiFillArea(Right, Top+1, Right, Bottom-1, VertStyle, Attr);
/* Fill in the bottom horizontal line */
TuiDrawBoxBottomLine(Left, Bottom, Right, VertStyle, HorzStyle, Attr);
/* Draw the shadow */
if (Shadow)
{
TuiDrawShadow(Left, Top, Right, Bottom);
}
}
VOID TuiDrawStatusText(PCSTR StatusText)