Skip to content

Commit

Permalink
Merge pull request #31 from wuwao1/master
Browse files Browse the repository at this point in the history
fix TileLayout DPI
  • Loading branch information
fawdlstty authored Apr 17, 2024
2 parents e97a930 + 4ba7db8 commit 43c89bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DuiLib/Control/UILabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ namespace DuiLib {
faw::string_t sText = GetText ();
m_bNeedEstimateSize = false;
m_szAvailableLast = szAvailable;
m_cxyFixedLast = m_cxyFixed;
m_cxyFixedLast = GetManager()->GetDPIObj()->Scale(m_cxyFixed);
if (sText.empty())
return { m_cxyFixed.cx , m_cxyFixed.cy };
return { m_cxyFixedLast.cx , m_cxyFixedLast.cy };
// 自动计算宽度
if ((m_uTextStyle & DT_SINGLELINE) != 0) {
// 高度
Expand Down
13 changes: 8 additions & 5 deletions DuiLib/Layout/UITileLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace DuiLib {
}

SIZE CTileLayoutUI::GetItemSize () const {
if (m_pManager) return m_pManager->GetDPIObj()->Scale(m_szItem);
return m_szItem;
}

Expand Down Expand Up @@ -48,10 +49,11 @@ namespace DuiLib {
rc = m_rcItem;

// Adjust for inset
rc.left += m_rcInset.left;
rc.top += m_rcInset.top;
rc.right -= m_rcInset.right;
rc.bottom -= m_rcInset.bottom;
auto rcInset = GetInset();
rc.left += rcInset.left;
rc.top += rcInset.top;
rc.right -= rcInset.right;
rc.bottom -= rcInset.bottom;

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

// Position the elements
if (m_szItem.cx > 0) m_nColumns = (rc.right - rc.left) / m_szItem.cx;
auto szItem = GetItemSize();
if (szItem.cx > 0) m_nColumns = (rc.right - rc.left) / szItem.cx;
if (m_nColumns == 0) m_nColumns = 1;

int cyNeeded = 0;
Expand Down

0 comments on commit 43c89bd

Please sign in to comment.