[haiku-commits] BRANCH looncraz-github.setviewuicolor [8c0d56c205c7] in src: apps/haikudepot/ui servers/app kits/interface apps/haikudepot/ui_generic kits/shared

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 1 Oct 2015 18:02:06 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: 24bb725ec18ff738a6c5e61e7cbabb742ee33d21
new head: 8c0d56c205c7e1abb691a3bc3e2586f80919677e
overview: https://github.com/looncraz/haiku/compare/24bb725ec18f...8c0d56c205c7

----------------------------------------------------------------------------

8c0d56c205c7: Numerous Little Things

HaikuDepot
Started, but have not completed, adaptation. Its reliance on a stateful
text formatting system is making the going a little slower than I'd
prefer, but I'm almost there :p
* On another note, not sure if I should use document colors or list
colors - for now, I'm using list (default colors are the same for both).

BView
Improved handling with layout-enabled views, now take which color
changed into account.

BButton
Some modification to make integrating smoother with applications
which desire to affect its appearance (such as BToolBar).

BMenuBar
Use SetLowUIColor - per Axel - to permit application override and
reduce some incidental overhead per draw.

BToolBar
Adjust to ensure buttons match without any other effort.

Appearance
Stop spamming set_ui_color() on Revert()

app_server
Improve merging logic, prevent message invalidation, retry failed
messages, enforce a default sending timeout, repair DelayedInvalidate
in the chance that the current view changed or was removed since the
call, repaired a glitch where Decorator colors would become corrupted
when setting the decorator twice, and probably something else I failed
to note.

Almost everything works exactly as expected now, just a few apps that
aren't as proper as they should be.

