CHANGED: #1471 CWidgetManager no longer depends on CViewPointer. Instead it depends on the new class CViewPointerBase.

--HG--
branch : gui-refactoring
This commit is contained in:
dfighter1985 2012-06-07 23:57:02 +02:00
parent 3c74576ba9
commit fbd1d5533c
17 changed files with 207 additions and 172 deletions

View file

@ -143,7 +143,7 @@ bool CContextualCursor::context(const std::string &contextName, float dist, cons
CInterfaceManager *IM = CInterfaceManager::getInstance();
if(IM)
{
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
{
if (!functions.isString)

View file

@ -239,7 +239,7 @@ void checkUnderCursor()
return;
// Get the cursor instance
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor == 0)
return;

View file

@ -124,7 +124,7 @@ bool InitMouseWithCursor (bool hardware)
{
Driver->showCursor(true);
CViewPointer *pointer = CWidgetManager::getInstance()->getPointer();
CViewPointer *pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if (pointer)
{
float x = (float)pointer->getX()/(float)Driver->getWindowWidth();
@ -145,7 +145,7 @@ bool InitMouseWithCursor (bool hardware)
else
{
CInterfaceManager *pIm = CInterfaceManager::getInstance();
CViewPointer *vp = CWidgetManager::getInstance()->getPointer();
CViewPointer *vp = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
Driver->showCursor(false);
SetMousePosFirstTime = false;
if (vp)
@ -247,7 +247,7 @@ void SetMouseFreeLook ()
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{
CViewPointer *pointer = CWidgetManager::getInstance()->getPointer();
CViewPointer *pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if (pointer)
pointer->show (false);
}
@ -281,7 +281,7 @@ void SetMouseCursor (bool updatePos)
if (instance)
{
// Get the cursor instance
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if (cursor)
{
sint32 ix, iy;
@ -319,7 +319,7 @@ void SetMouseCursor (bool updatePos)
if (instance)
{
// Get the cursor instance
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if (cursor)
{
cursor->setPointerPos(ix, iy);
@ -342,7 +342,7 @@ void SetMouseCursor (bool updatePos)
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{
CViewPointer *pointer = CWidgetManager::getInstance()->getPointer();
CViewPointer *pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if (pointer)
pointer->show (true);
}

View file

@ -2194,7 +2194,7 @@ void CGroupContainer::draw ()
// manage rollover
CViewPointer *mousePointer = CWidgetManager::getInstance()->getPointer();
CViewPointer *mousePointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if (mousePointer)
{
bool dontFade = false;
@ -3641,7 +3641,7 @@ void CGroupContainer::setOpenable(bool openable)
void CGroupContainer::rollOverAlphaUp()
{
CInterfaceManager *im = CInterfaceManager::getInstance();
CViewPointer *vp = CWidgetManager::getInstance()->getPointer();
CViewPointer *vp = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
float speed = im->getAlphaRolloverSpeed();
if (!isIn(vp->getX(), vp->getY()))
{

View file

@ -268,7 +268,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event)
{
CViewPointer &rIP = *CWidgetManager::getInstance()->getPointer();
CViewPointer &rIP = *static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
NLGUI::CEventDescriptorMouse eventDesc;

View file

@ -2481,7 +2481,7 @@ uint CInterfaceManager::getDepth (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentW
bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event)
{
bool handled= false;
CViewPointer *_Pointer = CWidgetManager::getInstance()->getPointer();
CViewPointer *_Pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if( event.getType() == NLGUI::CEventDescriptor::system )
{

View file

@ -361,7 +361,7 @@ void CViewBitmapCombo::draw()
&& my < py + (sint32) itemh)
{
overItem = true;
if (CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton)
if ( static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton)
{
textId = getTexId(_TexsPushedId, texIndex);
color = getCol(_ColPushed, texIndex);
@ -416,7 +416,7 @@ void CViewBitmapCombo::draw()
//
if (_CD.Unrolled.getBool())
{
if (overItem && CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton)
if (overItem && static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton)
{
textId = getTexId(_TexsId, selectedTexIndex);
color = getCol(_Col, selectedTexIndex);
@ -436,7 +436,7 @@ void CViewBitmapCombo::draw()
&& my < py + (sint32) itemh
)
{
if (CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton)
if ( static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton)
{
textId = getTexId(_TexsPushedId, selectedTexIndex);
color = getCol(_ColPushed, selectedTexIndex);

View file

@ -16,10 +16,7 @@
#include "stdpch.h"
#include "../input.h"
//
#include "view_pointer.h"
#include "interface_manager.h"
#include "nel/gui/view_renderer.h"
@ -45,12 +42,9 @@ NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "pointer");
// --------------------------------------------------------------------------------------------------------------------
CViewPointer::CViewPointer (const TCtorParam &param)
: CViewBase(param),
: CViewPointerBase(param),
_Buttons(NLMISC::noButton)
{
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
_PointerDown = false;
_PointerVisible = true;
_TxIdDefault = -2;
_TxIdMoveWindow = -2;
_TxIdResizeBRTL = -2;
@ -608,111 +602,6 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB)
// +++ SET +++
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::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 CViewPointer::setPointerDispPos (sint32 x, sint32 y)
{
setX (x);
setY (y);
updateCoords ();
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::resetPointerPos ()
{
_PointerOldX = _PointerX;
_PointerOldY = _PointerY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::setPointerDown (bool pd)
{
_PointerDown = pd;
if (_PointerDown == true)
{
_PointerDownX = _PointerX;
_PointerDownY = _PointerY;
}
if (_PointerDown == false)
_PointerDrag = false;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::setPointerDownString (const std::string &s)
{
_PointerDownString = s;
}
// +++ GET +++
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::getPointerPos (sint32 &x, sint32 &y)
{
x = _PointerX;
y = _PointerY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::getPointerDispPos (sint32 &x, sint32 &y)
{
x = getX();
y = getY();
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::getPointerOldPos (sint32 &x, sint32 &y)
{
x = _PointerOldX;
y = _PointerOldY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::getPointerDownPos (sint32 &x, sint32 &y)
{
x = _PointerDownX;
y = _PointerDownY;
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointer::getPointerDown ()
{
return _PointerDown;
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointer::getPointerDrag ()
{
return _PointerDrag;
}
// --------------------------------------------------------------------------------------------------------------------
std::string CViewPointer::getPointerDownString ()
{
return _PointerDownString;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::setStringMode (bool stringCursor)

View file

@ -21,7 +21,7 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
#include "view_base.h"
#include "view_pointer_base.h"
class CGroupContainer;
class CCtrlBase;
@ -33,35 +33,16 @@ class CCtrlBase;
* \date 2002
*/
class CViewPointer : public CViewBase
class CViewPointer : public CViewPointerBase
{
friend void SetMouseFreeLook ();
friend void SetMouseCursor (bool updateMousePos);
public:
DECLARE_UI_CLASS( CViewPointerBase )
CViewPointer (const TCtorParam &param);
bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
void draw ();
// 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;}
// Set cursor mode
void setStringMode (bool stringCursor);
bool getStringMode() const {return _StringMode;}
@ -135,18 +116,6 @@ private:
sint32 _OffsetX;
sint32 _OffsetY;
// (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 ?
NLMISC::TMouseButton _Buttons;
CGroupContainer *_LastHightLight;

View file

@ -0,0 +1,122 @@
#include "view_pointer_base.h"
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) :
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;
}

View file

@ -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 &param );
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

View file

@ -18,7 +18,7 @@
#include "interface_group.h"
#include "group_container.h"
#include "group_in_scene.h"
#include "view_pointer.h"
#include "view_pointer_base.h"
#include "group_editbox_base.h"
#include "ctrl_draggable.h"

View file

@ -27,7 +27,7 @@ class CInterfaceElement;
class CCtrlBase;
class CViewBase;
class CInterfaceGroup;
class CViewPointer;
class CViewPointerBase;
class IParser
{
@ -184,8 +184,8 @@ public:
float _DeltaTimeStopingContextHelp;
CViewPointer* getPointer(){ return _Pointer; }
void setPointer( CViewPointer *pointer ){ _Pointer = pointer; }
CViewPointerBase* getPointer(){ return _Pointer; }
void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; }
/**
* get the window under a spot
@ -278,7 +278,7 @@ private:
std::vector< SModalWndInfo > _ModalStack;
static std::string _CtrlLaunchingModalId;
NLMISC::CRefPtr< CCtrlBase > curContextHelp;
CViewPointer *_Pointer;
CViewPointerBase *_Pointer;
NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder;

View file

@ -1738,7 +1738,7 @@ bool mainLoop()
if(!CViewRenderer::getInstance()->isMinimized())
{
// Get the cursor instance
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
{
// Get the pointer position (in pixel)

View file

@ -150,7 +150,7 @@ void CUserControls::aiMode()
IM->enableMouseHandling(false);
EventsListener.enableMouseSmoothing(true);
// Get the cursor instance and hide.
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
{
// Freelook mode.

View file

@ -507,7 +507,7 @@ void CUserControls::freeLook(bool fullMode)
// disable interface mouse handling.
IM->enableMouseHandling(false);
// Get the cursor instance
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
{
// Hide the Cursor.
@ -590,7 +590,7 @@ void CUserControls::cameraLook(bool fullMode)
// disable interface mouse handling.
IM->enableMouseHandling(false);
// Get the cursor instance
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
{
// Hide the Cursor.

View file

@ -155,7 +155,7 @@ uint32 CTool::getScreenHeight()
void CTool::getMousePos(sint32 &x, sint32 &y)
{
//H_AUTO(R2_CTool_getMousePos)
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor == NULL)
{
x = y = -1;
@ -753,7 +753,7 @@ bool CTool::isMouseCaptured()
void CTool::setMouseCursor(const char *cursorTexture)
{
//H_AUTO(R2_CTool_setMouseCursor)
CViewPointer *cursor = CWidgetManager::getInstance()->getPointer();
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
{
cursor->setCursor(cursorTexture);