[PATCH 0/1] MR10017: comctl32 : center icon in LV_VIEW_ICON mode by adjusting icon position calculation.
Fix icon display issue in "Faststone Image Viewer". -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10017
From: Maotong Zhang <zmtong1988@gmail.com> Fix icon display issue in "Faststone Image Viewer". --- dlls/comctl32/listview.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index f91e63f1f5b..1cdcae5ca35 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -2415,8 +2415,9 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW Icon.bottom = Icon.top; if (infoPtr->himlNormal) { - Icon.right += infoPtr->iconSize.cx; + Icon.right += infoPtr->iconSize.cx + (Icon.left * 2); Icon.bottom += infoPtr->iconSize.cy; + if(Icon.right > Box.right) Box.right = Icon.right; } } else /* LV_VIEW_SMALLICON, LV_VIEW_LIST or LV_VIEW_DETAILS */ @@ -2499,7 +2500,7 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW uFormat = oversizedBox ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS; else uFormat = LV_SL_DT_FLAGS; - + DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT); if (rcText.right != rcText.left) @@ -2514,7 +2515,7 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW calc_label: if (infoPtr->uView == LV_VIEW_ICON) { - Label.left = Box.left + (infoPtr->nItemWidth - labelSize.cx) / 2; + Label.left = Box.left + (infoPtr->nItemWidth - labelSize.cx) / 2 + Icon.left; Label.top = Box.top + ICON_TOP_PADDING_HITABLE + infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; Label.right = Label.left + labelSize.cx; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10017
Could you upload a screenshot demonstrating the changes before and after the MR? And please keep the coding style consistent with the surrounding code and don't introduce unrelated white space changes. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10017#note_128611
{width="548" height="208"} Thumbnail exceeds the border. {width=546 height=170} The revised effect. I can't think of a better solution. Maybe there are better calculations. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10017#note_128612
participants (3)
-
Maotong Zhang -
Maotong Zhang (@xiaotong) -
Zhiyi Zhang (@zhiyi)