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,
|
1110 | 1110 | rgb_color highColor = HighColor(); |
1111 | 1111 | |
1112 | 1112 | rgb_color textColor = ui_color(B_LIST_ITEM_TEXT_COLOR); |
| 1113 | rgb_color bgColor = ui_color(B_LIST_BACKGROUND_COLOR); |
1113 | 1114 | float tintDisabled = B_LIGHTEN_2_TINT; |
| 1115 | float tintHighlight = B_LIGHTEN_1_TINT; |
1114 | 1116 | |
1115 | 1117 | if (textColor.red + textColor.green + textColor.blue > 125 * 3) |
1116 | 1118 | tintDisabled = B_DARKEN_2_TINT; |
1117 | 1119 | |
| 1120 | if (bgColor.red + bgColor.green + bgColor.blue > 125 * 3) |
| 1121 | tintHighlight = B_DARKEN_1_TINT; |
| 1122 | |
1118 | 1123 | if (isSelected) { |
1119 | 1124 | SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR)); |
1120 | 1125 | textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR); |
| 1126 | } else if (isHighlight) { |
| 1127 | SetHighColor(tint_color(bgColor, tintHighlight)); |
1121 | 1128 | } else |
1122 | | SetHighColor(ui_color(B_LIST_BACKGROUND_COLOR)); |
1123 | | |
1124 | | if (isHighlight) { |
1125 | | textColor = keyboard_navigation_color(); |
1126 | | } |
| 1129 | SetHighColor(bgColor); |
1127 | 1130 | |
1128 | 1131 | SetLowColor(HighColor()); |
1129 | 1132 | |
1130 | 1133 | FillRect(frame.InsetByCopy(1.0, 1.0)); |
1131 | 1134 | |
1132 | 1135 | if (focus) { |
1133 | | SetHighColor(keyboard_navigation_color()); |
| 1136 | rgb_color focusColor = keyboard_navigation_color(); |
| 1137 | SetHighColor(focusColor); |
1134 | 1138 | StrokeRect(frame.InsetByCopy(1.0, 1.0)); |
| 1139 | |
| 1140 | if (!isSelected) |
| 1141 | textColor = focusColor; |
1135 | 1142 | } |
1136 | 1143 | |
1137 | 1144 | SetHighColor(textColor); |
… |
… |
BCalendarView::_DrawItem(BView* owner, BRect frame, const char* text,
|
1141 | 1148 | float offsetH = frame.Width() / 2.0; |
1142 | 1149 | float offsetV = frame.Height() / 2.0 + FontHeight(owner) / 2.0 - 2.0; |
1143 | 1150 | |
| 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 | |
1144 | 1158 | DrawString(text, BPoint(frame.right - offsetH - StringWidth(text) / 2.0, |
1145 | 1159 | frame.top + offsetV)); |
1146 | 1160 | |