Skip to content

Commit 1bcc46d

Browse files
committed
Refactor QuickOpenDlg::onDrawItem to optimize performance
1 parent 8692619 commit 1bcc46d

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/Explorer/QuickOpenDialog.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -645,25 +645,21 @@ BOOL QuickOpenDlg::onDrawItem(LPDRAWITEMSTRUCT drawItem)
645645
if (ODA_FOCUS == (drawItem->itemAction & ODA_FOCUS)) {
646646
return TRUE;
647647
}
648-
649648
const HDC& hdc = drawItem->hDC;
649+
ThemeRenderer& theme = ThemeRenderer::Instance();
650+
650651
COLORREF backgroundMatchColor = RGB(254, 230, 177);
651652
COLORREF matchColor = RGB(0, 0, 0);
652-
653-
COLORREF backgroundColor = ThemeRenderer::Instance().GetColors().secondary_bg;
654-
COLORREF textColor1 = ThemeRenderer::Instance().GetColors().secondary;
653+
COLORREF backgroundColor = theme.GetColors().secondary_bg;
654+
COLORREF textColor1 = theme.GetColors().secondary;
655655
COLORREF textColor2 = RGB(128, 128, 128);
656-
656+
HBRUSH backgroundBrush = theme.GetBrush(ThemeRenderer::BrushType::SecondaryBg);
657657
if (ODS_SELECTED == ((drawItem->itemState) & (ODS_SELECTED))) {
658-
backgroundColor = ThemeRenderer::Instance().GetColors().primary_bg;
659-
textColor1 = ThemeRenderer::Instance().GetColors().primary;
660-
textColor2 = RGB(128, 128, 128);
658+
backgroundColor = theme.GetColors().primary_bg;
659+
textColor1 = theme.GetColors().primary;
660+
backgroundBrush = theme.GetBrush(ThemeRenderer::BrushType::PrimaryBg);
661661
}
662-
663-
// Fill background
664-
const HBRUSH hBrush = ::CreateSolidBrush(backgroundColor);
665-
::FillRect(hdc, &drawItem->rcItem, hBrush);
666-
::DeleteObject(hBrush);
662+
::FillRect(hdc, &drawItem->rcItem, backgroundBrush);
667663

668664
RECT drawPosition = drawItem->rcItem;
669665
drawPosition.top += _layout.itemMargin;

src/Explorer/ThemeRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ HBRUSH ThemeRenderer::GetBrush(BrushType type) const
9494
case BrushType::PrimaryBorder:
9595
return m_brushes.primary_border;
9696
default:
97-
return m_brushes.body_bg; // デフォルトは本文背景を返す
97+
return m_brushes.body_bg;
9898
}
9999
}
100100

@@ -270,4 +270,4 @@ LRESULT ThemeRenderer::EditProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
270270
break;
271271
}
272272
return ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
273-
}
273+
}

0 commit comments

Comments
 (0)