From 36df12a51a8b7236d61af3e51c405c81aedc4af3 Mon Sep 17 00:00:00 2001 From: Felix Ehlers Date: Fri, 8 Oct 2021 23:55:31 +0200 Subject: [PATCH] diskprobe: Add striped look and vertical line separators * vertical lines per 4 bytes displayed * striped line colors Change-Id: I08508f15a60c5ceab8e3088faca9c03576c129e0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4563 Tested-by: Commit checker robot Reviewed-by: Adrien Destugues --- src/apps/diskprobe/DataView.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index 007da0eca6..6869fd0cca 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -398,14 +398,42 @@ DataView::Draw(BRect updateRect) char line[255]; BPoint location(kHorizontalSpace, kVerticalSpace + fAscent); + const float kTintDarkenTouch = (B_NO_TINT + B_DARKEN_1_TINT) / 2.0f; + + for (uint32 lineNum = 0, i = 0; i < fSizeInView; lineNum++, i += kBlockSize) { + // Tint every 2nd line to create a striped background + + float tint = (lineNum % 2 == 0) ? B_NO_TINT : kTintDarkenTouch; + SetLowUIColor(B_DOCUMENT_BACKGROUND_COLOR, tint); + + FillRect(BRect(location.x - kHorizontalSpace, + kVerticalSpace + lineNum * fFontHeight, + location.x - kHorizontalSpace / 2 + Bounds().right, + kVerticalSpace + (lineNum + 1) * fFontHeight), B_SOLID_LOW); - for (uint32 i = 0; i < fSizeInView; i += kBlockSize) { ConvertLine(line, i, fData + i, fSizeInView - i); DrawString(line, location); location.y += fFontHeight; } + // Draw first vertical line after 18 chars ("0000: xx xx xx xx") + // Next three vertical lines require an offset of 12 chars ("xx xx xx xx") + + BPoint line_start(kHorizontalSpace + fCharWidth * 18 + fCharWidth / 2, 0); + BPoint line_end(line_start.x, Bounds().bottom); + + rgb_color lineColor = tint_color(lineColor, B_LIGHTEN_2_TINT); + uint32 kDrawNumLines = 3; + + BeginLineArray(kDrawNumLines); + for (uint32 i = 0; i < kDrawNumLines; i++) { + AddLine(line_start, line_end, lineColor); + line_start.x += fCharWidth * 12; + line_end.x = line_start.x; + } + EndLineArray(); + DrawSelection(); }