Ticket #13714: 0001-BCalendarView-change-visuals-for-today.patch

File 0001-BCalendarView-change-visuals-for-today.patch, 2.7 KB (added by humdinger, 7 years ago)

new patch, incorporating this ticket's comments

  • src/kits/shared/CalendarView.cpp

    From d763149f54fc687a81fb1d41f3176674ac44f10a Mon Sep 17 00:00:00 2001
    From: Humdinger <humdingerb@gmail.com>
    Date: Sun, 17 Sep 2017 10:09:26 +0200
    Subject: [PATCH] BCalendarView: change visuals for 'today'
    
    Only using the keyboard navigation colour to indicate the current day isn't that
    nice in all situations. When using custom system colours, like white on blue
    for selected items, it can become barely readable.
    
    Now we
    * use bold type face for 'today',
    * tint 'today's background (lighten for dark, darken for bright bgColor),
    * use B_LIST_SELECTED_BACKGROUND_COLOR and B_LIST_SELECTED_ITEM_TEXT_COLOR
      for the selected day,
    * keyboard navigation colour only for the frame and text when doing keyboard
      navigation
    
    Fixes #13714
    ---
     src/kits/shared/CalendarView.cpp | 26 ++++++++++++++++++++------
     1 file changed, 20 insertions(+), 6 deletions(-)
    
    diff --git a/src/kits/shared/CalendarView.cpp b/src/kits/shared/CalendarView.cpp
    index 7bb0c86..8ff8771 100644
    a b BCalendarView::_DrawItem(BView* owner, BRect frame, const char* text,  
    11101110    rgb_color highColor = HighColor();
    11111111
    11121112    rgb_color textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
     1113    rgb_color bgColor = ui_color(B_LIST_BACKGROUND_COLOR);
    11131114    float tintDisabled = B_LIGHTEN_2_TINT;
     1115    float tintHighlight = B_LIGHTEN_1_TINT;
    11141116
    11151117    if (textColor.red + textColor.green + textColor.blue > 125 * 3)
    11161118        tintDisabled  = B_DARKEN_2_TINT;
    11171119
     1120    if (bgColor.red + bgColor.green + bgColor.blue > 125 * 3)
     1121        tintHighlight = B_DARKEN_1_TINT;
     1122
    11181123    if (isSelected) {
    11191124        SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
    11201125        textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR);
     1126    } else if (isHighlight) {
     1127        SetHighColor(tint_color(bgColor, tintHighlight));
    11211128    } else
    1122         SetHighColor(ui_color(B_LIST_BACKGROUND_COLOR));
    1123 
    1124     if (isHighlight) {
    1125         textColor = keyboard_navigation_color();
    1126     }
     1129        SetHighColor(bgColor);
    11271130
    11281131    SetLowColor(HighColor());
    11291132
    11301133    FillRect(frame.InsetByCopy(1.0, 1.0));
    11311134
    11321135    if (focus) {
    1133         SetHighColor(keyboard_navigation_color());
     1136        rgb_color focusColor = keyboard_navigation_color();
     1137        SetHighColor(focusColor);
    11341138        StrokeRect(frame.InsetByCopy(1.0, 1.0));
     1139
     1140        if (!isSelected)
     1141            textColor = focusColor;
    11351142    }
    11361143
    11371144    SetHighColor(textColor);
    BCalendarView::_DrawItem(BView* owner, BRect frame, const char* text,  
    11411148    float offsetH = frame.Width() / 2.0;
    11421149    float offsetV = frame.Height() / 2.0 + FontHeight(owner) / 2.0 - 2.0;
    11431150
     1151    BFont font(be_plain_font);
     1152    if (isHighlight)
     1153        font.SetFace(B_BOLD_FACE);
     1154    else
     1155        font.SetFace(B_REGULAR_FACE);
     1156    SetFont(&font);
     1157
    11441158    DrawString(text, BPoint(frame.right - offsetH - StringWidth(text) / 2.0,
    11451159            frame.top + offsetV));
    11461160