MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / HitTestAttachments

Method HitTestAttachments

src/windows/MessageList.cpp:1221–1282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219}
1220
1221void MessageList::HitTestAttachments(POINT pt, BOOL& hit)
1222{
1223 auto msg = FindMessageByPoint(pt);
1224
1225 if (msg == m_messages.end())
1226 {
1227 _fail:
1228 if (m_highlightedAttachmentMessage)
1229 {
1230 auto msg2 = FindMessage(m_highlightedAttachmentMessage);
1231 if (msg2 != m_messages.end())
1232 {
1233 for (auto& x : msg2->m_attachmentData) {
1234 if (x.m_bHighlighted) {
1235 x.m_bHighlighted = false;
1236
1237 if (!x.m_pAttachment->IsImage())
1238 InvalidateRect(m_hwnd, &x.m_textRect, FALSE);
1239 }
1240 }
1241 }
1242 }
1243
1244 m_highlightedAttachment = 0;
1245 m_highlightedAttachmentMessage = 0;
1246 return;
1247 }
1248
1249 AttachmentItem* pAttach = NULL;
1250 bool inText = false, inAdd = false;
1251 for (size_t i = 0; i < msg->m_attachmentData.size(); i++)
1252 {
1253 AttachmentItem* pData = &msg->m_attachmentData[i];
1254
1255 inText = PtInRect(&pData->m_textRect, pt);
1256 inAdd = PtInRect(&pData->m_addRect, pt);
1257 if (inText || inAdd) {
1258 pAttach = pData;
1259 break;
1260 }
1261 }
1262
1263 if (!pAttach) {
1264 msg = m_messages.end();
1265 goto _fail;
1266 }
1267
1268 hit = TRUE;
1269 if (pAttach->m_pAttachment->m_id == m_highlightedAttachment)
1270 return;
1271
1272 m_highlightedAttachment = pAttach->m_pAttachment->m_id;
1273 m_highlightedAttachmentMessage = msg->m_msg->m_snowflake;
1274 pAttach->m_bHighlighted = true;
1275
1276 if (!pAttach->m_pAttachment->IsImage())
1277 {
1278 if (inText)

Callers 1

WndProcMethod · 0.80

Calls 4

DbgPrintWFunction · 0.85
IsImageMethod · 0.80
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected