CHANGED: #1471 CCtrlBaseButton is now part of the NELGUI Library.

--HG--
branch : gui-refactoring
This commit is contained in:
dfighter1985 2012-06-15 22:40:08 +02:00
parent a05fe020c3
commit dfb1f0ed37
24 changed files with 107 additions and 115 deletions

View file

@ -108,6 +108,9 @@ namespace NLGUI
void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") );
void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") );
// Submit a generic event
void submitEvent( const std::string &evt );
private:
CAHManager(){}
static CAHManager *_GlobalInstance;

View file

@ -292,6 +292,13 @@ namespace NLGUI
void removeOptions( std::string name );
void removeAllOptions();
// Enable mouse Events to interface. if false, release Captures.
void enableMouseHandling( bool handle );
bool isMouseHandlingEnabled() const{ return _MouseHandlingEnabled; }
// Get the User DblClick Delay (according to save...), in milisecond
uint getUserDblClickDelay();
static IParser *parser;
private:
@ -333,6 +340,8 @@ namespace NLGUI
NLMISC::CCDBNodeLeaf *_GProp;
NLMISC::CCDBNodeLeaf *_BProp;
NLMISC::CCDBNodeLeaf *_AProp;
bool _MouseHandlingEnabled;
};
}

View file

@ -276,6 +276,12 @@ namespace NLGUI
pAH->execute(NULL, event);
}
void CAHManager::submitEvent( const std::string &evt )
{
// Submit the event to the quick help system
runActionHandler( "submit_quick_help", NULL, evt );
}
// ------------------------------------------------------------------------------------------------
class CAHSet : public IActionHandler

View file