[ looncraz <looncraz@xxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit: 8c0d56c205c7e1abb691a3bc3e2586f80919677e
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Thu Oct 1 15:40:48 2015 UTC

----------------------------------------------------------------------------

28 files changed, 251 insertions(+), 171 deletions(-)
headers/os/interface/View.h | 3 +-
.../haikudepot/textview/CharacterStyleData.cpp | 8 +-
src/apps/haikudepot/textview/ParagraphLayout.cpp | 2 +-
.../haikudepot/textview/TextDocumentView.cpp | 4 +-
src/apps/haikudepot/textview/TextView.cpp | 7 +-
src/apps/haikudepot/ui/FeaturedPackagesView.cpp | 29 ++++---
src/apps/haikudepot/ui/PackageInfoView.cpp | 54 ++++++-------
src/apps/haikudepot/ui/PackageListView.cpp | 7 +-
src/apps/haikudepot/ui_generic/BitmapView.cpp | 12 +--
src/apps/haikudepot/ui_generic/LinkView.cpp | 11 +--
src/apps/haikudepot/ui_generic/LinkView.h | 4 +-
src/apps/haikudepot/ui_generic/RatingView.cpp | 8 +-
src/kits/interface/Button.cpp | 11 ++-
src/kits/interface/MenuBar.cpp | 4 +-
src/kits/interface/MenuItem.cpp | 8 +-
src/kits/interface/View.cpp | 59 +++++++--------
src/kits/interface/Window.cpp | 5 +-
src/kits/shared/ToolBar.cpp | 45 +++++++++--
src/preferences/appearance/APRView.cpp | 4 +-
src/servers/app/DelayedMessage.cpp | 4 +-
src/servers/app/DelayedMessageLooper.cpp | 80 ++++++++++++++------
src/servers/app/DelayedMessageLooper.h | 3 +
src/servers/app/DelayedMessageThread.cpp | 10 +--
src/servers/app/ServerWindow.cpp | 14 +++-
src/servers/app/View.cpp | 15 ++++
src/servers/app/View.h | 2 +
src/servers/app/decorator/Decorator.cpp | 7 +-
src/servers/app/stackandtile/SATDecorator.cpp | 2 +-

----------------------------------------------------------------------------

diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h
index c1381e1..f03a273 100644
--- a/headers/os/interface/View.h
+++ b/headers/os/interface/View.h
@@ -690,7 +690,8 @@ private:

void _Activate(bool state);
void _Attach();
- void
_ColorsUpdated(BMessage*);
+ void
_ColorsUpdated(BMessage* message,
+
color_which which);
void _Detach();
void _Draw(BRect
screenUpdateRect);
void
_DrawAfterChildren(BRect screenUpdateRect);
diff --git a/src/apps/haikudepot/textview/CharacterStyleData.cpp
b/src/apps/haikudepot/textview/CharacterStyleData.cpp
index 1103205..48cbe3a 100644
--- a/src/apps/haikudepot/textview/CharacterStyleData.cpp
+++ b/src/apps/haikudepot/textview/CharacterStyleData.cpp
@@ -18,10 +18,10 @@ CharacterStyleData::CharacterStyleData()

fGlyphSpacing(0.0f),

- fFgColor((rgb_color){ 0, 0, 0, 255 }),
- fBgColor((rgb_color){ 255, 255, 255, 255 }),
- fStrikeOutColor((rgb_color){ 0, 0, 0, 255 }),
- fUnderlineColor((rgb_color){ 0, 0, 0, 255 }),
+ fFgColor(ui_color(B_PANEL_TEXT_COLOR)),
+ fBgColor(ui_color(B_PANEL_BACKGROUND_COLOR)),
+ fStrikeOutColor(fFgColor),
+ fUnderlineColor(fFgColor),

fStrikeOutStyle(STRIKE_OUT_NONE),
fUnderlineStyle(UNDERLINE_NONE)
diff --git a/src/apps/haikudepot/textview/ParagraphLayout.cpp
b/src/apps/haikudepot/textview/ParagraphLayout.cpp
index 864bd16..6714152 100644
--- a/src/apps/haikudepot/textview/ParagraphLayout.cpp
+++ b/src/apps/haikudepot/textview/ParagraphLayout.cpp
@@ -261,7 +261,7 @@ ParagraphLayout::Draw(BView* view, const BPoint& offset)
const Bullet& bullet = fParagraphStyle.Bullet();
if (bullet.Spacing() > 0.0f && bullet.String().Length() > 0) {
// Draw bullet at offset
- view->SetHighColor(0, 0, 0, 255);
+ view->SetHighUIColor(B_PANEL_TEXT_COLOR);
BPoint bulletPos(offset);
bulletPos.x += fParagraphStyle.FirstLineInset()
+ fParagraphStyle.LineInset();
diff --git a/src/apps/haikudepot/textview/TextDocumentView.cpp
b/src/apps/haikudepot/textview/TextDocumentView.cpp
index 1584d24..2cddc3e 100644
--- a/src/apps/haikudepot/textview/TextDocumentView.cpp
+++ b/src/apps/haikudepot/textview/TextDocumentView.cpp
@@ -41,8 +41,8 @@ TextDocumentView::TextDocumentView(const char* name)
// Set default TextEditor
SetTextEditor(TextEditorRef(new(std::nothrow) TextEditor(), true));

- SetViewColor(B_TRANSPARENT_COLOR);
- SetLowColor(255, 255, 255, 255);
+ SetViewUIColor(B_LIST_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
}


diff --git a/src/apps/haikudepot/textview/TextView.cpp
b/src/apps/haikudepot/textview/TextView.cpp
index ee806cc..e4eb46c 100644
--- a/src/apps/haikudepot/textview/TextView.cpp
+++ b/src/apps/haikudepot/textview/TextView.cpp
@@ -10,9 +10,6 @@ TextView::TextView(const char* name)
:
BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
{
- SetViewColor(B_TRANSPARENT_COLOR);
- SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-
BFont font;
GetFont(&font);

@@ -41,9 +38,7 @@ TextView::Draw(BRect updateRect)
void
TextView::AttachedToWindow()
{
- BView* parent = Parent();
- if (parent != NULL)
- SetLowColor(parent->ViewColor());
+ AdoptParentColors();
}


diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
index fc3e33e..e07d80b 100644
--- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
+++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
@@ -44,7 +44,9 @@ public:
new(std::nothrow)
OnePackageMessagePackageListener(this)),
fSelected(false)
{
- SetViewColor(255, 255, 255);
+ SetViewUIColor(B_LIST_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
+ SetHighUIColor(B_LIST_ITEM_TEXT_COLOR);
SetEventMask(B_POINTER_EVENTS);

fIconView = new BitmapView("package icon view");
@@ -67,7 +69,7 @@ public:
font.SetSize(std::max(9.0f, floorf(font.Size() * 0.92f)));
font.SetFamilyAndStyle(family, "Italic");
fPublisherView->SetFont(&font);
- fPublisherView->SetHighColor(kLightBlack);
+ fPublisherView->SetHighUIColor(B_PANEL_TEXT_COLOR);

// Summary text view
fSummaryView = new MarkupTextView("package summary");
@@ -78,14 +80,14 @@ public:

fAvgRating = new BStringView("package average rating", "");
fAvgRating->SetFont(&font);
- fAvgRating->SetHighColor(kLightBlack);
+ fAvgRating->SetHighUIColor(B_PANEL_TEXT_COLOR);

fVoteInfo = new BStringView("package vote info", "");
// small font
GetFont(&font);
font.SetSize(std::max(9.0f, floorf(font.Size() * 0.85f)));
fVoteInfo->SetFont(&font);
- fVoteInfo->SetHighColor(kLightBlack);
+ fVoteInfo->SetHighUIColor(B_PANEL_TEXT_COLOR, B_LIGHTEN_1_TINT);

BLayoutBuilder::Group<>(this)
.Add(fIconView)
@@ -227,11 +229,13 @@ public:
return;
fSelected = selected;

- rgb_color bgColor;
- if (fSelected)
- bgColor = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
- else
- bgColor = (rgb_color){ 255, 255, 255, 255 };
+ color_which bgColor = B_LIST_BACKGROUND_COLOR;
+ color_which textColor = B_LIST_ITEM_TEXT_COLOR;
+
+ if (fSelected) {
+ bgColor = B_LIST_SELECTED_BACKGROUND_COLOR;
+ textColor = B_LIST_SELECTED_ITEM_TEXT_COLOR;
+ }

List<BView*, true> views;

@@ -248,8 +252,9 @@ public:
for (int32 i = 0; i < views.CountItems(); i++) {
BView* view = views.ItemAtFast(i);

- view->SetViewColor(bgColor);
- view->SetLowColor(bgColor);
+ view->SetViewUIColor(bgColor);
+ view->SetLowUIColor(bgColor);
+ view->SetHighUIColor(textColor);
view->Invalidate();
}
}
@@ -286,7 +291,7 @@ FeaturedPackagesView::FeaturedPackagesView()
SetLayout(layout);

ScrollableGroupView* containerView = new ScrollableGroupView();
- containerView->SetViewColor(255, 255, 255);
+ containerView->SetViewUIColor(B_LIST_BACKGROUND_COLOR);
fPackageListLayout = containerView->GroupLayout();

BScrollView* scrollView = new BScrollView(
diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 03178c5..57f225f 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -127,9 +127,10 @@ public:
BView("diagram bar view", B_WILL_DRAW),
fValue(0.0f)
{
- SetViewColor(B_TRANSPARENT_COLOR);
- SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
- SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
+ SetHighUIColor(LowUIColor(), B_DARKEN_2_TINT);
+ // TODO: smart tinting...
}

virtual ~DiagramBarView()
@@ -138,11 +139,8 @@ public:

virtual void AttachedToWindow()
{
- BView* parent = Parent();
- if (parent != NULL) {
- SetLowColor(parent->ViewColor());
- SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
- }
+ AdoptParentColors();
+ SetHighUIColor(LowUIColor(), B_DARKEN_2_TINT);
}

virtual void Draw(BRect updateRect)
@@ -325,7 +323,7 @@ public:
fRatingLayout = new BCardLayout();
ratingStack->SetLayout(fRatingLayout);
ratingStack->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
B_SIZE_UNSET));
- ratingStack->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ ratingStack->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

BGroupView* ratingGroup = new BGroupView(B_HORIZONTAL,
B_USE_SMALL_SPACING);
@@ -471,7 +469,7 @@ public:
fStatusLabel(NULL),
fStatusBar(NULL)
{
- SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

SetLayout(fLayout);
fLayout->AddItem(BSpaceLayoutItem::CreateGlue());
@@ -684,11 +682,11 @@ public:
fEmailIcon("text/x-email"),
fWebsiteIcon("text/html")
{
- SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
- kContentTint));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint);
+ // TODO: smart tint

fDescriptionView = new MarkupTextView("description view");
- fDescriptionView->SetLowColor(ViewColor());
+ fDescriptionView->SetLowUIColor(ViewUIColor());
fDescriptionView->SetInsets(be_plain_font->Size());

BScrollView* scrollView = new CustomScrollView(
@@ -714,17 +712,17 @@ public:

fEmailIconView = new BitmapView("email icon view");
fEmailLinkView = new LinkView("email link view", "",
- new BMessage(MSG_EMAIL_PUBLISHER), kLightBlack);
+ new BMessage(MSG_EMAIL_PUBLISHER));
fEmailLinkView->SetFont(&smallFont);

fWebsiteIconView = new BitmapView("website icon view");
fWebsiteLinkView = new LinkView("website link view", "",
- new BMessage(MSG_VISIT_PUBLISHER_WEBSITE), kLightBlack);
+ new BMessage(MSG_VISIT_PUBLISHER_WEBSITE));
fWebsiteLinkView->SetFont(&smallFont);

