CHANGED: #1471 CWidgetManager no longer depends on CViewPointer. Instead it depends on the new class CViewPointerBase.
--HG-- branch : gui-refactoringhg/feature/sse2
parent
3c74576ba9
commit
fbd1d5533c
@ -0,0 +1,122 @@
|
||||
#include "view_pointer_base.h"
|
||||
|
||||
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam ¶m ) :
|
||||
CViewBase( param )
|
||||
{
|
||||
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
|
||||
_PointerDown = false;
|
||||
_PointerVisible = true;
|
||||
}
|
||||
|
||||
CViewPointerBase::~CViewPointerBase()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
|
||||
{
|
||||
if (_PointerDown)
|
||||
{
|
||||
if (!_PointerDrag)
|
||||
{
|
||||
if (((_PointerX - _PointerDownX) != 0) ||
|
||||
((_PointerY - _PointerDownY) != 0))
|
||||
{
|
||||
_PointerDrag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_PointerOldX = getX();
|
||||
_PointerOldY = getY();
|
||||
|
||||
_PointerX = x;
|
||||
_PointerY = y;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y)
|
||||
{
|
||||
setX (x);
|
||||
setY (y);
|
||||
updateCoords ();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::resetPointerPos ()
|
||||
{
|
||||
_PointerOldX = _PointerX;
|
||||
_PointerOldY = _PointerY;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerDown (bool pd)
|
||||
{
|
||||
_PointerDown = pd;
|
||||
|
||||
if (_PointerDown == true)
|
||||
{
|
||||
_PointerDownX = _PointerX;
|
||||
_PointerDownY = _PointerY;
|
||||
}
|
||||
|
||||
if (_PointerDown == false)
|
||||
_PointerDrag = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerDownString (const std::string &s)
|
||||
{
|
||||
_PointerDownString = s;
|
||||
}
|
||||
|
||||
// +++ GET +++
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerX;
|
||||
y = _PointerY;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = getX();
|
||||
y = getY();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerOldX;
|
||||
y = _PointerOldY;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerDownX;
|
||||
y = _PointerDownY;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
bool CViewPointerBase::getPointerDown ()
|
||||
{
|
||||
return _PointerDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
bool CViewPointerBase::getPointerDrag ()
|
||||
{
|
||||
return _PointerDrag;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
std::string CViewPointerBase::getPointerDownString ()
|
||||
{
|
||||
return _PointerDownString;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
#ifndef VIEW_POINTER_BASE_H
|
||||
#define VIEW_POINTER_BASE_H
|
||||
|
||||
#include "view_base.h"
|
||||
|
||||
class CViewPointerBase : public CViewBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CViewPointerBase )
|
||||
|
||||
CViewPointerBase( const TCtorParam ¶m );
|
||||
virtual ~CViewPointerBase();
|
||||
|
||||
// Set the pointer position.
|
||||
void setPointerPos (sint32 x, sint32 y);
|
||||
void setPointerDispPos (sint32 x, sint32 y);
|
||||
|
||||
void resetPointerPos ();
|
||||
void setPointerDown (bool pd);
|
||||
void setPointerDownString (const std::string &s);
|
||||
|
||||
void getPointerPos (sint32 &x, sint32 &y);
|
||||
void getPointerDispPos (sint32 &x, sint32 &y);
|
||||
|
||||
void getPointerOldPos (sint32 &x, sint32 &y);
|
||||
void getPointerDownPos (sint32 &x, sint32 &y);
|
||||
bool getPointerDown ();
|
||||
std::string getPointerDownString ();
|
||||
bool getPointerDrag ();
|
||||
|
||||
/// Is the pointer visible ?
|
||||
bool show() const {return _PointerVisible;}
|
||||
|
||||
void draw(){}
|
||||
|
||||
protected:
|
||||
// (x,y) is from the TopLeft corner of the window
|
||||
sint32 _PointerX; // Current pointer position (raw, before snapping)
|
||||
sint32 _PointerY;
|
||||
sint32 _PointerOldX; // Previous frame pointer position
|
||||
sint32 _PointerOldY;
|
||||
bool _PointerDown; // Is the pointer down ?
|
||||
sint32 _PointerDownX; // Pointer down position
|
||||
sint32 _PointerDownY;
|
||||
std::string _PointerDownString; // What is under the pointer at the down position
|
||||
bool _PointerDrag; // Is the pointer down and we have moved ?
|
||||
bool _PointerVisible; // Is the pointer visible or hidden ?
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue