Ticket #12568: BButton-Color-Adapt.patch

File BButton-Color-Adapt.patch, 2.3 KB (added by looncraz, 9 years ago)
  • src/kits/interface/Button.cpp

    From 9b99c678f1d824929cac15e6297000c68941d3bf Mon Sep 17 00:00:00 2001
    From: looncraz <looncraz@looncraz.net>
    Date: Sat, 9 Jan 2016 13:13:21 -0600
    Subject: [PATCH] Improve BButton Color Adaptability
    
    View color now shows through, so we keep the view color in sync with the
    parent to act as the button background color.  The low color is used to
    determine the button color.  The high color is used to determine the
    button label color.
    
    The default low and high colors are the control background and text colors,
    respectfully. To maintain the identical appearance as before, the default
    control background color is tinted to match the default panel background
    color. As the color has a gradient applied anyway, no one will notice a
    difference while playing with custom control colors.
    ---
     src/kits/interface/Button.cpp | 15 ++++++++++-----
     1 file changed, 10 insertions(+), 5 deletions(-)
    
    diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp
    index ab728e5..6d3fd4b 100644
    a b void  
    133133BButton::Draw(BRect updateRect)
    134134{
    135135    BRect rect(Bounds());
    136     rgb_color background = LowColor();
     136    rgb_color background = ViewColor();
     137    rgb_color base = LowColor();
     138    rgb_color textColor = HighColor();
    137139
    138     // Darken default control color to match default panel color.
    139     rgb_color base = tint_color(ui_color(B_CONTROL_BACKGROUND_COLOR), 1.115);
    140140    uint32 flags = be_control_look->Flags(this);
    141141    if (_Flag(FLAG_DEFAULT))
    142142        flags |= BControlLook::B_DEFAULT_BUTTON;
    BButton::Draw(BRect updateRect)  
    163163        (Value() == B_CONTROL_OFF
    164164                ? B_INACTIVE_ICON_BITMAP : B_ACTIVE_ICON_BITMAP)
    165165            | (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP));
    166     be_control_look->DrawLabel(this, Label(), icon, rect, updateRect,
    167         base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
     166
     167    be_control_look->DrawLabel(this, Label(), icon, rect, updateRect, base,
     168        flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &textColor);
    168169}
    169170
    170171
    BButton::AttachedToWindow()  
    230231{
    231232    BControl::AttachedToWindow();
    232233
     234    // Tint default control background color to match default panel background.
     235    SetLowUIColor(B_CONTROL_BACKGROUND_COLOR, 1.115);
     236    SetHighUIColor(B_CONTROL_TEXT_COLOR);
     237
    233238    if (IsDefault())
    234239        Window()->SetDefaultButton(this);
    235240}