mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Merge branch 'no_hitting' into 'master'
Don't perform a hit test outside the page's bounds Closes #5923 See merge request OpenMW/openmw!710
This commit is contained in:
commit
b79f26380b
@ -115,6 +115,7 @@
|
||||
Bug #5906: Sunglare doesn't work with Mesa drivers and AMD GPUs
|
||||
Bug #5912: ImprovedBound mod doesn't work
|
||||
Bug #5914: BM: The Swimmer can't reach destination
|
||||
Bug #5923: Clicking on empty spaces between journal entries might show random topics
|
||||
Bug #5934: AddItem command doesn't accept negative values
|
||||
Feature #390: 3rd person look "over the shoulder"
|
||||
Feature #832: OpenMW-CS: Handle deleted references
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "bookpage.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "MyGUI_RenderItem.h"
|
||||
#include "MyGUI_RenderManager.h"
|
||||
#include "MyGUI_TextureUtility.h"
|
||||
@ -894,6 +896,27 @@ protected:
|
||||
return mIsPageReset || (mPage != page);
|
||||
}
|
||||
|
||||
std::optional<MyGUI::IntPoint> getAdjustedPos(int left, int top, bool move = false)
|
||||
{
|
||||
if (!mBook)
|
||||
return {};
|
||||
|
||||
if (mPage >= mBook->mPages.size())
|
||||
return {};
|
||||
|
||||
MyGUI::IntPoint pos (left, top);
|
||||
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
|
||||
// work around inconsistency in MyGUI where the mouse press coordinates aren't
|
||||
// transformed by the current Layer (even though mouse *move* events are).
|
||||
if(!move)
|
||||
pos = mNode->getLayer()->getPosition(left, top);
|
||||
#endif
|
||||
pos.left -= mCroppedParent->getAbsoluteLeft ();
|
||||
pos.top -= mCroppedParent->getAbsoluteTop ();
|
||||
pos.top += mViewTop;
|
||||
return pos;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
typedef TypesetBookImpl::StyleImpl Style;
|
||||
@ -952,16 +975,10 @@ public:
|
||||
|
||||
void onMouseMove (int left, int top)
|
||||
{
|
||||
if (!mBook)
|
||||
return;
|
||||
|
||||
if (mPage >= mBook->mPages.size())
|
||||
return;
|
||||
|
||||
left -= mCroppedParent->getAbsoluteLeft ();
|
||||
top -= mCroppedParent->getAbsoluteTop ();
|
||||
|
||||
Style * hit = mBook->hitTestWithMargin (left, mViewTop + top);
|
||||
Style * hit = nullptr;
|
||||
if(auto pos = getAdjustedPos(left, top, true))
|
||||
if(pos->top <= mViewBottom)
|
||||
hit = mBook->hitTestWithMargin (pos->left, pos->top);
|
||||
|
||||
if (mLastDown == MyGUI::MouseButton::None)
|
||||
{
|
||||
@ -991,24 +1008,11 @@ public:
|
||||
|
||||
void onMouseButtonPressed (int left, int top, MyGUI::MouseButton id)
|
||||
{
|
||||
if (!mBook)
|
||||
return;
|
||||
auto pos = getAdjustedPos(left, top);
|
||||
|
||||
if (mPage >= mBook->mPages.size())
|
||||
return;
|
||||
|
||||
// work around inconsistency in MyGUI where the mouse press coordinates aren't
|
||||
// transformed by the current Layer (even though mouse *move* events are).
|
||||
MyGUI::IntPoint pos (left, top);
|
||||
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
|
||||
pos = mNode->getLayer()->getPosition(left, top);
|
||||
#endif
|
||||
pos.left -= mCroppedParent->getAbsoluteLeft ();
|
||||
pos.top -= mCroppedParent->getAbsoluteTop ();
|
||||
|
||||
if (mLastDown == MyGUI::MouseButton::None)
|
||||
if (pos && mLastDown == MyGUI::MouseButton::None)
|
||||
{
|
||||
mFocusItem = mBook->hitTestWithMargin (pos.left, mViewTop + pos.top);
|
||||
mFocusItem = pos->top <= mViewBottom ? mBook->hitTestWithMargin (pos->left, pos->top) : nullptr;
|
||||
mItemActive = true;
|
||||
|
||||
dirtyFocusItem ();
|
||||
@ -1019,25 +1023,11 @@ public:
|
||||
|
||||
void onMouseButtonReleased(int left, int top, MyGUI::MouseButton id)
|
||||
{
|
||||
if (!mBook)
|
||||
return;
|
||||
auto pos = getAdjustedPos(left, top);
|
||||
|
||||
if (mPage >= mBook->mPages.size())
|
||||
return;
|
||||
|
||||
// work around inconsistency in MyGUI where the mouse release coordinates aren't
|
||||
// transformed by the current Layer (even though mouse *move* events are).
|
||||
MyGUI::IntPoint pos (left, top);
|
||||
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
|
||||
pos = mNode->getLayer()->getPosition(left, top);
|
||||
#endif
|
||||
|
||||
pos.left -= mCroppedParent->getAbsoluteLeft ();
|
||||
pos.top -= mCroppedParent->getAbsoluteTop ();
|
||||
|
||||
if (mLastDown == id)
|
||||
if (pos && mLastDown == id)
|
||||
{
|
||||
Style * item = mBook->hitTestWithMargin (pos.left, mViewTop + pos.top);
|
||||
Style * item = pos->top <= mViewBottom ? mBook->hitTestWithMargin (pos->left, pos->top) : nullptr;
|
||||
|
||||
bool clicked = mFocusItem == item;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user