CHANGED: #1471 The classes moved in the previous commit are now under the NLGUI namespace.

--HG--
branch : gui-refactoring
This commit is contained in:
dfighter1985 2012-06-09 03:57:40 +02:00
parent 56a75a90ab
commit c792abe091
44 changed files with 8337 additions and 8074 deletions

View file

@ -24,18 +24,21 @@
#include "nel/misc/xml_auto_ptr.h"
#include <map>
/**
namespace NLGUI
{
class CCtrlBase;
/**
* interface for action handlers
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCtrlBase;
class IActionHandler
{
public:
class IActionHandler
{
public:
// Execute the answer to the action
// Params has the following form : paramName=theParam|paramName2=theParam2|...
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { }
@ -45,16 +48,16 @@ public:
static std::string getParam (const std::string &Params, const std::string &ParamName);
static void getAllParams (const std::string &Params, std::vector< std::pair<std::string,std::string> > &AllParams);
};
};
/**
/**
interface for action handlers factory
no release in this factory : a handler must be destroyed by the control that created it
*/
class CAHManager
{
public:
class CAHManager
{
public:
typedef std::map< std::string, IActionHandler* > TFactoryMap;
typedef std::map< IActionHandler*, std::string > TNameMap;
@ -105,17 +108,17 @@ public:
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("") );
private:
private:
CAHManager(){}
static CAHManager *_GlobalInstance;
};
};
/// Ah name must all be lower case
#define REGISTER_ACTION_HANDLER(handler ,name) \
class handler##Factory : public handler \
{ \
public: \
/// Ah name must all be lower case
#define REGISTER_ACTION_HANDLER(handler ,name) \
class handler##Factory : public handler \
{ \
public: \
handler##Factory () \
{ \
nlassert(name!=NULL); \
@ -129,8 +132,11 @@ public:
pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \
pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \
}; \
}; \
}; \
handler##Factory handler##FactoryInstance ; \
\
}
#endif //NL_ACTION_HANDLER_H

View file

@ -23,9 +23,11 @@
#include "nel/gui/view_base.h"
#include "nel/gui/event_descriptor.h"
class CCtrlBase : public CViewBase
namespace NLGUI
{
public:
class CCtrlBase : public CViewBase
{
public:
// Tooltip mode
enum TToolTipParentType
@ -38,7 +40,7 @@ public:
NumToolTipParentRef
};
public:
public:
/// Constructor
CCtrlBase(const TCtorParam &param) : CViewBase(param)
@ -142,7 +144,7 @@ public:
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
virtual void serial(NLMISC::IStream &f);
protected:
protected:
// This is the ContextHelp filled by default in parse()
ucstring _ContextHelp;
CStringShared _OnContextHelp;
@ -154,10 +156,11 @@ protected:
THotSpot _ToolTipPosRef : 6;
THotSpot _ToolTipParentPosRefAlt : 6;
THotSpot _ToolTipPosRefAlt : 6;
protected:
protected:
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
};
};
}
#endif // RZ_VIEW_BASE_H

View file

@ -1,11 +1,31 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CTRL_DRAGGABLE_H
#define CTRL_DRAGGABLE_H
#include "nel/gui/ctrl_base.h"
class CCtrlDraggable : public CCtrlBase
namespace NLGUI
{
public:
class CCtrlDraggable : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlDraggable )
CCtrlDraggable( const TCtorParam &param );
@ -30,13 +50,15 @@ public:
REFLECT_BOOL("dragable", isDraggable, setDraggable);
REFLECT_EXPORT_END
protected:
protected:
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
private:
private:
static CCtrlDraggable *_LastDraggedSheet;
bool dragged;
bool draggable;
};
};
}
#endif

View file

@ -19,11 +19,14 @@
#include "nel/gui/ctrl_base.h"
class CInterfaceGroup;
class CCtrlScrollBase : public CCtrlBase
namespace NLGUI
{
public:
class CInterfaceGroup;
class CCtrlScrollBase : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlScrollBase )
CCtrlScrollBase( const TCtorParam &param );
@ -44,12 +47,14 @@ public:
// Necessary because of reflection, no other purpose
void draw(){}
protected:
protected:
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
private:
private:
};
};
}
#endif

View file

@ -20,10 +20,12 @@
#include "nel/gui/interface_group.h"
class CGroupContainerBase : public CInterfaceGroup
namespace NLGUI
{
public:
class CGroupContainerBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupContainerBase )
CGroupContainerBase( const TCtorParam &param );
@ -74,7 +76,7 @@ public:
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
REFLECT_EXPORT_END
protected:
protected:
void triggerAlphaSettingsChangedAH();
uint8 _ContainerAlpha;
@ -87,8 +89,13 @@ protected:
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
private:
private:
};
}
};
#endif

View file

@ -20,9 +20,12 @@
#include "nel/gui/interface_group.h"
class CGroupEditBoxBase : public CInterfaceGroup
namespace NLGUI
{
public:
class CGroupEditBoxBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupEditBoxBase )
CGroupEditBoxBase( const TCtorParam &param );
@ -48,7 +51,7 @@ public:
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
REFLECT_EXPORT_END
protected:
protected:
bool _RecoverFocusOnEnter : 1;
std::string _AHOnFocus;
@ -56,9 +59,11 @@ protected:
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
private:
private:
};
};
}
#endif

View file

@ -23,15 +23,19 @@
#include "nel/gui/interface_group.h"
// ***************************************************************************
/** A Group with a background and a frame displayed
namespace NLGUI
{
// ***************************************************************************
/** A Group with a background and a frame displayed
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupFrame : public CInterfaceGroup
{
public:
class CGroupFrame : public CInterfaceGroup
{
public:
/// Constructor
CGroupFrame(const TCtorParam &param);
@ -52,8 +56,8 @@ public:
static void resetDisplayTypes() { _DispTypes.clear(); }
// ******************
protected:
// ******************
protected:
bool _DisplayFrame;
@ -98,8 +102,9 @@ protected:
}
};
static std::vector<SDisplayType> _DispTypes;
};
};
}
#endif // NL_GROUP_FRAME_H

View file

@ -22,17 +22,19 @@
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
namespace NLGUI
{
// ***************************************************************************
/**
// ***************************************************************************
/**
* A group with special modal options
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupModal : public CGroupFrame
{
public:
class CGroupModal : public CGroupFrame
{
public:
bool SpawnOnMousePos : 1;
bool ExitClickOut : 1;
bool ExitClickL : 1;
@ -46,7 +48,7 @@ public:
std::string OnClickOutParams;
std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured
std::string OnPostClickOutParams;
public:
public:
/// Constructor
CGroupModal(const TCtorParam &param);
@ -59,11 +61,12 @@ public:
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
REFLECT_EXPORT_END
// ******************
protected:
// ******************
protected:
sint32 _MouseDeltaX, _MouseDeltaY;
};
};
}
#endif // NL_GROUP_MODAL_H

View file

@ -27,16 +27,20 @@
#include "nel/gui/reflect.h"
#include "nel/gui/interface_common.h"
using namespace NLGUI;
class CGroupList;
class CGroupParagraph;
class CInterfaceLink;
class CInterfaceElement;
class CInterfaceGroup;
class CViewBase;
class CCtrlBase;
class IActionHandler;
namespace NLGUI
{
/**
class CInterfaceLink;
class CInterfaceElement;
class CInterfaceGroup;
class CViewBase;
class CCtrlBase;
class IActionHandler;
/**
* A visitor to walk a tree of interface elements and apply a teartment on them.
*
* For each vsited element, visitElement() is called
@ -48,25 +52,25 @@ class IActionHandler;
* \author Nevrax France
* \date 2003
*/
class CInterfaceElementVisitor
{
public:
class CInterfaceElementVisitor
{
public:
virtual void visit(CInterfaceElement * /* elem */) {}
virtual void visitGroup(CInterfaceGroup * /* group */) {}
virtual void visitView(CViewBase * /* view */) {}
virtual void visitCtrl(CCtrlBase * /* ctrl */) {}
};
};
/**
/**
* class describing a localisable interface element, i.e. : an element with coordinates
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
{
public:
class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
{
public:
enum EStrech
@ -454,7 +458,7 @@ public:
return "";
}
protected:
protected:
///the parent
CInterfaceGroup* _Parent;
@ -492,8 +496,8 @@ protected:
NLMISC::CRefPtr<CInterfaceElement> _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it
// Friend Class
friend class CGroupList;
friend class CGroupParagraph;
friend class ::CGroupList;
friend class ::CGroupParagraph;
// True if must modulate the global color with the view
bool _ModulateGlobalColor;
@ -509,25 +513,25 @@ protected:
void parseSizeRef(const char *sizeRef);
void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH);
private:
private:
//void snapSize();
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
TLinkVect *_Links; // links, or NULL if no link
};
};
extern NLMISC::CStringMapper *_UIStringMapper;
/**
extern NLMISC::CStringMapper *_UIStringMapper;
/**
* class to compress string usage in the interface
* \author Matthieu 'Trap' Besson
* \author Nevrax France
* \date October 2003
*/
class CStringShared
{
class CStringShared
{
public:
public:
CStringShared()
{
_Id = NLMISC::CStringMapper::emptyId();
@ -582,15 +586,19 @@ public:
}
}
private:
private:
NLMISC::TStringId _Id;
};
};
inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }
inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); }
inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }
inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); }
}
using namespace NLGUI;
#endif // NL_INTERFACE_ELEMENT_H
/* End of interface_element.h */

View file

@ -22,10 +22,12 @@
#include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h"
// ----------------------------------------------------------------------------
class CInterfaceGroup : public CCtrlBase
namespace NLGUI
{
public:
class CInterfaceGroup : public CCtrlBase
{
public:
DECLARE_UI_CLASS(CInterfaceGroup)
/// Constructor
@ -309,7 +311,7 @@ public:
// Return the current Depth, with no ZBias applied.
float getDepthForZSort() const { return _DepthForZSort; }
protected:
protected:
void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH);
void restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH);
@ -326,7 +328,7 @@ protected:
// notify children controls & groups that 'active' has been called on one of their parent
void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc);
protected:
protected:
/// children interface elements
std::vector<CInterfaceGroup*> _ChildrenGroups;
@ -380,7 +382,7 @@ protected:
IActionHandler *_AHOnEscape;
CStringShared _AHOnEscapeParams;
private:
private:
void addToEltOrder(CViewBase *view, sint order);
@ -394,10 +396,12 @@ private:
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLUAOnDbChange;
TLUAOnDbChange _LUAOnDbChange;
void removeAllLUAOnDbChange();
protected:
protected:
void parseMaxSizeRef(const char *ptr);
// @}
};
};
}
#endif // NL_INTERFACE_GROUP_H

View file

@ -27,17 +27,10 @@ namespace NLGUI
class CReflectedProperty;
class CInterfaceExprValue;
class CInterfaceExprNode;
}
class CInterfaceElement;
class CInterfaceGroup;
class CInterfaceElement;
class CInterfaceGroup;
using namespace NLGUI;
/** A link in an interface.
/** A link in an interface.
* A link is an object that can read one or several values from the database, that can evaluate an expression
* on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to
* an interface property that has been exported by an interface element (the export system uses reflect.h).
@ -55,15 +48,15 @@ using namespace NLGUI;
* \author Nevrax France
* \date 2002
*/
class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver
{
public:
class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver
{
public:
#ifdef NL_DEBUG
// for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager
// and was created by calling CInterfaceManager::addLink, contains the name of this link
std::string LinkName;
#endif
public:
public:
struct CTargetInfo
{
CInterfaceElement *Elem;
@ -84,7 +77,7 @@ public:
void onObserverCallFlush();
};
public:
public:
CInterfaceLink();
~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement
/** Make a link between the given interface element properties and a value that depends on database entries.
@ -126,8 +119,8 @@ public:
* \return true if all targets are valid
*/
static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector<CInterfaceLink::CTargetInfo> &targetsVect);
////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
friend struct CRemoveTargetPred;
// a target property
struct CTarget
@ -135,12 +128,12 @@ private:
CInterfaceElement *_InterfaceElement;
const CReflectedProperty *_Property;
};
private:
private:
typedef std::list<CInterfaceLink *> TLinkList;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
typedef std::vector<NLMISC::ICDBNode *> TNodeVect;
private:
private:
std::vector<CTarget> _Targets;
TNodeVect _ObservedNodes;
std::string _Expr;
@ -176,7 +169,7 @@ private:
void unlinkFromTriggerList(uint list);
//@}
private:
private:
/** Inherited from ICDBNode::IPropertyObserver
* This doesn't update the node directly, but mark it as 'triggered'
* The node is really updated during the call to 'updateTrigeredLinks()'
@ -186,6 +179,8 @@ private:
void removeObservers(const TNodeVect &nodes);
// debug : check that there are as many targets as reference to a link
void checkNbRefs();
};
};
}
#endif

View file

@ -28,11 +28,13 @@ namespace NL3D
class UAnimationSet;
}
// ***************************************************************************
class CInterfaceOptionValue
namespace NLGUI
{
public:
// ***************************************************************************
class CInterfaceOptionValue
{
public:
CInterfaceOptionValue()
{
_Color= NLMISC::CRGBA::White;
@ -52,21 +54,21 @@ public:
// returned when InterfaceOptions param not found
static const CInterfaceOptionValue NullValue;
private:
private:
std::string _Str;
NLMISC::CRGBA _Color;
sint32 _Int;
float _Float;
bool _Boolean;
};
};
// ***************************************************************************
class CInterfaceOptions : public NLMISC::CRefCount
{
// ***************************************************************************
class CInterfaceOptions : public NLMISC::CRefCount
{
public:
public:
CInterfaceOptions();
virtual ~CInterfaceOptions();
@ -86,12 +88,13 @@ public:
// copy basic map only from other CInterfaceOptions (non virtual method)
void copyBasicMap(const CInterfaceOptions &other);
protected:
protected:
std::map<std::string, CInterfaceOptionValue> _ParamValue;
};
};
}
#endif // NL_INTERFACE_LAYER_H

View file

@ -23,9 +23,12 @@
#include "nel/misc/factory.h"
#include "nel/gui/interface_element.h"
class CViewBase : public CInterfaceElement
namespace NLGUI
{
public:
class CViewBase : public CInterfaceElement
{
public:
// for factory construction
struct TCtorParam
@ -74,8 +77,9 @@ public:
// special for mouse over : return true and fill the name of the cursor to display
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
};
};
}
#endif // RZ_VIEW_BASE_H

View file

@ -1,11 +1,31 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef VIEW_POINTER_BASE_H
#define VIEW_POINTER_BASE_H
#include "nel/gui/view_base.h"
class CViewPointerBase : public CViewBase
namespace NLGUI
{
public:
class CViewPointerBase : public CViewBase
{
public:
DECLARE_UI_CLASS( CViewPointerBase )
CViewPointerBase( const TCtorParam &param );
@ -33,7 +53,7 @@ public:
void draw(){}
protected:
protected:
// (x,y) is from the TopLeft corner of the window
sint32 _PointerX; // Current pointer position (raw, before snapping)
sint32 _PointerY;
@ -46,10 +66,12 @@ protected:
bool _PointerDrag; // Is the pointer down and we have moved ?
bool _PointerVisible; // Is the pointer visible or hidden ?
private:
private:
};
};
}
#endif

View file

@ -23,30 +23,33 @@
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_common.h"
class CInterfaceElement;
class CCtrlBase;
class CViewBase;
class CInterfaceGroup;
class CViewPointerBase;
class CInterfaceOptions;
namespace NLMISC
{
class CCDBNodeLeaf;
}
class IParser
namespace NLGUI
{
public:
class CInterfaceElement;
class CCtrlBase;
class CViewBase;
class CInterfaceGroup;
class CViewPointerBase;
class CInterfaceOptions;
class IParser
{
public:
virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0;
};
};
/// Manages the GUI widgets
class CWidgetManager{
public:
/// Manages the GUI widgets
class CWidgetManager{
public:
// Master groups encapsulate all windows
struct SMasterGroup
@ -291,7 +294,7 @@ public:
static IParser *parser;
private:
private:
CWidgetManager();
~CWidgetManager();
@ -330,7 +333,9 @@ private:
NLMISC::CCDBNodeLeaf *_GProp;
NLMISC::CCDBNodeLeaf *_BProp;
NLMISC::CCDBNodeLeaf *_AProp;
};
};
}
#endif

View file

@ -25,13 +25,16 @@
using namespace std;
using namespace NLMISC;
// ------------------------------------------------------------------------------------------------
CAHManager *CAHManager::_GlobalInstance = NULL;
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
static void skipBlankAtStart (string &start)
namespace NLGUI
{
// ------------------------------------------------------------------------------------------------
CAHManager *CAHManager::_GlobalInstance = NULL;
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
static void skipBlankAtStart (string &start)
{
while (!start.empty())
{
if ((start[0] == ' ' || start[0] == '\t' || start[0] == '\r' || start[0] == '\n'))
@ -39,11 +42,11 @@ static void skipBlankAtStart (string &start)
else
break;
}
}
}
// ------------------------------------------------------------------------------------------------
static void skipBlankAtEnd (string &end)
{
// ------------------------------------------------------------------------------------------------
static void skipBlankAtEnd (string &end)
{
while (!end.empty())
{
if ((end[end.size()-1] == ' ' || end[end.size()-1] == '\t' || end[end.size()-1] == '\r' || end[end.size()-1] == '\n'))
@ -51,11 +54,11 @@ static void skipBlankAtEnd (string &end)
else
break;
}
}
}
// ------------------------------------------------------------------------------------------------
std::string IActionHandler::getParam (const string &Params, const string &ParamName)
{
// ------------------------------------------------------------------------------------------------
std::string IActionHandler::getParam (const string &Params, const string &ParamName)
{
string allparam = Params;
skipBlankAtStart (allparam);
string param = toLower (ParamName);
@ -78,11 +81,11 @@ std::string IActionHandler::getParam (const string &Params, const string &ParamN
skipBlankAtStart (allparam);
}
return "";
}
}
// ------------------------------------------------------------------------------------------------
void IActionHandler::getAllParams (const string &Params, vector< pair<string,string> > &vAllParams)
{
// ------------------------------------------------------------------------------------------------
void IActionHandler::getAllParams (const string &Params, vector< pair<string,string> > &vAllParams)
{
string allparam = Params;
skipBlankAtStart (allparam);
while (allparam.size() > 0)
@ -103,11 +106,11 @@ void IActionHandler::getAllParams (const string &Params, vector< pair<string,str
allparam = allparam.substr(p+1,allparam.size());
skipBlankAtStart (allparam);
}
}
}
// ------------------------------------------------------------------------------------------------
IActionHandler* CAHManager::getAH(const std::string &name, std::string &params)
{
// ------------------------------------------------------------------------------------------------
IActionHandler* CAHManager::getAH(const std::string &name, std::string &params)
{
// Special AH form?
string::size_type i= name.find(':');
if(i!=string::npos)
@ -119,11 +122,11 @@ IActionHandler* CAHManager::getAH(const std::string &name, std::string &params)
// standalone form
else
return getActionHandler(name);
}
}
// ------------------------------------------------------------------------------------------------
IActionHandler* CAHManager::getAH(const std::string &name, CStringShared &params)
{
// ------------------------------------------------------------------------------------------------
IActionHandler* CAHManager::getAH(const std::string &name, CStringShared &params)
{
// Special AH form?
string::size_type i= name.find(':');
if(i!=string::npos)
@ -135,11 +138,11 @@ IActionHandler* CAHManager::getAH(const std::string &name, CStringShared &params
// standalone form
else
return getActionHandler(name);
}
}
// ------------------------------------------------------------------------------------------------
void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string &paramRet)
{
// ------------------------------------------------------------------------------------------------
void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string &paramRet)
{
CXMLAutoPtr prop;
// Read the action handler and any param he defines
@ -168,10 +171,10 @@ void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId,
if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) )
paramRet = string((const char*)prop);
}
}
}
void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared &paramRet)
{
void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared &paramRet)
{
CXMLAutoPtr prop;
// Read the action handler and any param he defines
@ -200,11 +203,11 @@ void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId,
if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) )
paramRet = string((const char*)prop);
}
}
}
// ------------------------------------------------------------------------------------------------
void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams)
{
// ------------------------------------------------------------------------------------------------
void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams)
{
if (ahCmdLine.empty()) return;
// Special AH form ("ah:params") ?
@ -246,11 +249,11 @@ void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller,
pAH = it->second;
const std::string event = ahName + ":" + ahParams;
pAH->execute(NULL, event);
}
}
// ------------------------------------------------------------------------------------------------
void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params)
{
// ------------------------------------------------------------------------------------------------
void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params)
{
if (pAH == NULL)
{
nlwarning ("no action handler");
@ -271,13 +274,13 @@ void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, cons
pAH = it->second;
const std::string event = AHName + ":" + Params;
pAH->execute(NULL, event);
}
}
// ------------------------------------------------------------------------------------------------
class CAHSet : public IActionHandler
{
public:
// ------------------------------------------------------------------------------------------------
class CAHSet : public IActionHandler
{
public:
virtual void execute (CCtrlBase *pCaller, const string &Params)
{
string dblink = getParam (Params, "dblink");
@ -369,14 +372,14 @@ public:
nlwarning("<CAHSet::execute> Couldn't evaluate expression to affect, expr = %s", expr.c_str());
}
}
};
REGISTER_ACTION_HANDLER (CAHSet, "set");
};
REGISTER_ACTION_HANDLER (CAHSet, "set");
// ------------------------------------------------------------------------------------------------
class CAHCopy : public IActionHandler
{
public:
// ------------------------------------------------------------------------------------------------
class CAHCopy : public IActionHandler
{
public:
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
{
string dbdst = getParam (Params, "dbdst");
@ -438,14 +441,14 @@ public:
// copy
ipdst.setSInt64 (ipsrc.getSInt64());
}
};
REGISTER_ACTION_HANDLER (CAHCopy, "copy");
};
REGISTER_ACTION_HANDLER (CAHCopy, "copy");
// ------------------------------------------------------------------------------------------------
class CAHResizeW : public IActionHandler
{
public:
// ------------------------------------------------------------------------------------------------
class CAHResizeW : public IActionHandler
{
public:
virtual void execute (CCtrlBase *pCaller, const string &Params)
{
string elt = getParam (Params, "elt");
@ -474,25 +477,25 @@ public:
pIE->setW (newW);
pIE->invalidateCoords();
}
};
REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w");
};
REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w");
////////////////////////////////
// EDITION OF CONTAINER ALPHA //
////////////////////////////////
////////////////////////////////
// EDITION OF CONTAINER ALPHA //
////////////////////////////////
// the container whose alpha is being edited
static CGroupContainerBase *AlphaChooserTarget = NULL;
static bool OldUseGlobalAlpha;
static uint8 OldContentAlpha;
static uint8 OldBgAlpha;
static uint8 OldRolloverAlphaBG;
static uint8 OldRolloverAlphaContent;
// the container whose alpha is being edited
static CGroupContainerBase *AlphaChooserTarget = NULL;
static bool OldUseGlobalAlpha;
static uint8 OldContentAlpha;
static uint8 OldBgAlpha;
static uint8 OldRolloverAlphaBG;
static uint8 OldRolloverAlphaContent;
// observer to change the container alpha
class CContainerAlphaObserver : public ICDBNode::IPropertyObserver
{
public:
// observer to change the container alpha
class CContainerAlphaObserver : public ICDBNode::IPropertyObserver
{
public:
bool On;
enum TTargetAlpha { ContentAlpha = 0, BgAlpha, RolloverAlphaContent, RolloverAlphaBG };
TTargetAlpha Target;
@ -509,14 +512,14 @@ public:
case RolloverAlphaBG: AlphaChooserTarget->setRolloverAlphaContainer((uint8) (255 - (uint8) leaf->getValue32())); break;
}
}
};
};
// ------------------------------------------------------------------------------------------------
class CAHChooseUIAlpha : public IActionHandler
{
public:
// ------------------------------------------------------------------------------------------------
class CAHChooseUIAlpha : public IActionHandler
{
public:
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
{
CGroupContainerBase *gc = NULL;
@ -583,7 +586,7 @@ public:
_RolloverAlphaBGObs.Target = CContainerAlphaObserver::RolloverAlphaBG;
_RolloverAlphaContentObs.Target = CContainerAlphaObserver::RolloverAlphaContent;
}
private:
private:
// instance of observer to copy alpha from db to a container
CContainerAlphaObserver _ContentAlphaObs;
CContainerAlphaObserver _BgAlphaObs;
@ -596,12 +599,12 @@ private:
CCDBNodeLeaf *_UiVariableBGAlpha;
CCDBNodeLeaf *_UiVariableRolloverAlphaContent;
CCDBNodeLeaf *_UiVariableRolloverAlphaBG;
};
REGISTER_ACTION_HANDLER (CAHChooseUIAlpha, "choose_ui_alpha");
};
REGISTER_ACTION_HANDLER (CAHChooseUIAlpha, "choose_ui_alpha");
// ------------------------------------------------------------------------------------------------
class CAHCancelChooseUIAlpha : public IActionHandler
{
// ------------------------------------------------------------------------------------------------
class CAHCancelChooseUIAlpha : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */)
{
if (AlphaChooserTarget)
@ -613,12 +616,12 @@ class CAHCancelChooseUIAlpha : public IActionHandler
AlphaChooserTarget->setRolloverAlphaContent(OldRolloverAlphaContent);
}
}
};
REGISTER_ACTION_HANDLER (CAHCancelChooseUIAlpha, "cancel_choose_ui_alpha");
};
REGISTER_ACTION_HANDLER (CAHCancelChooseUIAlpha, "cancel_choose_ui_alpha");
// ------------------------------------------------------------------------------------------------
class CAHUseGlobalAlphaSettings : public IActionHandler
{
// ------------------------------------------------------------------------------------------------
class CAHUseGlobalAlphaSettings : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */)
{
if (AlphaChooserTarget)
@ -627,13 +630,13 @@ class CAHUseGlobalAlphaSettings : public IActionHandler
NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1);
}
}
};
REGISTER_ACTION_HANDLER (CAHUseGlobalAlphaSettings, "use_global_alpha_settings");
};
REGISTER_ACTION_HANDLER (CAHUseGlobalAlphaSettings, "use_global_alpha_settings");
// ------------------------------------------------------------------------------------------------
class CAHLockUnlock : public IActionHandler
{
// ------------------------------------------------------------------------------------------------
class CAHLockUnlock : public IActionHandler
{
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
{
CGroupContainerBase *gc = NULL;
@ -648,12 +651,12 @@ class CAHLockUnlock : public IActionHandler
//gc->setMovable(!gc->isMovable());
gc->setLocked(!gc->isLocked());
}
};
REGISTER_ACTION_HANDLER (CAHLockUnlock, "lock_unlock");
};
REGISTER_ACTION_HANDLER (CAHLockUnlock, "lock_unlock");
// ------------------------------------------------------------------------------------------------
class CAHSetTransparent : public IActionHandler
{
// ------------------------------------------------------------------------------------------------
class CAHSetTransparent : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params)
{
CGroupContainerBase *pGC = dynamic_cast< CGroupContainerBase* >(CWidgetManager::getInstance()->getElementFromId(Params));
@ -666,12 +669,12 @@ class CAHSetTransparent : public IActionHandler
pGC->setRolloverAlphaContent((uint8) 0);
}
}
};
REGISTER_ACTION_HANDLER (CAHSetTransparent, "set_transparent");
};
REGISTER_ACTION_HANDLER (CAHSetTransparent, "set_transparent");
// ------------------------------------------------------------------------------------------------
class CAHSetAlpha : public IActionHandler
{
// ------------------------------------------------------------------------------------------------
class CAHSetAlpha : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params)
{
string ui = getParam (Params, "target");
@ -689,20 +692,22 @@ class CAHSetAlpha : public IActionHandler
pGC->setRolloverAlphaContent((uint8) 0);
}
}
};
REGISTER_ACTION_HANDLER (CAHSetAlpha, "set_alpha");
};
REGISTER_ACTION_HANDLER (CAHSetAlpha, "set_alpha");
// ------------------------------------------------------------------------------------------------
class CAHUnlockAllContainer : public IActionHandler
{
// ------------------------------------------------------------------------------------------------
class CAHUnlockAllContainer : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
{
const vector<CWidgetManager::SMasterGroup> &rVMG = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
{
// const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
// const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).unlockAllContainers();
}
}
};
REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container");
};
REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container");
}

View file

@ -24,15 +24,18 @@
using namespace NLMISC;
// ***************************************************************************
CCtrlBase::~CCtrlBase()
namespace NLGUI
{
CWidgetManager::getInstance()->removeRefOnCtrl (this);
}
// ***************************************************************************
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
{
// ***************************************************************************
CCtrlBase::~CCtrlBase()
{
CWidgetManager::getInstance()->removeRefOnCtrl (this);
}
// ***************************************************************************
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
{
if (event.getType() == NLGUI::CEventDescriptor::system)
{
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
@ -55,11 +58,11 @@ bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
}
}
return false;
}
}
// ***************************************************************************
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
// ***************************************************************************
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CViewBase::parse(cur, parentGroup))
return false;
@ -140,11 +143,11 @@ bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
if (prop) _ToolTipInstant = convertBool(prop);
return true;
}
}
// ***************************************************************************
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
{
// ***************************************************************************
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
if(prop)
@ -165,29 +168,29 @@ void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THot
childHS = posRef;
}
}
}
}
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
ucstring help;
getContextHelp(help);
std::string sTmp = _OnContextHelp;
return help.empty() && sTmp.empty();
}
}
// ***************************************************************************
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
{
// ***************************************************************************
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitCtrl(this);
CInterfaceElement::visit(visitor);
}
}
// ***************************************************************************
void CCtrlBase::serial(NLMISC::IStream &f)
{
// ***************************************************************************
void CCtrlBase::serial(NLMISC::IStream &f)
{
CViewBase::serial(f);
f.serial(_ContextHelp);
f.serial(_OnContextHelp);
@ -212,12 +215,13 @@ void CCtrlBase::serial(NLMISC::IStream &f)
_ToolTipPosRefAlt = tmpToolTipPosRefAlt;
//
nlSerialBitBool(f, _ToolTipInstant);
}
}
// ***************************************************************************
std::string CCtrlBase::getContextHelpWindowName() const
{
// ***************************************************************************
std::string CCtrlBase::getContextHelpWindowName() const
{
return "context_help";
}
}

View file

@ -1,11 +1,32 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_draggable.h"
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
namespace NLGUI
{
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
{
dragged = false;
draggable = false;
}
}
}

