Ticket #12603: MenuField-LowColor.patch

File MenuField-LowColor.patch, 1.7 KB (added by looncraz, 8 years ago)
  • src/kits/interface/MenuField.cpp

    From 8a258624c22a368fb3c51bcc467282f585fa66d6 Mon Sep 17 00:00:00 2001
    From: looncraz <looncraz@looncraz.net>
    Date: Sun, 17 Jan 2016 12:06:36 +0000
    Subject: [PATCH] MenuField Low Color (for frame)
    
    BMenuField's frame is drawn from the LowColor() which is adopted from its
    parent.  However, we should be adopting the parent's view color for our low
    color, otherwise we sometimes end up with a miscolored border (most often white).
    
    This was not noticed earlier as most views have matching view and low colors.
    
    Fixes ticket #12603
    ---
     src/kits/interface/MenuField.cpp | 19 ++++++++++++++++---
     1 file changed, 16 insertions(+), 3 deletions(-)
    
    diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp
    index 3318dad..62aa993 100644
    a b void  
    428428BMenuField::AttachedToWindow()
    429429{
    430430    CALLED();
    431     AdoptParentColors();
     431
     432    // Our low color must match the parent's view color.
     433    if (Parent() != NULL) {
     434        AdoptParentColors();
     435
     436        float tint = B_NO_TINT;
     437        color_which which = ViewUIColor(&tint);
     438
     439        if (which == B_NO_COLOR)
     440            SetLowColor(ViewColor());
     441        else
     442            SetLowUIColor(which, tint);
     443    } else
     444        AdoptSystemColors();
    432445}
    433446
    434447
    BMenuField::_DrawLabel(BRect updateRect)  
    10651078        flags |= BControlLook::B_DISABLED;
    10661079
    10671080    // save the current low color
    1068     const rgb_color lowColor = LowColor();
     1081    PushState();
    10691082    rgb_color textColor;
    10701083
    10711084    MenuPrivate menuPrivate(fMenuBar);
    BMenuField::_DrawLabel(BRect updateRect)  
    10821095        BAlignment(fAlign, B_ALIGN_MIDDLE), &textColor);
    10831096
    10841097    // restore the previous low color
    1085     SetLowColor(lowColor);
     1098    PopState();
    10861099}
    10871100
    10881101