1
0
mirror of https://github.com/OpenTrespasser/JurassicParkTrespasser.git synced 2024-12-22 00:21:58 +00:00

Ctrls: add mousewheel support for CUIListBox

- extract ScrollUp and ScrollDown
This commit is contained in:
Michael 2021-04-03 01:14:09 +02:00
parent c448e9785b
commit 498130ed0d
2 changed files with 33 additions and 14 deletions
jp2_pc/Source/Trespass

View File

@ -1069,28 +1069,42 @@ BOOL CUIListbox::LButtonUp(int x, int y, UINT keyFlags)
return TRUE;
}
void CUIListbox::ScrollUp()
{
if (int iNewTop = m_iTop - 1; iNewTop >= 0)
{
m_iTop = iNewTop;
m_bUpdate = TRUE;
}
}
void CUIListbox::ScrollDown()
{
if (int iNewTop = m_iTop + 1; iNewTop <= m_vInfo.size() - m_iItemsMaxVis)
{
m_iTop = iNewTop;
m_bUpdate = TRUE;
}
}
BOOL CUIListbox::MouseWheel(int x, int y, int zDelta, UINT keyFlags)
{
if (zDelta > 0)
ScrollUp();
else if (zDelta < 0)
ScrollDown();
return TRUE;
}
void CUIListbox::UIButtonUp(CUIButton * pbutton)
{
int iNewTop;
if ((pbutton->GetID() == IDSCROLLUP) && (pbutton->GetActive()))
{
iNewTop = m_iTop - 1;
if (iNewTop >= 0)
{
m_iTop = iNewTop;
m_bUpdate = TRUE;
}
ScrollUp();
}
else if ((pbutton->GetID() == IDSCROLLDN) && (pbutton->GetActive()))
{
iNewTop = m_iTop + 1;
if (iNewTop <= m_vInfo.size()- m_iItemsMaxVis)
{
m_iTop = iNewTop;
m_bUpdate = TRUE;
}
ScrollDown();
}
if (m_bUpdate)

View File

@ -102,6 +102,7 @@ public:
virtual void ReleaseCapture() {;}
virtual void MouseMove(int x, int y, UINT keyFlags);
virtual BOOL MouseWheel(int x, int y, int zDelta, UINT keyFlags) { return FALSE; }
virtual BOOL LButtonDown(int x, int y, BOOL bDoubleClick, UINT keyFlags);
virtual BOOL LButtonUp(int x, int y, UINT keyFlags);
@ -211,6 +212,7 @@ public:
virtual BOOL LButtonDown(int x, int y, BOOL bDoubleClick, UINT keyFlags) override;
virtual BOOL LButtonUp(int x, int y, UINT keyFlags) override;
virtual BOOL MouseWheel(int x, int y, int zDelta, UINT keyFlags) override;
virtual BOOL TokenLoad(HANDLE hFile) override;
@ -305,6 +307,9 @@ private:
void Update();
BOOL InitSurface();
void ScrollUp();
void ScrollDown();
};