MCPcopy Create free account
hub / github.com/cinience/RedisStudio / EnsureVisible

Method EnsureVisible

DuiLib/Control/UIList.cpp:632–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632void CListUI::EnsureVisible(int iIndex)
633{
634 if( m_iCurSel < 0 ) return;
635 RECT rcItem = m_pList->GetItemAt(iIndex)->GetPos();
636 RECT rcList = m_pList->GetPos();
637 RECT rcListInset = m_pList->GetInset();
638
639 rcList.left += rcListInset.left;
640 rcList.top += rcListInset.top;
641 rcList.right -= rcListInset.right;
642 rcList.bottom -= rcListInset.bottom;
643
644 CScrollBarUI* pHorizontalScrollBar = m_pList->GetHorizontalScrollBar();
645 if( pHorizontalScrollBar && pHorizontalScrollBar->IsVisible() ) rcList.bottom -= pHorizontalScrollBar->GetFixedHeight();
646
647 int iPos = m_pList->GetScrollPos().cy;
648 if( rcItem.top >= rcList.top && rcItem.bottom < rcList.bottom ) return;
649 int dx = 0;
650 if( rcItem.top < rcList.top ) dx = rcItem.top - rcList.top;
651 if( rcItem.bottom > rcList.bottom ) dx = rcItem.bottom - rcList.bottom;
652 Scroll(0, dx);
653}
654
655void CListUI::Scroll(int dx, int dy)
656{

Callers

nothing calls this directly

Calls 6

GetInsetMethod · 0.80
IsVisibleMethod · 0.80
GetFixedHeightMethod · 0.80
GetItemAtMethod · 0.45
GetScrollPosMethod · 0.45

Tested by

no test coverage detected