[MSPAINT] Define GRIP_SIZE macro and use it (#4192)

Reduce magic numbers. CORE-17931
This commit is contained in:
Katayama Hirofumi MZ 2021-12-26 23:05:47 +09:00 committed by GitHub
parent 9e1386db43
commit 614354ccb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 53 deletions

View file

@ -65,31 +65,24 @@ ForceRefreshSelectionContents()
int CSelectionWindow::IdentifyCorner(int iXPos, int iYPos, int iWidth, int iHeight)
{
if (iYPos < 3)
{
if (iXPos < 3)
return ACTION_RESIZE_TOP_LEFT;
if ((iXPos < iWidth / 2 + 2) && (iXPos >= iWidth / 2 - 1))
return ACTION_RESIZE_TOP;
if (iXPos >= iWidth - 3)
return ACTION_RESIZE_TOP_RIGHT;
}
if ((iYPos < iHeight / 2 + 2) && (iYPos >= iHeight / 2 - 1))
{
if (iXPos < 3)
return ACTION_RESIZE_LEFT;
if (iXPos >= iWidth - 3)
return ACTION_RESIZE_RIGHT;
}
if (iYPos >= iHeight - 3)
{
if (iXPos < 3)
return ACTION_RESIZE_BOTTOM_LEFT;
if ((iXPos < iWidth / 2 + 2) && (iXPos >= iWidth / 2 - 1))
return ACTION_RESIZE_BOTTOM;
if (iXPos >= iWidth - 3)
return ACTION_RESIZE_BOTTOM_RIGHT;
}
POINT pt = { iXPos, iYPos };
HWND hwndChild = ChildWindowFromPointEx(pt, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED);
if (hwndChild == sizeboxLeftTop)
return ACTION_RESIZE_TOP_LEFT;
if (hwndChild == sizeboxCenterTop)
return ACTION_RESIZE_TOP;
if (hwndChild == sizeboxRightTop)
return ACTION_RESIZE_TOP_RIGHT;
if (hwndChild == sizeboxRightCenter)
return ACTION_RESIZE_RIGHT;
if (hwndChild == sizeboxLeftCenter)
return ACTION_RESIZE_LEFT;
if (hwndChild == sizeboxCenterBottom)
return ACTION_RESIZE_BOTTOM;
if (hwndChild == sizeboxRightBottom)
return ACTION_RESIZE_BOTTOM_RIGHT;
if (hwndChild == sizeboxLeftBottom)
return ACTION_RESIZE_BOTTOM_LEFT;
return 0;
}
@ -197,8 +190,8 @@ LRESULT CSelectionWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, B
}
else
{
int w = Zoomed(selectionModel.GetDestRectWidth()) + 6;
int h = Zoomed(selectionModel.GetDestRectHeight()) + 6;
int w = Zoomed(selectionModel.GetDestRectWidth()) + 2 * GRIP_SIZE;
int h = Zoomed(selectionModel.GetDestRectHeight()) + 2 * GRIP_SIZE;
m_ptPos.x = GET_X_LPARAM(lParam);
m_ptPos.y = GET_Y_LPARAM(lParam);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) NULL);