Skip to content

Commit

Permalink
* General color-related polish changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed Jun 7, 2024
1 parent 288bd85 commit ef1569d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
16 changes: 16 additions & 0 deletions src/windows/MessageList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3896,6 +3896,22 @@ std::list<MessageItem>::iterator MessageList::FindMessageByPointAuthorRect(POINT
return m_messages.end();
}

COLORREF MessageList::GetDarkerBackgroundColor() const
{
COLORREF bgColor;
auto style = GetLocalSettings()->GetMessageStyle();
if (style == MS_IMAGE)
bgColor = m_backgroundColor;
else if (style == MS_FLATBR)
bgColor = GetSysColor(COLOR_WINDOW);
else
bgColor = GetSysColor(COLOR_3DFACE);

COLORREF hint = IsColorDark(bgColor) ? 0xFFFFFF : 0x000000;

return LerpColor(hint, bgColor, 90, 100);
}

void MessageList::FullRecalcAndRepaint()
{
for (auto& msg : m_messages) {
Expand Down
10 changes: 1 addition & 9 deletions src/windows/MessageList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,7 @@ class MessageList
std::list<MessageItem>::iterator FindMessageByPointAuthorRect(POINT pt);

public:
COLORREF GetDarkerBackgroundColor() const
{
COLORREF crWindow = m_backgroundColor;
COLORREF crShadow = ((((m_backgroundColor & 0xFEFEFE) >> 1) + ((m_backgroundColor & 0xFCFCFC) >> 2)) & 0xDFDFDF) + 0x202020;
int r1 = crWindow & 0xFF, r2 = crShadow & 0xFF;
int g1 = (crWindow >> 8) & 0xFF, g2 = (crShadow >> 8) & 0xFF;
int b1 = (crWindow >> 16) & 0xFF, b2 = (crShadow >> 16) & 0xFF;
return RGB((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2);
}
COLORREF GetDarkerBackgroundColor() const;

COLORREF InvertIfNeeded(COLORREF color) const
{
Expand Down
1 change: 1 addition & 0 deletions src/windows/RoleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void RoleList::DrawRole(HDC hdc, RoleItem* role)
case MS_3DFACE:
DrawEdge(hdc, &rect, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE | BF_ADJUST);
case MS_FLAT:
case MS_IMAGE:
oldBkColor = SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
break;
case MS_FLATBR:
Expand Down

0 comments on commit ef1569d

Please sign in to comment.