From c9bd4d84b9992c986063f5cfebf92787324e0276 Mon Sep 17 00:00:00 2001 From: looncraz Date: Wed, 6 Jan 2016 20:25:39 -0600 Subject: [PATCH] Interface Kit: Correct button colors. What appeared to be multiple issues was just one issue: BButton was drawing the control background color for its border, whereas the previous system drew the control low color, which was the parent's view color. Neither is correct, no border should be drawn at all. This made it appear that the default button was larger than it was and also made it appear that some apps had a "white" border around the buttons. In addition, BButton can now use the default BControl color behavior and BButton exclusively adopt either parental or system colors without worrying about the case in which another view has set the button's view color manually. Signed-off-by: Augustin Cavalier --- src/kits/interface/Button.cpp | 21 +++------------------ src/kits/interface/Control.cpp | 6 ++++-- src/kits/interface/ControlLook.cpp | 5 +---- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp index 68b2884cc8..ab728e5355 100644 --- a/src/kits/interface/Button.cpp +++ b/src/kits/interface/Button.cpp @@ -132,14 +132,11 @@ 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(ViewColor(), buttonTint); + + // Darken default control color to match default panel color. + rgb_color base = tint_color(ui_color(B_CONTROL_BACKGROUND_COLOR), 1.115); uint32 flags = be_control_look->Flags(this); if (_Flag(FLAG_DEFAULT)) flags |= BControlLook::B_DEFAULT_BUTTON; @@ -232,18 +229,6 @@ 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. - if (Parent() != NULL) { - float tint = B_NO_TINT; - color_which which = ViewUIColor(&tint); - if (which != B_NO_COLOR) - SetLowUIColor(which, tint); - else - SetLowColor(ViewColor()); - } if (IsDefault()) Window()->SetDefaultButton(this); diff --git a/src/kits/interface/Control.cpp b/src/kits/interface/Control.cpp index 1882e8bf7a..3009da4593 100644 --- a/src/kits/interface/Control.cpp +++ b/src/kits/interface/Control.cpp @@ -153,8 +153,10 @@ BControl::AttachedToWindow() { AdoptParentColors(); - if (ViewColor() == B_TRANSPARENT_COLOR) - SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + if (ViewColor() == B_TRANSPARENT_COLOR + || Parent() == NULL) { + AdoptSystemColors(); + } // Force view color as low color if (Parent() != NULL) { diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index dfeb6e3fb5..e4c3152518 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -2159,10 +2159,7 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags); // draw default button indicator - view->SetHighColor(background); - view->FillRect(rect); - view->SetHighColor(base); - view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius); + // Allow a 1-pixel border of the background to come through. rect.InsetBy(1, 1); view->SetHighColor(defaultIndicatorColor);