[haiku-commits] BRANCH looncraz-github.setviewuicolor [fd211b0b9e18] in src: kits/interface apps/terminal apps/mediaplayer/interface

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 20 Oct 2015 05:17:02 +0200 (CEST)

added 3 changesets to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: 1b38b2e15e616122fd673db53af72a33f26b7f81
new head: fd211b0b9e18e6bfc9d6508fb4907cf491f635a2
overview: https://github.com/looncraz/haiku/compare/1b38b2e15e61...fd211b0b9e18

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

e1a77dfdc82c: Check for existing low color

It is desirable to default to setting the low color to match the view
color in most cases by default, however we don't wat to crush any
existing user choices.

Incidentally, this repaired the background for ActivityMonitor during
updates.

0de94a27ff87: Various Minor Improvements

Slider's background was stuck when added to a layout directly to the
top view (such as in CharacterMap), this resolves this issue.

The remainder is just cleanup or simplification.

fd211b0b9e18: Terminal Resize Text Correction

When resizing Terminal with the recent changes the text would become
messed up since BStringView was trying to adopt parental colors
blindly. Attempting to override this before attachment of the
string view would fail as parental colors would still be adopted.

As such, I created a public BView method HasDefaultColors() and
now Terminal uses any user-defined Terminal color settings for the
resizing text.

In addition, AdoptParentColors() will now also adopt parent highcolors.

[ looncraz <looncraz@xxxxxxxxxxxx> ]

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

8 files changed, 59 insertions(+), 20 deletions(-)
headers/os/interface/View.h | 1 +
src/apps/mediaplayer/interface/DurationView.cpp | 6 ++----
src/apps/terminal/TermView.cpp | 6 ++++--
src/kits/interface/ChannelSlider.cpp | 14 +++++++++++++
src/kits/interface/Slider.cpp | 10 ++++++---
src/kits/interface/StringView.cpp | 9 +++++---
src/kits/interface/TextControl.cpp | 10 ++++-----
src/kits/interface/View.cpp | 23 ++++++++++++++++++---

############################################################################

Commit: e1a77dfdc82cce8b74adf37d1b9a3a6cffd972a0
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Tue Oct 20 01:27:32 2015 UTC

Check for existing low color

It is desirable to default to setting the low color to match the view
color in most cases by default, however we don't wat to crush any
existing user choices.

Incidentally, this repaired the background for ActivityMonitor during
updates.

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

diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp
index f270acb..f2be2a4 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -2600,7 +2600,8 @@ BView::SetViewUIColor(color_which which, float tint)
fState->archiving_flags &= ~B_VIEW_WHICH_VIEW_COLOR_BIT;
}

- SetLowUIColor(which, tint);
+ if (!fState->IsValid(B_VIEW_WHICH_LOW_COLOR_BIT))
+ SetLowUIColor(which, tint);
}



############################################################################

Commit: 0de94a27ff87afb3be26a18c5b2253c5ee49372d
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Tue Oct 20 01:31:43 2015 UTC

Various Minor Improvements

Slider's background was stuck when added to a layout directly to the
top view (such as in CharacterMap), this resolves this issue.

The remainder is just cleanup or simplification.

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

diff --git a/src/apps/mediaplayer/interface/DurationView.cpp
b/src/apps/mediaplayer/interface/DurationView.cpp
index b2644c6..7f4ddda 100644
--- a/src/apps/mediaplayer/interface/DurationView.cpp
+++ b/src/apps/mediaplayer/interface/DurationView.cpp
@@ -50,11 +50,9 @@ DurationView::MouseDown(BPoint where)
void
DurationView::MessageReceived(BMessage* message)
{
- if (message->what == B_COLORS_UPDATED) {
- if (BColorMap::Get(message, B_PANEL_BACKGROUND_COLOR) == B_OK
- || BColorMap::Get(message, B_PANEL_TEXT_COLOR) == B_OK)
+ if (message->what == B_COLORS_UPDATED
+ && BColorMap::Get(message, B_PANEL_TEXT_COLOR) == B_OK)
_UpdateTextColor();
- }

BStringView::MessageReceived(message);
}
diff --git a/src/kits/interface/ChannelSlider.cpp
b/src/kits/interface/ChannelSlider.cpp
index 28f6e48..e118a91 100644
--- a/src/kits/interface/ChannelSlider.cpp
+++ b/src/kits/interface/ChannelSlider.cpp
@@ -12,6 +12,7 @@
#include <new>

