Skip to content

Commit

Permalink
Improve display when RR_RADIUS is changed to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Oct 23, 2024
1 parent 92bbd0f commit c8333dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
19 changes: 11 additions & 8 deletions Src/Common/MDITabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#endif

constexpr int RR_RADIUS = 3;
constexpr int RR_PADDING = 3;
constexpr int RR_SHADOWWIDTH = 3;

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -361,6 +362,7 @@ void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
const int lpx = ::GetDeviceCaps(lpDraw->hDC, LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
const int r = pointToPixel(RR_RADIUS);
const int pd = pointToPixel(RR_PADDING);
const int sw = pointToPixel(RR_SHADOWWIDTH);

CRect rc = lpDraw->rcItem;
Expand All @@ -385,7 +387,7 @@ void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
SetTextColor(lpDraw->hDC, GetSysColor(COLOR_BTNTEXT));
}
CSize iconsize(determineIconSize(), determineIconSize());
rc.left += sw * 2 + iconsize.cx;
rc.left += sw + pd + iconsize.cx;
SetBkMode(lpDraw->hDC, TRANSPARENT);
HWND hwndFrame = reinterpret_cast<HWND>(item.lParam);
if (::IsWindow(hwndFrame))
Expand All @@ -396,7 +398,8 @@ void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
if (hIcon != nullptr)
DrawIconEx(lpDraw->hDC, rc.left - iconsize.cx, rc.top + (rc.Height() - iconsize.cy) / 2, hIcon, iconsize.cx, iconsize.cy, 0, nullptr, DI_NORMAL);
}
rc.left += sw;
rc.left += pd;
rc.right -= pd;
DrawText(lpDraw->hDC, szBuf, -1, &rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);

int nItem = GetItemIndexFromPoint(m_rcCurrentCloseButtom.CenterPoint());
Expand Down Expand Up @@ -498,13 +501,13 @@ CRect CMyTabCtrl::GetCloseButtonRect(int nItem)
CClientDC dc(this);
const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
const int r = pointToPixel(RR_RADIUS);
const int pd = pointToPixel(RR_PADDING);
const int sw = pointToPixel(RR_SHADOWWIDTH);
CRect rc, rcClient;
CSize size(determineIconSize(), determineIconSize());
GetClientRect(&rcClient);
GetItemRect(nItem, &rc);
rc.left = rc.right - size.cx - sw - r;
rc.left = rc.right - size.cx - sw - pd;
rc.right = rc.left + size.cx;
int y = (rcClient.top + rcClient.bottom) / 2;
rc.top = y - size.cy / 2 + 1;
Expand Down Expand Up @@ -644,9 +647,9 @@ BOOL CMDITabBar::Create(CMDIFrameWnd* pMainFrame)
CClientDC dc(this);
const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
const int r = pointToPixel(RR_RADIUS);
const int pd = pointToPixel(RR_PADDING);
const int sw = pointToPixel(RR_SHADOWWIDTH);
m_tabCtrl.SetPadding(CSize(sw + r * 2 + determineIconSize() / 2, sw + r));
m_tabCtrl.SetPadding(CSize(sw + pd * 2 + determineIconSize() / 2, sw + pd));

NONCLIENTMETRICS ncm = { sizeof NONCLIENTMETRICS };
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof NONCLIENTMETRICS, &ncm, 0);
Expand All @@ -672,10 +675,10 @@ CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)

const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
const int r = pointToPixel(RR_RADIUS);
const int pd = pointToPixel(RR_PADDING);
const int sw = pointToPixel(RR_SHADOWWIDTH);
int my = m_bOnTitleBar ? (m_bMaximized ? (-m_top + 2) : 2) : 0;
CSize size(SHRT_MAX, my + tm.tmHeight + (sw + r) * 2);
CSize size(SHRT_MAX, my + tm.tmHeight + (sw + pd) * 2);
return size;
}

Expand Down
10 changes: 5 additions & 5 deletions Src/EditorFilepathBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#endif

constexpr int RR_RADIUS = 3;
constexpr int RR_PADDING = 3;
constexpr int RR_SHADOWWIDTH = 3;

BEGIN_MESSAGE_MAP(CEditorFilePathBar, CDialogBar)
Expand Down Expand Up @@ -84,7 +85,7 @@ CSize CEditorFilePathBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
dc.SelectObject(pOldFont);
const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
int cy = pointToPixel(3 + RR_SHADOWWIDTH * 2);
int cy = pointToPixel(3 + RR_SHADOWWIDTH + RR_PADDING);
return CSize(SHRT_MAX, 1 + tm.tmHeight + cy);
}

Expand Down Expand Up @@ -134,10 +135,9 @@ void CEditorFilePathBar::Resize(int widths[])
CClientDC dc(this);
const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
const int r = pointToPixel(RR_RADIUS);
const int sw = pointToPixel(RR_SHADOWWIDTH);
CRect rc2 = rc;
rc2.DeflateRect(sw + r, sw);
rc2.DeflateRect(sw + sw, sw);
m_Edit[pane].MoveWindow(&rc2);
m_Edit[pane].RefreshDisplayText();
resized = true;
Expand All @@ -164,11 +164,11 @@ void CEditorFilePathBar::DoPaint(CDC* pDC)
const COLORREF clrShadow =
CEColor::GetIntermediateColor(clrBarBackcolor, GetSysColor(COLOR_3DSHADOW), m_Edit[pane].GetActive() ? 0.5f : 0.8f);
rc.OffsetRect(-rcBar.left, -rcBar.top);
DrawRoundedRectWithShadow(pDC->m_hDC, rc.left - r, rc.top, rc.right - rc.left + 2 * r, rc.bottom - rc.top, r, sw,
DrawRoundedRectWithShadow(pDC->m_hDC, rc.left - sw, rc.top, rc.right - rc.left + 2 * sw, rc.bottom - rc.top, r, sw,
clrBackcolor, clrShadow, clrBarBackcolor);
if (pane == m_nPanes - 1)
{
CRect rc2{ rc.right + r + sw, 0, rcBar.Width(), rcBar.Height() };
CRect rc2{ rc.right + sw + sw, 0, rcBar.Width(), rcBar.Height() };
pDC->FillSolidRect(&rc2, clrBarBackcolor);
}
}
Expand Down

0 comments on commit c8333dc

Please sign in to comment.