Merge pull request #7740 from Robyt3/UI-Mouse-Clamp

Fix mouse being outside of UI screen on right and bottom edges
This commit is contained in:
Dennis Felsing 2023-12-28 22:33:27 +00:00 committed by GitHub
commit ee2dd0ac1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -179,8 +179,8 @@ void CUI::OnCursorMove(float X, float Y)
{
if(!CheckMouseLock())
{
m_UpdatedMousePos.x = clamp(m_UpdatedMousePos.x + X, 0.0f, (float)Graphics()->WindowWidth());
m_UpdatedMousePos.y = clamp(m_UpdatedMousePos.y + Y, 0.0f, (float)Graphics()->WindowHeight());
m_UpdatedMousePos.x = clamp(m_UpdatedMousePos.x + X, 0.0f, Graphics()->WindowWidth() - 1.0f);
m_UpdatedMousePos.y = clamp(m_UpdatedMousePos.y + Y, 0.0f, Graphics()->WindowHeight() - 1.0f);
}
m_UpdatedMouseDelta += vec2(X, Y);

View file

@ -2978,7 +2978,7 @@ void CEditor::DoMapEditor(CUIRect View)
}
static void *s_pEditorID = (void *)&s_pEditorID;
const bool Inside = !m_GuiActive || UI()->MouseInside(&View);
const bool Inside = UI()->MouseInside(&View);
// fetch mouse position
float wx = UI()->MouseWorldX();
@ -8164,7 +8164,7 @@ void CEditor::Render()
m_PopupEventWasActivated = true;
}
if(m_Dialog == DIALOG_NONE && !UI()->IsPopupHovered() && (!m_GuiActive || UI()->MouseInside(&View)))
if(m_Dialog == DIALOG_NONE && !UI()->IsPopupHovered() && UI()->MouseInside(&View))
{
// handle zoom hotkeys
if(Input()->KeyPress(KEY_KP_MINUS))
@ -8472,8 +8472,8 @@ void CEditor::HandleCursorMovement()
if(!UI()->CheckMouseLock())
{
s_MouseX = clamp<float>(s_MouseX + MouseRelX, 0.0f, Graphics()->WindowWidth());
s_MouseY = clamp<float>(s_MouseY + MouseRelY, 0.0f, Graphics()->WindowHeight());
s_MouseX = clamp(s_MouseX + MouseRelX, 0.0f, Graphics()->WindowWidth() - 1.0f);
s_MouseY = clamp(s_MouseY + MouseRelY, 0.0f, Graphics()->WindowHeight() - 1.0f);
}
// update positions for ui, but only update ui when rendering