diff --git a/src/discord/LocalSettings.cpp b/src/discord/LocalSettings.cpp index ad6b2ebf..0943efaf 100644 --- a/src/discord/LocalSettings.cpp +++ b/src/discord/LocalSettings.cpp @@ -74,6 +74,9 @@ bool LocalSettings::Load() if (j.contains("EnableTLSVerification")) m_bEnableTLSVerification = j["EnableTLSVerification"]; + if (j.contains("ReducePadding")) + m_bReducePadding = j["ReducePadding"]; + if (m_bSaveWindowSize) { if (j.contains("WindowWidth")) @@ -119,6 +122,7 @@ bool LocalSettings::Save() j["SaveWindowSize"] = m_bSaveWindowSize; j["CheckUpdates"] = m_bCheckUpdates; j["EnableTLSVerification"] = m_bEnableTLSVerification; + j["ReducePadding"] = m_bReducePadding; j["RemindUpdateCheckOn"] = (long long)(m_remindUpdatesOn); if (m_bSaveWindowSize) { j["WindowWidth"] = m_width; diff --git a/src/discord/LocalSettings.hpp b/src/discord/LocalSettings.hpp index ebdec771..6958c520 100644 --- a/src/discord/LocalSettings.hpp +++ b/src/discord/LocalSettings.hpp @@ -51,6 +51,12 @@ class LocalSettings bool GetSaveWindowSize() const { return m_bSaveWindowSize; } + void SetReducePadding(bool b) { + m_bReducePadding = b; + } + bool GetReducePadding() const { + return m_bReducePadding; + } void SetStartMaximized(bool b) { m_bStartMaximized = b; } @@ -106,6 +112,7 @@ class LocalSettings bool m_bCheckUpdates = false; bool m_bAskToCheckUpdates = true; bool m_bEnableTLSVerification = true; + bool m_bReducePadding = false; time_t m_remindUpdatesOn = 0; int m_width = 1000; int m_height = 700; diff --git a/src/resource.h b/src/resource.h index 7743501d..322a248b 100644 --- a/src/resource.h +++ b/src/resource.h @@ -278,9 +278,9 @@ #define IDC_ICON_WARN_CONNECT 868 #define IDC_ICON_WARN_WEBSOCKETSTUFF 869 #define IDC_ICON_WARN_WEBSOCKETSTUFF2 870 -#define IDC_CHECK1 871 #define IDC_ENABLE_TLS_CHECKS 871 #define IDC_CHECK_UPDATES 872 +#define IDC_REDUCE_PADDING 873 #define ID_FILE_PREFERENCES 1001 #define ID_FILE_STOPALLSPEECH 1002 #define ID_FILE_EXIT 1003 @@ -359,7 +359,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 73 #define _APS_NEXT_COMMAND_VALUE 1069 -#define _APS_NEXT_CONTROL_VALUE 873 +#define _APS_NEXT_CONTROL_VALUE 874 #define _APS_NEXT_SYMED_VALUE 40000 #endif #endif diff --git a/src/resource.rc b/src/resource.rc index 15e18f04..99e16bc1 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -416,9 +416,11 @@ BEGIN CONTROL "Gradient",IDC_RADIO_GRADIENT,"Button",BS_AUTORADIOBUTTON,12,78,43,10 CONTROL "Flat Color 1",IDC_RADIO_FLAT_1,"Button",BS_AUTORADIOBUTTON,12,91,53,10 CONTROL "Flat Color 2",IDC_RADIO_FLAT_2,"Button",BS_AUTORADIOBUTTON,12,104,53,10 - GROUPBOX "Window Settings",IDC_STATIC,6,127,245,38 - CONTROL "Save window size",IDC_SAVE_WINDOW_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,72,10 - CONTROL "Start maximized",IDC_START_MAXIMIZED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,150,67,10 + GROUPBOX "Window Settings",IDC_STATIC,6,127,245,50 + CONTROL "Save window size",IDC_SAVE_WINDOW_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,230,10 + CONTROL "Start maximized",IDC_START_MAXIMIZED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,150,229,10 + CONTROL "Reduce UI padding (for smaller screens)",IDC_REDUCE_PADDING, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,163,228,10 END IDD_DIALOG_PROFILE_POPOUT DIALOGEX 0, 0, 228, 218 @@ -593,7 +595,7 @@ BEGIN LEFTMARGIN, 6 RIGHTMARGIN, 251 TOPMARGIN, 7 - BOTTOMMARGIN, 192 + BOTTOMMARGIN, 234 END IDD_DIALOG_PROFILE_POPOUT, DIALOG diff --git a/src/windows/Main.cpp b/src/windows/Main.cpp index 558d5a32..2b14410a 100644 --- a/src/windows/Main.cpp +++ b/src/windows/Main.cpp @@ -198,12 +198,12 @@ void ProperlySizeControls(HWND hWnd) GetClientRect(hWnd, &rect); rcClient = rect; - int scaled10 = ScaleByDPI(10); + int borderSize = ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 5 : 10); - rect.left += scaled10; - rect.top += scaled10; - rect.right -= scaled10; - rect.bottom -= scaled10; + rect.left += borderSize; + rect.top += borderSize; + rect.right -= borderSize; + rect.bottom -= borderSize; HWND hWndMsg = g_pMessageList->m_hwnd; HWND hWndChv = g_pChannelView->m_hwnd; @@ -235,40 +235,40 @@ void ProperlySizeControls(HWND hWnd) bool bRepaint = true; // Create a message list - rect.left += g_ChannelViewListWidth + scaled10 + g_GuildListerWidth + scaled10; - rect.bottom -= g_MessageEditorHeight + g_pMessageEditor->ExpandedBy() + scaled10; - rect.top += g_GuildHeaderHeight; - if (g_bMemberListVisible) rect.right -= g_MemberListWidth + scaled10; + rect.left += g_ChannelViewListWidth + borderSize + g_GuildListerWidth + borderSize; + rect.bottom -= g_MessageEditorHeight + g_pMessageEditor->ExpandedBy() + borderSize; + rect.top += g_GuildHeaderHeight + borderSize; + if (g_bMemberListVisible) rect.right -= g_MemberListWidth + borderSize; MoveWindow(hWndMsg, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint); - rect.left = rect.right + scaled10; + rect.left = rect.right + borderSize; rect.right = rect.left + g_MemberListWidth; rect.bottom = rect2.bottom; MoveWindow(hWndMel, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint); rect = rect2; - rect.left += g_GuildListerWidth + scaled10; + rect.left += g_GuildListerWidth + borderSize; rect.right = rect.left + g_ChannelViewListWidth; rect.bottom -= g_BottomBarHeight; - rect.top += g_GuildHeaderHeight; + rect.top += g_GuildHeaderHeight + borderSize; MoveWindow(hWndChv, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint); rect = rect2; - rect.left += g_GuildListerWidth + scaled10; - rect.top = rect.bottom - g_BottomBarHeight + scaled10; + rect.left += g_GuildListerWidth + borderSize; + rect.top = rect.bottom - g_BottomBarHeight + borderSize; rect.right = rect.left + g_ChannelViewListWidth; MoveWindow(hWndPfv, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint); rect = rect2; - rect.left = g_ChannelViewListWidth + scaled10 + scaled10 + g_GuildListerWidth + scaled10; + rect.left = g_ChannelViewListWidth + borderSize + borderSize + g_GuildListerWidth + borderSize; rect.top = rect.bottom - g_MessageEditorHeight - g_pMessageEditor->ExpandedBy(); - if (g_bMemberListVisible) rect.right -= g_MemberListWidth + scaled10; + if (g_bMemberListVisible) rect.right -= g_MemberListWidth + borderSize; int textInputHeight = rect.bottom - rect.top, textInputWidth = rect.right - rect.left; MoveWindow(hWndTin, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint); rect = rect2; - rect.left += g_GuildListerWidth + scaled10; - rect.bottom = rect.top + g_GuildHeaderHeight - scaled10; + rect.left += g_GuildListerWidth + borderSize; + rect.bottom = rect.top + g_GuildHeaderHeight; MoveWindow(hWndGuh, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, FALSE); rect = rect2; @@ -650,13 +650,19 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } case WM_REPAINTMSGLIST: { - InvalidateRect(g_pMessageList->m_hwnd, NULL, false); + InvalidateRect(g_pMessageList->m_hwnd, NULL, FALSE); break; } case WM_MSGLISTUPDATEMODE: { g_pMessageList->UpdateBackgroundBrush(); - InvalidateRect(g_pMessageList->m_hwnd, NULL, false); + InvalidateRect(g_pMessageList->m_hwnd, NULL, TRUE); + break; + } + case WM_REPOSITIONEVERYTHING: + { + ProperlySizeControls(hWnd); + InvalidateRect(hWnd, NULL, TRUE); break; } case WM_RECALCMSGLIST: diff --git a/src/windows/Measurements.hpp b/src/windows/Measurements.hpp index 290e39aa..0ed8aeb1 100644 --- a/src/windows/Measurements.hpp +++ b/src/windows/Measurements.hpp @@ -2,7 +2,7 @@ #define PROFILE_PICTURE_SIZE_DEF 36 #define CHANNEL_VIEW_LIST_WIDTH 200 -#define GUILD_HEADER_HEIGHT 40 +#define GUILD_HEADER_HEIGHT 30 #define GUILD_HEADER_RIGHT_WIDTH 150 #define GUILD_LISTER_WIDTH (PROFILE_PICTURE_SIZE_DEF + 16) #define MEMBER_LIST_WIDTH 200 diff --git a/src/windows/MessageList.cpp b/src/windows/MessageList.cpp index 8276f4aa..cae7c87f 100644 --- a/src/windows/MessageList.cpp +++ b/src/windows/MessageList.cpp @@ -15,11 +15,58 @@ #define IDC_HAND MAKEINTRESOURCE(32649) #endif//IDC_HAND -#define ATTACHMENT_HEIGHT (ScaleByDPI(40)) -#define ATTACHMENT_GAP (ScaleByDPI(4)) -#define DATE_GAP_HEIGHT (ScaleByDPI(20)) +#define ATTACHMENT_HEIGHT (ScaleByDPI(40)) #define PROFILE_PICTURE_GAP (PROFILE_PICTURE_SIZE + 8); +// ADJUSTABLE MEASUREMENTS +int GetMessageBorderPadding() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 4 : 10); +} + +int GetEmbedBorderPadding() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 4 : 10); +} + +int GetAuthorAndDatePadding() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 4 : 10); +} + +int GetDateAndEditDatePadding() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 5); +} + +int GetMessageAndEmbedGap() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 5); +} + +int GetMessageAndAttachmentGap() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 5); +} + +int GetReplyPadHeight() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 5); +} + +int GetGapBetweenEmbedItems() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 5); +} + +int GetEmbedGap() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 5); +} + +int GetAuthorAndMessagePadding() { + return GetLocalSettings()->GetReducePadding() ? 0 : ScaleByDPI(5); +} + +int GetAttachmentGap() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 2 : 4); +} + +int GetDateGapHeight() { + return ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 14 : 20); +} + static int GetProfileBorderRenderSize() { return ScaleByDPI(Supports32BitIcons() ? (PROFILE_PICTURE_SIZE_DEF + 12) : 64); @@ -121,7 +168,7 @@ void RichEmbedItem::Update() void RichEmbedItem::Measure(HDC hdc, RECT& messageRect, bool isCompact) { - const int borderSize = ScaleByDPI(10); + const int borderSize = GetEmbedBorderPadding(); SIZE sz { 0, 0 }; RECT rcItem = messageRect; @@ -129,8 +176,8 @@ void RichEmbedItem::Measure(HDC hdc, RECT& messageRect, bool isCompact) rcItem.top += borderSize; rcItem.right -= borderSize * 2; rcItem.bottom -= borderSize * 2; - rcItem.right -= ScaleByDPI(20); - rcItem.bottom -= ScaleByDPI(20); + rcItem.right -= GetEmbedBorderPadding() * 2; + rcItem.bottom -= GetEmbedBorderPadding() * 2; if (!isCompact) rcItem.right -= ScaleByDPI(PROFILE_PICTURE_SIZE_DEF + 12); @@ -207,7 +254,7 @@ void RichEmbedItem::Measure(HDC hdc, RECT& messageRect, bool isCompact) } else m_dateSize = sz; - int gap = ScaleByDPI(5); + int gap = GetGapBetweenEmbedItems(); LONG footerPlusDateXSize = m_footerSize.cx; if (m_dateSize.cx) { if (footerPlusDateXSize) @@ -269,7 +316,7 @@ void RichEmbedItem::Draw(HDC hdc, RECT& messageRect) ri::SetDCBrushColor(hdc, oldCol); // Draw the thing - const int borderSize = ScaleByDPI(10); + const int borderSize = GetEmbedBorderPadding(); const int gap = ScaleByDPI(5); int sizeY = 0; rc.left += ScaleByDPI(4); @@ -395,8 +442,8 @@ void MessageList::MeasureMessage( HGDIOBJ gdiObj = SelectObject(hdc, g_AuthorTextFont); RECT rcCommon1 = msgRect, rcCommon2; RECT rc; - rcCommon1.right -= ScaleByDPI(20); - rcCommon1.bottom -= ScaleByDPI(20); + rcCommon1.right -= GetMessageBorderPadding(); + rcCommon1.bottom -= GetMessageBorderPadding(); if (placeinchain == 0) { rcCommon2 = rcCommon1; if (!bIsCompact) @@ -423,7 +470,7 @@ void MessageList::MeasureMessage( if (strReplyMsg) { rc = rcCommon1; - rc.right -= ScaleByDPI(5) - replyauthwidth; + rc.right -= GetAuthorAndMessagePadding() - replyauthwidth; replyheight2 = DrawText(hdc, strReplyMsg, -1, &rc, DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX); replymsgwidth = rc.right - rc.left; } @@ -440,30 +487,30 @@ void MessageList::MeasureMessage( datewidth = 0; SelectObject(hdc, g_DateTextFont); rc = msgRect; - rc.right -= ScaleByDPI(20); - rc.bottom -= ScaleByDPI(20); + rc.right -= GetMessageBorderPadding() * 2; + rc.bottom -= GetMessageBorderPadding() * 2; DrawText(hdc, strDate, -1, &rc, DT_CALCRECT | DT_NOPREFIX); datewidth += rc.right - rc.left; if (strDateEdit) { rc = msgRect; - rc.right -= ScaleByDPI(20); - rc.bottom -= ScaleByDPI(20); + rc.right -= GetMessageBorderPadding() * 2; + rc.bottom -= GetMessageBorderPadding() * 2; DrawText(hdc, strDateEdit, -1, &rc, DT_CALCRECT | DT_NOPREFIX); - datewidth += rc.right - rc.left + ScaleByDPI(10); + datewidth += rc.right - rc.left + GetAuthorAndDatePadding(); } } else datewidth = 0; SelectObject(hdc, g_MessageTextFont); rc = msgRect; - rc.right -= ScaleByDPI(20); - rc.bottom -= ScaleByDPI(20); + rc.right -= GetMessageBorderPadding() * 2; + rc.bottom -= GetMessageBorderPadding() * 2; if (!bIsCompact) rc.right -= ScaleByDPI(PROFILE_PICTURE_SIZE_DEF + 12); DrawingContext mddc(hdc); - strMsg.Layout(&mddc, Rect(W32RECT(rc)), bIsCompact ? (authwidth + datewidth + ScaleByDPI(10)) : 0); + strMsg.Layout(&mddc, Rect(W32RECT(rc)), bIsCompact ? (authwidth + datewidth + GetAuthorAndDatePadding()) : 0); Rect ext = strMsg.GetExtent(); textheight = ext.Height(); @@ -757,7 +804,7 @@ void MessageList::RefetchMessages(Snowflake gapCulprit) for (auto& msg : m_messages) { if (msg.m_msg.m_snowflake == m_firstShownMessage) { if (m_bManagedByOwner && msg.m_bIsDateGap) - oldYMessage += DATE_GAP_HEIGHT; + oldYMessage += GetDateGapHeight(); break; } oldYMessage += msg.m_height; @@ -1298,7 +1345,7 @@ void MessageList::DrawImageAttachment(HDC hdc, RECT& paintRect, AttachmentItem& attachItem.m_boxRect = childAttachRect; attachItem.m_textRect = childAttachRect; - attachRect.bottom = attachRect.top = childAttachRect.bottom + ATTACHMENT_GAP; + attachRect.bottom = attachRect.top = childAttachRect.bottom + GetAttachmentGap(); RECT intersRect; if (!IntersectRect(&intersRect, &paintRect, &childAttachRect)) @@ -1358,7 +1405,7 @@ void MessageList::DrawDefaultAttachment(HDC hdc, RECT& paintRect, AttachmentItem textRect.right = textRect.left + rcMeasure.right; childAttachRect.right = childAttachRect.left + iconSize + iconSize + width + ScaleByDPI(20); - attachRect.bottom = attachRect.top = childAttachRect.bottom + ATTACHMENT_GAP; + attachRect.bottom = attachRect.top = childAttachRect.bottom + GetAttachmentGap(); if (inView) { @@ -1653,7 +1700,7 @@ COLORREF MessageList::DrawMentionBackground(HDC hdc, RECT& rc, COLORREF chosenBk int MessageList::DrawMessageReply(HDC hdc, MessageItem& item, RECT& rc) { const int pfpOffset = ScaleByDPI(PROFILE_PICTURE_SIZE_DEF + 12); - const int replyOffset = item.m_replyHeight + ScaleByDPI(5); + const int replyOffset = item.m_replyHeight + GetReplyPadHeight(); RECT rcReply = rc; rcReply.bottom = rcReply.top + item.m_replyHeight; @@ -1784,7 +1831,7 @@ int MessageList::DrawMessageReply(HDC hdc, MessageItem& item, RECT& rc) rcReply.left += item.m_replyAuthorWidth; if (!isActionMessage) - rcReply.left += ScaleByDPI(5); + rcReply.left += GetAuthorAndMessagePadding(); SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); @@ -1847,19 +1894,19 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c const bool isChainBegin = item.m_placeInChain == 0; const bool isChainCont = item.m_placeInChain != 0; - rc.left += ScaleByDPI(10); - rc.right -= ScaleByDPI(10); - rc.bottom -= ScaleByDPI(10); + rc.left += GetMessageBorderPadding(); + rc.right -= GetMessageBorderPadding(); + rc.bottom -= GetMessageBorderPadding(); if (isChainBegin) - rc.top += ScaleByDPI(10); + rc.top += GetMessageBorderPadding(); if (!m_bManagedByOwner && item.m_bIsDateGap && isChainBegin) { RECT dgRect = msgRect; - dgRect.bottom = dgRect.top + DATE_GAP_HEIGHT; + dgRect.bottom = dgRect.top + GetDateGapHeight(); - rc.top += DATE_GAP_HEIGHT; - msgRect.top += DATE_GAP_HEIGHT; + rc.top += GetDateGapHeight(); + msgRect.top += GetDateGapHeight(); LPTSTR strDateGap = ConvertCppStringToTString(" " + item.m_msg.m_dateOnly + " "); COLORREF oldTextClr = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); @@ -1881,10 +1928,10 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c DrawText(hdc, strDateGap, -1, &rcMeasure, DT_CALCRECT | DT_NOPREFIX); int width = rcMeasure.right - rcMeasure.left; - int l1 = dgRect.left + ScaleByDPI(10); + int l1 = dgRect.left + GetMessageBorderPadding(); int r1 = dgRect.right / 2 - width / 2 - 1; int l2 = dgRect.right / 2 + width / 2 + 1; - int r2 = dgRect.right - ScaleByDPI(10) - 1; + int r2 = dgRect.right - GetMessageBorderPadding() - 1; POINT old; HGDIOBJ oldob = SelectObject(hdc, GetStockPen(DC_PEN)); @@ -2126,16 +2173,16 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c int oldLeft = rc.left; if (inView) { if (!bIsCompact || isActionMessage) - rc.left += authwidth + ScaleByDPI(10); + rc.left += authwidth + GetAuthorAndDatePadding(); rc.left += dateOffset; rc.left -= authorOffset; DrawText(hdc, strDate, -1, &rc, DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP); if (item.m_msg.m_timeEdited) { RECT rcMeasure{}; DrawText(hdc, strDate, -1, &rcMeasure, DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); - rc.left += rcMeasure.right - rcMeasure.left + ScaleByDPI(5); + rc.left += rcMeasure.right - rcMeasure.left + GetDateAndEditDatePadding(); DrawText(hdc, strEditDate, -1, &rc, DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP); - rc.left -= rcMeasure.right - rcMeasure.left + ScaleByDPI(5); + rc.left -= rcMeasure.right - rcMeasure.left + GetDateAndEditDatePadding(); } } rc.left = oldLeft; @@ -2237,14 +2284,17 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c } else { - if (!bIsCompact && isChainBegin) - rc.top += ScaleByDPI(5); + if (!bIsCompact && isChainBegin && !GetLocalSettings()->GetReducePadding()) + rc.top += GetAuthorAndMessagePadding(); RECT rcMsg = rc; rcMsg.bottom -= item.m_attachHeight + item.m_embedHeight; if (item.m_attachHeight) - rcMsg.bottom -= ATTACHMENT_GAP; - item.m_message.Layout(&mddc, Rect(W32RECT(rcMsg)), bIsCompact ? (item.m_authWidth + item.m_dateWidth + ScaleByDPI(10)) : 0); + rcMsg.bottom -= GetAttachmentGap(); + if (item.m_embedHeight) + rcMsg.bottom -= GetEmbedGap(); + + item.m_message.Layout(&mddc, Rect(W32RECT(rcMsg)), bIsCompact ? (item.m_authWidth + item.m_dateWidth + GetAuthorAndDatePadding()) : 0); Rect ext = item.m_message.GetExtent(); int height = std::max(item.m_authHeight, ext.Height()); @@ -2268,13 +2318,16 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c if (item.m_bWasMentioned) { COLORREF color; if (!bIsCompact) { - color = DrawMentionBackground(hdc, rc, chosenBkColor); + RECT rc2{ W32RECT(ext) }; + rc2.top += offsetY; + rc2.bottom += offsetY; + color = DrawMentionBackground(hdc, rc2, chosenBkColor); } else { RECT rc1, rc2; rc1 = rc2 = rc; - rc1.left += item.m_authWidth + item.m_dateWidth + ScaleByDPI(10); + rc1.left += item.m_authWidth + item.m_dateWidth + GetAuthorAndDatePadding(); rc1.bottom = rc1.top + item.m_authHeight; rc2.top += item.m_authHeight; @@ -2365,9 +2418,9 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c auto& embedVec = item.m_embedData; size_t sz = embedVec.size(); if (isChainBegin && sz) - embedRect.bottom += ScaleByDPI(5); + embedRect.bottom += GetMessageAndEmbedGap(); - embedRect.right = msgRect.right - ScaleByDPI(10); + embedRect.right = msgRect.right - GetAuthorAndDatePadding(); embedRect.top = embedRect.bottom; if (bIsCompact) embedRect.left = rc.left; @@ -2399,16 +2452,16 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c } } - embedRect.top += eitem.m_size.cy + ScaleByDPI(5); + embedRect.top += eitem.m_size.cy + GetEmbedGap(); embedRect.bottom = embedRect.top; } // draw available attachments, if any: RECT attachRect = embedRect; if (isChainBegin || sz != 0) - attachRect.bottom += ScaleByDPI(5) + ATTACHMENT_GAP; + attachRect.bottom += GetMessageAndAttachmentGap() + GetAttachmentGap(); - attachRect.right = msgRect.right - ScaleByDPI(10); + attachRect.right = msgRect.right - GetAuthorAndDatePadding(); attachRect.top = attachRect.bottom; if (bIsCompact) attachRect.left = rc.left; @@ -3394,7 +3447,7 @@ void MessageList::AdjustHeightInfo(const MessageItem& msg, int& height, int& tex bool isCompact = IsCompact(); int replyheight2 = replyheight; if (replyheight2) - replyheight2 += ScaleByDPI(5); + replyheight2 += GetReplyPadHeight(); bool isChainCont = msg.m_placeInChain != 0; if (isChainCont) @@ -3405,17 +3458,17 @@ void MessageList::AdjustHeightInfo(const MessageItem& msg, int& height, int& tex if (IsActionMessage(msg.m_msg.m_type)) { replyheight2 = 0; - height = replyheight2 + authheight + ScaleByDPI(20); + height = replyheight2 + authheight + GetMessageBorderPadding() * 2; } else if (isCompact) { - height = replyheight2 + std::max(textheight, authheight) + ScaleByDPI(20); + height = replyheight2 + std::max(textheight, authheight) + GetMessageBorderPadding() * 2; } else { - int pad = 25; - if (!authheight) pad = 20; - if (isChainCont) pad = 10; + int pad = GetMessageBorderPadding() * 2 + GetAuthorAndMessagePadding(); + if (!authheight) pad = GetMessageBorderPadding() * 2; + if (isChainCont) pad = GetMessageBorderPadding(); height = replyheight2 + textheight + authheight + ScaleByDPI(pad); } @@ -3423,13 +3476,13 @@ void MessageList::AdjustHeightInfo(const MessageItem& msg, int& height, int& tex // If a date gap, add an extra X pixels if (!m_bManagedByOwner && msg.m_bIsDateGap) - height += DATE_GAP_HEIGHT, minHeight += DATE_GAP_HEIGHT; + height += GetDateGapHeight(), minHeight += GetDateGapHeight(); // also figure out embed size embedheight = 0; for (auto& emb : msg.m_embedData) { - int inc = emb.m_size.cy + ScaleByDPI(5); + int inc = emb.m_size.cy + GetEmbedGap(); height += inc; embedheight += inc; } @@ -3441,9 +3494,9 @@ void MessageList::AdjustHeightInfo(const MessageItem& msg, int& height, int& tex // XXX improve? int inc = 0; if (att.m_contentType == ContentType::BLOB) - inc = ATTACHMENT_HEIGHT + ATTACHMENT_GAP; + inc = ATTACHMENT_HEIGHT + GetAttachmentGap(); else - inc = att.m_previewHeight + ATTACHMENT_GAP; + inc = att.m_previewHeight + GetAttachmentGap(); height += inc; attachheight += inc; @@ -3451,16 +3504,16 @@ void MessageList::AdjustHeightInfo(const MessageItem& msg, int& height, int& tex if (isChainCont) { if (embedheight != 0) - height -= ScaleByDPI(5); + height -= GetEmbedGap(); else if (attachheight != 0) - height -= ATTACHMENT_GAP; + height -= GetAttachmentGap(); } else { // add some separators if (attachheight != 0) - height += ScaleByDPI(5); + height += GetMessageAndAttachmentGap(); if (embedheight != 0) - height += ScaleByDPI(5); + height += GetMessageAndEmbedGap(); } if (!IsActionMessage(msg.m_msg.m_type) && !IsCompact() && !isChainCont && height < minHeight) @@ -3553,9 +3606,9 @@ int MessageList::RecalcMessageSizes(bool update, int& repaintSize, Snowflake add } if (bIsDateGap && !msgOldIsDateGap) - iter->m_height += DATE_GAP_HEIGHT; + iter->m_height += GetDateGapHeight(); if (!bIsDateGap && msgOldIsDateGap) - iter->m_height -= DATE_GAP_HEIGHT; + iter->m_height -= GetDateGapHeight(); if (oldHeight != iter->m_height) { diff --git a/src/windows/OptionsDialog.cpp b/src/windows/OptionsDialog.cpp index 97a886f2..e8d6baee 100644 --- a/src/windows/OptionsDialog.cpp +++ b/src/windows/OptionsDialog.cpp @@ -290,6 +290,10 @@ INT_PTR CALLBACK ChildDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa GetLocalSettings()->SetMessageStyle(MS_FLATBR); SendMessage(g_Hwnd, WM_MSGLISTUPDATEMODE, 0, 0); break; + case IDC_REDUCE_PADDING: + GetLocalSettings()->SetReducePadding(IsDlgButtonChecked(hWnd, IDC_REDUCE_PADDING)); + SendMessage(g_Hwnd, WM_REPOSITIONEVERYTHING, 0, 0); + break; case IDC_SAVE_WINDOW_SIZE: GetLocalSettings()->SetSaveWindowSize(IsDlgButtonChecked(hWnd, IDC_SAVE_WINDOW_SIZE)); break; diff --git a/src/windows/WindowMessages.hpp b/src/windows/WindowMessages.hpp index 4d3e9b9d..7f982d7c 100644 --- a/src/windows/WindowMessages.hpp +++ b/src/windows/WindowMessages.hpp @@ -56,4 +56,5 @@ enum eWmUserMsgs WM_CONNECTERROR, WM_UPDATEUSER, // Snowflake[1] WM_UPDATEEMOJI, // Snowflake[1] + WM_REPOSITIONEVERYTHING, };