[haiku-commits] haiku: hrev51431 - src/kits/shared

  • From: humdingerb@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 22 Sep 2017 18:33:16 +0200 (CEST)

hrev51431 adds 1 changeset to branch 'master'
old head: 916d4f5d7537d734fd99053f76ac70ce983c5c1d
new head: 9d30b95ab363c3c9d8347a23246a72a454c6eb82
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=9d30b95ab363+%5E916d4f5d7537

----------------------------------------------------------------------------

9d30b95ab363: 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

                                        [ Humdinger <humdingerb@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51431
Commit:      9d30b95ab363c3c9d8347a23246a72a454c6eb82
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9d30b95ab363
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Sun Sep 17 08:09:26 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/13714

----------------------------------------------------------------------------

1 file changed, 21 insertions(+), 7 deletions(-)
src/kits/shared/CalendarView.cpp | 28 +++++++++++++++++++++-------

----------------------------------------------------------------------------

diff --git a/src/kits/shared/CalendarView.cpp b/src/kits/shared/CalendarView.cpp
index 7bb0c86..33a0771 100644
--- a/src/kits/shared/CalendarView.cpp
+++ b/src/kits/shared/CalendarView.cpp
@@ -1110,28 +1110,35 @@ BCalendarView::_DrawItem(BView* owner, BRect frame, 
const char* text,
        rgb_color highColor = HighColor();
 
        rgb_color textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
+       rgb_color bgColor = ui_color(B_LIST_BACKGROUND_COLOR);
        float tintDisabled = B_LIGHTEN_2_TINT;
+       float tintHighlight = B_LIGHTEN_1_TINT;
 
        if (textColor.red + textColor.green + textColor.blue > 125 * 3)
                tintDisabled  = B_DARKEN_2_TINT;
 
+       if (bgColor.red + bgColor.green + bgColor.blue > 125 * 3)
+               tintHighlight = B_DARKEN_1_TINT;
+
        if (isSelected) {
                SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
                textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR);
-       } else
-               SetHighColor(ui_color(B_LIST_BACKGROUND_COLOR));
-
-       if (isHighlight) {
-               textColor = keyboard_navigation_color();
-       }
+       } else if (isHighlight)
+               SetHighColor(tint_color(bgColor, tintHighlight));
+       else
+               SetHighColor(bgColor);
 
        SetLowColor(HighColor());
 
        FillRect(frame.InsetByCopy(1.0, 1.0));
 
        if (focus) {
-               SetHighColor(keyboard_navigation_color());
+               rgb_color focusColor = keyboard_navigation_color();
+               SetHighColor(focusColor);
                StrokeRect(frame.InsetByCopy(1.0, 1.0));
+
+               if (!isSelected)
+                       textColor = focusColor;
        }
 
        SetHighColor(textColor);
@@ -1141,6 +1148,13 @@ BCalendarView::_DrawItem(BView* owner, BRect frame, 
const char* text,
        float offsetH = frame.Width() / 2.0;
        float offsetV = frame.Height() / 2.0 + FontHeight(owner) / 2.0 - 2.0;
 
+       BFont font(be_plain_font);
+       if (isHighlight)
+               font.SetFace(B_BOLD_FACE);
+       else
+               font.SetFace(B_REGULAR_FACE);
+       SetFont(&font);
+
        DrawString(text, BPoint(frame.right - offsetH - StringWidth(text) / 2.0,
                        frame.top + offsetV));
 


Other related posts:

  • » [haiku-commits] haiku: hrev51431 - src/kits/shared - humdingerb