BGroupView* leftGroup = new BGroupView(B_VERTICAL,
B_USE_DEFAULT_SPACING);
- leftGroup->SetViewColor(ViewColor());
+ leftGroup->SetViewUIColor(ViewUIColor());

BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0.0f)
// .Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
@@ -867,8 +865,8 @@ public:
:
BGroupView(B_HORIZONTAL, 0.0f)
{
- SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
- kContentTint));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint);
+ // todo: smart tint

fAvatarView = new BitmapView("avatar view");
if (rating.User().Avatar().Get() != NULL) {
@@ -928,7 +926,7 @@ public:
// fDownVoteCountView->SetText(voteCountLabel);

fTextView = new TextView("rating text");
- fTextView->SetViewColor(ViewColor());
+ fTextView->SetViewUIColor(ViewUIColor());
ParagraphStyle paragraphStyle(fTextView->ParagraphStyle());
paragraphStyle.SetJustify(true);
fTextView->SetParagraphStyle(paragraphStyle);
@@ -981,8 +979,7 @@ public:
:
BGridView("rating summary view", B_USE_HALF_ITEM_SPACING, 0.0f)
{
- SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
- kContentTint - 0.1));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint - 0.1);

BLayoutBuilder::Grid<> layoutBuilder(this);

@@ -1049,14 +1046,13 @@ public:
fThumbsUpIcon(BitmapRef(new SharedBitmap(502), true)),
fThumbsDownIcon(BitmapRef(new SharedBitmap(503), true))
{
- SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
- kContentTint));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint);

fRatingSummaryView = new RatingSummaryView();

ScrollableGroupView* ratingsContainerView = new
ScrollableGroupView();
- ratingsContainerView->SetViewColor(
- tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
kContentTint));
+ ratingsContainerView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR,
+
kContentTint);
fRatingContainerLayout = ratingsContainerView->GroupLayout();

BScrollView* scrollView = new RatingsScrollView(
@@ -1178,8 +1174,7 @@ public:
:
BGroupView("package contents view", B_HORIZONTAL)
{
- SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
- kContentTint));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint);

fPackageContents = new PackageContentsView("contents_list");
AddChild(fPackageContents);
@@ -1218,11 +1213,10 @@ public:
:
BGroupView("package changelog view", B_HORIZONTAL)
{
- SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
- kContentTint));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint);

