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

Method HitTestInteractables

src/windows/MessageList.cpp:1284–1356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1282}
1283
1284void MessageList::HitTestInteractables(POINT pt, BOOL& hit)
1285{
1286 auto msg = FindMessageByPoint(pt);
1287
1288 if (msg == m_messages.end())
1289 {
1290 _fail:
1291 if (m_highlightedInteractableMessage)
1292 {
1293 auto msg2 = FindMessage(m_highlightedInteractableMessage);
1294 if (msg2 != m_messages.end())
1295 {
1296 for (auto& x : msg2->m_interactableData) {
1297 if (x.m_bHighlighted) {
1298 x.m_bHighlighted = false;
1299 if (x.ShouldInvalidateOnHover()) {
1300 RECT rc = RectToNative(x.m_rect);
1301 InvalidateRect(m_hwnd, &rc, FALSE);
1302 }
1303 }
1304 }
1305 }
1306 }
1307
1308 m_highlightedInteractable = SIZE_MAX;
1309 m_highlightedInteractableMessage = 0;
1310 return;
1311 }
1312
1313 InteractableItem* pItem = NULL;
1314 for (size_t i = 0; i < msg->m_interactableData.size(); i++)
1315 {
1316 InteractableItem* pData = &msg->m_interactableData[i];
1317
1318 RECT rect = RectToNative(pData->m_rect);
1319 if (PtInRect(&rect, pt)) {
1320 pItem = pData;
1321 break;
1322 }
1323 }
1324
1325 if (!pItem) {
1326 msg = m_messages.end();
1327 goto _fail;
1328 }
1329
1330 hit = TRUE;
1331 if (pItem->m_wordIndex == m_highlightedInteractable)
1332 return;
1333
1334 // find old interactable
1335 for (size_t i = 0; i < msg->m_interactableData.size(); i++) {
1336 InteractableItem* pData = &msg->m_interactableData[i];
1337 if (pData->m_wordIndex == m_highlightedInteractable) {
1338 pData->m_bHighlighted = false;
1339 if (pData->ShouldInvalidateOnHover()) {
1340 RECT rect = RectToNative(pData->m_rect);
1341 InvalidateRect(m_hwnd, &rect, FALSE);

Callers 1

WndProcMethod · 0.80

Calls 5

RectToNativeFunction · 0.85
DbgPrintWFunction · 0.85
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected