Pressing shift makes slider move slower (fixes #455)

This commit is contained in:
def 2016-05-03 15:11:52 +02:00
parent a954241169
commit bad26a3a8a
2 changed files with 20 additions and 2 deletions

View file

@ -72,6 +72,7 @@ CMenus::CMenus()
m_NeedSendDummyinfo = false;
m_MenuActive = true;
m_UseMouseButtons = true;
m_MouseSlow = false;
m_EscapePressed = false;
m_EnterPressed = false;
@ -432,6 +433,9 @@ float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current)
if(!UI()->MouseButton(0))
UI()->SetActiveItem(0);
if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT))
m_MouseSlow = true;
float Min = pRect->y;
float Max = pRect->h-Handle.h;
float Cur = UI()->MouseY()-OffsetY;
@ -488,6 +492,9 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current)
if(!UI()->MouseButton(0))
UI()->SetActiveItem(0);
if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT))
m_MouseSlow = true;
float Min = pRect->x;
float Max = pRect->w-Handle.w;
float Cur = UI()->MouseX()-OffsetX;
@ -917,6 +924,8 @@ int CMenus::Render()
CUIRect Screen = *UI()->Screen();
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
m_MouseSlow = false;
static bool s_First = true;
if(s_First)
{
@ -1679,8 +1688,16 @@ bool CMenus::OnMouseMove(float x, float y)
m_MousePos.y = y;
#else
UI()->ConvertMouseMove(&x, &y);
m_MousePos.x += x;
m_MousePos.y += y;
if(m_MouseSlow)
{
m_MousePos.x += x * 0.05f;
m_MousePos.y += y * 0.05f;
}
else
{
m_MousePos.x += x;
m_MousePos.y += y;
}
#endif
if(m_MousePos.x < 0) m_MousePos.x = 0;
if(m_MousePos.y < 0) m_MousePos.y = 0;

View file

@ -98,6 +98,7 @@ class CMenus : public CComponent
bool m_MenuActive;
bool m_UseMouseButtons;
vec2 m_MousePos;
bool m_MouseSlow;
int64 m_LastInput;