https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ee32f9b86e5490c6db2227...
commit ee32f9b86e5490c6db2227da2aff236f7f3c68b5 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Feb 20 02:46:23 2022 +0100 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Mon Feb 21 02:54:00 2022 +0100
[FREELDR:UI] Isolate TuiDrawBox() top/bottom horizontal lines drawing into their own helpers. --- boot/freeldr/freeldr/include/ui/tui.h | 32 ++++++++++- boot/freeldr/freeldr/ui/tui.c | 103 +++++++++++++++++++++++++--------- 2 files changed, 108 insertions(+), 27 deletions(-)
diff --git a/boot/freeldr/freeldr/include/ui/tui.h b/boot/freeldr/freeldr/include/ui/tui.h index b952a06822d..cb90ae214a3 100644 --- a/boot/freeldr/freeldr/include/ui/tui.h +++ b/boot/freeldr/freeldr/include/ui/tui.h @@ -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 diff --git a/boot/freeldr/freeldr/ui/tui.c b/boot/freeldr/freeldr/ui/tui.c index 3950f93df2d..c75afedc236 100644 --- a/boot/freeldr/freeldr/ui/tui.c +++ b/boot/freeldr/freeldr/ui/tui.c @@ -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; - LLCorner = D_LL; - LRCorner = D_LR; } }
- // Fill in box background - if (Fill) + 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) { - TuiFillArea(Left, Top, Right, Bottom, ' ', Attr); + 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 corners - TuiFillArea(Left, Top, Left, Top, ULCorner, Attr); - TuiFillArea(Right, Top, Right, Top, URCorner, Attr); TuiFillArea(Left, Bottom, Left, Bottom, LLCorner, Attr); + TuiFillArea(Left+1, Bottom, Right-1, Bottom, HorzStyle, Attr); TuiFillArea(Right, Bottom, Right, Bottom, LRCorner, Attr); +}
- // Fill in left line +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); - // 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);
- // Draw the shadow + /* 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)