View file

@ -16,51 +16,57 @@
#include "nel/gui/ctrl_scroll_base.h"
CCtrlScrollBase::CCtrlScrollBase( const TCtorParam &param ) :
CCtrlBase( param )
namespace NLGUI
{
CCtrlScrollBase::CCtrlScrollBase( const TCtorParam &param ) :
CCtrlBase( param )
{
_Target = NULL;
}
}
CCtrlScrollBase::~CCtrlScrollBase()
{
}
CCtrlScrollBase::~CCtrlScrollBase()
{
}
void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG )
{
void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}
sint32 CCtrlScrollBase::moveTrackX( sint32 dx )
{
sint32 CCtrlScrollBase::moveTrackX( sint32 dx )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
return 0;
}
}
sint32 CCtrlScrollBase::moveTrackY( sint32 dy )
{
sint32 CCtrlScrollBase::moveTrackY( sint32 dy )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
return 0;
}
}
void CCtrlScrollBase::moveTargetX( sint32 dx )
{
void CCtrlScrollBase::moveTargetX( sint32 dx )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}
void CCtrlScrollBase::moveTargetY( sint32 dy )
{
void CCtrlScrollBase::moveTargetY( sint32 dy )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}

View file

@ -17,76 +17,81 @@
#include "nel/gui/group_container_base.h"
CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam &param ) :
CInterfaceGroup( param )
namespace NLGUI
{
CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam &param ) :
CInterfaceGroup( param )
{
_ContentAlpha = 255;
_ContainerAlpha = 255;
_RolloverAlphaContainer = 0;
_RolloverAlphaContent = 0;
_Locked = false;
_UseGlobalAlpha = true;
}
}
CGroupContainerBase::~CGroupContainerBase()
{
}
CGroupContainerBase::~CGroupContainerBase()
{
}
void CGroupContainerBase::removeAllContainers()
{
void CGroupContainerBase::removeAllContainers()
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}
void CGroupContainerBase::setLocked( bool locked )
{
void CGroupContainerBase::setLocked( bool locked )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}
// ***************************************************************************
void CGroupContainerBase::triggerAlphaSettingsChangedAH()
{
// ***************************************************************************
void CGroupContainerBase::triggerAlphaSettingsChangedAH()
{
if (_AHOnAlphaSettingsChanged != NULL)
CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams);
}
}
// ***************************************************************************
void CGroupContainerBase::setUseGlobalAlpha(bool use)
{
// ***************************************************************************
void CGroupContainerBase::setUseGlobalAlpha(bool use)
{
_UseGlobalAlpha = use;
triggerAlphaSettingsChangedAH();
}
}
// ***************************************************************************
void CGroupContainerBase::setContainerAlpha(uint8 alpha)
{
// ***************************************************************************
void CGroupContainerBase::setContainerAlpha(uint8 alpha)
{
_ContainerAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
}
// ***************************************************************************
void CGroupContainerBase::setContentAlpha(uint8 alpha)
{
// ***************************************************************************
void CGroupContainerBase::setContentAlpha(uint8 alpha)
{
_ContentAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha)
{
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha)
{
_RolloverAlphaContent = alpha;
triggerAlphaSettingsChangedAH();
}
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha)
{
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha)
{
_RolloverAlphaContainer = alpha;
triggerAlphaSettingsChangedAH();
}
}

View file

@ -1,14 +1,36 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/group_editbox_base.h"
CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL;
CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam &param ) :
CInterfaceGroup( param )
namespace NLGUI
{
CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL;
CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam &param ) :
CInterfaceGroup( param )
{
_RecoverFocusOnEnter = true;
}
CGroupEditBoxBase::~CGroupEditBoxBase()
{
}
CGroupEditBoxBase::~CGroupEditBoxBase()
{
}
}

View file

@ -24,26 +24,29 @@
using namespace std;
using namespace NLMISC;
NLMISC_REGISTER_OBJECT(CViewBase, CGroupFrame, std::string, "frame");
// ***************************************************************************
vector<CGroupFrame::SDisplayType> CGroupFrame::_DispTypes;
// ***************************************************************************
CGroupFrame::CGroupFrame(const TCtorParam &param)
: CInterfaceGroup(param)
namespace NLGUI
{
NLMISC_REGISTER_OBJECT(CViewBase, CGroupFrame, std::string, "frame");
// ***************************************************************************
vector<CGroupFrame::SDisplayType> CGroupFrame::_DispTypes;
// ***************************************************************************
CGroupFrame::CGroupFrame(const TCtorParam &param)
: CInterfaceGroup(param)
{
_DisplayFrame = true;
_Color = CRGBA(255,255,255,255);
_DispType = 0;
_DisplayFrameDefined= false;
_ColorDefined= false;
_DispTypeDefined= false;
}
}
// ***************************************************************************
bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
// ***************************************************************************
bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CInterfaceGroup::parse(cur, parentGroup))
return false;
@ -148,12 +151,12 @@ bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
return true;
}
}
// ***************************************************************************
void CGroupFrame::draw ()
{
// ***************************************************************************
void CGroupFrame::draw ()
{
if (_DisplayFrame)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
@ -220,11 +223,11 @@ void CGroupFrame::draw ()
}
// draw the components
CInterfaceGroup::draw();
}
}
// ***************************************************************************
void CGroupFrame::copyOptionFrom(const CGroupFrame &other)
{
// ***************************************************************************
void CGroupFrame::copyOptionFrom(const CGroupFrame &other)
{
CInterfaceGroup::copyOptionFrom(other);
// Copy option only if they were not explicitly defined in xml
@ -234,16 +237,19 @@ void CGroupFrame::copyOptionFrom(const CGroupFrame &other)
_Color = other._Color;
if(!_DispTypeDefined)
_DispType = other._DispType;
}
}
// ***************************************************************************
void CGroupFrame::setColorAsString(const string & col)
{
// ***************************************************************************
void CGroupFrame::setColorAsString(const string & col)
{
_Color = convertColor (col.c_str());
}
// ***************************************************************************
string CGroupFrame::getColorAsString() const
{
return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A);
}
}
// ***************************************************************************
string CGroupFrame::getColorAsString() const
{
return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A);
}

View file

@ -20,17 +20,19 @@
#include "nel/gui/interface_element.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/i_xml.h"
using namespace std;
#include "nel/misc/i_xml.h"
NLMISC_REGISTER_OBJECT(CViewBase, CGroupModal, std::string, "modal");
// ***************************************************************************
CGroupModal::CGroupModal(const TCtorParam &param)
: CGroupFrame(param)
namespace NLGUI
{
NLMISC_REGISTER_OBJECT(CViewBase, CGroupModal, std::string, "modal");
// ***************************************************************************
CGroupModal::CGroupModal(const TCtorParam &param)
: CGroupFrame(param)
{
SpawnOnMousePos= true;
ExitClickOut= true;
ExitClickL= false;
@ -41,12 +43,12 @@ CGroupModal::CGroupModal(const TCtorParam &param)
_MouseDeltaX= _MouseDeltaY= 0;
//By default, modal are escapable
_Escapable= true;
}
}
// ***************************************************************************
bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
// ***************************************************************************
bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CGroupFrame::parse(cur, parentGroup))
return false;
@ -89,11 +91,11 @@ bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
_Active = false;
return true;
}
}
// ***************************************************************************
void CGroupModal::updateCoords ()
{
// ***************************************************************************
void CGroupModal::updateCoords ()
{
// if snap to mouse pos.
if(SpawnOnMousePos)
{
@ -170,6 +172,7 @@ void CGroupModal::updateCoords ()
CGroupFrame::updateCoords();
}
}
}
}

View file

