From 13553050f9a2463d4ea3ecacad0ca8c314960994 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Mon, 9 Sep 2024 11:46:01 -0400 Subject: [PATCH] HaikuDepot: MarkupTextView SetForegroundColor to HighUIColor Also the bullet point color Allow Usage Conditions window to be resized Tint disabled color instead of hardcoding Copyright 2024 Haiku, Inc. Fixes the other half of #19067 Change-Id: Ibf74d9dd673807b0f107e56cefb5b30916baed96 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8262 Reviewed-by: Adrien Destugues Haiku-Format: Haiku-format Bot Tested-by: Commit checker robot --- .../haikudepot/textview/ParagraphLayout.cpp | 1 - .../ui/ToLatestUserUsageConditionsWindow.cpp | 13 ++++++------- .../ui/UserUsageConditionsWindow.cpp | 18 ++++++++---------- .../haikudepot/ui_generic/MarkupTextView.cpp | 17 ++++++++++++----- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/apps/haikudepot/textview/ParagraphLayout.cpp b/src/apps/haikudepot/textview/ParagraphLayout.cpp index 789f0d5dd6..593ccae95a 100644 --- a/src/apps/haikudepot/textview/ParagraphLayout.cpp +++ b/src/apps/haikudepot/textview/ParagraphLayout.cpp @@ -264,7 +264,6 @@ ParagraphLayout::Draw(BView* view, const BPoint& offset) const Bullet& bullet = fParagraphStyle.Bullet(); if (bullet.Spacing() > 0.0f && bullet.String().Length() > 0) { // Draw bullet at offset - view->SetHighUIColor(B_PANEL_TEXT_COLOR); BPoint bulletPos(offset); bulletPos.x += fParagraphStyle.FirstLineInset() + fParagraphStyle.LineInset(); diff --git a/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp b/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp index 0429027a6e..bc7dd3f6ff 100644 --- a/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp +++ b/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp @@ -1,5 +1,6 @@ /* * Copyright 2020, Andrew Lindesay . + * Copyright 2024 Haiku, Inc. All rights reserved. * All rights reserved. Distributed under the terms of the MIT License. */ @@ -48,14 +49,12 @@ enum { }; -ToLatestUserUsageConditionsWindow::ToLatestUserUsageConditionsWindow( - BWindow* parent, - Model& model, const UserDetail& userDetail) +ToLatestUserUsageConditionsWindow::ToLatestUserUsageConditionsWindow(BWindow* parent, Model& model, + const UserDetail& userDetail) : - BWindow(BRect(), B_TRANSLATE("Update usage conditions"), - B_FLOATING_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, - B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS - | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE), + BWindow(BRect(), B_TRANSLATE("Update usage conditions"), B_FLOATING_WINDOW_LOOK, + B_MODAL_SUBSET_WINDOW_FEEL, + B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE | B_NOT_CLOSABLE), fModel(model), fUserDetail(userDetail), fWorkerThread(-1), diff --git a/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp b/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp index 947bba3d5b..2dbbe6f92f 100644 --- a/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp +++ b/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp @@ -1,5 +1,6 @@ /* * Copyright 2019-2021, Andrew Lindesay . + * Copyright 2024 Haiku, Inc. All rights reserved. * All rights reserved. Distributed under the terms of the MIT License. */ @@ -53,10 +54,8 @@ UserUsageConditionsWindow::UserUsageConditionsWindow(Model& model, UserUsageConditions& userUsageConditions) : - BWindow(BRect(), B_TRANSLATE("Usage conditions"), - B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, - B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS - | B_NOT_RESIZABLE | B_NOT_ZOOMABLE), + BWindow(BRect(), B_TRANSLATE("Usage conditions"), B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE), fMode(FIXED), fModel(model), fIntroductionTextView(NULL), @@ -94,13 +93,12 @@ UserUsageConditionsWindow::UserUsageConditionsWindow(Model& model, _DisplayData(userDetail, userUsageConditions); } -UserUsageConditionsWindow::UserUsageConditionsWindow( - Model& model, UserUsageConditionsSelectionMode mode) + +UserUsageConditionsWindow::UserUsageConditionsWindow(Model& model, + UserUsageConditionsSelectionMode mode) : - BWindow(BRect(), B_TRANSLATE("Usage conditions"), - B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, - B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS - | B_NOT_RESIZABLE | B_NOT_ZOOMABLE), + BWindow(BRect(), B_TRANSLATE("Usage conditions"), B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE), fMode(mode), fModel(model), fWorkerThread(-1) diff --git a/src/apps/haikudepot/ui_generic/MarkupTextView.cpp b/src/apps/haikudepot/ui_generic/MarkupTextView.cpp index 68f81aeb7e..135e005070 100644 --- a/src/apps/haikudepot/ui_generic/MarkupTextView.cpp +++ b/src/apps/haikudepot/ui_generic/MarkupTextView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2013-2014, Stephan Aßmus . + * Copyright 2024 Haiku, Inc. All rights reserved. * All rights reserved. Distributed under the terms of the MIT License. */ @@ -7,9 +8,6 @@ #include "MarkupTextView.h" -static const rgb_color kLightBlack = (rgb_color){ 60, 60, 60, 255 }; - - MarkupTextView::MarkupTextView(const char* name) : TextDocumentView(name) @@ -31,7 +29,15 @@ MarkupTextView::MarkupTextView(const char* name) void MarkupTextView::SetText(const BString& markupText) { - SetTextDocument(fMarkupParser.CreateDocumentFromMarkup(markupText)); + TextDocumentRef document(new(std::nothrow) TextDocument(), true); + + CharacterStyle regularStyle(fMarkupParser.NormalCharacterStyle()); + regularStyle.SetForegroundColor(HighUIColor()); + + fMarkupParser.SetStyles(regularStyle, fMarkupParser.NormalParagraphStyle()); + fMarkupParser.AppendMarkup(document, markupText); + + SetTextDocument(document); } @@ -60,7 +66,8 @@ MarkupTextView::SetDisabledText(const BString& text) paragraphStyle.SetAlignment(ALIGN_CENTER); CharacterStyle disabledStyle(fMarkupParser.NormalCharacterStyle()); - disabledStyle.SetForegroundColor(kLightBlack); + rgb_color disabled = tint_color(HighColor(), HighColor().IsLight() ? B_DARKEN_1_TINT : 0.853); + disabledStyle.SetForegroundColor(disabled); Paragraph paragraph(paragraphStyle); paragraph.Append(TextSpan(text, disabledStyle));