diff --git a/src/kits/interface/AboutWindow.cpp b/src/kits/interface/AboutWindow.cpp index fa84cf5c98..a5f32c31a6 100644 --- a/src/kits/interface/AboutWindow.cpp +++ b/src/kits/interface/AboutWindow.cpp @@ -1,10 +1,11 @@ /* - * Copyright 2007-2012 Haiku, Inc. + * Copyright 2007-2015 Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: * Ryan Leavengood * John Scipione + * Joseph Groover */ @@ -68,6 +69,8 @@ public: const char* signature); virtual ~AboutView(); + virtual void AllAttached(); + BTextView* InfoView() const { return fInfoView; }; BBitmap* Icon(); @@ -99,7 +102,7 @@ StripeView::StripeView(BBitmap* icon) BView("StripeView", B_WILL_DRAW), fIcon(icon) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); float width = 0.0f; if (icon != NULL) @@ -159,6 +162,7 @@ AboutView::AboutView(const char* appName, const char* signature) : BGroupView("AboutView", B_VERTICAL) { + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fNameView = new BStringView("name", appName); BFont font; fNameView->GetFont(&font); @@ -176,7 +180,6 @@ AboutView::AboutView(const char* appName, const char* signature) fInfoView->MakeEditable(false); fInfoView->SetWordWrap(true); fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0); - fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR)); fInfoView->SetStylable(true); BScrollView* infoViewScroller = new BScrollView( @@ -205,7 +208,8 @@ AboutView::AboutView(const char* appName, const char* signature) .End() .End() .AddGlue() - .End(); + .View()->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + } @@ -214,6 +218,15 @@ AboutView::~AboutView() } +void +AboutView::AllAttached() +{ + fNameView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fInfoView->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR); + fVersionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); +} + + // #pragma mark - AboutView private methods diff --git a/src/kits/interface/AbstractSpinner.cpp b/src/kits/interface/AbstractSpinner.cpp index 576697a835..f426b5e220 100644 --- a/src/kits/interface/AbstractSpinner.cpp +++ b/src/kits/interface/AbstractSpinner.cpp @@ -311,9 +311,6 @@ SpinnerButton::SpinnerButton(BRect frame, const char* name, fIsMouseOver(false), fRepeatDelay(100000) { - rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR); - SetViewColor(bgColor); - SetLowColor(bgColor); } @@ -327,6 +324,7 @@ SpinnerButton::AttachedToWindow() { fParent = static_cast(Parent()); + AdoptParentColors(); BView::AttachedToWindow(); } @@ -534,9 +532,6 @@ SpinnerTextView::SpinnerTextView(BRect rect, BRect textRect) B_WILL_DRAW | B_NAVIGABLE), fParent(NULL) { - rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR); - SetViewColor(bgColor); - SetLowColor(bgColor); } @@ -550,6 +545,7 @@ SpinnerTextView::AttachedToWindow() { fParent = static_cast(Parent()); + AdoptParentColors(); BTextView::AttachedToWindow(); } @@ -1480,10 +1476,6 @@ BAbstractSpinner::_DrawTextView(BRect updateRect) void BAbstractSpinner::_InitObject() { - rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR); - SetViewColor(bgColor); - SetLowColor(bgColor); - fAlignment = B_ALIGN_LEFT; fButtonStyle = SPINNER_BUTTON_PLUS_MINUS; @@ -1594,7 +1586,6 @@ void BAbstractSpinner::_UpdateTextViewColors(bool enable) { rgb_color textColor; - rgb_color bgColor; BFont font; fTextView->GetFontAndColor(0, &font); @@ -1608,15 +1599,22 @@ BAbstractSpinner::_UpdateTextViewColors(bool enable) fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor); - if (enable) - bgColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); - else { - bgColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_LIGHTEN_2_TINT); + if (enable) { + fTextView->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR); + fTextView->SetLowUIColor(ViewUIColor()); + } else { + color_which which = ViewUIColor(); + + if (which != B_NO_COLOR) { + fTextView->SetViewUIColor(which, B_LIGHTEN_2_TINT); + fTextView->SetLowUIColor(which, B_LIGHTEN_2_TINT); + } else { + rgb_color color = tint_color(ViewColor(), B_LIGHTEN_2_TINT); + fTextView->SetViewColor(color); + fTextView->SetLowColor(color); + } } - fTextView->SetViewColor(bgColor); - fTextView->SetLowColor(bgColor); } diff --git a/src/kits/interface/Alert.cpp b/src/kits/interface/Alert.cpp index 8e29a6bb6c..f924604184 100644 --- a/src/kits/interface/Alert.cpp +++ b/src/kits/interface/Alert.cpp @@ -497,7 +497,7 @@ BAlert::_Init(const char* text, const char* button0, const char* button1, fIconView = new TAlertView(); fTextView = new BTextView("_tv_"); - fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fTextView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); fTextView->MakeEditable(false); @@ -718,7 +718,7 @@ TAlertView::TAlertView() BView("TAlertView", B_WILL_DRAW), fIconBitmap(NULL) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); } diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 581c755271..ff749d2c67 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2013 Haiku, Inc. All rights reserved. + * Copyright 2001-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -162,10 +162,15 @@ _BMCMenuBar_::AttachedToWindow() if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0) SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); - if (Parent() != NULL) - SetLowColor(Parent()->LowColor()); - else - SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR)); + if (Parent() != NULL) { + color_which which = Parent()->LowUIColor(); + if (which == B_NO_COLOR) + SetLowColor(Parent()->LowColor()); + else + SetLowUIColor(which); + + } else + SetLowUIColor(B_MENU_BACKGROUND_COLOR); fPreviousWidth = Bounds().Width(); } diff --git a/src/kits/interface/Box.cpp b/src/kits/interface/Box.cpp index d243a911e6..fe0a395b98 100644 --- a/src/kits/interface/Box.cpp +++ b/src/kits/interface/Box.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2013 Haiku, Inc. All Rights Reserved. + * Copyright 2001-2015 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT license. * * Authors: @@ -49,9 +49,6 @@ BBox::BBox(BRect frame, const char* name, uint32 resizingMode, uint32 flags, BView(frame, name, resizingMode, flags | B_WILL_DRAW | B_FRAME_EVENTS), fStyle(border) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - _InitObject(); } @@ -61,9 +58,6 @@ BBox::BBox(const char* name, uint32 flags, border_style border, BView* child) BView(name, flags | B_WILL_DRAW | B_FRAME_EVENTS), fStyle(border) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - _InitObject(); if (child) @@ -76,9 +70,6 @@ BBox::BBox(border_style border, BView* child) BView(NULL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), fStyle(border) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - _InitObject(); if (child) @@ -269,7 +260,7 @@ BBox::Draw(BRect updateRect) font_height fontHeight; GetFontHeight(&fontHeight); - SetHighColor(0, 0, 0); + SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); DrawString(fLabel, BPoint(10.0f, ceilf(fontHeight.ascent))); } @@ -280,15 +271,12 @@ BBox::Draw(BRect updateRect) void BBox::AttachedToWindow() { - BView* parent = Parent(); - if (parent != NULL) { - // inherit the color from parent - rgb_color color = parent->ViewColor(); - if (color == B_TRANSPARENT_COLOR) - color = ui_color(B_PANEL_BACKGROUND_COLOR); + AdoptParentColors(); - SetViewColor(color); - SetLowColor(color); + if (ViewColor() == B_TRANSPARENT_COLOR) { + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + SetLowUIColor(B_PANEL_BACKGROUND_COLOR); + SetHighUIColor(B_PANEL_TEXT_COLOR); } // The box could have been resized in the mean time @@ -666,6 +654,8 @@ BBox::_InitObject(BMessage* archive) if (archive->FindBool("_lblview", &hasLabelView) == B_OK) fLabelView = ChildAt(0); } + + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); } diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp index b685d9e6fc..68b2884cc8 100644 --- a/src/kits/interface/Button.cpp +++ b/src/kits/interface/Button.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2014 Haiku Inc. All rights reserved. + * Copyright 2001-2015 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -132,9 +132,14 @@ BButton::Archive(BMessage* data, bool deep) const void BButton::Draw(BRect updateRect) { + // Allow improved customization & integration + float buttonTint = B_DARKEN_1_TINT; + if (ViewUIColor() != B_CONTROL_BACKGROUND_COLOR) + buttonTint = B_NO_TINT; + BRect rect(Bounds()); rgb_color background = LowColor(); - rgb_color base = background; + rgb_color base = tint_color(ViewColor(), buttonTint); uint32 flags = be_control_look->Flags(this); if (_Flag(FLAG_DEFAULT)) flags |= BControlLook::B_DEFAULT_BUTTON; @@ -223,17 +228,25 @@ BButton::MouseDown(BPoint where) } } - void BButton::AttachedToWindow() { BControl::AttachedToWindow(); - // low color will now be the parents view color + SetViewUIColor(B_CONTROL_BACKGROUND_COLOR); + + // Ensure BButton's low color is the parent's VIEW color. + // We don't want to adopt the standard control lowcolor. + if (Parent() != NULL) { + float tint = B_NO_TINT; + color_which which = ViewUIColor(&tint); + if (which != B_NO_COLOR) + SetLowUIColor(which, tint); + else + SetLowColor(ViewColor()); + } if (IsDefault()) Window()->SetDefaultButton(this); - - SetViewColor(B_TRANSPARENT_COLOR); } diff --git a/src/kits/interface/ChannelSlider.cpp b/src/kits/interface/ChannelSlider.cpp index 8f8d41a0d9..bfe893eb5e 100644 --- a/src/kits/interface/ChannelSlider.cpp +++ b/src/kits/interface/ChannelSlider.cpp @@ -149,10 +149,7 @@ BChannelSlider::Archive(BMessage* into, bool deep) const void BChannelSlider::AttachedToWindow() { - BView* parent = Parent(); - if (parent != NULL) - SetViewColor(parent->ViewColor()); - + AdoptParentColors(); BChannelControl::AttachedToWindow(); } @@ -181,6 +178,21 @@ BChannelSlider::AllDetached() void BChannelSlider::MessageReceived(BMessage* message) { + if (message->what == B_COLORS_UPDATED + && fBacking != NULL && fBackingView != NULL) { + rgb_color color; + if (message->FindColor(ui_color_name(B_PANEL_BACKGROUND_COLOR), &color) + == B_OK + && fBacking->Lock()) { + + if (fBackingView->LockLooper()) { + fBackingView->SetLowColor(color); + fBackingView->UnlockLooper(); + } + fBacking->Unlock(); + } + } + switch (message->what) { case B_SET_PROPERTY: { case B_GET_PROPERTY: @@ -230,6 +242,7 @@ BChannelSlider::Draw(BRect updateRect) _UpdateFontDimens(); _DrawThumbs(); + SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); BRect bounds(Bounds()); if (Label()) { float labelWidth = StringWidth(Label()); @@ -709,8 +722,6 @@ BChannelSlider::_InitData() fInitialValues = NULL; fMinPoint = 0; fFocusChannel = -1; - - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } diff --git a/src/kits/interface/CheckBox.cpp b/src/kits/interface/CheckBox.cpp index c8fb055160..fc17585ed0 100644 --- a/src/kits/interface/CheckBox.cpp +++ b/src/kits/interface/CheckBox.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2014 Haiku, Inc. All rights reserved. + * Copyright 2001-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -111,7 +111,7 @@ BCheckBox::Draw(BRect updateRect) BRect checkBoxRect(_CheckBoxFrame()); BRect rect(checkBoxRect); - be_control_look->DrawCheckBox(this, rect, updateRect,base, flags); + be_control_look->DrawCheckBox(this, rect, updateRect, base, flags); BRect labelRect(Bounds()); labelRect.left = checkBoxRect.right + 1 diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index 1da6e90657..0379cd5d0c 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -333,13 +333,10 @@ BColorControl::SetEnabled(bool enabled) void BColorControl::AttachedToWindow() { - if (Parent()) - SetViewColor(Parent()->ViewColor()); - else - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - BControl::AttachedToWindow(); + AdoptParentColors(); + fRedText->SetTarget(this); fGreenText->SetTarget(this); fBlueText->SetTarget(this); diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 10f2d58996..2c0ed08e2a 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -68,7 +68,6 @@ All rights reserved. #include -#include "ColorTools.h" #include "ObjectList.h" @@ -1423,6 +1422,16 @@ BColumnListView::SetColor(ColumnListViewColor colorIndex, const rgb_color color) } fColorList[colorIndex] = color; + fCustomColors = true; +} + + +void +BColumnListView::ResetColors() +{ + fCustomColors = false; + _UpdateColors(); + Invalidate(); } @@ -1458,6 +1467,7 @@ void BColumnListView::SetSelectionColor(rgb_color color) { fColorList[B_COLOR_SELECTION] = color; + fCustomColors = true; } @@ -1465,6 +1475,7 @@ void BColumnListView::SetBackgroundColor(rgb_color color) { fColorList[B_COLOR_BACKGROUND] = color; + fCustomColors = true; fOutlineView->Invalidate(); // repaint with new color } @@ -1474,6 +1485,7 @@ void BColumnListView::SetEditColor(rgb_color color) { fColorList[B_COLOR_EDIT_BACKGROUND] = color; + fCustomColors = true; } @@ -1662,6 +1674,9 @@ BColumnListView::MessageReceived(BMessage* message) fOutlineView->MessageReceived(message); return; } + } else if (message->what == B_COLORS_UPDATED) { + // Todo: Is it worthwhile to optimize this? + _UpdateColors(); } BView::MessageReceived(message); @@ -2045,32 +2060,8 @@ BColumnListView::_Init() if (bounds.Height() <= 0) bounds.bottom = 100; - fColorList[B_COLOR_BACKGROUND] = ui_color(B_LIST_BACKGROUND_COLOR); - fColorList[B_COLOR_TEXT] = ui_color(B_LIST_ITEM_TEXT_COLOR); - fColorList[B_COLOR_ROW_DIVIDER] = tint_color( - ui_color(B_LIST_SELECTED_BACKGROUND_COLOR), B_DARKEN_2_TINT); - fColorList[B_COLOR_SELECTION] = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); - fColorList[B_COLOR_SELECTION_TEXT] = - ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR); - - // For non focus selection uses the selection color as BListView - fColorList[B_COLOR_NON_FOCUS_SELECTION] = - ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); - - // edit mode doesn't work very well - fColorList[B_COLOR_EDIT_BACKGROUND] = tint_color( - ui_color(B_LIST_SELECTED_BACKGROUND_COLOR), B_DARKEN_1_TINT); - fColorList[B_COLOR_EDIT_BACKGROUND].alpha = 180; - - // Unused color - fColorList[B_COLOR_EDIT_TEXT] = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR); - - fColorList[B_COLOR_HEADER_BACKGROUND] = ui_color(B_PANEL_BACKGROUND_COLOR); - fColorList[B_COLOR_HEADER_TEXT] = ui_color(B_PANEL_TEXT_COLOR); - - // Unused colors - fColorList[B_COLOR_SEPARATOR_LINE] = ui_color(B_LIST_ITEM_TEXT_COLOR); - fColorList[B_COLOR_SEPARATOR_BORDER] = ui_color(B_LIST_ITEM_TEXT_COLOR); + fCustomColors = false; + _UpdateColors(); BRect titleRect; BRect outlineRect; @@ -2102,6 +2093,41 @@ BColumnListView::_Init() } +void +BColumnListView::_UpdateColors() +{ + if (fCustomColors) + return; + + fColorList[B_COLOR_BACKGROUND] = ui_color(B_LIST_BACKGROUND_COLOR); + fColorList[B_COLOR_TEXT] = ui_color(B_LIST_ITEM_TEXT_COLOR); + fColorList[B_COLOR_ROW_DIVIDER] = tint_color( + ui_color(B_LIST_SELECTED_BACKGROUND_COLOR), B_DARKEN_2_TINT); + fColorList[B_COLOR_SELECTION] = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); + fColorList[B_COLOR_SELECTION_TEXT] = + ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR); + + // For non focus selection uses the selection color as BListView + fColorList[B_COLOR_NON_FOCUS_SELECTION] = + ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); + + // edit mode doesn't work very well + fColorList[B_COLOR_EDIT_BACKGROUND] = tint_color( + ui_color(B_LIST_SELECTED_BACKGROUND_COLOR), B_DARKEN_1_TINT); + fColorList[B_COLOR_EDIT_BACKGROUND].alpha = 180; + + // Unused color + fColorList[B_COLOR_EDIT_TEXT] = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR); + + fColorList[B_COLOR_HEADER_BACKGROUND] = ui_color(B_PANEL_BACKGROUND_COLOR); + fColorList[B_COLOR_HEADER_TEXT] = ui_color(B_PANEL_TEXT_COLOR); + + // Unused colors + fColorList[B_COLOR_SEPARATOR_LINE] = ui_color(B_LIST_ITEM_TEXT_COLOR); + fColorList[B_COLOR_SEPARATOR_BORDER] = ui_color(B_LIST_ITEM_TEXT_COLOR); +} + + void BColumnListView::_GetChildViewRects(const BRect& bounds, BRect& titleRect, BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect) diff --git a/src/kits/interface/Control.cpp b/src/kits/interface/Control.cpp index 6cef099db5..1882e8bf7a 100644 --- a/src/kits/interface/Control.cpp +++ b/src/kits/interface/Control.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2013, Haiku, Inc. + * Copyright 2001-2015, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -151,19 +151,20 @@ BControl::WindowActivated(bool active) void BControl::AttachedToWindow() { - rgb_color color; + AdoptParentColors(); - BView* parent = Parent(); - if (parent != NULL) { - // inherit the color from parent - color = parent->ViewColor(); - if (color == B_TRANSPARENT_COLOR) - color = ui_color(B_PANEL_BACKGROUND_COLOR); - } else - color = ui_color(B_PANEL_BACKGROUND_COLOR); + if (ViewColor() == B_TRANSPARENT_COLOR) + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); - SetViewColor(color); - SetLowColor(color); + // Force view color as low color + if (Parent() != NULL) { + float tint = B_NO_TINT; + color_which which = ViewUIColor(&tint); + if (which != B_NO_COLOR) + SetLowUIColor(which, tint); + else + SetLowColor(ViewColor()); + } if (!Messenger().IsValid()) SetTarget(Window()); @@ -610,6 +611,9 @@ BControl::operator=(const BControl &) void BControl::InitData(BMessage* data) { + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + SetLowUIColor(ViewUIColor()); + fLabel = NULL; SetLabel(B_EMPTY_STRING); fValue = B_CONTROL_OFF; diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 3cfad71874..dfeb6e3fb5 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -92,7 +92,7 @@ BControlLook::ComposeSpacing(float spacing) uint32 BControlLook::Flags(BControl* control) const { - uint32 flags = 0; + uint32 flags = B_IS_CONTROL; if (!control->IsEnabled()) flags |= B_DISABLED; @@ -1763,29 +1763,29 @@ BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect, void BControlLook::DrawLabel(BView* view, const char* label, BRect rect, - const BRect& updateRect, const rgb_color& base, uint32 flags) + const BRect& updateRect, const rgb_color& base, uint32 flags, + const rgb_color* textColor) { DrawLabel(view, label, NULL, rect, updateRect, base, flags, - DefaultLabelAlignment()); + DefaultLabelAlignment(), textColor); } void BControlLook::DrawLabel(BView* view, const char* label, BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags, - const BAlignment& alignment) + const BAlignment& alignment, const rgb_color* textColor) { - DrawLabel(view, label, NULL, rect, updateRect, base, flags, alignment); + DrawLabel(view, label, NULL, rect, updateRect, base, flags, alignment, + textColor); } void BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, - uint32 flags, const BPoint& where) + uint32 flags, const BPoint& where, const rgb_color* textColor) { // setup the text color - // TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here, - // or elliminate that constant alltogether (stippi: +1). BWindow* window = view->Window(); bool isDesktop = window @@ -1799,19 +1799,20 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, rgb_color color; rgb_color glowColor; + if (textColor != NULL) + glowColor = *textColor; + else if ((flags & B_IS_CONTROL) != 0) + glowColor = ui_color(B_CONTROL_TEXT_COLOR); + else + glowColor = ui_color(B_PANEL_TEXT_COLOR); + + color = glowColor; + if (isDesktop) low = view->Parent()->ViewColor(); else low = base; - if (low.red + low.green + low.blue > 128 * 3) { - color = tint_color(low, B_DARKEN_MAX_TINT); - glowColor = kWhite; - } else { - color = tint_color(low, B_LIGHTEN_MAX_TINT); - glowColor = kBlack; - } - if ((flags & B_DISABLED) != 0) { color.red = (uint8)(((int32)low.red + color.red + 1) / 2); color.green = (uint8)(((int32)low.green + color.green + 1) / 2); @@ -1847,7 +1848,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, view->SetDrawingMode(B_OP_ALPHA); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); // Draw glow or outline - if (glowColor == kWhite) { + if (glowColor.Brightness() > 128) { font.SetFalseBoldWidth(2.0); view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); @@ -1864,7 +1865,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, font.SetFalseBoldWidth(0.0); view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); - } else if (glowColor == kBlack) { + } else { font.SetFalseBoldWidth(1.0); view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); @@ -1891,17 +1892,18 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, void BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, - BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags) + BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags, + const rgb_color* textColor) { DrawLabel(view, label, icon, rect, updateRect, base, flags, - DefaultLabelAlignment()); + DefaultLabelAlignment(), textColor); } void BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags, - const BAlignment& alignment) + const BAlignment& alignment, const rgb_color* textColor) { if (!rect.Intersects(updateRect)) return; @@ -1967,7 +1969,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, if (textHeight < height) location.y += ceilf((height - textHeight) / 2); - DrawLabel(view, truncatedLabel.String(), base, flags, location); + DrawLabel(view, truncatedLabel.String(), base, flags, location, textColor); } @@ -2147,6 +2149,7 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, drawing_mode oldMode = view->DrawingMode(); if ((flags & B_DEFAULT_BUTTON) != 0) { + defaultIndicatorColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR); cornerBgColor = defaultIndicatorColor; edgeLightColor = _EdgeLightColor(defaultIndicatorColor, contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), diff --git a/src/kits/interface/GridView.cpp b/src/kits/interface/GridView.cpp index 9012f93db2..2fd96a6ab6 100644 --- a/src/kits/interface/GridView.cpp +++ b/src/kits/interface/GridView.cpp @@ -13,7 +13,7 @@ BGridView::BGridView(float horizontalSpacing, float verticalSpacing) : BView(NULL, 0, new BGridLayout(horizontalSpacing, verticalSpacing)) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptSystemColors(); } @@ -22,7 +22,7 @@ BGridView::BGridView(const char* name, float horizontalSpacing, : BView(name, 0, new BGridLayout(horizontalSpacing, verticalSpacing)) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptSystemColors(); } diff --git a/src/kits/interface/GroupView.cpp b/src/kits/interface/GroupView.cpp index dce7e7abe1..b4a62d84c4 100644 --- a/src/kits/interface/GroupView.cpp +++ b/src/kits/interface/GroupView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku, Inc. All rights reserved. + * Copyright 2010-2015 Haiku, Inc. All rights reserved. * Copyright 2006, Ingo Weinhold . * * Distributed under the terms of the MIT License. @@ -8,12 +8,14 @@ #include +extern "C" void printf(const char*, ...); + BGroupView::BGroupView(orientation orientation, float spacing) : BView(NULL, 0, new BGroupLayout(orientation, spacing)) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptSystemColors(); } @@ -22,7 +24,7 @@ BGroupView::BGroupView(const char* name, orientation orientation, : BView(name, 0, new BGroupLayout(orientation, spacing)) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptSystemColors(); } @@ -30,6 +32,7 @@ BGroupView::BGroupView(BMessage* from) : BView(from) { + AdoptSystemColors(); } diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index 515ac8b4eb..8071ec96a7 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2013 Haiku, Inc. All rights resrerved. + * Copyright 2001-2015 Haiku, Inc. All rights resrerved. * Distributed under the terms of the MIT license. * * Authors: @@ -1449,9 +1449,8 @@ BListView::_InitObject(list_view_type type) fTrack = new track_data; fTrack->try_drag = false; fTrack->item_index = -1; - - SetViewColor(ui_color(B_LIST_BACKGROUND_COLOR)); - SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR)); + SetViewUIColor(B_LIST_BACKGROUND_COLOR); + SetLowUIColor(B_LIST_BACKGROUND_COLOR); } diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index a93340b8c8..b00620012d 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1407,7 +1407,7 @@ void BMenu::DrawBackground(BRect updateRect) { if (be_control_look != NULL) { - rgb_color base = sMenuInfo.background_color; + rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); uint32 flags = 0; if (!IsEnabled()) flags |= BControlLook::B_DISABLED; @@ -1435,7 +1435,7 @@ BMenu::DrawBackground(BRect updateRect) } rgb_color oldColor = HighColor(); - SetHighColor(sMenuInfo.background_color); + SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR)); FillRect(Bounds() & updateRect, B_SOLID_HIGH); SetHighColor(oldColor); } @@ -1469,7 +1469,7 @@ BMenu::_InitData(BMessage* archive) fLayoutData = new LayoutData; fLayoutData->lastResizingMode = ResizingMode(); - SetLowColor(sMenuInfo.background_color); + SetLowUIColor(B_MENU_BACKGROUND_COLOR); SetViewColor(B_TRANSPARENT_COLOR); fTriggerEnabled = sMenuInfo.triggers_always_shown; diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 4351e73a3f..79005e559b 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -745,4 +745,6 @@ BMenuBar::_InitData(menu_layout layout) fLastBounds = new BRect(Bounds()); SetItemMargins(8, 2, 8, 2); _SetIgnoreHidden(true); + SetLowUIColor(B_MENU_BACKGROUND_COLOR); + SetViewColor(B_TRANSPARENT_COLOR); } diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index fd312af307..3318dad21c 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -428,19 +428,7 @@ void BMenuField::AttachedToWindow() { CALLED(); - rgb_color color; - - BView* parent = Parent(); - if (parent != NULL) { - // inherit the color from parent - color = parent->ViewColor(); - if (color == B_TRANSPARENT_COLOR) - color = ui_color(B_PANEL_BACKGROUND_COLOR); - } else - color = ui_color(B_PANEL_BACKGROUND_COLOR); - - SetViewColor(color); - SetLowColor(color); + AdoptParentColors(); } @@ -1078,6 +1066,7 @@ BMenuField::_DrawLabel(BRect updateRect) // save the current low color const rgb_color lowColor = LowColor(); + rgb_color textColor; MenuPrivate menuPrivate(fMenuBar); if (menuPrivate.State() != MENU_STATE_CLOSED) { @@ -1085,10 +1074,12 @@ BMenuField::_DrawLabel(BRect updateRect) SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR)); BRect fillRect(rect.InsetByCopy(0, kVMargin)); FillRect(fillRect, B_SOLID_LOW); - } + textColor = ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR); + } else + textColor = ui_color(B_MENU_ITEM_TEXT_COLOR); be_control_look->DrawLabel(this, label, rect, updateRect, LowColor(), flags, - BAlignment(fAlign, B_ALIGN_MIDDLE)); + BAlignment(fAlign, B_ALIGN_MIDDLE), &textColor); // restore the previous low color SetLowColor(lowColor); diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index d51280c538..e4bf883c08 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -445,8 +445,8 @@ BMenuItem::DrawContent() void BMenuItem::Draw() { - const rgb_color lowColor = fSuper->LowColor(); - const rgb_color highColor = fSuper->HighColor(); + const color_which lowColor = fSuper->LowUIColor(); + const color_which highColor = fSuper->HighUIColor(); bool enabled = IsEnabled(); bool selected = IsSelected(); @@ -493,8 +493,8 @@ BMenuItem::Draw() } // restore the parent menu's low color and high color - fSuper->SetLowColor(lowColor); - fSuper->SetHighColor(highColor); + fSuper->SetLowUIColor(lowColor); + fSuper->SetHighUIColor(highColor); } diff --git a/src/kits/interface/MenuWindow.cpp b/src/kits/interface/MenuWindow.cpp index 42889a9be6..e8e5eeb4c6 100644 --- a/src/kits/interface/MenuWindow.cpp +++ b/src/kits/interface/MenuWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku, Inc. + * Copyright 2001-2015, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -79,7 +79,7 @@ BMenuScroller::BMenuScroller(BRect frame) BView(frame, "menu scroller", 0, B_WILL_DRAW | B_FRAME_EVENTS), fEnabled(false) { - SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); + SetViewUIColor(B_MENU_BACKGROUND_COLOR); } diff --git a/src/kits/interface/ScrollView.cpp b/src/kits/interface/ScrollView.cpp index 029c083e1b..905114c58d 100644 --- a/src/kits/interface/ScrollView.cpp +++ b/src/kits/interface/ScrollView.cpp @@ -738,7 +738,7 @@ BScrollView::_Init(bool horizontal, bool vertical) fBorders = BControlLook::B_ALL_BORDERS; if (be_control_look != NULL) - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); if (horizontal) { fHorizontalScrollBar = new BScrollBar(BRect(0, 0, 14, 14), "_HSB_", diff --git a/src/kits/interface/Slider.cpp b/src/kits/interface/Slider.cpp index 479a81ca6e..fa1ac56cc7 100644 --- a/src/kits/interface/Slider.cpp +++ b/src/kits/interface/Slider.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2013 Haiku, Inc. + * Copyright 2001-2015 Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -394,7 +394,10 @@ BSlider::AttachedToWindow() BView* view = OffscreenView(); if (view && view->LockLooper()) { view->SetViewColor(B_TRANSPARENT_COLOR); - view->SetLowColor(LowColor()); + if (LowUIColor() != B_NO_COLOR) + view->SetLowUIColor(LowUIColor()); + else + view->SetLowColor(LowColor()); view->UnlockLooper(); } @@ -411,6 +414,12 @@ void BSlider::AllAttached() { BControl::AllAttached(); + + // When using a layout we may not have a parent, so we need to employ the + // standard system colors manually. Due to how layouts work, this must + // happen here, rather than in AttachedToWindow(). + if (Parent() == NULL) + SetLowUIColor(B_PANEL_BACKGROUND_COLOR); } @@ -1006,7 +1015,7 @@ BSlider::DrawHashMarks() BView* view = OffscreenView(); if (be_control_look != NULL) { - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = ui_color(B_CONTROL_MARK_COLOR); uint32 flags = be_control_look->Flags(this); be_control_look->DrawSliderHashMarks(view, frame, frame, base, fHashMarkCount, fHashMarks, flags, fOrientation); diff --git a/src/kits/interface/SplitView.cpp b/src/kits/interface/SplitView.cpp index 6a174d5db6..79fc9814e0 100644 --- a/src/kits/interface/SplitView.cpp +++ b/src/kits/interface/SplitView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2006, Ingo Weinhold . + * Copyright 2015, Haiku, Inc. * All rights reserved. Distributed under the terms of the MIT License. */ @@ -20,7 +21,6 @@ BSplitView::BSplitView(orientation orientation, float spacing) B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INVALIDATE_AFTER_LAYOUT, fSplitLayout = new BSplitLayout(orientation, spacing)) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } @@ -236,6 +236,13 @@ BSplitView::AddChild(int32 index, BLayoutItem* child, float weight) } +void +BSplitView::AttachedToWindow() +{ + AdoptParentColors(); +} + + void BSplitView::Draw(BRect updateRect) { diff --git a/src/kits/interface/StatusBar.cpp b/src/kits/interface/StatusBar.cpp index 7cd4f74ea0..4da4fa38c1 100644 --- a/src/kits/interface/StatusBar.cpp +++ b/src/kits/interface/StatusBar.cpp @@ -1,11 +1,12 @@ /* - * Copyright 2001-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2015, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Marc Flerackers (mflerackers@androme.be) * Axel Dörfler, axeld@pinc-software.de * Stephan Aßmus + * Joseph Groover */ /*! BStatusBar displays a "percentage-of-completion" gauge. */ @@ -23,8 +24,9 @@ #include - -static const rgb_color kDefaultBarColor = {50, 150, 255, 255}; +enum internalFlags { + kCustomBarColor = 1 +}; BStatusBar::BStatusBar(BRect frame, const char *name, const char *label, @@ -69,8 +71,10 @@ BStatusBar::BStatusBar(BMessage *archive) } int32 color; - if (archive->FindInt32("_bcolor", (int32 *)&color) == B_OK) + if (archive->FindInt32("_bcolor", (int32 *)&color) == B_OK) { fBarColor = *(rgb_color *)&color; + fInternalFlags |= kCustomBarColor; + } if (archive->FindFloat("_val", &floatValue) == B_OK) fCurrent = floatValue; @@ -104,7 +108,7 @@ BStatusBar::Archive(BMessage *archive, bool deep) const if (fCustomBarHeight) err = archive->AddFloat("_high", fBarHeight); - if (err == B_OK && fBarColor != kDefaultBarColor) + if (err == B_OK && fInternalFlags & kCustomBarColor) err = archive->AddInt32("_bcolor", (const uint32 &)fBarColor); if (err == B_OK && fCurrent != 0) @@ -138,18 +142,13 @@ BStatusBar::AttachedToWindow() ResizeTo(Bounds().Width(), height); SetViewColor(B_TRANSPARENT_COLOR); - rgb_color lowColor = B_TRANSPARENT_COLOR; - BView* parent = Parent(); - if (parent != NULL) - lowColor = parent->ViewColor(); - - if (lowColor == B_TRANSPARENT_COLOR) - lowColor = ui_color(B_PANEL_BACKGROUND_COLOR); - - SetLowColor(lowColor); + AdoptParentColors(); fTextDivider = Bounds().Width(); + + if ((fInternalFlags & kCustomBarColor) == 0) + fBarColor = ui_color(B_CONTROL_MARK_COLOR); } @@ -311,7 +310,8 @@ BStatusBar::Draw(BRect updateRect) GetFont(&font); if (rightText.Length()) { - font.TruncateString(&rightText, B_TRUNCATE_BEGINNING, rect.Width()); + font.TruncateString(&rightText, B_TRUNCATE_BEGINNING, + rect.Width()); fTextDivider -= StringWidth(rightText.String()); } @@ -320,14 +320,22 @@ BStatusBar::Draw(BRect updateRect) font.TruncateString(&leftText, B_TRUNCATE_END, width); } - SetHighColor(ui_color(B_CONTROL_TEXT_COLOR)); + rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); + + if (backgroundColor != ui_color(B_PANEL_BACKGROUND_COLOR)) { + if (backgroundColor.Brightness() > 100) + textColor = make_color(0, 0, 0, 255); + else + textColor = make_color(255, 255, 255, 255); + } + + SetHighColor(textColor); if (leftText.Length()) DrawString(leftText.String(), BPoint(rect.left, baseLine)); if (rightText.Length()) DrawString(rightText.String(), BPoint(fTextDivider, baseLine)); - } // Draw bar @@ -344,22 +352,22 @@ BStatusBar::Draw(BRect updateRect) } // First bevel - SetHighColor(tint_color(ui_color ( B_PANEL_BACKGROUND_COLOR ), B_DARKEN_1_TINT)); + SetHighColor(tint_color(backgroundColor, B_DARKEN_1_TINT)); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); - SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT)); + SetHighColor(tint_color(backgroundColor, B_LIGHTEN_2_TINT)); StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1)); rect.InsetBy(1, 1); // Second bevel - SetHighColor(tint_color(ui_color ( B_PANEL_BACKGROUND_COLOR ), B_DARKEN_4_TINT)); + SetHighColor(tint_color(backgroundColor, B_DARKEN_4_TINT)); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); - SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetHighColor(backgroundColor); StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1)); @@ -387,7 +395,7 @@ BStatusBar::Draw(BRect updateRect) // empty space rect.left = rect.right + 1; rect.right = barFrame.right; - SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT)); + SetHighColor(tint_color(backgroundColor, B_LIGHTEN_MAX_TINT)); FillRect(rect); } } @@ -423,6 +431,17 @@ BStatusBar::MessageReceived(BMessage *message) break; } + case B_COLORS_UPDATED: + { + // Change the bar color IF we don't have an application-set color. + if ((fInternalFlags & kCustomBarColor) == 0) { + message->FindColor(ui_color_name(B_CONTROL_MARK_COLOR), + &fBarColor); + } + + break; + } + default: BView::MessageReceived(message); break; @@ -457,6 +476,7 @@ BStatusBar::MouseMoved(BPoint point, uint32 transit, const BMessage *message) void BStatusBar::SetBarColor(rgb_color color) { + fInternalFlags |= kCustomBarColor; fBarColor = color; Invalidate(); @@ -755,8 +775,8 @@ BStatusBar::_InitObject() fBarHeight = -1.0; fTextDivider = Bounds().Width(); - fBarColor = kDefaultBarColor; fCustomBarHeight = false; + fInternalFlags = 0; SetFlags(Flags() | B_FRAME_EVENTS); } diff --git a/src/kits/interface/StringView.cpp b/src/kits/interface/StringView.cpp index e4d1ca7fb5..29a6c93f75 100644 --- a/src/kits/interface/StringView.cpp +++ b/src/kits/interface/StringView.cpp @@ -128,16 +128,16 @@ BStringView::Archive(BMessage* data, bool deep) const void BStringView::AttachedToWindow() { - rgb_color color = B_TRANSPARENT_COLOR; + if (HasDefaultColors()) { + AdoptParentColors(); + SetHighUIColor(B_PANEL_TEXT_COLOR); + } - BView* parent = Parent(); - if (parent != NULL) - color = parent->ViewColor(); - - if (color == B_TRANSPARENT_COLOR) - color = ui_color(B_PANEL_BACKGROUND_COLOR); - - SetViewColor(color); + if (ViewColor() == B_TRANSPARENT_COLOR) { + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + SetLowUIColor(B_PANEL_BACKGROUND_COLOR); + SetHighUIColor(B_PANEL_TEXT_COLOR); + } } @@ -254,7 +254,8 @@ BStringView::Draw(BRect updateRect) if (!fText) return; - SetLowColor(ViewColor()); + if (LowUIColor() == B_NO_COLOR) + SetLowColor(ViewColor()); font_height fontHeight; GetFontHeight(&fontHeight); diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp index 28c93c6c33..734890b4c6 100644 --- a/src/kits/interface/TabView.cpp +++ b/src/kits/interface/TabView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2013 Haiku, Inc. All rights reserved. + * Copyright 2001-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -1224,10 +1224,8 @@ BTabView::_InitObject(bool layouted, button_width width) fTabOffset = 0.0f; fBorderStyle = B_FANCY_BORDER; - rgb_color color = ui_color(B_PANEL_BACKGROUND_COLOR); - - SetViewColor(color); - SetLowColor(color); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + SetLowUIColor(B_PANEL_BACKGROUND_COLOR); font_height fh; GetFontHeight(&fh); @@ -1264,8 +1262,8 @@ BTabView::_InitContainerView(bool layouted) _LayoutContainerView(layouted); if (createdContainer) { - fContainerView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - fContainerView->SetLowColor(fContainerView->ViewColor()); + fContainerView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fContainerView->SetLowUIColor(B_PANEL_BACKGROUND_COLOR); AddChild(fContainerView); } } diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 3e2707f3fa..c05a1bcc93 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -357,7 +357,7 @@ BTextControl::Draw(BRect updateRect) BRect rect = fText->Frame(); rect.InsetBy(-2, -2); - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color base = ViewColor(); uint32 flags = fLook; if (!enabled) flags |= BControlLook::B_DISABLED; @@ -464,6 +464,16 @@ BTextControl::LayoutInvalidated(bool descendants) void BTextControl::MessageReceived(BMessage* message) { + if (message->what == B_COLORS_UPDATED) { + + if (message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR)) + || message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR)) + || message->HasColor(ui_color_name(B_DOCUMENT_BACKGROUND_COLOR)) + || message->HasColor(ui_color_name(B_DOCUMENT_TEXT_COLOR))) { + _UpdateTextViewColors(IsEnabled()); + } + } + if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) { BMessage reply(B_REPLY); bool handled = false; @@ -1025,30 +1035,20 @@ BTextControl::operator=(const BTextControl&) void BTextControl::_UpdateTextViewColors(bool enable) { - rgb_color textColor; - rgb_color color; + rgb_color textColor = ui_color(B_DOCUMENT_TEXT_COLOR); + rgb_color viewColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); BFont font; fText->GetFontAndColor(0, &font); - if (enable) - textColor = ui_color(B_DOCUMENT_TEXT_COLOR); - else { - textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DISABLED_LABEL_TINT); + if (!enable) { + textColor = disable_color(textColor, ViewColor()); + viewColor = disable_color(ViewColor(), viewColor); } fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); - - if (enable) - color = ui_color(B_DOCUMENT_BACKGROUND_COLOR); - else { - color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_LIGHTEN_2_TINT); - } - - fText->SetViewColor(color); - fText->SetLowColor(color); + fText->SetViewColor(viewColor); + fText->SetLowColor(viewColor); } diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 37a0d0ca93..7aee6a30bd 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -3051,8 +3051,10 @@ BTextView::_InitObject(BRect textRect, const BFont* initialFont, _NormalizeFont(&font); + rgb_color documentTextColor = ui_color(B_DOCUMENT_TEXT_COLOR); + if (initialColor == NULL) - initialColor = &kBlackColor; + initialColor = &documentTextColor; fText = new BPrivate::TextGapBuffer; fLines = new LineBuffer; @@ -3113,6 +3115,7 @@ BTextView::_InitObject(BRect textRect, const BFont* initialFont, fLastClickOffset = -1; SetDoesUndo(true); + SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR); } diff --git a/src/kits/interface/ToolTip.cpp b/src/kits/interface/ToolTip.cpp index 2885c4732e..f5a4873f1b 100644 --- a/src/kits/interface/ToolTip.cpp +++ b/src/kits/interface/ToolTip.cpp @@ -219,7 +219,7 @@ BTextToolTip::_InitData(const char* text) fTextView = new BTextView("tool tip text"); fTextView->SetText(text); fTextView->MakeEditable(false); - fTextView->SetViewColor(ui_color(B_TOOL_TIP_BACKGROUND_COLOR)); + fTextView->SetViewUIColor(B_TOOL_TIP_BACKGROUND_COLOR); rgb_color color = ui_color(B_TOOL_TIP_TEXT_COLOR); fTextView->SetFontAndColor(NULL, 0, &color); fTextView->SetWordWrap(false); diff --git a/src/kits/interface/ToolTipManager.cpp b/src/kits/interface/ToolTipManager.cpp index 5084adcebf..7f4d8a5da9 100644 --- a/src/kits/interface/ToolTipManager.cpp +++ b/src/kits/interface/ToolTipManager.cpp @@ -66,7 +66,7 @@ ToolTipView::ToolTipView(BToolTip* tip) fHidden(false) { fToolTip->AcquireReference(); - SetViewColor(ui_color(B_TOOL_TIP_BACKGROUND_COLOR)); + SetViewUIColor(B_TOOL_TIP_BACKGROUND_COLOR); BGroupLayout* layout = new BGroupLayout(B_VERTICAL); layout->SetInsets(5, 5, 5, 5);