@ -15,15 +15,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "ctrl_base_button.h"
#include "interface_manager.h"
#include "nel/gui/ctrl_base_button.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../time_client.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/lua_ihm.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/db_manager.h"
using namespace std;
@ -205,9 +202,10 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
if (!_Active || _Frozen)
return false;
sint64 T1 = NLMISC::CTime::getLocalTime();
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
@ -227,7 +225,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
{
if (_AHOnLeftDblClick)
{
if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < pIM->getUserDblClickDelay())
if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay())
{
CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams);
_LeftDblClickHandled = true;
@ -308,7 +306,6 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
{
_LastLeftClickButton = NULL;
bool handled= false;
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (CWidgetManager::getInstance()->getCapturePointerRight() != this)
return false;
@ -338,11 +335,9 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
{
if (_AHOnClockTick != NULL)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams);
}
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
{
if (!_LeftLongClickHandled)
@ -445,8 +440,7 @@ void CCtrlBaseButton::unselect()
// ***************************************************************************
void CCtrlBaseButton::updateOver(bool &lastOver)
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
if (!pIM->isMouseHandlingEnabled())
if (!CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
_Over = false;
return;
@ -500,10 +494,9 @@ void CCtrlBaseButton::runLeftClickAction()
{
if(_AHOnLeftClick != NULL)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
//nlinfo("clicked on %s", _Id.c_str());
pIM->submitEvent ("button_click:"+getId());//TEMP
CAHManager::getInstance()->submitEvent( "button_click:" + getId() );
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
//pIM->submitEvent ("button_click:"+getId());
}

View file

@ -25,6 +25,12 @@
#include "nel/gui/group_editbox_base.h"
#include "nel/gui/interface_options.h"
namespace
{
const uint DOUBLE_CLICK_MIN = 50;
const uint DOUBLE_CLICK_MAX = 750;
}
namespace NLGUI
{
@ -1379,6 +1385,43 @@ namespace NLGUI
_OptionsMap.clear();
}
// ***************************************************************************
void CWidgetManager::enableMouseHandling( bool handle )
{
_MouseHandlingEnabled = handle;
if(!handle)
{
if(!getPointer())
return;
// If Left captured, reset
if( getCapturePointerLeft() )
setCapturePointerLeft( NULL );
// Same for Right
if( getCapturePointerRight() )
setCapturePointerRight( NULL );
// Avoid any problem with modals
disableModalWindow();
}
}
// ***************************************************************************
uint CWidgetManager::getUserDblClickDelay()
{
uint nVal = 50;
NLMISC::CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED");
if( pNL != NULL )
nVal = pNL->getValue32();
uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f);
return dbclickDelay;
}
CWidgetManager::CWidgetManager()
{
_Pointer = NULL;
@ -1389,6 +1432,8 @@ namespace NLGUI
_GlobalColor = NLMISC::CRGBA(255,255,255,255);
_GlobalColorForContent = _GlobalColor;
_ContentAlpha = 255;
_MouseHandlingEnabled = true;
}
CWidgetManager::~CWidgetManager()

View file

@ -88,7 +88,7 @@
#include "actions_client.h"
#include "attack_list.h"
#include "interface_v3/player_trade.h"
#include "interface_v3/ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
#include "weather.h"
#include "forage_source_cl.h"
#include "connection.h"

View file

@ -40,7 +40,7 @@
#include "macrocmd_manager.h"
#include "inventory_manager.h"
#include "ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
#include "../connection.h"
#include "view_bitmap.h"

View file

@ -32,7 +32,7 @@ using namespace NLMISC;
#include "../entities.h"
#include "interface_manager.h"
#include "action_handler_tools.h"
#include "ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
////////////
// GLOBAL //

View file

@ -1152,7 +1152,7 @@ public:
// **** Cyclic Cast? (dblclick)
bool cyclic;
// Manage "DblHit"
uint dbclickDelay = pIM->getUserDblClickDelay();
uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay();
// if success to "dblclick"
if(LastIndex==(sint)memoryIndex && T1<=LastHitTime+dbclickDelay )
cyclic= true;

View file

@ -24,7 +24,7 @@
#include "inventory_manager.h"
#include "nel/gui/action_handler.h"
#include "../client_cfg.h"
#include "ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
#include "group_container.h"
#include "../string_manager_client.h"
#include "../net_manager.h"

View file

@ -19,7 +19,7 @@
#ifndef RZ_CTRL_BUTTON_H
#define RZ_CTRL_BUTTON_H
#include "ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI

View file

@ -19,7 +19,7 @@
#ifndef NL_CTRL_TEXT_BUTTON_H
#define NL_CTRL_TEXT_BUTTON_H
#include "ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"

View file

@ -919,7 +919,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event)
{
if (_WaitToOpenClose)
{
uint dbclickDelay = pIM->getUserDblClickDelay();
uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay();
if ((T1 - _WaitToOpenCloseDate) > dbclickDelay)
{
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(_Parent);
@ -3203,7 +3203,7 @@ void CGroupContainer::setActive (bool state)
else
CWidgetManager::getInstance()->setBackWindow(this);
}
pIM->submitEvent((state?"show:":"hide:")+getId());
CAHManager::getInstance()->submitEvent((state?"show:":"hide:")+getId());
CInterfaceGroup::setActive(state);
}

View file

@ -798,7 +798,7 @@ bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event)
if (_Blinking)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
uint dbclickDelay = pIM->getUserDblClickDelay();
uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay();
if ((T1 - _BlinkDate) > dbclickDelay)
{
if (_BlinkState)

View file

@ -566,7 +566,7 @@ void CGroupTree::draw()
// change the over
bool bDisplayOver = true;
if (!pIM->isMouseHandlingEnabled())
if (!CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
bDisplayOver = false;
}

View file

@ -258,7 +258,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event)
}
}
// **** Event Mouse
else if(CWidgetManager::getInstance()->getPointer() && _Focus /* && pIM->isMouseHandlingEnabled() */ &&
else if(CWidgetManager::getInstance()->getPointer() && _Focus /* && CWidgetManager::getInstance()->isMouseHandlingEnabled() */ &&
( event == EventMouseMoveId ||
event == EventMouseDownId ||
event == EventMouseUpId ||
@ -282,7 +282,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event)
// button down ?
static volatile bool doTest = false;
if (!doTest || (doTest && pIM->isMouseHandlingEnabled()))
if (!doTest || (doTest && CWidgetManager::getInstance()->isMouseHandlingEnabled()))
{
if (event==EventMouseDownId)
{

View file

@ -182,10 +182,6 @@ CChatDisplayer * ChatDisplayer = NULL;
void initActions();
void uninitActions();
// ------------------------------------------------------------------------------------------------
static const uint DOUBLE_CLICK_MIN = 50;
static const uint DOUBLE_CLICK_MAX = 750;
///\todo nico: remove this dummy displayer
NLMISC::CLog g_log;
@ -278,7 +274,6 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext
_GlobalRolloverFactorContent = 255;
_GlobalRolloverFactorContainer = 255;
_MouseOverWindow= false;
_MouseHandlingEnabled= true;
_ConfigLoaded = false;
_LogState = false;
_KeysLoaded = false;
@ -2610,7 +2605,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event)
eventDesc.setX( _Pointer->getX() );
eventDesc.setY( _Pointer->getY() );
if( _MouseHandlingEnabled )
if( CWidgetManager::getInstance()->isMouseHandlingEnabled() )
{
// First thing to do : Capture handling
if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL)
@ -3493,32 +3488,6 @@ void CInterfaceManager::disableContextHelpForControl(CCtrlBase *pCtrl)
disableContextHelp();
}
// ***************************************************************************
void CInterfaceManager::enableMouseHandling(bool handle)
{
_MouseHandlingEnabled= handle;
if(!handle)
{
if(!CWidgetManager::getInstance()->getPointer())
return;
// If Left captured, reset
if( CWidgetManager::getInstance()->getCapturePointerLeft() )
{
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
}
// Same for Right
if( CWidgetManager::getInstance()->getCapturePointerRight() )
{
CWidgetManager::getInstance()->setCapturePointerRight(NULL);
}
// Avoid any problem with modals
CWidgetManager::getInstance()->disableModalWindow();
}
}
// ***************************************************************************
void CInterfaceManager::displayDebugInfo(const ucstring &str, TSystemInfoMode mode /*=InfoMsg*/)
@ -4039,26 +4008,6 @@ void CInterfaceManager::restoreAllContainersBackupPosition()
}
}
// ***************************************************************************
uint CInterfaceManager::getUserDblClickDelay()
{
uint nVal = 50;
CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED");
if (pNL != NULL)
nVal = pNL->getValue32();
uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f);
return dbclickDelay;
}
// ***************************************************************************
void CInterfaceManager::submitEvent (const std::string &event)
{
// Submit the event to the quick help system
CAHManager::getInstance()->runActionHandler("submit_quick_help", NULL, event);
}
// ***************************************************************************
void CInterfaceManager::visit(CInterfaceElementVisitor *visitor)
{

View file

@ -387,10 +387,6 @@ public:
bool isMouseOverWindow() const {return _MouseOverWindow;}
// Enable mouse Events to interface. if false, release Captures.
void enableMouseHandling(bool handle);
bool isMouseHandlingEnabled() const { return _MouseHandlingEnabled; }
// Modes
void setMode(uint8 newMode);
uint8 getMode() const { return _CurrentMode; }
@ -414,12 +410,6 @@ public:
void displayUICtrlBBoxs(const std::string &uiFilter);
void displayUIGroupBBoxs(const std::string &uiFilter);
// Get the User DblClick Delay (according to save...), in milisecond
uint getUserDblClickDelay();
// Submit a generic event
void submitEvent (const std::string &event);
// visit all elements of the interface manager
void visit(CInterfaceElementVisitor *visitor);
@ -743,9 +733,6 @@ private:
// System Options
CInterfaceOptionValue _SystemOptions[NumSystemOptions];
bool _MouseHandlingEnabled;
// Modes
CInterfaceConfig::CDesktopImage _Modes[MAX_NUM_MODES];
uint8 _CurrentMode;

View file

@ -199,7 +199,7 @@ void CViewPointer::draw ()
_LastHightLight = NULL;
}
if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && pIM->isMouseHandlingEnabled())
if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
CCtrlMover *pCM = dynamic_cast<CCtrlMover*>( CWidgetManager::getInstance()->getCapturePointerLeft());
if ((pCM != NULL) && (pCM->canMove() == true))
@ -308,7 +308,7 @@ void CViewPointer::draw ()
}
// Draw the cursor type that are under the pointer
if (pIM->isMouseHandlingEnabled())
if (CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
// Sorts the controls according to their depth, to approximate as best the CapturePointerLeft algo.
// Especially important so that Resizers controls get the precedence over the move control (else could randomly bug like in chat group)
@ -363,7 +363,7 @@ void CViewPointer::draw ()
}
}
if (pIM->isMouseHandlingEnabled())
if (CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
if (rICL.empty())
{
@ -381,7 +381,7 @@ void CViewPointer::draw ()
}
}
if (_StringMode && pIM->isMouseHandlingEnabled())
if (_StringMode && CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor;
if (stringCursor)

View file

@ -99,7 +99,7 @@ void CUserControls::aiMode()
}
if( EventsListener.isMouseButtonReleased (leftButton) )
{
if(T1 <= _LeftClickEnd+IM->getUserDblClickDelay())
if(T1 <= _LeftClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay())
{
dblClickLeft = true;
}
@ -114,7 +114,7 @@ void CUserControls::aiMode()
}
if( EventsListener.isMouseButtonReleased (rightButton) )
{
if(T1 <= _RightClickEnd+IM->getUserDblClickDelay())
if(T1 <= _RightClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay())
{
dblClickRight = true;
}
@ -141,13 +141,13 @@ void CUserControls::aiMode()
}
// Give back the mouse handling to the interface.
IM->enableMouseHandling(true);
CWidgetManager::getInstance()->enableMouseHandling(true);
}
else if (EventsListener.isMouseButtonDown (rightButton))
{
if((T1-_RightClickStart) > _TimeLongClick)
{
IM->enableMouseHandling(false);
CWidgetManager::getInstance()->enableMouseHandling(false);
EventsListener.enableMouseSmoothing(true);
// Get the cursor instance and hide.
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );

View file

@ -505,7 +505,7 @@ void CUserControls::freeLook(bool fullMode)
// FREE LOOK : Hide the cursor
// disable interface mouse handling.
IM->enableMouseHandling(false);
CWidgetManager::getInstance()->enableMouseHandling(false);
// Get the cursor instance
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
@ -588,7 +588,7 @@ void CUserControls::cameraLook(bool fullMode)
// CAMERA LOOK : Hide the cursor
// disable interface mouse handling.
IM->enableMouseHandling(false);
CWidgetManager::getInstance()->enableMouseHandling(false);
// Get the cursor instance
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
if(cursor)
@ -747,7 +747,7 @@ void CUserControls::commonMove()
}
if( EventsListener.isMouseButtonReleased (leftButton) )
{
if(T1 <= _LeftClickEnd+IM->getUserDblClickDelay())
if(T1 <= _LeftClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay())
{
dblClickLeft = true;
}
@ -762,7 +762,7 @@ void CUserControls::commonMove()
}
if( EventsListener.isMouseButtonReleased (rightButton) )
{
if(T1 <= _RightClickEnd+IM->getUserDblClickDelay())
if(T1 <= _RightClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay())
{
dblClickRight = true;
}
@ -814,7 +814,7 @@ void CUserControls::commonMove()
// Give back the mouse handling to the interface.
IM->enableMouseHandling(true);
CWidgetManager::getInstance()->enableMouseHandling(true);
EventsListener.enableMouseSmoothing(false);
}
@ -831,7 +831,7 @@ void CUserControls::commonMove()
}
// Give back the mouse handling to the interface.
IM->enableMouseHandling(true);
CWidgetManager::getInstance()->enableMouseHandling(true);
EventsListener.enableMouseSmoothing(false);
}
@ -1313,7 +1313,7 @@ void CUserControls::stopFreeLook()
// Cursor mode
SetMouseCursor ();
// Give back the mouse handling to the interface.
CInterfaceManager::getInstance()->enableMouseHandling(true);
CWidgetManager::getInstance()->enableMouseHandling(true);
}