#include <Bitmap.h>
+#include <ColorMap.h>
#include <ControlLook.h>
#include <Debug.h>
#include <PropertyInfo.h>
@@ -178,6 +179,19 @@ BChannelSlider::AllDetached()
void
BChannelSlider::MessageReceived(BMessage* message)
{
+ if (message->what == B_COLORS_UPDATED
+ && fBacking != NULL && fBackingView != NULL) {
+ rgb_color color;
+ if (BColorMap::Get(message, 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:
diff --git a/src/kits/interface/Slider.cpp b/src/kits/interface/Slider.cpp
index 4d0acd5..33e269a 100644
--- a/src/kits/interface/Slider.cpp
+++ b/src/kits/interface/Slider.cpp
@@ -411,6 +411,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);
}


@@ -824,10 +830,8 @@ BSlider::Draw(BRect updateRect)
fOffScreenView->SetLowColor(LowColor());
#endif

- if (drawBackground && background.Frame().IsValid()) {
- AdoptParentColors();
+ if (drawBackground && background.Frame().IsValid())
OffscreenView()->FillRegion(&background, B_SOLID_LOW);
- }

#if USE_OFF_SCREEN_VIEW
fOffScreenView->Sync();
diff --git a/src/kits/interface/TextControl.cpp
b/src/kits/interface/TextControl.cpp
index 36aa9b0..f0c53ae 100644
--- a/src/kits/interface/TextControl.cpp
+++ b/src/kits/interface/TextControl.cpp
@@ -466,12 +466,12 @@ void
BTextControl::MessageReceived(BMessage* message)
{
if (message->what == B_COLORS_UPDATED) {
- BColorMap colorSet(message);
+ BColorMap colors(message);

- if (colorSet.HasColor(B_PANEL_BACKGROUND_COLOR)
- || colorSet.HasColor(B_PANEL_TEXT_COLOR)
- || colorSet.HasColor(B_DOCUMENT_BACKGROUND_COLOR)
- || colorSet.HasColor(B_DOCUMENT_TEXT_COLOR)) {
+ if (colors.HasColor(B_PANEL_BACKGROUND_COLOR)
+ || colors.HasColor(B_PANEL_TEXT_COLOR)
+ || colors.HasColor(B_DOCUMENT_BACKGROUND_COLOR)
+ || colors.HasColor(B_DOCUMENT_TEXT_COLOR)) {
_UpdateTextViewColors(IsEnabled());
}
}

############################################################################

Commit: fd211b0b9e18e6bfc9d6508fb4907cf491f635a2
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Tue Oct 20 04:01:35 2015 UTC

Terminal Resize Text Correction

When resizing Terminal with the recent changes the text would become
messed up since BStringView was trying to adopt parental colors
blindly. Attempting to override this before attachment of the
string view would fail as parental colors would still be adopted.

As such, I created a public BView method HasDefaultColors() and
now Terminal uses any user-defined Terminal color settings for the
resizing text.

In addition, AdoptParentColors() will now also adopt parent highcolors.

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

diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h
index 733fef0..f8a02c7 100644
--- a/headers/os/interface/View.h
+++ b/headers/os/interface/View.h
@@ -238,6 +238,7 @@ public:
void SetViewCursor(const
BCursor* cursor,
bool
sync = true);

+ bool HasDefaultColors()
const;
void AdoptParentColors();
virtual void SetViewColor(rgb_color color);
void SetViewColor(uchar red,
uchar green, uchar blue,
diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp
index eb6c9b9..dc41228 100644
--- a/src/apps/terminal/TermView.cpp
+++ b/src/apps/terminal/TermView.cpp
@@ -1451,10 +1451,12 @@ TermView::FrameResized(float width, float height)
bool hasResizeView = fResizeRunner != NULL;
if (!hasResizeView) {
// show the current size in a view
- fResizeView = new BStringView(BRect(100, 100, 300, 140),
- B_TRANSLATE("size"), "");
+ fResizeView = new BStringView(BRect(100, 100, 300, 140),
"size", "");
fResizeView->SetAlignment(B_ALIGN_CENTER);
fResizeView->SetFont(be_bold_font);
+ fResizeView->SetViewColor(fTextBackColor);
+ fResizeView->SetLowColor(fTextBackColor);
+ fResizeView->SetHighColor(fTextForeColor);

BMessage message(MSG_REMOVE_RESIZE_VIEW_IF_NEEDED);
fResizeRunner = new(std::nothrow)
BMessageRunner(BMessenger(this),
diff --git a/src/kits/interface/StringView.cpp
b/src/kits/interface/StringView.cpp
index 6f8c1f1..cb27823 100644
--- a/src/kits/interface/StringView.cpp
+++ b/src/kits/interface/StringView.cpp
@@ -128,8 +128,10 @@ BStringView::Archive(BMessage* data, bool deep) const
void
BStringView::AttachedToWindow()
{
- AdoptParentColors();
- SetHighUIColor(B_PANEL_TEXT_COLOR);
+ if (HasDefaultColors()) {
+ AdoptParentColors();
+ SetHighUIColor(B_PANEL_TEXT_COLOR);
+ }
}


@@ -246,7 +248,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/View.cpp b/src/kits/interface/View.cpp
index f2be2a4..48a5e24 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -2508,7 +2508,6 @@ BView::LowUIColor(float* tint) const
}
}

-
if (tint != NULL)
*tint = fState->which_low_color_tint;

@@ -2516,6 +2515,18 @@ BView::LowUIColor(float* tint) const
}


+bool
+BView::HasDefaultColors() const
+{
+ return fState->which_view_color == B_NO_COLOR
+ && fState->which_high_color == B_NO_COLOR
+ && fState->which_low_color == B_NO_COLOR
+ && fState->view_color == make_color(255, 255, 255)
+ && fState->low_color == fState->view_color
+ && fState->high_color == make_color(0, 0, 0);
+}
+
+
void
BView::AdoptParentColors()
{
@@ -2533,13 +2544,18 @@ BView::AdoptParentColors()
SetViewColor(parent->ViewColor());

color_which which = parent->LowUIColor(&tint);
-
if (which != B_NO_COLOR)
SetLowUIColor(which, tint);
else if (viewWhich != B_NO_COLOR)
SetLowUIColor(viewWhich, viewTint);
else
SetLowColor(parent->LowColor());
+
+ which = parent->HighUIColor(&tint);
+ if (which != B_NO_COLOR)
+ SetHighUIColor(which, tint);
+ else
+ SetHighColor(parent->HighColor());
}




Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.setviewuicolor [fd211b0b9e18] in src: kits/interface apps/terminal apps/mediaplayer/interface - looncraz-github . setviewuicolor