Skip to content

Commit 43c89bd

Browse files
authored
Merge pull request #31 from wuwao1/master
fix TileLayout DPI
2 parents e97a930 + 4ba7db8 commit 43c89bd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

DuiLib/Control/UILabel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ namespace DuiLib {
9696
faw::string_t sText = GetText ();
9797
m_bNeedEstimateSize = false;
9898
m_szAvailableLast = szAvailable;
99-
m_cxyFixedLast = m_cxyFixed;
99+
m_cxyFixedLast = GetManager()->GetDPIObj()->Scale(m_cxyFixed);
100100
if (sText.empty())
101-
return { m_cxyFixed.cx , m_cxyFixed.cy };
101+
return { m_cxyFixedLast.cx , m_cxyFixedLast.cy };
102102
// 自动计算宽度
103103
if ((m_uTextStyle & DT_SINGLELINE) != 0) {
104104
// 高度

DuiLib/Layout/UITileLayout.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace DuiLib {
1515
}
1616

1717
SIZE CTileLayoutUI::GetItemSize () const {
18+
if (m_pManager) return m_pManager->GetDPIObj()->Scale(m_szItem);
1819
return m_szItem;
1920
}
2021

@@ -48,10 +49,11 @@ namespace DuiLib {
4849
rc = m_rcItem;
4950

5051
// Adjust for inset
51-
rc.left += m_rcInset.left;
52-
rc.top += m_rcInset.top;
53-
rc.right -= m_rcInset.right;
54-
rc.bottom -= m_rcInset.bottom;
52+
auto rcInset = GetInset();
53+
rc.left += rcInset.left;
54+
rc.top += rcInset.top;
55+
rc.right -= rcInset.right;
56+
rc.bottom -= rcInset.bottom;
5557

5658
if (m_items.GetSize () == 0) {
5759
ProcessScrollBar (rc, 0, 0);
@@ -62,7 +64,8 @@ namespace DuiLib {
6264
if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible ()) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight ();
6365

6466
// Position the elements
65-
if (m_szItem.cx > 0) m_nColumns = (rc.right - rc.left) / m_szItem.cx;
67+
auto szItem = GetItemSize();
68+
if (szItem.cx > 0) m_nColumns = (rc.right - rc.left) / szItem.cx;
6669
if (m_nColumns == 0) m_nColumns = 1;
6770

6871
int cyNeeded = 0;

0 commit comments

Comments
 (0)