mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Take ClipEnable/Disable into account when checking mouse pos
This commit is contained in:
parent
d2365df927
commit
a30eff82a3
|
@ -1014,7 +1014,7 @@ int CMenus::DoKeyReader(CButtonContainer *pBC, const CUIRect *pRect, int Key)
|
|||
static const void *pGrabbedID = 0;
|
||||
static bool MouseReleased = true;
|
||||
static int ButtonUsed = 0;
|
||||
int Inside = UI()->MouseInside(pRect);
|
||||
int Inside = UI()->MouseInside(pRect) && UI()->MouseInsideClip();
|
||||
int NewKey = Key;
|
||||
|
||||
if(!UI()->MouseButton(0) && !UI()->MouseButton(1) && pGrabbedID == pBC->GetID())
|
||||
|
|
|
@ -17,6 +17,7 @@ CUI::CUI()
|
|||
m_pActiveItem = 0;
|
||||
m_pLastActiveItem = 0;
|
||||
m_pBecommingHotItem = 0;
|
||||
m_Clipped = false;
|
||||
|
||||
m_MouseX = 0;
|
||||
m_MouseY = 0;
|
||||
|
@ -53,6 +54,11 @@ int CUI::MouseInside(const CUIRect *r) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool CUI::MouseInsideClip() const
|
||||
{
|
||||
return !m_Clipped || MouseInside(&m_ClipRect) == 1;
|
||||
}
|
||||
|
||||
void CUI::ConvertMouseMove(float *x, float *y) const
|
||||
{
|
||||
float Fac = (float)(g_Config.m_UiMousesens)/g_Config.m_InpMousesens;
|
||||
|
@ -91,6 +97,8 @@ float CUIRect::Scale() const
|
|||
|
||||
void CUI::ClipEnable(const CUIRect *r)
|
||||
{
|
||||
m_ClipRect = *r;
|
||||
m_Clipped = true;
|
||||
float XScale = Graphics()->ScreenWidth()/Screen()->w;
|
||||
float YScale = Graphics()->ScreenHeight()/Screen()->h;
|
||||
Graphics()->ClipEnable((int)(r->x*XScale), (int)(r->y*YScale), (int)(r->w*XScale), (int)(r->h*YScale));
|
||||
|
@ -99,6 +107,8 @@ void CUI::ClipEnable(const CUIRect *r)
|
|||
void CUI::ClipDisable()
|
||||
{
|
||||
Graphics()->ClipDisable();
|
||||
m_ClipRect = {};
|
||||
m_Clipped = false;
|
||||
}
|
||||
|
||||
void CUIRect::HSplitMid(CUIRect *pTop, CUIRect *pBottom) const
|
||||
|
@ -273,6 +283,8 @@ int CUI::DoButtonLogic(const void *pID, const char *pText, int Checked, const CU
|
|||
// logic
|
||||
int ReturnValue = 0;
|
||||
int Inside = MouseInside(pRect);
|
||||
if(m_Clipped)
|
||||
Inside &= MouseInside(&m_ClipRect);
|
||||
static int ButtonUsed = 0;
|
||||
|
||||
if(CheckActiveItem(pID))
|
||||
|
|
|
@ -30,12 +30,14 @@ class CUI
|
|||
const void *m_pLastActiveItem;
|
||||
const void *m_pBecommingHotItem;
|
||||
bool m_ActiveItemValid;
|
||||
bool m_Clipped;
|
||||
float m_MouseX, m_MouseY; // in gui space
|
||||
float m_MouseWorldX, m_MouseWorldY; // in world space
|
||||
unsigned m_MouseButtons;
|
||||
unsigned m_LastMouseButtons;
|
||||
|
||||
CUIRect m_Screen;
|
||||
CUIRect m_ClipRect;
|
||||
class IGraphics *m_pGraphics;
|
||||
class ITextRender *m_pTextRender;
|
||||
|
||||
|
@ -101,6 +103,7 @@ public:
|
|||
void FinishCheck() { if(!m_ActiveItemValid) SetActiveItem(0); };
|
||||
|
||||
int MouseInside(const CUIRect *pRect) const;
|
||||
bool MouseInsideClip() const;
|
||||
void ConvertMouseMove(float *x, float *y) const;
|
||||
|
||||
CUIRect *Screen();
|
||||
|
|
Loading…
Reference in a new issue