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 <waddlesplash@gmail.com>
This commit is contained in:
looncraz 2016-01-06 20:25:39 -06:00 committed by Augustin Cavalier
parent 8487f27d5b
commit c9bd4d84b9
3 changed files with 8 additions and 24 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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);