kits/interface: Convert to using Set*UIColor.

Signed-off-by: Augustin Cavalier <[email protected]>
Patches 0003-0017 from looncraz, unmodified.
This commit is contained in:
looncraz
2016-01-04 07:04:45 -05:00
committed by Augustin Cavalier
parent 7f9368cae5
commit 7a96554cb3
30 changed files with 320 additions and 227 deletions
+17 -4
View File
@@ -1,10 +1,11 @@
/* /*
* Copyright 2007-2012 Haiku, Inc. * Copyright 2007-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Ryan Leavengood <[email protected]> * Ryan Leavengood <[email protected]>
* John Scipione <[email protected]> * John Scipione <[email protected]>
* Joseph Groover <[email protected]>
*/ */
@@ -68,6 +69,8 @@ public:
const char* signature); const char* signature);
virtual ~AboutView(); virtual ~AboutView();
virtual void AllAttached();
BTextView* InfoView() const { return fInfoView; }; BTextView* InfoView() const { return fInfoView; };
BBitmap* Icon(); BBitmap* Icon();
@@ -99,7 +102,7 @@ StripeView::StripeView(BBitmap* icon)
BView("StripeView", B_WILL_DRAW), BView("StripeView", B_WILL_DRAW),
fIcon(icon) fIcon(icon)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
float width = 0.0f; float width = 0.0f;
if (icon != NULL) if (icon != NULL)
@@ -159,6 +162,7 @@ AboutView::AboutView(const char* appName, const char* signature)
: :
BGroupView("AboutView", B_VERTICAL) BGroupView("AboutView", B_VERTICAL)
{ {
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
fNameView = new BStringView("name", appName); fNameView = new BStringView("name", appName);
BFont font; BFont font;
fNameView->GetFont(&font); fNameView->GetFont(&font);
@@ -176,7 +180,6 @@ AboutView::AboutView(const char* appName, const char* signature)
fInfoView->MakeEditable(false); fInfoView->MakeEditable(false);
fInfoView->SetWordWrap(true); fInfoView->SetWordWrap(true);
fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0); fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0);
fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
fInfoView->SetStylable(true); fInfoView->SetStylable(true);
BScrollView* infoViewScroller = new BScrollView( BScrollView* infoViewScroller = new BScrollView(
@@ -205,7 +208,8 @@ AboutView::AboutView(const char* appName, const char* signature)
.End() .End()
.End() .End()
.AddGlue() .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 // #pragma mark - AboutView private methods
+16 -18
View File
@@ -311,9 +311,6 @@ SpinnerButton::SpinnerButton(BRect frame, const char* name,
fIsMouseOver(false), fIsMouseOver(false),
fRepeatDelay(100000) fRepeatDelay(100000)
{ {
rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(bgColor);
SetLowColor(bgColor);
} }
@@ -327,6 +324,7 @@ SpinnerButton::AttachedToWindow()
{ {
fParent = static_cast<BAbstractSpinner*>(Parent()); fParent = static_cast<BAbstractSpinner*>(Parent());
AdoptParentColors();
BView::AttachedToWindow(); BView::AttachedToWindow();
} }
@@ -534,9 +532,6 @@ SpinnerTextView::SpinnerTextView(BRect rect, BRect textRect)
B_WILL_DRAW | B_NAVIGABLE), B_WILL_DRAW | B_NAVIGABLE),
fParent(NULL) fParent(NULL)
{ {
rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(bgColor);
SetLowColor(bgColor);
} }
@@ -550,6 +545,7 @@ SpinnerTextView::AttachedToWindow()
{ {
fParent = static_cast<BAbstractSpinner*>(Parent()); fParent = static_cast<BAbstractSpinner*>(Parent());
AdoptParentColors();
BTextView::AttachedToWindow(); BTextView::AttachedToWindow();
} }
@@ -1480,10 +1476,6 @@ BAbstractSpinner::_DrawTextView(BRect updateRect)
void void
BAbstractSpinner::_InitObject() BAbstractSpinner::_InitObject()
{ {
rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(bgColor);
SetLowColor(bgColor);
fAlignment = B_ALIGN_LEFT; fAlignment = B_ALIGN_LEFT;
fButtonStyle = SPINNER_BUTTON_PLUS_MINUS; fButtonStyle = SPINNER_BUTTON_PLUS_MINUS;
@@ -1594,7 +1586,6 @@ void
BAbstractSpinner::_UpdateTextViewColors(bool enable) BAbstractSpinner::_UpdateTextViewColors(bool enable)
{ {
rgb_color textColor; rgb_color textColor;
rgb_color bgColor;
BFont font; BFont font;
fTextView->GetFontAndColor(0, &font); fTextView->GetFontAndColor(0, &font);
@@ -1608,15 +1599,22 @@ BAbstractSpinner::_UpdateTextViewColors(bool enable)
fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor); fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor);
if (enable) if (enable) {
bgColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR); fTextView->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR);
else { fTextView->SetLowUIColor(ViewUIColor());
bgColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), } else {
B_LIGHTEN_2_TINT); 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);
} }
+2 -2
View File
@@ -497,7 +497,7 @@ BAlert::_Init(const char* text, const char* button0, const char* button1,
fIconView = new TAlertView(); fIconView = new TAlertView();
fTextView = new BTextView("_tv_"); 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); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
fTextView->MakeEditable(false); fTextView->MakeEditable(false);
@@ -718,7 +718,7 @@ TAlertView::TAlertView()
BView("TAlertView", B_WILL_DRAW), BView("TAlertView", B_WILL_DRAW),
fIconBitmap(NULL) fIconBitmap(NULL)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
} }
+10 -5
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -162,10 +162,15 @@ _BMCMenuBar_::AttachedToWindow()
if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0) if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0)
SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (Parent() != NULL) if (Parent() != NULL) {
SetLowColor(Parent()->LowColor()); color_which which = Parent()->LowUIColor();
else if (which == B_NO_COLOR)
SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR)); SetLowColor(Parent()->LowColor());
else
SetLowUIColor(which);
} else
SetLowUIColor(B_MENU_BACKGROUND_COLOR);
fPreviousWidth = Bounds().Width(); fPreviousWidth = Bounds().Width();
} }
+9 -19
View File
@@ -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. * Distributed under the terms of the MIT license.
* *
* Authors: * 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), BView(frame, name, resizingMode, flags | B_WILL_DRAW | B_FRAME_EVENTS),
fStyle(border) fStyle(border)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
_InitObject(); _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), BView(name, flags | B_WILL_DRAW | B_FRAME_EVENTS),
fStyle(border) fStyle(border)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
_InitObject(); _InitObject();
if (child) if (child)
@@ -76,9 +70,6 @@ BBox::BBox(border_style border, BView* child)
BView(NULL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), BView(NULL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP),
fStyle(border) fStyle(border)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
_InitObject(); _InitObject();
if (child) if (child)
@@ -269,7 +260,7 @@ BBox::Draw(BRect updateRect)
font_height fontHeight; font_height fontHeight;
GetFontHeight(&fontHeight); GetFontHeight(&fontHeight);
SetHighColor(0, 0, 0); SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
DrawString(fLabel, BPoint(10.0f, ceilf(fontHeight.ascent))); DrawString(fLabel, BPoint(10.0f, ceilf(fontHeight.ascent)));
} }
@@ -280,15 +271,12 @@ BBox::Draw(BRect updateRect)
void void
BBox::AttachedToWindow() BBox::AttachedToWindow()
{ {
BView* parent = Parent(); AdoptParentColors();
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);
SetViewColor(color); if (ViewColor() == B_TRANSPARENT_COLOR) {
SetLowColor(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 // 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) if (archive->FindBool("_lblview", &hasLabelView) == B_OK)
fLabelView = ChildAt(0); fLabelView = ChildAt(0);
} }
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
} }
+19 -6
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -132,9 +132,14 @@ BButton::Archive(BMessage* data, bool deep) const
void void
BButton::Draw(BRect updateRect) 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()); BRect rect(Bounds());
rgb_color background = LowColor(); rgb_color background = LowColor();
rgb_color base = background; rgb_color base = tint_color(ViewColor(), buttonTint);
uint32 flags = be_control_look->Flags(this); uint32 flags = be_control_look->Flags(this);
if (_Flag(FLAG_DEFAULT)) if (_Flag(FLAG_DEFAULT))
flags |= BControlLook::B_DEFAULT_BUTTON; flags |= BControlLook::B_DEFAULT_BUTTON;
@@ -223,17 +228,25 @@ BButton::MouseDown(BPoint where)
} }
} }
void void
BButton::AttachedToWindow() BButton::AttachedToWindow()
{ {
BControl::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()) if (IsDefault())
Window()->SetDefaultButton(this); Window()->SetDefaultButton(this);
SetViewColor(B_TRANSPARENT_COLOR);
} }
+17 -6
View File
@@ -149,10 +149,7 @@ BChannelSlider::Archive(BMessage* into, bool deep) const
void void
BChannelSlider::AttachedToWindow() BChannelSlider::AttachedToWindow()
{ {
BView* parent = Parent(); AdoptParentColors();
if (parent != NULL)
SetViewColor(parent->ViewColor());
BChannelControl::AttachedToWindow(); BChannelControl::AttachedToWindow();
} }
@@ -181,6 +178,21 @@ BChannelSlider::AllDetached()
void void
BChannelSlider::MessageReceived(BMessage* message) 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) { switch (message->what) {
case B_SET_PROPERTY: { case B_SET_PROPERTY: {
case B_GET_PROPERTY: case B_GET_PROPERTY:
@@ -230,6 +242,7 @@ BChannelSlider::Draw(BRect updateRect)
_UpdateFontDimens(); _UpdateFontDimens();
_DrawThumbs(); _DrawThumbs();
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
BRect bounds(Bounds()); BRect bounds(Bounds());
if (Label()) { if (Label()) {
float labelWidth = StringWidth(Label()); float labelWidth = StringWidth(Label());
@@ -709,8 +722,6 @@ BChannelSlider::_InitData()
fInitialValues = NULL; fInitialValues = NULL;
fMinPoint = 0; fMinPoint = 0;
fFocusChannel = -1; fFocusChannel = -1;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
} }
+2 -2
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -111,7 +111,7 @@ BCheckBox::Draw(BRect updateRect)
BRect checkBoxRect(_CheckBoxFrame()); BRect checkBoxRect(_CheckBoxFrame());
BRect rect(checkBoxRect); BRect rect(checkBoxRect);
be_control_look->DrawCheckBox(this, rect, updateRect,base, flags); be_control_look->DrawCheckBox(this, rect, updateRect, base, flags);
BRect labelRect(Bounds()); BRect labelRect(Bounds());
labelRect.left = checkBoxRect.right + 1 labelRect.left = checkBoxRect.right + 1
+2 -5
View File
@@ -333,13 +333,10 @@ BColorControl::SetEnabled(bool enabled)
void void
BColorControl::AttachedToWindow() BColorControl::AttachedToWindow()
{ {
if (Parent())
SetViewColor(Parent()->ViewColor());
else
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BControl::AttachedToWindow(); BControl::AttachedToWindow();
AdoptParentColors();
fRedText->SetTarget(this); fRedText->SetTarget(this);
fGreenText->SetTarget(this); fGreenText->SetTarget(this);
fBlueText->SetTarget(this); fBlueText->SetTarget(this);
+53 -27
View File
@@ -68,7 +68,6 @@ All rights reserved.
#include <ObjectListPrivate.h> #include <ObjectListPrivate.h>
#include "ColorTools.h"
#include "ObjectList.h" #include "ObjectList.h"
@@ -1423,6 +1422,16 @@ BColumnListView::SetColor(ColumnListViewColor colorIndex, const rgb_color color)
} }
fColorList[colorIndex] = color; fColorList[colorIndex] = color;
fCustomColors = true;
}
void
BColumnListView::ResetColors()
{
fCustomColors = false;
_UpdateColors();
Invalidate();
} }
@@ -1458,6 +1467,7 @@ void
BColumnListView::SetSelectionColor(rgb_color color) BColumnListView::SetSelectionColor(rgb_color color)
{ {
fColorList[B_COLOR_SELECTION] = color; fColorList[B_COLOR_SELECTION] = color;
fCustomColors = true;
} }
@@ -1465,6 +1475,7 @@ void
BColumnListView::SetBackgroundColor(rgb_color color) BColumnListView::SetBackgroundColor(rgb_color color)
{ {
fColorList[B_COLOR_BACKGROUND] = color; fColorList[B_COLOR_BACKGROUND] = color;
fCustomColors = true;
fOutlineView->Invalidate(); fOutlineView->Invalidate();
// repaint with new color // repaint with new color
} }
@@ -1474,6 +1485,7 @@ void
BColumnListView::SetEditColor(rgb_color color) BColumnListView::SetEditColor(rgb_color color)
{ {
fColorList[B_COLOR_EDIT_BACKGROUND] = color; fColorList[B_COLOR_EDIT_BACKGROUND] = color;
fCustomColors = true;
} }
@@ -1662,6 +1674,9 @@ BColumnListView::MessageReceived(BMessage* message)
fOutlineView->MessageReceived(message); fOutlineView->MessageReceived(message);
return; return;
} }
} else if (message->what == B_COLORS_UPDATED) {
// Todo: Is it worthwhile to optimize this?
_UpdateColors();
} }
BView::MessageReceived(message); BView::MessageReceived(message);
@@ -2045,32 +2060,8 @@ BColumnListView::_Init()
if (bounds.Height() <= 0) if (bounds.Height() <= 0)
bounds.bottom = 100; bounds.bottom = 100;
fColorList[B_COLOR_BACKGROUND] = ui_color(B_LIST_BACKGROUND_COLOR); fCustomColors = false;
fColorList[B_COLOR_TEXT] = ui_color(B_LIST_ITEM_TEXT_COLOR); _UpdateColors();
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);
BRect titleRect; BRect titleRect;
BRect outlineRect; 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 void
BColumnListView::_GetChildViewRects(const BRect& bounds, BRect& titleRect, BColumnListView::_GetChildViewRects(const BRect& bounds, BRect& titleRect,
BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect) BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect)
+16 -12
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013, Haiku, Inc. * Copyright 2001-2015, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -151,19 +151,20 @@ BControl::WindowActivated(bool active)
void void
BControl::AttachedToWindow() BControl::AttachedToWindow()
{ {
rgb_color color; AdoptParentColors();
BView* parent = Parent(); if (ViewColor() == B_TRANSPARENT_COLOR)
if (parent != NULL) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
// 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); // Force view color as low color
SetLowColor(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()) if (!Messenger().IsValid())
SetTarget(Window()); SetTarget(Window());
@@ -610,6 +611,9 @@ BControl::operator=(const BControl &)
void void
BControl::InitData(BMessage* data) BControl::InitData(BMessage* data)
{ {
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetLowUIColor(ViewUIColor());
fLabel = NULL; fLabel = NULL;
SetLabel(B_EMPTY_STRING); SetLabel(B_EMPTY_STRING);
fValue = B_CONTROL_OFF; fValue = B_CONTROL_OFF;
+25 -22
View File
@@ -92,7 +92,7 @@ BControlLook::ComposeSpacing(float spacing)
uint32 uint32
BControlLook::Flags(BControl* control) const BControlLook::Flags(BControl* control) const
{ {
uint32 flags = 0; uint32 flags = B_IS_CONTROL;
if (!control->IsEnabled()) if (!control->IsEnabled())
flags |= B_DISABLED; flags |= B_DISABLED;
@@ -1763,29 +1763,29 @@ BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect,
void void
BControlLook::DrawLabel(BView* view, const char* label, BRect rect, 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, DrawLabel(view, label, NULL, rect, updateRect, base, flags,
DefaultLabelAlignment()); DefaultLabelAlignment(), textColor);
} }
void void
BControlLook::DrawLabel(BView* view, const char* label, BRect rect, 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 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 void
BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, 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 // 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(); BWindow* window = view->Window();
bool isDesktop = window bool isDesktop = window
@@ -1799,19 +1799,20 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
rgb_color color; rgb_color color;
rgb_color glowColor; 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) if (isDesktop)
low = view->Parent()->ViewColor(); low = view->Parent()->ViewColor();
else else
low = base; 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) { if ((flags & B_DISABLED) != 0) {
color.red = (uint8)(((int32)low.red + color.red + 1) / 2); color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
color.green = (uint8)(((int32)low.green + color.green + 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->SetDrawingMode(B_OP_ALPHA);
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
// Draw glow or outline // Draw glow or outline
if (glowColor == kWhite) { if (glowColor.Brightness() > 128) {
font.SetFalseBoldWidth(2.0); font.SetFalseBoldWidth(2.0);
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); 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); font.SetFalseBoldWidth(0.0);
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
} else if (glowColor == kBlack) { } else {
font.SetFalseBoldWidth(1.0); font.SetFalseBoldWidth(1.0);
view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
@@ -1891,17 +1892,18 @@ BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
void void
BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, 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, DrawLabel(view, label, icon, rect, updateRect, base, flags,
DefaultLabelAlignment()); DefaultLabelAlignment(), textColor);
} }
void void
BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, 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 BAlignment& alignment) const BAlignment& alignment, const rgb_color* textColor)
{ {
if (!rect.Intersects(updateRect)) if (!rect.Intersects(updateRect))
return; return;
@@ -1967,7 +1969,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
if (textHeight < height) if (textHeight < height)
location.y += ceilf((height - textHeight) / 2); 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(); drawing_mode oldMode = view->DrawingMode();
if ((flags & B_DEFAULT_BUTTON) != 0) { if ((flags & B_DEFAULT_BUTTON) != 0) {
defaultIndicatorColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR);
cornerBgColor = defaultIndicatorColor; cornerBgColor = defaultIndicatorColor;
edgeLightColor = _EdgeLightColor(defaultIndicatorColor, edgeLightColor = _EdgeLightColor(defaultIndicatorColor,
contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
+2 -2
View File
@@ -13,7 +13,7 @@ BGridView::BGridView(float horizontalSpacing, float verticalSpacing)
: :
BView(NULL, 0, new BGridLayout(horizontalSpacing, 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)) BView(name, 0, new BGridLayout(horizontalSpacing, verticalSpacing))
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AdoptSystemColors();
} }
+6 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010 Haiku, Inc. All rights reserved. * Copyright 2010-2015 Haiku, Inc. All rights reserved.
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
@@ -8,12 +8,14 @@
#include <GroupView.h> #include <GroupView.h>
extern "C" void printf(const char*, ...);
BGroupView::BGroupView(orientation orientation, float spacing) BGroupView::BGroupView(orientation orientation, float spacing)
: :
BView(NULL, 0, new BGroupLayout(orientation, 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)) 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) BView(from)
{ {
AdoptSystemColors();
} }
+3 -4
View File
@@ -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. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -1449,9 +1449,8 @@ BListView::_InitObject(list_view_type type)
fTrack = new track_data; fTrack = new track_data;
fTrack->try_drag = false; fTrack->try_drag = false;
fTrack->item_index = -1; fTrack->item_index = -1;
SetViewUIColor(B_LIST_BACKGROUND_COLOR);
SetViewColor(ui_color(B_LIST_BACKGROUND_COLOR)); SetLowUIColor(B_LIST_BACKGROUND_COLOR);
SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
} }
+3 -3
View File
@@ -1407,7 +1407,7 @@ void
BMenu::DrawBackground(BRect updateRect) BMenu::DrawBackground(BRect updateRect)
{ {
if (be_control_look != NULL) { if (be_control_look != NULL) {
rgb_color base = sMenuInfo.background_color; rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
uint32 flags = 0; uint32 flags = 0;
if (!IsEnabled()) if (!IsEnabled())
flags |= BControlLook::B_DISABLED; flags |= BControlLook::B_DISABLED;
@@ -1435,7 +1435,7 @@ BMenu::DrawBackground(BRect updateRect)
} }
rgb_color oldColor = HighColor(); rgb_color oldColor = HighColor();
SetHighColor(sMenuInfo.background_color); SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR));
FillRect(Bounds() & updateRect, B_SOLID_HIGH); FillRect(Bounds() & updateRect, B_SOLID_HIGH);
SetHighColor(oldColor); SetHighColor(oldColor);
} }
@@ -1469,7 +1469,7 @@ BMenu::_InitData(BMessage* archive)
fLayoutData = new LayoutData; fLayoutData = new LayoutData;
fLayoutData->lastResizingMode = ResizingMode(); fLayoutData->lastResizingMode = ResizingMode();
SetLowColor(sMenuInfo.background_color); SetLowUIColor(B_MENU_BACKGROUND_COLOR);
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
fTriggerEnabled = sMenuInfo.triggers_always_shown; fTriggerEnabled = sMenuInfo.triggers_always_shown;
+2
View File
@@ -745,4 +745,6 @@ BMenuBar::_InitData(menu_layout layout)
fLastBounds = new BRect(Bounds()); fLastBounds = new BRect(Bounds());
SetItemMargins(8, 2, 8, 2); SetItemMargins(8, 2, 8, 2);
_SetIgnoreHidden(true); _SetIgnoreHidden(true);
SetLowUIColor(B_MENU_BACKGROUND_COLOR);
SetViewColor(B_TRANSPARENT_COLOR);
} }
+6 -15
View File
@@ -428,19 +428,7 @@ void
BMenuField::AttachedToWindow() BMenuField::AttachedToWindow()
{ {
CALLED(); CALLED();
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);
SetViewColor(color);
SetLowColor(color);
} }
@@ -1078,6 +1066,7 @@ BMenuField::_DrawLabel(BRect updateRect)
// save the current low color // save the current low color
const rgb_color lowColor = LowColor(); const rgb_color lowColor = LowColor();
rgb_color textColor;
MenuPrivate menuPrivate(fMenuBar); MenuPrivate menuPrivate(fMenuBar);
if (menuPrivate.State() != MENU_STATE_CLOSED) { if (menuPrivate.State() != MENU_STATE_CLOSED) {
@@ -1085,10 +1074,12 @@ BMenuField::_DrawLabel(BRect updateRect)
SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR)); SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
BRect fillRect(rect.InsetByCopy(0, kVMargin)); BRect fillRect(rect.InsetByCopy(0, kVMargin));
FillRect(fillRect, B_SOLID_LOW); 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, 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 // restore the previous low color
SetLowColor(lowColor); SetLowColor(lowColor);
+4 -4
View File
@@ -445,8 +445,8 @@ BMenuItem::DrawContent()
void void
BMenuItem::Draw() BMenuItem::Draw()
{ {
const rgb_color lowColor = fSuper->LowColor(); const color_which lowColor = fSuper->LowUIColor();
const rgb_color highColor = fSuper->HighColor(); const color_which highColor = fSuper->HighUIColor();
bool enabled = IsEnabled(); bool enabled = IsEnabled();
bool selected = IsSelected(); bool selected = IsSelected();
@@ -493,8 +493,8 @@ BMenuItem::Draw()
} }
// restore the parent menu's low color and high color // restore the parent menu's low color and high color
fSuper->SetLowColor(lowColor); fSuper->SetLowUIColor(lowColor);
fSuper->SetHighColor(highColor); fSuper->SetHighUIColor(highColor);
} }
+2 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2009, Haiku, Inc. * Copyright 2001-2015, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -79,7 +79,7 @@ BMenuScroller::BMenuScroller(BRect frame)
BView(frame, "menu scroller", 0, B_WILL_DRAW | B_FRAME_EVENTS), BView(frame, "menu scroller", 0, B_WILL_DRAW | B_FRAME_EVENTS),
fEnabled(false) fEnabled(false)
{ {
SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); SetViewUIColor(B_MENU_BACKGROUND_COLOR);
} }
+1 -1
View File
@@ -738,7 +738,7 @@ BScrollView::_Init(bool horizontal, bool vertical)
fBorders = BControlLook::B_ALL_BORDERS; fBorders = BControlLook::B_ALL_BORDERS;
if (be_control_look != NULL) if (be_control_look != NULL)
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
if (horizontal) { if (horizontal) {
fHorizontalScrollBar = new BScrollBar(BRect(0, 0, 14, 14), "_HSB_", fHorizontalScrollBar = new BScrollBar(BRect(0, 0, 14, 14), "_HSB_",
+12 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -394,7 +394,10 @@ BSlider::AttachedToWindow()
BView* view = OffscreenView(); BView* view = OffscreenView();
if (view && view->LockLooper()) { if (view && view->LockLooper()) {
view->SetViewColor(B_TRANSPARENT_COLOR); view->SetViewColor(B_TRANSPARENT_COLOR);
view->SetLowColor(LowColor()); if (LowUIColor() != B_NO_COLOR)
view->SetLowUIColor(LowUIColor());
else
view->SetLowColor(LowColor());
view->UnlockLooper(); view->UnlockLooper();
} }
@@ -411,6 +414,12 @@ void
BSlider::AllAttached() BSlider::AllAttached()
{ {
BControl::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(); BView* view = OffscreenView();
if (be_control_look != NULL) { 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); uint32 flags = be_control_look->Flags(this);
be_control_look->DrawSliderHashMarks(view, frame, frame, base, be_control_look->DrawSliderHashMarks(view, frame, frame, base,
fHashMarkCount, fHashMarks, flags, fOrientation); fHashMarkCount, fHashMarks, flags, fOrientation);
+8 -1
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* Copyright 2015, Haiku, Inc.
* All rights reserved. Distributed under the terms of the MIT License. * 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, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INVALIDATE_AFTER_LAYOUT,
fSplitLayout = new BSplitLayout(orientation, spacing)) 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 void
BSplitView::Draw(BRect updateRect) BSplitView::Draw(BRect updateRect)
{ {
+43 -23
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Marc Flerackers (mflerackers@androme.be) * Marc Flerackers (mflerackers@androme.be)
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
/*! BStatusBar displays a "percentage-of-completion" gauge. */ /*! BStatusBar displays a "percentage-of-completion" gauge. */
@@ -23,8 +24,9 @@
#include <binary_compatibility/Interface.h> #include <binary_compatibility/Interface.h>
enum internalFlags {
static const rgb_color kDefaultBarColor = {50, 150, 255, 255}; kCustomBarColor = 1
};
BStatusBar::BStatusBar(BRect frame, const char *name, const char *label, BStatusBar::BStatusBar(BRect frame, const char *name, const char *label,
@@ -69,8 +71,10 @@ BStatusBar::BStatusBar(BMessage *archive)
} }
int32 color; int32 color;
if (archive->FindInt32("_bcolor", (int32 *)&color) == B_OK) if (archive->FindInt32("_bcolor", (int32 *)&color) == B_OK) {
fBarColor = *(rgb_color *)&color; fBarColor = *(rgb_color *)&color;
fInternalFlags |= kCustomBarColor;
}
if (archive->FindFloat("_val", &floatValue) == B_OK) if (archive->FindFloat("_val", &floatValue) == B_OK)
fCurrent = floatValue; fCurrent = floatValue;
@@ -104,7 +108,7 @@ BStatusBar::Archive(BMessage *archive, bool deep) const
if (fCustomBarHeight) if (fCustomBarHeight)
err = archive->AddFloat("_high", fBarHeight); err = archive->AddFloat("_high", fBarHeight);
if (err == B_OK && fBarColor != kDefaultBarColor) if (err == B_OK && fInternalFlags & kCustomBarColor)
err = archive->AddInt32("_bcolor", (const uint32 &)fBarColor); err = archive->AddInt32("_bcolor", (const uint32 &)fBarColor);
if (err == B_OK && fCurrent != 0) if (err == B_OK && fCurrent != 0)
@@ -138,18 +142,13 @@ BStatusBar::AttachedToWindow()
ResizeTo(Bounds().Width(), height); ResizeTo(Bounds().Width(), height);
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
rgb_color lowColor = B_TRANSPARENT_COLOR;
BView* parent = Parent(); AdoptParentColors();
if (parent != NULL)
lowColor = parent->ViewColor();
if (lowColor == B_TRANSPARENT_COLOR)
lowColor = ui_color(B_PANEL_BACKGROUND_COLOR);
SetLowColor(lowColor);
fTextDivider = Bounds().Width(); fTextDivider = Bounds().Width();
if ((fInternalFlags & kCustomBarColor) == 0)
fBarColor = ui_color(B_CONTROL_MARK_COLOR);
} }
@@ -311,7 +310,8 @@ BStatusBar::Draw(BRect updateRect)
GetFont(&font); GetFont(&font);
if (rightText.Length()) { if (rightText.Length()) {
font.TruncateString(&rightText, B_TRUNCATE_BEGINNING, rect.Width()); font.TruncateString(&rightText, B_TRUNCATE_BEGINNING,
rect.Width());
fTextDivider -= StringWidth(rightText.String()); fTextDivider -= StringWidth(rightText.String());
} }
@@ -320,14 +320,22 @@ BStatusBar::Draw(BRect updateRect)
font.TruncateString(&leftText, B_TRUNCATE_END, width); 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()) if (leftText.Length())
DrawString(leftText.String(), BPoint(rect.left, baseLine)); DrawString(leftText.String(), BPoint(rect.left, baseLine));
if (rightText.Length()) if (rightText.Length())
DrawString(rightText.String(), BPoint(fTextDivider, baseLine)); DrawString(rightText.String(), BPoint(fTextDivider, baseLine));
} }
// Draw bar // Draw bar
@@ -344,22 +352,22 @@ BStatusBar::Draw(BRect updateRect)
} }
// First bevel // 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.LeftBottom(), rect.LeftTop());
StrokeLine(rect.RightTop()); 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.left + 1, rect.bottom), rect.RightBottom());
StrokeLine(BPoint(rect.right, rect.top + 1)); StrokeLine(BPoint(rect.right, rect.top + 1));
rect.InsetBy(1, 1); rect.InsetBy(1, 1);
// Second bevel // 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.LeftBottom(), rect.LeftTop());
StrokeLine(rect.RightTop()); StrokeLine(rect.RightTop());
SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetHighColor(backgroundColor);
StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom());
StrokeLine(BPoint(rect.right, rect.top + 1)); StrokeLine(BPoint(rect.right, rect.top + 1));
@@ -387,7 +395,7 @@ BStatusBar::Draw(BRect updateRect)
// empty space // empty space
rect.left = rect.right + 1; rect.left = rect.right + 1;
rect.right = barFrame.right; 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); FillRect(rect);
} }
} }
@@ -423,6 +431,17 @@ BStatusBar::MessageReceived(BMessage *message)
break; 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: default:
BView::MessageReceived(message); BView::MessageReceived(message);
break; break;
@@ -457,6 +476,7 @@ BStatusBar::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
void void
BStatusBar::SetBarColor(rgb_color color) BStatusBar::SetBarColor(rgb_color color)
{ {
fInternalFlags |= kCustomBarColor;
fBarColor = color; fBarColor = color;
Invalidate(); Invalidate();
@@ -755,8 +775,8 @@ BStatusBar::_InitObject()
fBarHeight = -1.0; fBarHeight = -1.0;
fTextDivider = Bounds().Width(); fTextDivider = Bounds().Width();
fBarColor = kDefaultBarColor;
fCustomBarHeight = false; fCustomBarHeight = false;
fInternalFlags = 0;
SetFlags(Flags() | B_FRAME_EVENTS); SetFlags(Flags() | B_FRAME_EVENTS);
} }
+11 -10
View File
@@ -128,16 +128,16 @@ BStringView::Archive(BMessage* data, bool deep) const
void void
BStringView::AttachedToWindow() BStringView::AttachedToWindow()
{ {
rgb_color color = B_TRANSPARENT_COLOR; if (HasDefaultColors()) {
AdoptParentColors();
SetHighUIColor(B_PANEL_TEXT_COLOR);
}
BView* parent = Parent(); if (ViewColor() == B_TRANSPARENT_COLOR) {
if (parent != NULL) SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
color = parent->ViewColor(); SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
SetHighUIColor(B_PANEL_TEXT_COLOR);
if (color == B_TRANSPARENT_COLOR) }
color = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(color);
} }
@@ -254,7 +254,8 @@ BStringView::Draw(BRect updateRect)
if (!fText) if (!fText)
return; return;
SetLowColor(ViewColor()); if (LowUIColor() == B_NO_COLOR)
SetLowColor(ViewColor());
font_height fontHeight; font_height fontHeight;
GetFontHeight(&fontHeight); GetFontHeight(&fontHeight);
+5 -7
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -1224,10 +1224,8 @@ BTabView::_InitObject(bool layouted, button_width width)
fTabOffset = 0.0f; fTabOffset = 0.0f;
fBorderStyle = B_FANCY_BORDER; fBorderStyle = B_FANCY_BORDER;
rgb_color color = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
SetViewColor(color);
SetLowColor(color);
font_height fh; font_height fh;
GetFontHeight(&fh); GetFontHeight(&fh);
@@ -1264,8 +1262,8 @@ BTabView::_InitContainerView(bool layouted)
_LayoutContainerView(layouted); _LayoutContainerView(layouted);
if (createdContainer) { if (createdContainer) {
fContainerView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fContainerView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
fContainerView->SetLowColor(fContainerView->ViewColor()); fContainerView->SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
AddChild(fContainerView); AddChild(fContainerView);
} }
} }
+18 -18
View File
@@ -357,7 +357,7 @@ BTextControl::Draw(BRect updateRect)
BRect rect = fText->Frame(); BRect rect = fText->Frame();
rect.InsetBy(-2, -2); rect.InsetBy(-2, -2);
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color base = ViewColor();
uint32 flags = fLook; uint32 flags = fLook;
if (!enabled) if (!enabled)
flags |= BControlLook::B_DISABLED; flags |= BControlLook::B_DISABLED;
@@ -464,6 +464,16 @@ BTextControl::LayoutInvalidated(bool descendants)
void void
BTextControl::MessageReceived(BMessage* message) 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) { if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) {
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
bool handled = false; bool handled = false;
@@ -1025,30 +1035,20 @@ BTextControl::operator=(const BTextControl&)
void void
BTextControl::_UpdateTextViewColors(bool enable) BTextControl::_UpdateTextViewColors(bool enable)
{ {
rgb_color textColor; rgb_color textColor = ui_color(B_DOCUMENT_TEXT_COLOR);
rgb_color color; rgb_color viewColor = ui_color(B_DOCUMENT_BACKGROUND_COLOR);
BFont font; BFont font;
fText->GetFontAndColor(0, &font); fText->GetFontAndColor(0, &font);
if (enable) if (!enable) {
textColor = ui_color(B_DOCUMENT_TEXT_COLOR); textColor = disable_color(textColor, ViewColor());
else { viewColor = disable_color(ViewColor(), viewColor);
textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
B_DISABLED_LABEL_TINT);
} }
fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); fText->SetFontAndColor(&font, B_FONT_ALL, &textColor);
fText->SetViewColor(viewColor);
if (enable) fText->SetLowColor(viewColor);
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);
} }
+4 -1
View File
@@ -3051,8 +3051,10 @@ BTextView::_InitObject(BRect textRect, const BFont* initialFont,
_NormalizeFont(&font); _NormalizeFont(&font);
rgb_color documentTextColor = ui_color(B_DOCUMENT_TEXT_COLOR);
if (initialColor == NULL) if (initialColor == NULL)
initialColor = &kBlackColor; initialColor = &documentTextColor;
fText = new BPrivate::TextGapBuffer; fText = new BPrivate::TextGapBuffer;
fLines = new LineBuffer; fLines = new LineBuffer;
@@ -3113,6 +3115,7 @@ BTextView::_InitObject(BRect textRect, const BFont* initialFont,
fLastClickOffset = -1; fLastClickOffset = -1;
SetDoesUndo(true); SetDoesUndo(true);
SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR);
} }
+1 -1
View File
@@ -219,7 +219,7 @@ BTextToolTip::_InitData(const char* text)
fTextView = new BTextView("tool tip text"); fTextView = new BTextView("tool tip text");
fTextView->SetText(text); fTextView->SetText(text);
fTextView->MakeEditable(false); 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); rgb_color color = ui_color(B_TOOL_TIP_TEXT_COLOR);
fTextView->SetFontAndColor(NULL, 0, &color); fTextView->SetFontAndColor(NULL, 0, &color);
fTextView->SetWordWrap(false); fTextView->SetWordWrap(false);
+1 -1
View File
@@ -66,7 +66,7 @@ ToolTipView::ToolTipView(BToolTip* tip)
fHidden(false) fHidden(false)
{ {
fToolTip->AcquireReference(); fToolTip->AcquireReference();
SetViewColor(ui_color(B_TOOL_TIP_BACKGROUND_COLOR)); SetViewUIColor(B_TOOL_TIP_BACKGROUND_COLOR);
BGroupLayout* layout = new BGroupLayout(B_VERTICAL); BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
layout->SetInsets(5, 5, 5, 5); layout->SetInsets(5, 5, 5, 5);