fTextView = new MarkupTextView("changelog view");
- fTextView->SetLowColor(ViewColor());
+ fTextView->SetLowUIColor(ViewUIColor());
fTextView->SetInsets(be_plain_font->Size());

BScrollView* scrollView = new CustomScrollView(
diff --git a/src/apps/haikudepot/ui/PackageListView.cpp
b/src/apps/haikudepot/ui/PackageListView.cpp
index 3ef7c39..4972d56 100644
--- a/src/apps/haikudepot/ui/PackageListView.cpp
+++ b/src/apps/haikudepot/ui/PackageListView.cpp
@@ -632,10 +632,9 @@ public:
font.SetSize(9.0f);
SetFont(&font);

- SetViewColor(B_TRANSPARENT_COLOR);
- SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-
- SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
+ SetHighUIColor(LowUIColor(), B_DARKEN_4_TINT);
}

virtual BSize MinSize()
diff --git a/src/apps/haikudepot/ui_generic/BitmapView.cpp
b/src/apps/haikudepot/ui_generic/BitmapView.cpp
index 0bb8597..7ef6fe9 100644
--- a/src/apps/haikudepot/ui_generic/BitmapView.cpp
+++ b/src/apps/haikudepot/ui_generic/BitmapView.cpp
@@ -18,8 +18,8 @@ BitmapView::BitmapView(const char* name)
fBitmap(NULL),
fScaleBitmap(true)
{
- SetViewColor(B_TRANSPARENT_COLOR);
- SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
}


@@ -31,13 +31,7 @@ BitmapView::~BitmapView()
void
BitmapView::AttachedToWindow()
{
- BView* parent = Parent();
- if (parent != NULL) {
- rgb_color color = parent->ViewColor();
- if (color == B_TRANSPARENT_COLOR)
- color = parent->LowColor();
- SetLowColor(color);
- }
+ AdoptParentColors();
}


diff --git a/src/apps/haikudepot/ui_generic/LinkView.cpp
b/src/apps/haikudepot/ui_generic/LinkView.cpp
index 5d337fc..ab6e5e4 100644
--- a/src/apps/haikudepot/ui_generic/LinkView.cpp
+++ b/src/apps/haikudepot/ui_generic/LinkView.cpp
@@ -10,13 +10,10 @@
#include <String.h>