View file

@ -93,7 +93,7 @@ bool CTool::checkDoubleClick()
{
//H_AUTO(R2_CTool_checkDoubleClick)
if (_DoubleClickStartTime == -1) return false;
if (T0 - _DoubleClickStartTime >= getUI().getUserDblClickDelay()) return false;
if (T0 - _DoubleClickStartTime >= CWidgetManager::getInstance()->getUserDblClickDelay()) return false;
sint32 mx, my;
getMousePos(mx, my);
const sint32 moveThrehsold = 2;
@ -725,7 +725,7 @@ void CTool::captureMouse()
else
{
UserControls.captureMouse();
getUI().enableMouseHandling(false);
CWidgetManager::getInstance()->enableMouseHandling(false);
}
getUI().setContextHelpActive(false);
_MouseCaptured = true;
@ -737,7 +737,7 @@ void CTool::releaseMouse()
//H_AUTO(R2_CTool_releaseMouse)
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
UserControls.releaseMouse();
getUI().enableMouseHandling(true);
CWidgetManager::getInstance()->enableMouseHandling(true);
getUI().setContextHelpActive(true);
_MouseCaptured = false;
}

View file

@ -36,7 +36,7 @@
#include "verbose_clock.h"
#include "entity_sorter.h"
//
#include "../interface_v3/ctrl_base_button.h"
#include "nel/gui/ctrl_base_button.h"
//
#include "game_share/player_visual_properties.h"
#include "game_share/visual_slot_manager.h"