Compare commits

...

13 Commits

Author SHA1 Message Date
Ian Brun
2c52f38fe8
Merge pull request #163 from meekee7/ce-controls-2
Control and menu improvements from CE
2021-04-03 23:33:27 +02:00
Ian Brun
89ee2be9b6
Merge pull request #164 from meekee7/override-errors
Fix override errors in Release/Final builds
2021-04-03 23:30:38 +02:00
Michael
52ef160f5c ctrls.cpp: remove variable in ScrollUp and ScrollDown 2021-04-03 19:27:41 +02:00
Michael
e1c7e53ef4 ctrls.cpp: cast to signed type to avoid implicit cast of subterm to unsigned type. This fixes the glitchy behavior when moving the scrollbar up. 2021-04-03 14:24:25 +02:00
Michael
9556230685 Ctrls: add mousewheel support to CUISlider 2021-04-03 01:51:09 +02:00
Michael
46ad924a5d Mainwnd: add mousewheel support 2021-04-03 01:15:32 +02:00
Michael
1c9bb0d57a UIWnd: add mousewheel support 2021-04-03 01:14:53 +02:00
Michael
498130ed0d Ctrls: add mousewheel support for CUIListBox
- extract ScrollUp and ScrollDown
2021-04-03 01:14:09 +02:00
Michael
c448e9785b mainwnd.cpp: forward MMB down messages 2021-04-02 23:59:29 +02:00
Michael
8e1860e8f8 Message.cpp: enable logging code in all build types so that overrides always work 2021-04-02 22:09:53 +02:00
Michael
0550c007ed Message.hpp: enable logging code in all build types so that overrides always work 2021-04-02 22:09:41 +02:00
Michael
21d07eef0d Magnet.hpp: enable VER_PARTITION_MAGNETS in all build types so that overrides always work 2021-04-02 22:08:49 +02:00
meekee7
5bf9934591
Merge pull request #36 from OpenTrespasser/dev
Merge upstream/dev into staging
2021-03-09 12:50:20 +01:00
9 changed files with 79 additions and 18 deletions

View File

@ -101,7 +101,7 @@
#if VER_LOG_MESSAGES
#if 1
//******************************************************************************************
void CMessage::WriteToLog() const

View File

@ -228,7 +228,7 @@ protected:
//**************************************
#if VER_LOG_MESSAGES
#if 1
//******************************************************************************************
//

View File

@ -38,7 +38,7 @@
#include <list>
#include "Lib/EntityDBase/PhysicsInfo.hpp"
#define VER_PARTITION_MAGNETS VER_TEST
#define VER_PARTITION_MAGNETS 1
enum EMagnetFlag // Used for flags in CMagnet
// Prefix: emf

View File

@ -843,7 +843,7 @@ void CUIListbox::DoFrame(POINT ptMouse)
iThumbHeight = (m_rc.bottom - m_rc.top) - (2 + (2 * m_iScrollWidth));
y = (ptMouse.y - m_rc.top) - (m_iScrollWidth + 1);
iNewTop = (int)((double)((y - m_iMouseFromTop) * m_vInfo.size()) / (double) iThumbHeight);
iNewTop = (int)((double)((y - m_iMouseFromTop) * (int) m_vInfo.size()) / (double) iThumbHeight);
if (iNewTop < 0)
{
iNewTop = 0;
@ -1069,28 +1069,42 @@ BOOL CUIListbox::LButtonUp(int x, int y, UINT keyFlags)
return TRUE;
}
void CUIListbox::ScrollUp()
{
if ((m_iTop - 1) >= 0)
{
m_iTop--;
m_bUpdate = TRUE;
}
}
void CUIListbox::ScrollDown()
{
if ((m_iTop + 1) <= (m_vInfo.size() - m_iItemsMaxVis))
{
m_iTop++;
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)
@ -2632,6 +2646,19 @@ BOOL CUISlider::LButtonUp(int x, int y, UINT keyFlags)
return TRUE;
}
BOOL CUISlider::MouseWheel(int x, int y, int zDelta, UINT keyFlags)
{
//zDeltas are multiples of 120, see WM_MOUSEWHEEL documentation
int scrollstep = static_cast<int>(std::round(static_cast<double>(m_iUnits) / 20));
int scrolldistance = scrollstep * (zDelta / 120);
m_iCurrUnit = std::clamp(m_iCurrUnit + scrolldistance, 0, m_iUnits);
m_pParent->UISliderChange(this, m_iCurrUnit);
m_pParent->CtrlInvalidateRect(&m_rc);
return TRUE;
}
BOOL CUISlider::TokenLoad(HANDLE hFile)
{
BOOL bRet;

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();
};
@ -437,6 +442,7 @@ public:
virtual void MouseMove(int x, int y, UINT keyFlags) override;
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;

