|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
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 ();
|
|
|
|
|
auto pos = getAdjustedPos(left, top);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|