From 61282f95747daebc921d692dd7a3ed383b98744a Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 10 Jan 2021 13:49:17 +0100 Subject: [PATCH] Tracker: fix invisible selection text in disabled windows Regression introduced in hrev54742 which used DeskTextColor() on a non-desktop view. The view color isn't set anywhere in that case and does not match the background color, which led to drawing white text on a white background. Moreover, a second bug was stacked on that: the selection is drawn in "reverse video" (using the document color for the text and document text color for the background) only for active windows. For inactive ones, it is drawn normally, and then a middle-grey rectangle is alpha blended on top. Add a comment to clarify that and reintroduce the ckeck that had been removed. Also replace the hardcoded black for the selection background, so it will be more easily visible for people using dark mode. Fixes #16627. --- src/kits/tracker/Pose.cpp | 4 ++-- src/kits/tracker/PoseView.cpp | 6 +++++- src/kits/tracker/TextWidget.cpp | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/kits/tracker/Pose.cpp b/src/kits/tracker/Pose.cpp index 49d7cb3dab..b93c5c6c99 100644 --- a/src/kits/tracker/Pose.cpp +++ b/src/kits/tracker/Pose.cpp @@ -603,9 +603,9 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, && windowActive; if (index == 0 && selectDuringDraw) { - // draw with dark background to select text + // draw with "reverse video" to select text drawView->PushState(); - drawView->SetLowColor(0, 0, 0); + drawView->SetLowColor(ui_color(B_DOCUMENT_TEXT_COLOR)); } if (index == 0) { diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 12b9c78012..6eebdaf178 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -9044,7 +9044,11 @@ BPoseView::DeskTextColor() const // So here we check if the colors are different enough, and otherwise, // force the text to be either white or black. rgb_color textColor = ui_color(B_DOCUMENT_TEXT_COLOR); - rgb_color viewColor = ViewColor(); + rgb_color viewColor; + if (IsDesktopWindow()) + viewColor = ViewColor(); + else + viewColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); int textBrightness = BPrivate::perceptual_brightness(textColor); int viewBrightness = BPrivate::perceptual_brightness(viewColor); diff --git a/src/kits/tracker/TextWidget.cpp b/src/kits/tracker/TextWidget.cpp index 40271522fc..0b5f6c1551 100644 --- a/src/kits/tracker/TextWidget.cpp +++ b/src/kits/tracker/TextWidget.cpp @@ -544,7 +544,13 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, float, BPoseView* view, // set high color rgb_color highColor; - if (selected) + // for active views, the selection is drawn as inverse text (background color for the text, + // solid black for the background). + // For inactive windows, the text is drawn normally, then the selection rect is + // alpha-blended on top of it. + // This all happens in BPose::Draw before and after calling this function, here we are + // only concerned with setting the correct color for the text. + if (selected && view->Window()->IsActive()) highColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); else highColor = view->DeskTextColor();