View File

@ -70,6 +70,7 @@ public:
void OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags);
void OnChar(HWND hwnd, TCHAR ch, int cRepeat);
void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags);
void OnMouseWheel(HWND hwnd, int x, int y, int zDelta, UINT fwKeys);
void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags);
void OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags);
void OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags);

View File

@ -237,6 +237,11 @@ void CMainWnd::OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
}
}
void CMainWnd::OnMouseWheel(HWND hwnd, int x, int y, int zDelta, UINT fwKeys)
{
if (CUIWnd* puiwnd = m_pUIMgr->GetActiveUIWnd(); puiwnd && !puiwnd->m_bExitWnd)
puiwnd->OnMouseWheel(x, y, zDelta, fwKeys);
}
void CMainWnd::OnRButtonDown(HWND hwnd,
BOOL fDoubleClick,
@ -723,6 +728,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
HANDLE_MSG(hwnd, WM_KEYUP, g_pMainWnd->OnKey);
HANDLE_MSG(hwnd, WM_CHAR, g_pMainWnd->OnChar);
HANDLE_MSG(hwnd, WM_MOUSEMOVE, g_pMainWnd->OnMouseMove);
HANDLE_MSG(hwnd, WM_MOUSEWHEEL, g_pMainWnd->OnMouseWheel);
HANDLE_MSG(hwnd, WM_LBUTTONDOWN, g_pMainWnd->OnLButtonDown);
HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK, g_pMainWnd->OnLButtonDown);
HANDLE_MSG(hwnd, WM_LBUTTONUP, g_pMainWnd->OnLButtonUp);
@ -730,6 +736,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
HANDLE_MSG(hwnd, WM_ERASEBKGND, g_pMainWnd->OnEraseBkgnd);
HANDLE_MSG(hwnd, WM_RBUTTONDOWN, g_pMainWnd->OnRButtonDown);
HANDLE_MSG(hwnd, WM_RBUTTONDBLCLK, g_pMainWnd->OnRButtonDown);
HANDLE_MSG(hwnd, WM_MBUTTONDOWN, g_pMainWnd->OnMButtonDown);
HANDLE_MSG(hwnd, WM_TIMER, g_pMainWnd->OnTimer);
HANDLE_MSG(hwnd, WM_SYSCOMMAND, g_pMainWnd->OnSysCommand);
}

View File

@ -1000,6 +1000,25 @@ void CUIWnd::OnMouseMove(int x, int y, UINT keyFlags)
{
}
void CUIWnd::OnMouseWheel(int x, int y, int zDelta, UINT fwKeys)
{
if (m_vUICtrls.empty())
return;
for (auto i = m_vUICtrls.rbegin(); i != m_vUICtrls.rend() && *i; i++)
{
if (*i &&
(*i)->HitTest(m_pUIMgr->m_ptMouse.x, m_pUIMgr->m_ptMouse.y) &&
(*i)->MouseWheel(m_pUIMgr->m_ptMouse.x,
m_pUIMgr->m_ptMouse.y,
zDelta,
fwKeys))
{
return;
}
}
}
void CUIWnd::OnLButtonDown(BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
if (m_vUICtrls.size() == 0)

View File

@ -143,6 +143,7 @@ public:
virtual void OnKey(UINT vk, BOOL fDown, int cRepeat, UINT flags);
virtual void OnChar(TCHAR ch, int cRepeat);
virtual void OnMouseMove(int x, int y, UINT keyFlags);
virtual void OnMouseWheel(int x, int y, int zDelta, UINT fwKeys);
virtual void OnLButtonDown(BOOL fDoubleClick, int x, int y, UINT keyFlags);
virtual void OnLButtonUp(int x, int y, UINT keyFlags);
virtual void OnRButtonDown(BOOL fDoubleClick, int x, int y, UINT keyFlags);