From 985cc012236d9f892544cd20cc769a728b73bc12 Mon Sep 17 00:00:00 2001
From: looncraz <looncraz@looncraz.net>
Date: Sat, 9 Jan 2016 15:58:44 -0600
Subject: [PATCH] BAbstractSpinner Colors
Adopted parent colors for the text view - should not have done so.
Disabled colors were incorrect, so I also corrected those in this patch.
---
headers/private/interface/AbstractSpinner.h | 1 +
src/kits/interface/AbstractSpinner.cpp | 45 ++++++++++++++---------------
2 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/headers/private/interface/AbstractSpinner.h b/headers/private/interface/AbstractSpinner.h
index e822299..8326f48 100644
a
|
b
|
public:
|
59 | 59 | virtual void Draw(BRect updateRect); |
60 | 60 | virtual void FrameResized(float width, float height); |
61 | 61 | virtual void ValueChanged(); |
| 62 | virtual void MessageReceived(BMessage* message); |
62 | 63 | |
63 | 64 | virtual void Decrement() = 0; |
64 | 65 | virtual void Increment() = 0; |
diff --git a/src/kits/interface/AbstractSpinner.cpp b/src/kits/interface/AbstractSpinner.cpp
index f426b5e..ecccc88 100644
a
|
b
|
SpinnerTextView::AttachedToWindow()
|
545 | 545 | { |
546 | 546 | fParent = static_cast<BAbstractSpinner*>(Parent()); |
547 | 547 | |
548 | | AdoptParentColors(); |
549 | 548 | BTextView::AttachedToWindow(); |
550 | 549 | } |
551 | 550 | |
… |
… |
BAbstractSpinner::ValueChanged()
|
1070 | 1069 | |
1071 | 1070 | |
1072 | 1071 | void |
| 1072 | BAbstractSpinner::MessageReceived(BMessage* message) |
| 1073 | { |
| 1074 | if (!IsEnabled() && message->what == B_COLORS_UPDATED) |
| 1075 | _UpdateTextViewColors(false); |
| 1076 | |
| 1077 | BControl::MessageReceived(message); |
| 1078 | } |
| 1079 | |
| 1080 | |
| 1081 | void |
1073 | 1082 | BAbstractSpinner::MakeFocus(bool focus) |
1074 | 1083 | { |
1075 | 1084 | fTextView->MakeFocus(focus); |
… |
… |
BAbstractSpinner::_UpdateFrame()
|
1585 | 1594 | void |
1586 | 1595 | BAbstractSpinner::_UpdateTextViewColors(bool enable) |
1587 | 1596 | { |
1588 | | rgb_color textColor; |
1589 | | BFont font; |
1590 | | |
1591 | | fTextView->GetFontAndColor(0, &font); |
1592 | | |
1593 | | if (enable) |
1594 | | textColor = ui_color(B_DOCUMENT_TEXT_COLOR); |
1595 | | else { |
1596 | | textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), |
1597 | | B_DISABLED_LABEL_TINT); |
1598 | | } |
1599 | | |
1600 | | fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor); |
| 1597 | // Mimick BTextControl's appearance. |
| 1598 | rgb_color textColor = ui_color(B_DOCUMENT_TEXT_COLOR); |
1601 | 1599 | |
1602 | 1600 | if (enable) { |
1603 | 1601 | fTextView->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR); |
1604 | 1602 | fTextView->SetLowUIColor(ViewUIColor()); |
1605 | 1603 | } else { |
1606 | | color_which which = ViewUIColor(); |
1607 | | |
1608 | | if (which != B_NO_COLOR) { |
1609 | | fTextView->SetViewUIColor(which, B_LIGHTEN_2_TINT); |
1610 | | fTextView->SetLowUIColor(which, B_LIGHTEN_2_TINT); |
1611 | | } else { |
1612 | | rgb_color color = tint_color(ViewColor(), B_LIGHTEN_2_TINT); |
1613 | | fTextView->SetViewColor(color); |
1614 | | fTextView->SetLowColor(color); |
1615 | | } |
| 1604 | rgb_color color = ui_color(B_DOCUMENT_BACKGROUND_COLOR); |
| 1605 | color = disable_color(ViewColor(), color); |
| 1606 | textColor = disable_color(textColor, ViewColor()); |
| 1607 | |
| 1608 | fTextView->SetViewColor(color); |
| 1609 | fTextView->SetLowColor(color); |
1616 | 1610 | } |
1617 | 1611 | |
| 1612 | BFont font; |
| 1613 | fTextView->GetFontAndColor(0, &font); |
| 1614 | fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor); |
1618 | 1615 | } |
1619 | 1616 | |
1620 | 1617 | |