Skip to content

Commit

Permalink
Update issue #255 : Fixed clipping and positioning of merit, error an…
Browse files Browse the repository at this point in the history
…d type overlays in filters list on high DPI systems.
  • Loading branch information
mikecopperwhite committed Mar 4, 2019
1 parent 3a8105c commit e44b1c4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/filter_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
DSUtil::FilterTemplate *filter = (DSUtil::FilterTemplate*)item->itemData;
if (!filter) return ;

const int BORDER_PIXELS = GetSystemMetrics(SM_CXVSCROLL) / 2; // use a DPI independent system border size
CDC dc;
dc.Attach(item->hDC);

Expand All @@ -84,8 +85,7 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation

// draw filter name
CRect rcText = item->rcItem;
rcText.left += 3;
rcText.right -= 3;
GetItemRect(item->itemID, rcText, LVIR_LABEL);

CString type_text = _T("");
int idx = 0;
Expand Down Expand Up @@ -136,27 +136,24 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
}

// draw merit
rcText.left = rcText.right - 70;
dc.SetTextColor(color_info);
dc.SelectObject(&font_info);
CString info;
info.Format(_T("(0x%08X)"), filter->merit);
dc.DrawText(info, &rcText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);

rcText.right -= dc.GetTextExtent(info).cx + BORDER_PIXELS;

if (!filter->file_exists) {
CString error_text = _T("(!)");
CSize extent = dc.GetTextExtent(error_text);

rcText.right = rcText.left;
rcText.left = rcText.right - extent.cx - 2*2;
dc.SetTextColor(color_error);
dc.DrawText(error_text, &rcText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
dc.DrawText(error_text, &rcText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);

rcText.right -= dc.GetTextExtent(error_text).cx + BORDER_PIXELS;
}

// draw type text
int rx = rcText.left;
rcText.left = rx - 66;
rcText.right = rx - 16;
dc.SelectObject(&font_filter);
dc.SetTextColor(type_colors[idx]);
dc.DrawText(type_text, &rcText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
Expand Down

0 comments on commit e44b1c4

Please sign in to comment.