@ -29,11 +29,14 @@
using namespace std;
using namespace NLMISC;
CStringMapper *_UIStringMapper = NULL;
// ------------------------------------------------------------------------------------------------
CInterfaceElement::~CInterfaceElement()
namespace NLGUI
{
CStringMapper *_UIStringMapper = NULL;
// ------------------------------------------------------------------------------------------------
CInterfaceElement::~CInterfaceElement()
{
if (_Links) // remove any link that point to that element
{
for(TLinkVect::iterator it = _Links->begin(); it != _Links->end(); ++it)
@ -42,38 +45,38 @@ CInterfaceElement::~CInterfaceElement()
}
delete _Links;
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::parseError(CInterfaceGroup * parentGroup, const char *reason)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::parseError(CInterfaceGroup * parentGroup, const char *reason)
{
string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId();
nlinfo(tmp.c_str());
if (reason)
nlinfo("reason : %s", reason);
}
}
void CInterfaceElement::setIdRecurse(const std::string &newID)
{
void CInterfaceElement::setIdRecurse(const std::string &newID)
{
std::string baseId = _Parent ? _Parent->getId() : "ui";
setId(baseId + ":" + newID);
}
}
// ------------------------------------------------------------------------------------------------
std::string CInterfaceElement::getShortId() const
{
// ------------------------------------------------------------------------------------------------
std::string CInterfaceElement::getShortId() const
{
std::string::size_type last = _Id.find_last_of(':');
if (last != std::string::npos)
{
return _Id.substr(last + 1);
}
return _Id;
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{
// parse the basic properties
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"id" ));
if (ptr)
@ -125,15 +128,15 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
if (ptr) fromString((const char*)ptr, _H);
// snapping
// ptr = (char*) xmlGetProp( cur, (xmlChar*)"snap" );
// _Snap = 1;
// if (ptr)
// fromString((const char*)ptr, _Snap);
// if (_Snap <= 0)
// {
// parseError(parentGroup, "snap must be > 0" );
// return false;
// }
// ptr = (char*) xmlGetProp( cur, (xmlChar*)"snap" );
// _Snap = 1;
// if (ptr)
// fromString((const char*)ptr, _Snap);
// if (_Snap <= 0)
// {
// parseError(parentGroup, "snap must be > 0" );
// return false;
// }
ptr = (char*) xmlGetProp( cur, (xmlChar*) "posref" );
_ParentPosRef = Hotspot_BL;
@ -215,7 +218,7 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
}
}
// snapSize();
// snapSize();
ptr= (char*) xmlGetProp (cur, (xmlChar*)"global_color");
if(ptr)
@ -230,31 +233,31 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
if(ptr) _AvoidResizeParent= convertBool(ptr);
return true;
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setSizeRef(const std::string &sizeref)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setSizeRef(const std::string &sizeref)
{
parseSizeRef(sizeref.c_str());
}
}
// ------------------------------------------------------------------------------------------------
std::string CInterfaceElement::getSizeRefAsString() const
{
// ------------------------------------------------------------------------------------------------
std::string CInterfaceElement::getSizeRefAsString() const
{
return "IMPLEMENT ME!";
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::parseSizeRef(const char *sizeRefStr)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::parseSizeRef(const char *sizeRefStr)
{
parseSizeRef(sizeRefStr, _SizeRef, _SizeDivW, _SizeDivH);
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::parseSizeRef(const char *sizeRefStr, sint32 &sizeRef, sint32 &sizeDivW, sint32 &sizeDivH)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::parseSizeRef(const char *sizeRefStr, sint32 &sizeRef, sint32 &sizeDivW, sint32 &sizeDivH)
{
nlassert(sizeRefStr);
sizeRef = 0;
@ -289,11 +292,11 @@ void CInterfaceElement::parseSizeRef(const char *sizeRefStr, sint32 &sizeRef, si
++seekPtr;
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::updateCoords()
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::updateCoords()
{
_XReal = _X;
_YReal = _Y;
_WReal = getW();
@ -356,33 +359,33 @@ void CInterfaceElement::updateCoords()
_XReal -= _WReal/2;
if (hs & Hotspot_xR)
_XReal -= _WReal;
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::getCorner(sint32 &px, sint32 &py, THotSpot hs)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::getCorner(sint32 &px, sint32 &py, THotSpot hs)
{
px = _XReal;
py = _YReal;
if (hs & 1) px += _WReal;
if (hs & 2) px += _WReal >> 1;
if (hs & 8) py += _HReal;
if (hs & 16) py += _HReal >> 1;
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::move (sint32 dx, sint32 dy)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::move (sint32 dx, sint32 dy)
{
_X += dx;
_Y += dy;
invalidateCoords();
}
}
// ------------------------------------------------------------------------------------------------
/*void CInterfaceElement::resizeBR (sint32 sizeW, sint32 sizeH)
{
// ------------------------------------------------------------------------------------------------
/*void CInterfaceElement::resizeBR (sint32 sizeW, sint32 sizeH)
{
uint32 i = i / 0;
THotSpot hs = _PosRef;
@ -427,12 +430,12 @@ void CInterfaceElement::move (sint32 dx, sint32 dy)
// DO NOT TREAT THE MIDDLE HOTSPOT CASE
invalidateCoords();
}*/
}*/
// ------------------------------------------------------------------------------------------------
/*void CInterfaceElement::snapSize()
{
// ------------------------------------------------------------------------------------------------
/*void CInterfaceElement::snapSize()
{
sint32 snap = _Snap;
nlassert(snap > 0);
if (snap > 1)
@ -440,48 +443,48 @@ void CInterfaceElement::move (sint32 dx, sint32 dy)
_W = _W - (_W % snap);
_H = _H - (_H % snap);
}
}*/
}*/
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setW (sint32 w)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setW (sint32 w)
{
_W = w;
// sint32 snap = _Snap;
// nlassert(snap > 0);
// if (snap > 1)
// {
// _W = _W - (_W % snap);
// }
}
// sint32 snap = _Snap;
// nlassert(snap > 0);
// if (snap > 1)
// {
// _W = _W - (_W % snap);
// }
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setH (sint32 h)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setH (sint32 h)
{
_H = h;
// sint32 snap = _Snap;
// nlassert(snap > 0);
// if (snap > 1)
// {
// _H = _H - (_H % snap);
// }
}
// sint32 snap = _Snap;
// nlassert(snap > 0);
// if (snap > 1)
// {
// _H = _H - (_H % snap);
// }
}
// ------------------------------------------------------------------------------------------------
CInterfaceGroup* CInterfaceElement::getRootWindow ()
{
// ------------------------------------------------------------------------------------------------
CInterfaceGroup* CInterfaceElement::getRootWindow ()
{
if (_Parent == NULL)
return NULL;
if (_Parent->getParent() == NULL)
return dynamic_cast<CInterfaceGroup*>(this);
return _Parent->getRootWindow();
}
}
// ------------------------------------------------------------------------------------------------
uint CInterfaceElement::getParentDepth() const
{
// ------------------------------------------------------------------------------------------------
uint CInterfaceElement::getParentDepth() const
{
uint depth= 0;
CInterfaceGroup *parent= _Parent;
while(parent!=NULL)
@ -490,11 +493,11 @@ uint CInterfaceElement::getParentDepth() const
depth++;
}
return depth;
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isActiveThroughParents() const
{
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isActiveThroughParents() const
{
if(!getActive())
return false;
if(_Parent == NULL)
@ -505,12 +508,12 @@ bool CInterfaceElement::isActiveThroughParents() const
return true;
else
return _Parent->isActiveThroughParents();
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const string &prop, const char *val,
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const string &prop, const char *val,
const string &defVal)
{
{
if (val == NULL)
{
rIP.readSInt64 (defVal.c_str(), _Id+":"+prop);
@ -550,13 +553,13 @@ void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const strin
rIP.readSInt64 (val+decal, _Id+":"+prop);
}
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const string &prop, const char *val,
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const string &prop, const char *val,
const string &defVal)
{
{
if (val == NULL)
{
rIP.readSInt32 (defVal.c_str(), _Id+":"+prop);
@ -596,13 +599,13 @@ void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const strin
rIP.readSInt32 (val+decal, _Id+":"+prop);
}
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string &prop, const char *val,
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string &prop, const char *val,
const string &defVal)
{
{
if (val == NULL)
{
rIP.readBool (defVal.c_str(), _Id+":"+prop);
@ -636,12 +639,12 @@ void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string
rIP.readBool (val+decal, _Id+":"+prop);
}
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::string &prop,const char *val,const std::string &defVal)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::string &prop,const char *val,const std::string &defVal)
{
if (val == NULL)
{
rIP.readRGBA (defVal.c_str(), _Id+":"+prop);
@ -681,12 +684,12 @@ void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::stri
rIP.readRGBA (val+decal, _Id+":"+prop);
}
}
}
}
// ------------------------------------------------------------------------------------------------
THotSpot CInterfaceElement::convertHotSpot (const char *ptr)
{
// ------------------------------------------------------------------------------------------------
THotSpot CInterfaceElement::convertHotSpot (const char *ptr)
{
if ( !strnicmp(ptr,"TL",2) )
{
return Hotspot_TL;
@ -725,11 +728,11 @@ THotSpot CInterfaceElement::convertHotSpot (const char *ptr)
}
else
return Hotspot_BL;
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef)
{
nlassert(ptr);
// *** first hotspot
@ -748,35 +751,35 @@ void CInterfaceElement::convertHotSpotCouple (const char *ptr, THotSpot &parent
ptr++;
// convert second
posRef = convertHotSpot (ptr);
}
}
// ------------------------------------------------------------------------------------------------
NLMISC::CRGBA CInterfaceElement::convertColor (const char *ptr)
{
// ------------------------------------------------------------------------------------------------
NLMISC::CRGBA CInterfaceElement::convertColor (const char *ptr)
{
return NLMISC::CRGBA::stringToRGBA(ptr);
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::convertBool (const char *ptr)
{
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::convertBool (const char *ptr)
{
string str= ptr;
NLMISC::strlwr(str);
return str=="true"?true:false;
}
}
// ------------------------------------------------------------------------------------------------
NLMISC::CVector CInterfaceElement::convertVector (const char *ptr)
{
// ------------------------------------------------------------------------------------------------
NLMISC::CVector CInterfaceElement::convertVector (const char *ptr)
{
float x = 0.0f, y = 0.0f, z = 0.0f;
sscanf (ptr, "%f %f %f", &x, &y, &z);
return CVector(x,y,z);
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio)
{
std::string value = ptr;
if (!value.empty())
{
@ -792,12 +795,12 @@ void CInterfaceElement::convertPixelsOrRatio(const char *ptr, sint32 &pixels, fl
fromString(value, pixels);
}
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::addLink(CInterfaceLink *link)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::addLink(CInterfaceLink *link)
{
nlassert(link != NULL);
if (!_Links)
{
@ -814,12 +817,12 @@ void CInterfaceElement::addLink(CInterfaceLink *link)
{
_Links->push_back(linkPtr);
}
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::removeLink(CInterfaceLink *link)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::removeLink(CInterfaceLink *link)
{
nlassert(link != NULL);
if (!_Links)
{
@ -838,21 +841,21 @@ void CInterfaceElement::removeLink(CInterfaceLink *link)
delete _Links;
_Links = NULL;
}
}
}
// ------------------------------------------------------------------------------------------------
CInterfaceElement* CInterfaceElement::getMasterGroup() const
{
// ------------------------------------------------------------------------------------------------
CInterfaceElement* CInterfaceElement::getMasterGroup() const
{
if(getParent()==NULL)
return const_cast<CInterfaceElement*>(this);
else
return getParent()->getMasterGroup();
}
}
// ------------------------------------------------------------------------------------------------
CInterfaceGroup* CInterfaceElement::getParentContainer()
{
// ------------------------------------------------------------------------------------------------
CInterfaceGroup* CInterfaceElement::getParentContainer()
{
CInterfaceElement *parent = this;
while (parent)
{
@ -863,46 +866,46 @@ CInterfaceGroup* CInterfaceElement::getParentContainer()
parent = parent->getParent();
}
return NULL;
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isIn(sint x, sint y) const
{
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isIn(sint x, sint y) const
{
return (x >= _XReal) &&
(x < (_XReal + _WReal))&&
(y > _YReal) &&
(y <= (_YReal+ _HReal));
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isIn(sint x, sint y, uint width, uint height) const
{
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isIn(sint x, sint y, uint width, uint height) const
{
return (x + (sint) width) >= _XReal &&
(y + (sint) height) > _YReal &&
x < (_XReal + _WReal) &&
y <= (_YReal + _HReal);
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isIn(const CInterfaceElement &other) const
{
// ------------------------------------------------------------------------------------------------
bool CInterfaceElement::isIn(const CInterfaceElement &other) const
{
return isIn(other._XReal, other._YReal, other._WReal, other._HReal);
}
}
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setActive (bool state)
{
// ------------------------------------------------------------------------------------------------
void CInterfaceElement::setActive (bool state)
{
if (_Active != state)
{
_Active = state;
invalidateCoords();
}
}
}
// ***************************************************************************
void CInterfaceElement::invalidateCoords(uint8 numPass)
{
// ***************************************************************************
void CInterfaceElement::invalidateCoords(uint8 numPass)
{
// Get the "Root Group" ie the 1st son of the master group of us (eg "ui:interface:rootgroup" )
CInterfaceGroup *parent= getParent();
// if our parent is NULL, then we are the master group (error!)
@ -928,17 +931,17 @@ void CInterfaceElement::invalidateCoords(uint8 numPass)
uint8 &val= static_cast<CInterfaceElement*>(parent)->_InvalidCoords;
val= max(val, numPass);
}
}
}
// ***************************************************************************
void CInterfaceElement::checkCoords()
{
}
// ***************************************************************************
void CInterfaceElement::checkCoords()
{
}
// ***************************************************************************
bool CInterfaceElement::isSonOf(const CInterfaceElement *other) const
{
// ***************************************************************************
bool CInterfaceElement::isSonOf(const CInterfaceElement *other) const
{
const CInterfaceElement *currElem = this;
do
{
@ -947,17 +950,17 @@ bool CInterfaceElement::isSonOf(const CInterfaceElement *other) const
}
while (currElem);
return false;
}
}
// ***************************************************************************
void CInterfaceElement::resetInvalidCoords()
{
// ***************************************************************************
void CInterfaceElement::resetInvalidCoords()
{
_InvalidCoords= 0;
}
}
// ***************************************************************************
void CInterfaceElement::updateAllLinks()
{
// ***************************************************************************
void CInterfaceElement::updateAllLinks()
{
if (_Links)
{
for(TLinkVect::iterator it = _Links->begin(); it != _Links->end(); ++it)
@ -965,11 +968,11 @@ void CInterfaceElement::updateAllLinks()
(*it)->update();
}
}
}
}
// ***************************************************************************
void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other)
{
// ***************************************************************************
void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other)
{
_Active = other._Active;
_InvalidCoords = other._InvalidCoords;
_XReal = other._XReal;
@ -988,22 +991,22 @@ void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other)
_ModulateGlobalColor = other._ModulateGlobalColor;
_RenderLayer = other._RenderLayer;
}
}
// ***************************************************************************
void CInterfaceElement::center()
{
// ***************************************************************************
void CInterfaceElement::center()
{
// center the pc
CViewRenderer &vr = *CViewRenderer::getInstance();
uint32 sw, sh;
vr.getScreenSize(sw, sh);
setX(sw / 2 - getWReal() / 2);
setY(sh / 2 + getHReal() / 2);
}
}
// ***************************************************************************
void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &uiFilter)
{
// ***************************************************************************
void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &uiFilter)
{
CCtrlBase *ctrlBase = dynamic_cast<CCtrlBase*>(this);
CInterfaceGroup *groupBase = dynamic_cast<CInterfaceGroup*>(this);
if (
@ -1022,11 +1025,11 @@ void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &u
drawHotSpot(_PosRef, CRGBA::Red);
if (_Parent) _Parent->drawHotSpot(_ParentPosRef, CRGBA::Blue);
}
}
}
// ***************************************************************************
void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col)
{
// ***************************************************************************
void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col)
{
const sint32 radius = 2;
sint32 px, py;
//
@ -1058,11 +1061,11 @@ void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col)
CViewRenderer &vr = *CViewRenderer::getInstance();
vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col);
}
}
// ***************************************************************************
void CInterfaceElement::invalidateContent()
{
// ***************************************************************************
void CInterfaceElement::invalidateContent()
{
CInterfaceElement *elm = this;
while (elm)
{
@ -1072,79 +1075,79 @@ void CInterfaceElement::invalidateContent()
// Get the parent
elm = elm->getParent();
}
}
}
// ***************************************************************************
void CInterfaceElement::visit(CInterfaceElementVisitor *visitor)
{
// ***************************************************************************
void CInterfaceElement::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visit(this);
}
}
// ***************************************************************************
void CInterfaceElement::serialConfig(NLMISC::IStream &f)
{
// ***************************************************************************
void CInterfaceElement::serialConfig(NLMISC::IStream &f)
{
if (f.isReading())
{
throw NLMISC::ENewerStream(f);
nlassert(0);
}
}
}
// ***************************************************************************
void CInterfaceElement::onFrameUpdateWindowPos(sint dx, sint dy)
{
// ***************************************************************************
void CInterfaceElement::onFrameUpdateWindowPos(sint dx, sint dy)
{
_XReal+= dx;
_YReal+= dy;
}
}
// ***************************************************************************
void CInterfaceElement::dummySet(sint32 /* value */)
{
// ***************************************************************************
void CInterfaceElement::dummySet(sint32 /* value */)
{
nlwarning("Element can't be written.");
}
}
// ***************************************************************************
void CInterfaceElement::dummySet(const std::string &/* value */)
{
// ***************************************************************************
void CInterfaceElement::dummySet(const std::string &/* value */)
{
nlwarning("Element can't be written.");
}
}
// ***************************************************************************
int CInterfaceElement::luaUpdateCoords(CLuaState &ls)
{
// ***************************************************************************
int CInterfaceElement::luaUpdateCoords(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "updateCoords", 0);
updateCoords();
return 0;
}
}
// ***************************************************************************
int CInterfaceElement::luaInvalidateCoords(CLuaState &ls)
{
// ***************************************************************************
int CInterfaceElement::luaInvalidateCoords(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "updateCoords", 0);
invalidateCoords();
return 0;
}
}
// ***************************************************************************
int CInterfaceElement::luaInvalidateContent(CLuaState &ls)
{
// ***************************************************************************
int CInterfaceElement::luaInvalidateContent(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "invalidateContent", 0);
invalidateContent();
return 0;
}
}
// ***************************************************************************
int CInterfaceElement::luaCenter(CLuaState &ls)
{
// ***************************************************************************
int CInterfaceElement::luaCenter(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "center", 0);
center();
return 0;
}
}
// ***************************************************************************
int CInterfaceElement::luaSetPosRef(CLuaState &ls)
{
// ***************************************************************************
int CInterfaceElement::luaSetPosRef(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "setPosRef", 1);
CLuaIHM::check(ls, ls.isString(1), "setPosRef() requires a string in param 1");
@ -1161,11 +1164,11 @@ int CInterfaceElement::luaSetPosRef(CLuaState &ls)
}
return 0;
}
}
// ***************************************************************************
int CInterfaceElement::luaSetParentPos(CLuaState &ls)
{
// ***************************************************************************
int CInterfaceElement::luaSetParentPos(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "setParentPos", 1);
CInterfaceElement *ie = CLuaIHM::getUIOnStack(ls, 1);
if(ie)
@ -1173,13 +1176,13 @@ int CInterfaceElement::luaSetParentPos(CLuaState &ls)
setParentPos(ie);
}
return 0;
}
}
// ***************************************************************************
CInterfaceElement *CInterfaceElement::clone()
{
// ***************************************************************************
CInterfaceElement *CInterfaceElement::clone()
{
NLMISC::CMemStream dupStream;
nlassert(!dupStream.isReading());
CInterfaceGroup *oldParent = _Parent;
@ -1214,11 +1217,11 @@ CInterfaceElement *CInterfaceElement::clone()
_ParentSize = oldParentSize;
//
return begunThisCloneWarHas;
}
}
// ***************************************************************************
void CInterfaceElement::serial(NLMISC::IStream &f)
{
// ***************************************************************************
void CInterfaceElement::serial(NLMISC::IStream &f)
{
f.serialPolyPtr(_Parent);
f.serial(_Id);
f.serial(_Active);
@ -1235,12 +1238,12 @@ void CInterfaceElement::serial(NLMISC::IStream &f)
f.serial(_RenderLayer);
f.serial(_AvoidResizeParent);
nlassert(_Links == NULL); // not supported
}
}
// ***************************************************************************
void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah)
{
// ***************************************************************************
void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah)
{
std::string ahName;
if (f.isReading())
{
@ -1252,9 +1255,10 @@ void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah)
ahName = CAHManager::getInstance()->getActionHandlerName(ah);
f.serial(ahName);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -29,31 +29,34 @@
using namespace std;
using namespace NLMISC;
/////////////
// GLOBALS //
/////////////
CInterfaceLink::TLinkList CInterfaceLink::_LinkList;
CInterfaceLink::TLinkVect CInterfaceLink::_LinksWithNoTarget;
//
CInterfaceLink *CInterfaceLink::_FirstTriggeredLink[2] = { NULL, NULL };
CInterfaceLink *CInterfaceLink::_LastTriggeredLink[2] = { NULL, NULL };
CInterfaceLink *CInterfaceLink::_CurrUpdatedLink = NULL;
CInterfaceLink *CInterfaceLink::_NextUpdatedLink = NULL;
uint CInterfaceLink::_CurrentTriggeredLinkList = 0;
bool CInterfaceLink::_UpdateAllLinks = false;
///////////////
// FUNCTIONS //
///////////////
/** Tool fct : affect a value to a reflected property of an interface element.
*/
static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem, const CReflectedProperty &property)
namespace NLGUI
{
/////////////
// GLOBALS //
/////////////
CInterfaceLink::TLinkList CInterfaceLink::_LinkList;
CInterfaceLink::TLinkVect CInterfaceLink::_LinksWithNoTarget;
//
CInterfaceLink *CInterfaceLink::_FirstTriggeredLink[2] = { NULL, NULL };
CInterfaceLink *CInterfaceLink::_LastTriggeredLink[2] = { NULL, NULL };
CInterfaceLink *CInterfaceLink::_CurrUpdatedLink = NULL;
CInterfaceLink *CInterfaceLink::_NextUpdatedLink = NULL;
uint CInterfaceLink::_CurrentTriggeredLinkList = 0;
bool CInterfaceLink::_UpdateAllLinks = false;
///////////////
// FUNCTIONS //
///////////////
/** Tool fct : affect a value to a reflected property of an interface element.
*/
static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem, const CReflectedProperty &property)
{
CInterfaceExprValue valueToAffect = value;
switch(property.Type)
{
@ -128,29 +131,29 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem
}
return true;
}
}
CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater()
{
CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater()
{
NLGUI::CDBManager::getInstance()->addFlushObserver( this );
}
}
CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater()
{
}
CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater()
{
}
void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush()
{
void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush()
{
CInterfaceLink::updateTrigeredLinks();
}
}
/////////////
// MEMBERS //
/////////////
/////////////
// MEMBERS //
/////////////
//===========================================================
CInterfaceLink::CInterfaceLink() : _On(true)
{
//===========================================================
CInterfaceLink::CInterfaceLink() : _On(true)
{
// add an entry in the links list
_LinkList.push_front(this);
_ListEntry = _LinkList.begin();
@ -158,11 +161,11 @@ CInterfaceLink::CInterfaceLink() : _On(true)
_NextTriggeredLink[0] = _NextTriggeredLink[1] = NULL;
_Triggered[0] = _Triggered[1] = false;
_ParseTree = NULL;
}
}
//===========================================================
CInterfaceLink::~CInterfaceLink()
{
//===========================================================
CInterfaceLink::~CInterfaceLink()
{
if (this == _CurrUpdatedLink)
{
_CurrUpdatedLink = NULL;
@ -180,11 +183,11 @@ CInterfaceLink::~CInterfaceLink()
_LinkList.erase(_ListEntry);
delete _ParseTree;
}
}
//===========================================================
bool CInterfaceLink::init(const std::vector<CTargetInfo> &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup)
{
//===========================================================
bool CInterfaceLink::init(const std::vector<CTargetInfo> &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup)
{
CInterfaceExprValue result;
// Build the parse tree
nlassert(!_ParseTree);
@ -239,11 +242,11 @@ bool CInterfaceLink::init(const std::vector<CTargetInfo> &targets, const std::st
_AHCond = ahCond;
_AHParent = parentGroup;
return true;
}
}
//===========================================================
void CInterfaceLink::uninit()
{
//===========================================================
void CInterfaceLink::uninit()
{
for (uint32 i = 0; i < _LinksWithNoTarget.size(); i++)
{
CInterfaceLink *pLink = _LinksWithNoTarget[i];
@ -253,18 +256,18 @@ void CInterfaceLink::uninit()
return;
}
}
}
}
//===========================================================
void CInterfaceLink::update(ICDBNode * /* node */)
{
//===========================================================
void CInterfaceLink::update(ICDBNode * /* node */)
{
// mark link as triggered
linkInTriggerList(_CurrentTriggeredLinkList);
}
}
//===========================================================
void CInterfaceLink::createObservers(const TNodeVect &nodes)
{
//===========================================================
void CInterfaceLink::createObservers(const TNodeVect &nodes)
{
for(std::vector<ICDBNode *>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
{
if ((*it)->isLeaf())
@ -278,11 +281,11 @@ void CInterfaceLink::createObservers(const TNodeVect &nodes)
NLGUI::CDBManager::getInstance()->addBranchObserver( br, this );
}
}
}
}
//===========================================================
void CInterfaceLink::removeObservers(const TNodeVect &nodes)
{
//===========================================================
void CInterfaceLink::removeObservers(const TNodeVect &nodes)
{
for(std::vector<ICDBNode *>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
{
if ((*it)->isLeaf())
@ -296,11 +299,11 @@ void CInterfaceLink::removeObservers(const TNodeVect &nodes)
NLGUI::CDBManager::getInstance()->removeBranchObserver( br, this );
}
}
}
}
//===========================================================
void CInterfaceLink::updateAllLinks()
{
//===========================================================
void CInterfaceLink::updateAllLinks()
{
nlassert(!_UpdateAllLinks);
_UpdateAllLinks = true;
for(TLinkList::iterator it = _LinkList.begin(); it != _LinkList.end(); ++it)
@ -309,11 +312,11 @@ void CInterfaceLink::updateAllLinks()
pLink->update();
}
_UpdateAllLinks = false;
}
}
//===========================================================
void CInterfaceLink::update()
{
//===========================================================
void CInterfaceLink::update()
{
//_On = false; // prvent recursive calls
if (!_ParseTree) return;
static TNodeVect observedNodes; // should not be too big, so ok to keep it static.
@ -369,26 +372,26 @@ void CInterfaceLink::update()
}
//_On = true; // prevent recursive calls
}
}
// predicate to remove an element from a list
struct CRemoveTargetPred
{
// predicate to remove an element from a list
struct CRemoveTargetPred
{
CInterfaceElement *Target;
bool operator()(const CInterfaceLink::CTarget &target) const { return target._InterfaceElement == Target; }
};
};
//===========================================================
void CInterfaceLink::removeTarget(CInterfaceElement *elem)
{
//===========================================================
void CInterfaceLink::removeTarget(CInterfaceElement *elem)
{
CRemoveTargetPred pred;
pred.Target = elem;
_Targets.erase(std::remove_if(_Targets.begin(), _Targets.end(), pred), _Targets.end());
}
}
//===========================================================
bool CInterfaceLink::CTargetInfo::affect(const CInterfaceExprValue &value)
{
//===========================================================
bool CInterfaceLink::CTargetInfo::affect(const CInterfaceExprValue &value)
{
if (!Elem)
{
@ -404,7 +407,7 @@ bool CInterfaceLink::CTargetInfo::affect(const CInterfaceExprValue &value)
return false;
}
// try to affect the property
if (!::affect(value, *Elem, *property))
if (!NLGUI::affect(value, *Elem, *property))
{
nlwarning("<CInterfaceLink::CTargetInfo::affect> Couldn't convert the value to affect to %s", Elem->getId().c_str());
@ -412,11 +415,11 @@ bool CInterfaceLink::CTargetInfo::affect(const CInterfaceExprValue &value)
}
return true;
}
}
//===========================================================
void CInterfaceLink::removeAllLinks()
{
//===========================================================
void CInterfaceLink::removeAllLinks()
{
_LinksWithNoTarget.clear();
TLinkList::iterator curr = _LinkList.begin();
TLinkList::iterator nextIt;
@ -440,11 +443,11 @@ void CInterfaceLink::removeAllLinks()
curr = nextIt;
}
nlassert(_LinkList.empty());
}
}
// ***************************************************************************
bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm)
{
// ***************************************************************************
bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm)
{
// the last token of the target gives the name of the property
std::string::size_type lastPos = target.find_last_of(':');
if (lastPos == (target.length() - 1))
@ -488,12 +491,12 @@ bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup
targetElm = elm;
propertyName = elmProp;
return true;
}
}
// ***************************************************************************
bool CInterfaceLink::splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup,std::vector<CInterfaceLink::CTargetInfo> &targetsVect)
{
// ***************************************************************************
bool CInterfaceLink::splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup,std::vector<CInterfaceLink::CTargetInfo> &targetsVect)
{
std::vector<std::string> targetNames;
NLMISC::splitString(targets, ",", targetNames);
targetsVect.clear();
@ -521,24 +524,24 @@ bool CInterfaceLink::splitLinkTargets(const std::string &targets, CInterfaceGrou
targetsVect.push_back(ti);
}
return everythingOk;
}
}
//===========================================================
void CInterfaceLink::checkNbRefs()
{
//===========================================================
void CInterfaceLink::checkNbRefs()
{
uint numValidPtr = 0;
for(uint k = 0; k < _Targets.size(); ++k)
{
if (_Targets[k]._InterfaceElement != NULL) ++numValidPtr;
}
nlassert(numValidPtr == (uint) crefs);
}
}
//===========================================================
void CInterfaceLink::setTargetProperty (const std::string &Target, const CInterfaceExprValue &val)
{
//===========================================================
void CInterfaceLink::setTargetProperty (const std::string &Target, const CInterfaceExprValue &val)
{
// Eval target !
string elt = Target.substr(0,Target.rfind(':'));
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt);
@ -555,11 +558,11 @@ void CInterfaceLink::setTargetProperty (const std::string &Target, const CInt
vTargets[0].affect(val);
}
}
}
}
//-----------------------------------------------
void CInterfaceLink::linkInTriggerList(uint list)
{
//-----------------------------------------------
void CInterfaceLink::linkInTriggerList(uint list)
{
nlassert(list < 2);
if (_Triggered[list]) return; // already inserted in list
_Triggered[list] = true;
@ -576,11 +579,11 @@ void CInterfaceLink::linkInTriggerList(uint list)
_PrevTriggeredLink[list] = _LastTriggeredLink[list];
_LastTriggeredLink[list] = this;
}
}
}
//-----------------------------------------------
void CInterfaceLink::unlinkFromTriggerList(uint list)
{
//-----------------------------------------------
void CInterfaceLink::unlinkFromTriggerList(uint list)
{
nlassert(list < 2);
if (!_Triggered[list])
{
@ -610,15 +613,15 @@ void CInterfaceLink::unlinkFromTriggerList(uint list)
_PrevTriggeredLink[list] = NULL;
_NextTriggeredLink[list] = NULL;
_Triggered[list] = false;
}
}
//-----------------------------------------------
void CInterfaceLink::updateTrigeredLinks()
{
//-----------------------------------------------
void CInterfaceLink::updateTrigeredLinks()
{
static bool called = false;
nlassert(!called);
called = true;
@ -644,4 +647,8 @@ void CInterfaceLink::updateTrigeredLinks()
_CurrUpdatedLink = _FirstTriggeredLink[_CurrentTriggeredLinkList];
}
called = false;
}
}

View file

@ -23,37 +23,39 @@
using namespace std;
using namespace NLMISC;
// ***************************************************************************
const CInterfaceOptionValue CInterfaceOptionValue::NullValue;
// ***************************************************************************
void CInterfaceOptionValue::init(const std::string &str)
namespace NLGUI
{
const CInterfaceOptionValue CInterfaceOptionValue::NullValue;
// ***************************************************************************
void CInterfaceOptionValue::init(const std::string &str)
{
_Str= str;
fromString(str, _Int);
fromString(str, _Float);
_Color= CInterfaceElement::convertColor (str.c_str());
_Boolean= CInterfaceElement::convertBool(str.c_str());
}
}
// ----------------------------------------------------------------------------
// CInterfaceOptions
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// CInterfaceOptions
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
CInterfaceOptions::CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
CInterfaceOptions::CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
CInterfaceOptions::~CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
CInterfaceOptions::~CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
bool CInterfaceOptions::parse (xmlNodePtr cur)
{
// ----------------------------------------------------------------------------
bool CInterfaceOptions::parse (xmlNodePtr cur)
{
cur = cur->children;
bool ok = true;
while (cur)
@ -78,48 +80,49 @@ bool CInterfaceOptions::parse (xmlNodePtr cur)
cur = cur->next;
}
return ok;
}
}
// ***************************************************************************
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
{
// ***************************************************************************
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
{
_ParamValue= other._ParamValue;
}
}
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
string sLwrParamName = strlwr (sParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (sLwrParamName);
if (it != _ParamValue.end())
return it->second;
else
return CInterfaceOptionValue::NullValue;
}
}
// ***************************************************************************
const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const
{
// ***************************************************************************
const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const
{
return getValue(sParamName).getValStr();
}
// ***************************************************************************
sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const
{
}
// ***************************************************************************
sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const
{
return getValue(sParamName).getValSInt32();
}
// ***************************************************************************
float CInterfaceOptions::getValFloat(const std::string &sParamName) const
{
}
// ***************************************************************************
float CInterfaceOptions::getValFloat(const std::string &sParamName) const
{
return getValue(sParamName).getValFloat();
}
// ***************************************************************************
NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const
{
}
// ***************************************************************************
NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const
{
return getValue(sParamName).getValColor();
}
// ***************************************************************************
bool CInterfaceOptions::getValBool(const std::string &sParamName) const
{
}
// ***************************************************************************
bool CInterfaceOptions::getValBool(const std::string &sParamName) const
{
return getValue(sParamName).getValBool();
}
}
}