-LinkView::LinkView(const char* name, const char* string, BMessage* message,
- rgb_color color)
+LinkView::LinkView(const char* name, const char* string, BMessage* message)
:
BStringView(name, string),
BInvoker(message, NULL),
- fNormalColor(color),
- fHoverColor(make_color(1, 141, 211)),
fEnabled(true),
fMouseInside(false)
{
@@ -55,7 +52,7 @@ LinkView::Draw(BRect updateRect)
if (Text() == NULL)
return;

- SetLowColor(ViewColor());
+ SetLowUIColor(ViewUIColor());

font_height fontHeight;
GetFontHeight(&fontHeight);
@@ -86,12 +83,12 @@ void
LinkView::_UpdateLinkColor()
{
if (fEnabled && fMouseInside) {
- SetHighColor(fHoverColor);
+ SetHighUIColor(B_LINK_HOVER_COLOR);
BCursor cursor(B_CURSOR_ID_FOLLOW_LINK);
SetViewCursor(&cursor, true);
Invalidate();
} else {
- SetHighColor(fNormalColor);
+ SetHighUIColor(B_LINK_TEXT_COLOR);
BCursor cursor(B_CURSOR_SYSTEM_DEFAULT);
SetViewCursor(&cursor, true);
Invalidate();
diff --git a/src/apps/haikudepot/ui_generic/LinkView.h
b/src/apps/haikudepot/ui_generic/LinkView.h
index 059b954..4f5a30e 100644
--- a/src/apps/haikudepot/ui_generic/LinkView.h
+++ b/src/apps/haikudepot/ui_generic/LinkView.h
@@ -13,7 +13,7 @@
class LinkView : public BStringView, public BInvoker {
public:
LinkView(const
char* name, const char* string,
-
BMessage* message, rgb_color color);
+
BMessage* message);

virtual void MouseMoved(BPoint where, uint32
transit,
const
BMessage* dragMessage);
@@ -27,8 +27,6 @@ private:
void _UpdateLinkColor();

private:
- rgb_color fNormalColor;
- rgb_color fHoverColor;

bool fEnabled;
bool fMouseInside;
diff --git a/src/apps/haikudepot/ui_generic/RatingView.cpp
b/src/apps/haikudepot/ui_generic/RatingView.cpp
index aab3174..bd73310 100644
--- a/src/apps/haikudepot/ui_generic/RatingView.cpp
+++ b/src/apps/haikudepot/ui_generic/RatingView.cpp
@@ -17,8 +17,8 @@ RatingView::RatingView(const char* name)
fStarBitmap(501),
fRating(-1.0f)
{
- SetViewColor(B_TRANSPARENT_COLOR);
- SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
}


@@ -30,9 +30,7 @@ RatingView::~RatingView()
void
RatingView::AttachedToWindow()
{
- BView* parent = Parent();
- if (parent != NULL)
- SetLowColor(parent->ViewColor());
+ AdoptParentColors();
}


diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp
index eea5722..b2238fa 100644
--- a/src/kits/interface/Button.cpp
+++ b/src/kits/interface/Button.cpp
@@ -132,10 +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 = tint_color(ui_color(B_CONTROL_BACKGROUND_COLOR),
-
B_DARKEN_1_TINT);
+ rgb_color base = tint_color(ViewColor(), buttonTint);
uint32 flags = be_control_look->Flags(this);
if (_Flag(FLAG_DEFAULT))
flags |= BControlLook::B_DEFAULT_BUTTON;
@@ -228,6 +232,7 @@ void
BButton::AttachedToWindow()
{
BControl::AttachedToWindow();
+ 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.
@@ -242,8 +247,6 @@ BButton::AttachedToWindow()

if (IsDefault())
Window()->SetDefaultButton(this);
-
- SetViewColor(B_TRANSPARENT_COLOR);
}


diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp
index 80ce77c..79005e5 100644
--- a/src/kits/interface/MenuBar.cpp
+++ b/src/kits/interface/MenuBar.cpp
@@ -280,7 +280,7 @@ BMenuBar::Draw(BRect updateRect)
}

BRect rect(Bounds());
- rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
+ rgb_color base = LowColor();
uint32 flags = 0;

be_control_look->DrawBorder(this, rect, updateRect, base,
@@ -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/MenuItem.cpp b/src/kits/interface/MenuItem.cpp
index d51280c5..e4bf883 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/View.cpp b/src/kits/interface/View.cpp
index bc75436..29a1d6c 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -74,7 +74,6 @@ using std::nothrow;
# define BVTRACE ;
#endif

-const color_which kAllColors = (color_which)~0L;

static property_info sViewPropInfo[] = {
{ "Frame", { B_GET_PROPERTY, B_SET_PROPERTY },
@@ -2329,11 +2328,9 @@ BView::SetHighColor(rgb_color color)
void
BView::SetHighUIColor(color_which which, float tint)
{
- if (which == B_NO_COLOR) {
+ if (which == B_NO_COLOR)
SetHighColor(0, 0, 0, 255); // default high color
- fState->valid_flags &= ~B_VIEW_WHICH_HIGH_COLOR_BIT;
- fState->archiving_flags &= ~B_VIEW_WHICH_HIGH_COLOR_BIT;
- } else {
+ else {
SetHighColor(tint_color(ui_color(which), tint));
fState->valid_flags |= B_VIEW_WHICH_HIGH_COLOR_BIT;
fState->archiving_flags |= B_VIEW_WHICH_HIGH_COLOR_BIT;
@@ -2405,11 +2402,9 @@ BView::SetLowColor(rgb_color color)
void
BView::SetLowUIColor(color_which which, float tint)
{
- if (which == B_NO_COLOR) {
+ if (which == B_NO_COLOR)
SetLowColor(ViewColor()); // default low color
- fState->valid_flags &= ~B_VIEW_WHICH_LOW_COLOR_BIT;
- fState->archiving_flags &= ~B_VIEW_WHICH_LOW_COLOR_BIT;
- } else {
+ else {
SetLowColor(tint_color(ui_color(which), tint));
fState->valid_flags |= B_VIEW_WHICH_LOW_COLOR_BIT;
fState->archiving_flags |= B_VIEW_WHICH_LOW_COLOR_BIT;
@@ -4286,10 +4281,6 @@ BView::_AddChild(BView* child, BView* before)

child->_SetOwner(fOwner);
child->_CreateSelf();
-
- if (fLayoutData->fLayout != NULL)
- child->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
-
child->_Attach();

if (lockedOwner)
@@ -5383,6 +5374,12 @@ BView::_InitData(BRect frame, const char* name, uint32
resizingMode,
fLayoutData = new LayoutData;

fToolTip = NULL;
+
+ if (flags & B_SUPPORTS_LAYOUT) {
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+ SetLowUIColor(ViewUIColor());
+ SetHighUIColor(B_PANEL_TEXT_COLOR);
+ }
}


@@ -5711,7 +5708,7 @@ BView::_Attach()

if (fOwner != NULL
&& !fOwner->IsOffscreenWindow())
- _UpdateUIColor(kAllColors);
+ _UpdateUIColor(B_NO_COLOR);

fAttached = true;

@@ -5742,20 +5739,20 @@ BView::_Attach()


void
-BView::_ColorsUpdated(BMessage* message)
+BView::_ColorsUpdated(BMessage* message, color_which which)
{
// Force color update when we have a layout
if (fTopLevelView && fLayoutData->fLayout != NULL) {
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
Invalidate();
} else
- _UpdateUIColor(B_NO_COLOR);
+ _UpdateUIColor(which);

MessageReceived(message);

for (BView* child = fFirstChild; child != NULL;
child = child->fNextSibling) {
- child->_ColorsUpdated(message);
+ child->_ColorsUpdated(message, which);
}
}

@@ -5763,31 +5760,33 @@ BView::_ColorsUpdated(BMessage* message)
void
BView::_UpdateUIColor(color_which which)
{
- //TODO: check message if the 'which' is the same as in the state
- // Don't do this until we actually have that information from
- // the app_server!!
+ bool checkView = fState->which_view_color == which;
+ bool checkLow = fState->which_low_color == which;
+ bool checkHigh = fState->which_high_color == which;

- // The check should be:
- // fState->which_*_color == which
- // || (which == kAllColors
- // && fState->which_*_color != B_NO_COLOR)
+ // Forced refresh (on [re]attachment)
+ // checks only those which aren't B_NO_COLOR
+ if (which == B_NO_COLOR) {
+ checkView = !checkView;
+ checkLow = !checkLow;
+ checkHigh = !checkHigh;
+ }

- if (fState->which_view_color != B_NO_COLOR)
+ if (checkView)
SetViewUIColor(fState->which_view_color,
fState->which_view_color_tint);

- if (fState->which_low_color != B_NO_COLOR)
+ if (checkLow)
SetLowUIColor(fState->which_low_color,
fState->which_low_color_tint);

- if (fState->which_high_color != B_NO_COLOR)
+ if (checkHigh)
SetHighUIColor(fState->which_high_color,
fState->which_high_color_tint);

+ // Force a redraw no matter what, since our window is
+ // locked, we do it without a delay.
Invalidate();
- // We always redraw the view, as most system interface views
and most
- // user views will need to refresh manually, so the unwanted
overhead
- // of redrawing 5% of views without cause is negligible.
}


diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp
index d9e45aa..ef00166 100644
--- a/src/kits/interface/Window.cpp
+++ b/src/kits/interface/Window.cpp
@@ -1441,7 +1441,9 @@ FrameMoved(origin);

case B_COLORS_UPDATED:
{
- fTopView->_ColorsUpdated(message);
+ color_which which = B_NO_COLOR;
+ message->FindInt32("which", (int32*)&which);
+ fTopView->_ColorsUpdated(message, which);
target->MessageReceived(message);
break;
}
@@ -1449,6 +1451,7 @@ FrameMoved(origin);
case B_FONTS_UPDATED:
{
fTopView->_FontsUpdated(message);
+ target->MessageReceived(message);
break;
}

diff --git a/src/kits/shared/ToolBar.cpp b/src/kits/shared/ToolBar.cpp
index e29fe50..7d01485 100644
--- a/src/kits/shared/ToolBar.cpp
+++ b/src/kits/shared/ToolBar.cpp
@@ -14,7 +14,38 @@
namespace BPrivate {


-class LockableButton: public BButton {
+
+// Button to adopt backgrond color of toolbar
+class ToolBarButton : public BButton {
+public:
+ ToolBarButton(const char* name, const char* label,
+ BMessage* message);
+
+ void AttachedToWindow();
+};
+
+
+ToolBarButton::ToolBarButton(const char* name, const char* label,
+ BMessage* message)
+ :
+ BButton(name, label, message)
+ {}
+
+
+void
+ToolBarButton::AttachedToWindow()
+{
+ BButton::AttachedToWindow();
+ SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+ // have to remove the darkening caused by BButton's drawing
+}
+
+
+//# pragma mark -
+
+
+class LockableButton: public ToolBarButton {
public:
LockableButton(const char* name, const char* label,
BMessage* message);
@@ -26,7 +57,7 @@ public:
LockableButton::LockableButton(const char* name, const char* label,
BMessage* message)
:
- BButton(name, label, message)
+ ToolBarButton(name, label, message)
{
}

@@ -40,10 +71,13 @@ LockableButton::MouseDown(BPoint point)
SetBehavior(B_BUTTON_BEHAVIOR);

Message()->SetInt32("behavior", Behavior());
- BButton::MouseDown(point);
+ ToolBarButton::MouseDown(point);
}


+//#pragma mark -
+
+
BToolBar::BToolBar(BRect frame, orientation ont)
:
BGroupView(ont),
@@ -94,11 +128,11 @@ BToolBar::AddAction(BMessage* message, BHandler* target,
const BBitmap* icon, const char* toolTipText, const char* text,
bool lockable)
{
- BButton* button;
+ ToolBarButton* button;
if (lockable)
button = new LockableButton(NULL, NULL, message);
else
- button = new BButton(NULL, NULL, message);
+ button = new ToolBarButton(NULL, NULL, message);
button->SetIcon(icon);
button->SetFlat(true);
if (toolTipText != NULL)
@@ -186,7 +220,6 @@ BToolBar::FindButton(uint32 command) const

// #pragma mark - Private methods

-
void
BToolBar::Pulse()
{
diff --git a/src/preferences/appearance/APRView.cpp
b/src/preferences/appearance/APRView.cpp
index 3c3390c..88be37f 100644
--- a/src/preferences/appearance/APRView.cpp
+++ b/src/preferences/appearance/APRView.cpp
@@ -276,7 +276,9 @@ APRView::_UpdateAllColors()
for (int32 i = color_description_count() - 1; i >= 0; i--) {
color_which which = get_color_description(i)->which;
rgb_color color = fCurrentSet.GetColor(which);
- set_ui_color(which, color);
+ if (color != ui_color(which))
+ set_ui_color(which, color);
+

static_cast<ColorWhichItem*>(fAttrList->ItemAt(i))->SetColor(color);
fAttrList->InvalidateItem(i);
}
diff --git a/src/servers/app/DelayedMessage.cpp
b/src/servers/app/DelayedMessage.cpp
index 84be77b..3978b5b 100644
--- a/src/servers/app/DelayedMessage.cpp
+++ b/src/servers/app/DelayedMessage.cpp
@@ -13,7 +13,9 @@ DelayedMessage::DelayedMessage(int32 code, bigtime_t delay,
uint32 mergeMode)
:
fData(new DMMessageData(code, delay, mergeMode)),
fHandedOff(false)
- {}
+ {
+ SetTimeout(delay);
+ }


DelayedMessage::~DelayedMessage()
diff --git a/src/servers/app/DelayedMessageLooper.cpp
b/src/servers/app/DelayedMessageLooper.cpp
index 2ac0d00..bbf6b37 100644
--- a/src/servers/app/DelayedMessageLooper.cpp
+++ b/src/servers/app/DelayedMessageLooper.cpp
@@ -65,6 +65,7 @@ bool
DMMessageData::MergeData(DMMessageData* other)
{
if (!fValid
+ || other == NULL
|| other->fCode != fCode
|| fMergeMode == DM_NO_MERGE
|| other->fMergeMode == DM_NO_MERGE
@@ -72,33 +73,40 @@ DMMessageData::MergeData(DMMessageData* other)
|| other->fAttachments.CountItems() !=
fAttachments.CountItems())
return false;

- if (other->fMergeMode != DM_MERGE_CANCEL)
+ if (other->fMergeMode == DM_MERGE_CANCEL)
return true; // cancels message

- // Import the new data!
- // To do this, we need to delete our existing data
- // and copy in the new data from other
-
Attachment* attached = NULL;
Attachment* otherAttached = NULL;
- for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
- attached = fAttachments.ItemAt(index);
- otherAttached = other->fAttachments.ItemAt(index);

- if (attached == NULL
- || attached->size != otherAttached->size) {
- fValid = index == 0; // we can salvage the existing
message!
- return false;
- }
+ // Validate data integrity to merge duplicates
+ if (fMergeMode == DM_MERGE_DUPLICATES) {
+ for (int32 index = 0; index < fAttachments.CountItems();
++index) {
+ attached = fAttachments.ItemAt(index);
+ otherAttached = other->fAttachments.ItemAt(index);
+
+ if (attached == NULL
+ || otherAttached == NULL
+ || attached->data == NULL
+ || otherAttached->constData == NULL
+ || attached->size != otherAttached->size)
+ return false;

- if (fMergeMode == DM_MERGE_DUPLICATES) {
- // Compare the memory, if it's the same, we are good,
if not, return false
if (memcmp(attached->data, otherAttached->constData,
attached->size) != 0)
return false;
-
- continue;
}

+ return true;
+ }
+
+ if (fMergeMode != DM_MERGE_REPLACE)
+ return false;
+
+ // Import the new data!
+ for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
+ attached = fAttachments.ItemAt(index);
+ otherAttached = other->fAttachments.ItemAt(index);
+
// We already have allocated our memory, but the other data
// has not. So this reduces memory allocations.
memcpy(attached->data, otherAttached->constData,
attached->size);
@@ -152,7 +160,8 @@ DMMessageData::Attachment::~Attachment()

DMScheduledMessage::DMScheduledMessage(DelayedMessage& message)
:
- fData(message.HandOff())
+ fData(message.HandOff()),
+ fFailureCount(0)
{ }


@@ -176,15 +185,21 @@ status_t
DMScheduledMessage::SendMessage(port_id port)
{
if (fData == NULL
- || !fData->IsValid())
+ || !fData->IsValid()) {
+ fFailureCount += 100;
return B_BAD_DATA;
+ }

- if(port == B_BAD_PORT_ID)
+ if(port == B_BAD_PORT_ID) {
+ fFailureCount += 100;
return B_BAD_VALUE;
+ }

BPrivate::LinkSender sender(port);
- if (sender.StartMessage(fData->fCode) != B_OK)
+ if (sender.StartMessage(fData->fCode) != B_OK) {
+ fFailureCount += 100;
return B_ERROR;
+ }

BObjectList<DMMessageData::Attachment>& list = fData->fAttachments;
DMMessageData::Attachment* attached = NULL;
@@ -201,7 +216,11 @@ DMScheduledMessage::SendMessage(port_id port)
}
}

- return sender.Flush(fData->fSendTimeout);
+ error = sender.Flush(fData->fSendTimeout);
+ if (error != B_OK)
+ ++fFailureCount;
+
+ return error;
}


@@ -222,6 +241,13 @@ DMScheduledMessage::Merge(DelayedMessage& other)
}


+uint32
+DMScheduledMessage::FailureCount() const
+{
+ return fFailureCount;
+}
+
+
//#pragma mark DelayedMessageLooper


@@ -333,10 +359,14 @@ DelayedMessageLooper::SendDelayedMessages(bigtime_t*
nextDue)
break; // no need to continue, this is a sorted list
}

- if (message->SendMessage(MessagePort()) == B_OK)
+ if (message->SendMessage(MessagePort()) == B_OK) {
++sent;
-
- remove.AddItem(message);
+ remove.AddItem(message);
+ } else {
+ // allow retrying failed messages - once
+ if (message->FailureCount() > 1)
+ remove.AddItem(message);
+ }
}

// remove any entires in 'remove'
diff --git a/src/servers/app/DelayedMessageLooper.h
b/src/servers/app/DelayedMessageLooper.h
index 446da2c..cf6d59c 100644
--- a/src/servers/app/DelayedMessageLooper.h
+++ b/src/servers/app/DelayedMessageLooper.h
@@ -81,7 +81,10 @@ private:

bool Merge(DelayedMessage& message);

+ uint32 FailureCount() const;
+
DMMessageData* fData;
+ uint32 fFailureCount;

public:
bool operator < (const DMScheduledMessage& other) const
diff --git a/src/servers/app/DelayedMessageThread.cpp
b/src/servers/app/DelayedMessageThread.cpp
index 55b7dbf..e435b78 100644
--- a/src/servers/app/DelayedMessageThread.cpp
+++ b/src/servers/app/DelayedMessageThread.cpp
@@ -1,4 +1,5 @@
#include <Autolock.h>
+#include <SupportDefs.h>

#include "DelayedMessageLooper.h"
#include "DelayedMessageThread.h"
@@ -42,9 +43,8 @@ DelayedMessageThread::~DelayedMessageThread()
void
DelayedMessageThread::Wakeup(bigtime_t when)
{
- BAutolock _(fLock);
if (when < fNextForcedWakeup)
- fNextForcedWakeup = when;
+ atomic_set64(&fNextForcedWakeup, when);
}


@@ -82,7 +82,7 @@ DelayedMessageThread::_ThreadTask()

while (true) {
if (has_data(self))
- code = receive_data(&sender, NULL, 0);
+ code = receive_data(&sender, NULL, DM_MINIMUM_DELAY);
else
code = kThreadSleep;

@@ -93,9 +93,9 @@ DelayedMessageThread::_ThreadTask()

if (code == kThreadSleep)
while (system_time() < fNextForcedWakeup)
- snooze(2000);
+ snooze(DM_MINIMUM_DELAY * 2);

- if (fLock.LockWithTimeout(1000) == B_OK) {
+ if (fLock.LockWithTimeout(DM_MINIMUM_DELAY) == B_OK) {
DelayedMessageLooper* looper = NULL;

bigtime_t nextWakeup = B_INFINITE_TIMEOUT;
diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index 532a6d3..e773f0d 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -2054,8 +2054,17 @@ fDesktop->LockSingleWindow();
fCurrentView->Name(), invalidRect.left,
invalidRect.top,
invalidRect.right, invalidRect.bottom));

+ View* view = NULL;
+ if (link.Read<View*>(&view) != B_OK)
+ view = fCurrentView;
+
+ // make sure the view is still available!
+ if (view != fCurrentView
+ && !fWindow->TopView()->HasView(view))
+ break;
+
BRegion dirty(invalidRect);
- fWindow->InvalidateView(fCurrentView, dirty);
+ fWindow->InvalidateView(view, dirty);
}
break;
}
@@ -2074,7 +2083,8 @@ fDesktop->LockSingleWindow();
DelayedMessage delayed(AS_VIEW_INVALIDATE_RECT,
delay,
DM_MERGE_DUPLICATES);

- if (delayed.Attach<BRect>(invalidRect) == B_OK)
+ if (delayed.Attach<BRect>(invalidRect) == B_OK
+ && delayed.Attach<View*>(fCurrentView)
== B_OK)
ScheduleMessage(delayed);
}
break;
diff --git a/src/servers/app/View.cpp b/src/servers/app/View.cpp
index 7831b45..d758cfd 100644
--- a/src/servers/app/View.cpp
+++ b/src/servers/app/View.cpp
@@ -432,6 +432,21 @@ View::FindViews(uint32 flags, BObjectList<View>& list,
int32& left)
}


+bool
+View::HasView(View* view)
+{
+ if (view == this)
+ return true;
+
+ for (View* child = FirstChild(); child; child = child->NextSibling()) {
+ if (child->HasView(view))
+ return true;
+ }
+
+ return false;
+}
+
+
View*
View::ViewAt(const BPoint& where)
{
diff --git a/src/servers/app/View.h b/src/servers/app/View.h
index b2291af..0a22039 100644
--- a/src/servers/app/View.h
+++ b/src/servers/app/View.h
@@ -108,6 +108,8 @@ public:
void CollectTokensForChildren(BList*
tokenMap) const;
void FindViews(uint32 flags,
BObjectList<View>& list,
int32& left);
+
+ bool HasView(View* view);

View* ViewAt(const BPoint& where);

diff --git a/src/servers/app/decorator/Decorator.cpp
b/src/servers/app/decorator/Decorator.cpp
index bd241f0..39136d1 100644
--- a/src/servers/app/decorator/Decorator.cpp
+++ b/src/servers/app/decorator/Decorator.cpp
@@ -266,7 +266,7 @@ Decorator::SetLook(int32 tab, DesktopSettings& settings,
window_look look,
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
if (decoratorTab == NULL)
return;
- UpdateColors(settings);
+
_SetLook(decoratorTab, settings, look, updateRect);
_InvalidateFootprint();
// the border very likely changed
@@ -849,13 +849,8 @@ Decorator::DrawZoom(int32 tab)
rgb_color
Decorator::UIColor(color_which which)
{
-
DesktopSettings settings(fDesktop);
return settings.UIColor(which);
-
- // TODO: for now - calling ui_color() from within the app_server
- // will always return the default colors (as there is no be_app)
-// return ui_color(which);
}


diff --git a/src/servers/app/stackandtile/SATDecorator.cpp
b/src/servers/app/stackandtile/SATDecorator.cpp
index 6466cc0..efba5cc 100644
--- a/src/servers/app/stackandtile/SATDecorator.cpp
+++ b/src/servers/app/stackandtile/SATDecorator.cpp
@@ -51,7 +51,7 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect
frame,
:
DefaultDecorator(settings, frame, desktop)
{
-
+ UpdateColors(settings);
}




Other related posts: