Ticket #12574: BAbstractSpinner-Colors.patch

File BAbstractSpinner-Colors.patch, 3.1 KB (added by looncraz, 8 years ago)
  • headers/private/interface/AbstractSpinner.h

    From 985cc012236d9f892544cd20cc769a728b73bc12 Mon Sep 17 00:00:00 2001
    From: looncraz <looncraz@looncraz.net>
    Date: Sat, 9 Jan 2016 15:58:44 -0600
    Subject: [PATCH] BAbstractSpinner Colors
    
    Adopted parent colors for the text view - should not have done so.
    Disabled colors were incorrect, so I also corrected those in this patch.
    ---
     headers/private/interface/AbstractSpinner.h |  1 +
     src/kits/interface/AbstractSpinner.cpp      | 45 ++++++++++++++---------------
     2 files changed, 22 insertions(+), 24 deletions(-)
    
    diff --git a/headers/private/interface/AbstractSpinner.h b/headers/private/interface/AbstractSpinner.h
    index e822299..8326f48 100644
    a b public:  
    5959    virtual void                Draw(BRect updateRect);
    6060    virtual void                FrameResized(float width, float height);
    6161    virtual void                ValueChanged();
     62    virtual void                MessageReceived(BMessage* message);
    6263
    6364    virtual void                Decrement() = 0;
    6465    virtual void                Increment() = 0;
  • src/kits/interface/AbstractSpinner.cpp

    diff --git a/src/kits/interface/AbstractSpinner.cpp b/src/kits/interface/AbstractSpinner.cpp
    index f426b5e..ecccc88 100644
    a b SpinnerTextView::AttachedToWindow()  
    545545{
    546546    fParent = static_cast<BAbstractSpinner*>(Parent());
    547547
    548     AdoptParentColors();
    549548    BTextView::AttachedToWindow();
    550549}
    551550
    BAbstractSpinner::ValueChanged()  
    10701069
    10711070
    10721071void
     1072BAbstractSpinner::MessageReceived(BMessage* message)
     1073{
     1074    if (!IsEnabled() && message->what == B_COLORS_UPDATED)
     1075        _UpdateTextViewColors(false);
     1076
     1077    BControl::MessageReceived(message);
     1078}
     1079
     1080
     1081void
    10731082BAbstractSpinner::MakeFocus(bool focus)
    10741083{
    10751084    fTextView->MakeFocus(focus);
    BAbstractSpinner::_UpdateFrame()  
    15851594void
    15861595BAbstractSpinner::_UpdateTextViewColors(bool enable)
    15871596{
    1588     rgb_color textColor;
    1589     BFont font;
    1590 
    1591     fTextView->GetFontAndColor(0, &font);
    1592 
    1593     if (enable)
    1594         textColor = ui_color(B_DOCUMENT_TEXT_COLOR);
    1595     else {
    1596         textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
    1597             B_DISABLED_LABEL_TINT);
    1598     }
    1599 
    1600     fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor);
     1597    // Mimick BTextControl's appearance.
     1598    rgb_color textColor = ui_color(B_DOCUMENT_TEXT_COLOR);
    16011599
    16021600    if (enable) {
    16031601        fTextView->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR);
    16041602        fTextView->SetLowUIColor(ViewUIColor());
    16051603    } else {
    1606         color_which which = ViewUIColor();
    1607 
    1608         if (which != B_NO_COLOR) {
    1609             fTextView->SetViewUIColor(which, B_LIGHTEN_2_TINT);
    1610             fTextView->SetLowUIColor(which, B_LIGHTEN_2_TINT);
    1611         } else {
    1612             rgb_color color = tint_color(ViewColor(), B_LIGHTEN_2_TINT);
    1613             fTextView->SetViewColor(color);
    1614             fTextView->SetLowColor(color);
    1615         }
     1604        rgb_color color = ui_color(B_DOCUMENT_BACKGROUND_COLOR);
     1605        color = disable_color(ViewColor(), color);
     1606        textColor = disable_color(textColor, ViewColor());
     1607
     1608        fTextView->SetViewColor(color);
     1609        fTextView->SetLowColor(color);
    16161610    }
    16171611
     1612    BFont font;
     1613    fTextView->GetFontAndColor(0, &font);
     1614    fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor);
    16181615}
    16191616
    16201617