View file

@ -18,27 +18,32 @@
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
CViewBase::~CViewBase()
namespace NLGUI
{
CWidgetManager::getInstance()->removeRefOnView (this);
}
// ***************************************************************************
void CViewBase::dumpSize(uint depth /*=0*/) const
{
CViewBase::~CViewBase()
{
CWidgetManager::getInstance()->removeRefOnView (this);
}
// ***************************************************************************
void CViewBase::dumpSize(uint depth /*=0*/) const
{
std::string result;
result.resize(depth * 4, ' ');
std::string::size_type pos = _Id.find_last_of(':');
std::string shortID = pos == std::string::npos ? _Id : _Id.substr(pos);
result += NLMISC::toString("id=%s, w=%d, h=%d, x=%d, y=%d, wreal=%d, hreal=%d, xreal=%d, yreal=%d", shortID.c_str(), (int) _W, (int) _H, (int) _X, (int) _Y, (int) _WReal, (int) _HReal, (int) _XReal, (int) _YReal);
nlinfo(result.c_str());
}
}
// ***************************************************************************
void CViewBase::visit(CInterfaceElementVisitor *visitor)
{
// ***************************************************************************
void CViewBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitView(this);
CInterfaceElement::visit(visitor);
}
}

View file

@ -1,20 +1,40 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/view_pointer_base.h"
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) :
CViewBase( param )
namespace NLGUI
{
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) :
CViewBase( param )
{
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
_PointerDown = false;
_PointerVisible = true;
}
}
CViewPointerBase::~CViewPointerBase()
{
}
CViewPointerBase::~CViewPointerBase()
{
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
{
if (_PointerDown)
{
if (!_PointerDrag)
@ -32,26 +52,26 @@ void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
_PointerX = x;
_PointerY = y;
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y)
{
setX (x);
setY (y);
updateCoords ();
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::resetPointerPos ()
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::resetPointerPos ()
{
_PointerOldX = _PointerX;
_PointerOldY = _PointerY;
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDown (bool pd)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDown (bool pd)
{
_PointerDown = pd;
if (_PointerDown == true)
@ -62,61 +82,61 @@ void CViewPointerBase::setPointerDown (bool pd)
if (_PointerDown == false)
_PointerDrag = false;
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDownString (const std::string &s)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDownString (const std::string &s)
{
_PointerDownString = s;
}
}
// +++ GET +++
// +++ GET +++
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y)
{
x = _PointerX;
y = _PointerY;
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y)
{
x = getX();
y = getY();
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y)
{
x = _PointerOldX;
y = _PointerOldY;
}
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
{
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
{
x = _PointerDownX;
y = _PointerDownY;
}
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDown ()
{
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDown ()
{
return _PointerDown;
}
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDrag ()
{
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDrag ()
{
return _PointerDrag;
}
}
// --------------------------------------------------------------------------------------------------------------------
std::string CViewPointerBase::getPointerDownString ()
{
// --------------------------------------------------------------------------------------------------------------------
std::string CViewPointerBase::getPointerDownString ()
{
return _PointerDownString;
}
}

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@
using namespace NLMISC;
using namespace NL3D;
using namespace NLGUI;
// TODO nico : that stuff was coded in a hurry, but could be good to add it to NL3D with a better packaging later...

View file

@ -33,6 +33,8 @@ using namespace NL3D;
#include "../user_entity.h"
#include "../connection.h"
using namespace NLGUI;
////////////
// GLOBAL //
////////////

View file

@ -23,7 +23,10 @@
#include "nel/gui/action_handler.h"
#include "interface_manager.h"
class CInterfaceGroup;
namespace NLGUI
{
class CInterfaceGroup;
}
// ***************************************************************************

View file

@ -22,7 +22,11 @@
class CBotChatPage;
class CPrerequisitInfos;
class CInterfaceGroup;
namespace NLGUI
{
class CInterfaceGroup;
}
class IMissionPrereqInfosWaiter
{

View file

@ -21,7 +21,11 @@
#include "nel/misc/rgba.h"
class CViewBase;
namespace NLGUI
{
class CViewBase;
}
class ucstring;
namespace NLMISC{
class CCDBNodeLeaf;
@ -46,7 +50,7 @@ public:
* \param col the color of the text
* \param justified Should be true for justified text (stretch spaces of line to fill the full width)
*/
CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false);
NLGUI::CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false);
// Singleton access
static CChatTextManager &getInstance();

View file

@ -24,10 +24,15 @@
#include "game_share/chat_group.h"
namespace NLGUI
{
class CCtrlBase;
}
class CChatWindow;
class CGroupContainer;
class CGroupEditBox;
class CCtrlBase;
class CViewText;
/** Interface to react to a chat box entry
@ -240,7 +245,7 @@ public:
// Remove a chat window by its pointer
void removeChatWindow(CChatWindow *cw);
/// from a ctrl of a chat box that triggered a menu, or an event, retrieve the associated chat box
CChatWindow *getChatWindowFromCaller(CCtrlBase *caller);
CChatWindow *getChatWindowFromCaller(NLGUI::CCtrlBase *caller);
// Singleton pattern applied to the chat window manager
static CChatWindowManager &getInstance();
// try to rename a window

View file

@ -22,7 +22,11 @@
class CDBCtrlSheet;
class IActionHandler;
namespace NLGUI
{
class IActionHandler;
}
/** Infos about a selection group
*/

View file

@ -107,10 +107,6 @@
#include "../npc_icon.h"
#include "nel/gui/lua_helper.h"
namespace NLGUI
{
extern void luaDebuggerMainLoop();
}
using namespace NLGUI;
#include "nel/gui/lua_ihm.h"
#include "lua_ihm_ryzom.h"
@ -128,9 +124,14 @@ using namespace NLGUI;
using namespace NLMISC;
namespace NLGUI
{
extern void luaDebuggerMainLoop();
extern NLMISC::CStringMapper *_UIStringMapper;
}
extern CClientChatManager ChatMngr;
extern CContinentManager ContinentMngr;
extern CStringMapper *_UIStringMapper;
extern bool IsInRingSession;
extern CEventsListener EventsListener;

View file

@ -69,8 +69,12 @@ extern bool g_hidden;
// #define AJM_DEBUG_TRACK_INTERFACE_GROUPS
namespace NLGUI
{
class CInterfaceOptions;
}
class CGroupContainer;
class CInterfaceOptions;
class CInterfaceAnim;
class CGroupMenu;

View file

@ -20,6 +20,8 @@
#include "nel/gui/interface_options.h"
using namespace NLGUI;
// ***************************************************************************
class COptionsLayer : public CInterfaceOptions
{

View file

@ -29,17 +29,20 @@
#include "nel/gui/widget_manager.h"
using namespace NLGUI;
// ***************************************************************************
class CInterfaceElement;
class CInterfaceGroup;
namespace NLGUI
{
class CInterfaceElement;
class CInterfaceGroup;
class CInterfaceOptions;
class CInterfaceLink;
class CCtrlBase;
}
class CGroupContainer;
class CGroupList;
class CInterfaceOptions;
class CInterfaceAnim;
class CViewPointer;
class CInterfaceLink;
class CBrickJob;
class CCtrlBase;
// ***************************************************************************
/**

View file

@ -21,7 +21,16 @@
#include "nel/misc/resource_ptr.h"
class CInterfaceElement *getInterfaceResource(const std::string &key);
namespace NLGUI
{
class CInterfaceElement;
class CCtrlBase;
class CInterfaceGroup;
}
using namespace NLGUI;
CInterfaceElement *getInterfaceResource(const std::string &key);
/** Interface element ptr
* This pointer uses the NLMISC::CResourcePtr
@ -47,13 +56,12 @@ public:
};
// Some pointers
typedef CInterfacePtr<class CInterfaceElement>::TInterfacePtr CInterfaceElementPtr;
typedef CInterfacePtr<class CInterfaceGroup>::TInterfacePtr CInterfaceGroupPtr;
typedef CInterfacePtr<CInterfaceElement>::TInterfacePtr CInterfaceElementPtr;
typedef CInterfacePtr<CInterfaceGroup>::TInterfacePtr CInterfaceGroupPtr;
typedef CInterfacePtr<class CCtrlTextButton>::TInterfacePtr CCtrlTextButtonPtr;
typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<class CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<class CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr;
typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr;

View file

@ -24,7 +24,11 @@
#include "nel/gui/view_pointer_base.h"
class CGroupContainer;
class CCtrlBase;
namespace NLGUI
{
class CCtrlBase;
}
/**
* class describing the pointer

View file

@ -38,7 +38,7 @@ class CObjectTable;
* - one for the ui (displaying instance in the object tree for example)
* - one for the property sheet of the instance
*/
class CDisplayerBase : public NLMISC::IClassable, public CReflectableRefPtrTarget
class CDisplayerBase : public NLMISC::IClassable, public NLGUI::CReflectableRefPtrTarget
{
public:
typedef NLMISC::CSmartPtr<CDisplayerBase> TSmartPtr;