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

--HG--
branch : gui-refactoring
hg/feature/sse2
dfighter1985 13 years ago
parent 56a75a90ab
commit c792abe091

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

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

@ -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 #ifndef CTRL_DRAGGABLE_H
#define CTRL_DRAGGABLE_H #define CTRL_DRAGGABLE_H
#include "nel/gui/ctrl_base.h" #include "nel/gui/ctrl_base.h"
class CCtrlDraggable : public CCtrlBase namespace NLGUI
{ {
public:
class CCtrlDraggable : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlDraggable ) DECLARE_UI_CLASS( CCtrlDraggable )
CCtrlDraggable( const TCtorParam &param ); CCtrlDraggable( const TCtorParam &param );
@ -30,13 +50,15 @@ public:
REFLECT_BOOL("dragable", isDraggable, setDraggable); REFLECT_BOOL("dragable", isDraggable, setDraggable);
REFLECT_EXPORT_END REFLECT_EXPORT_END
protected: protected:
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; } static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
private: private:
static CCtrlDraggable *_LastDraggedSheet; static CCtrlDraggable *_LastDraggedSheet;
bool dragged; bool dragged;
bool draggable; bool draggable;
}; };
}
#endif #endif

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

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

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

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

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

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

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

@ -27,17 +27,10 @@ namespace NLGUI
class CReflectedProperty; class CReflectedProperty;
class CInterfaceExprValue; class CInterfaceExprValue;
class CInterfaceExprNode; 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 * 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 * 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). * 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 * \author Nevrax France
* \date 2002 * \date 2002
*/ */
class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver
{ {
public: public:
#ifdef NL_DEBUG #ifdef NL_DEBUG
// for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager // 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 // and was created by calling CInterfaceManager::addLink, contains the name of this link
std::string LinkName; std::string LinkName;
#endif #endif
public: public:
struct CTargetInfo struct CTargetInfo
{ {
CInterfaceElement *Elem; CInterfaceElement *Elem;
@ -84,7 +77,7 @@ public:
void onObserverCallFlush(); void onObserverCallFlush();
}; };
public: public:
CInterfaceLink(); CInterfaceLink();
~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement ~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. /** 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 * \return true if all targets are valid
*/ */
static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector<CInterfaceLink::CTargetInfo> &targetsVect); static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector<CInterfaceLink::CTargetInfo> &targetsVect);
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
private: private:
friend struct CRemoveTargetPred; friend struct CRemoveTargetPred;
// a target property // a target property
struct CTarget struct CTarget
@ -135,12 +128,12 @@ private:
CInterfaceElement *_InterfaceElement; CInterfaceElement *_InterfaceElement;
const CReflectedProperty *_Property; const CReflectedProperty *_Property;
}; };
private: private:
typedef std::list<CInterfaceLink *> TLinkList; typedef std::list<CInterfaceLink *> TLinkList;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr; typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect; typedef std::vector<TLinkSmartPtr> TLinkVect;
typedef std::vector<NLMISC::ICDBNode *> TNodeVect; typedef std::vector<NLMISC::ICDBNode *> TNodeVect;
private: private:
std::vector<CTarget> _Targets; std::vector<CTarget> _Targets;
TNodeVect _ObservedNodes; TNodeVect _ObservedNodes;
std::string _Expr; std::string _Expr;
@ -176,7 +169,7 @@ private:
void unlinkFromTriggerList(uint list); void unlinkFromTriggerList(uint list);
//@} //@}
private: private:
/** Inherited from ICDBNode::IPropertyObserver /** Inherited from ICDBNode::IPropertyObserver
* This doesn't update the node directly, but mark it as 'triggered' * This doesn't update the node directly, but mark it as 'triggered'
* The node is really updated during the call to 'updateTrigeredLinks()' * The node is really updated during the call to 'updateTrigeredLinks()'
@ -186,6 +179,8 @@ private:
void removeObservers(const TNodeVect &nodes); void removeObservers(const TNodeVect &nodes);
// debug : check that there are as many targets as reference to a link // debug : check that there are as many targets as reference to a link
void checkNbRefs(); void checkNbRefs();
}; };
}
#endif #endif

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

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

@ -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 #ifndef VIEW_POINTER_BASE_H
#define VIEW_POINTER_BASE_H #define VIEW_POINTER_BASE_H
#include "nel/gui/view_base.h" #include "nel/gui/view_base.h"
class CViewPointerBase : public CViewBase namespace NLGUI
{ {
public:
class CViewPointerBase : public CViewBase
{
public:
DECLARE_UI_CLASS( CViewPointerBase ) DECLARE_UI_CLASS( CViewPointerBase )
CViewPointerBase( const TCtorParam &param ); CViewPointerBase( const TCtorParam &param );
@ -33,7 +53,7 @@ public:
void draw(){} void draw(){}
protected: protected:
// (x,y) is from the TopLeft corner of the window // (x,y) is from the TopLeft corner of the window
sint32 _PointerX; // Current pointer position (raw, before snapping) sint32 _PointerX; // Current pointer position (raw, before snapping)
sint32 _PointerY; sint32 _PointerY;
@ -46,10 +66,12 @@ protected:
bool _PointerDrag; // Is the pointer down and we have moved ? bool _PointerDrag; // Is the pointer down and we have moved ?
bool _PointerVisible; // Is the pointer visible or hidden ? bool _PointerVisible; // Is the pointer visible or hidden ?
private: private:
};
}; }
#endif #endif

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

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

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

@ -1,11 +1,32 @@
#include "nel/gui/ctrl_draggable.h" // 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/>.
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL; #include "nel/gui/ctrl_draggable.h"
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) : namespace NLGUI
CCtrlBase( param )
{ {
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
{
dragged = false; dragged = false;
draggable = false; draggable = false;
} }
}

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

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

@ -1,14 +1,36 @@
#include "nel/gui/group_editbox_base.h" // 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/>.
CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL; #include "nel/gui/group_editbox_base.h"
CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam &param ) : namespace NLGUI
CInterfaceGroup( param )
{ {
CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL;
CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam &param ) :
CInterfaceGroup( param )
{
_RecoverFocusOnEnter = true; _RecoverFocusOnEnter = true;
} }
CGroupEditBoxBase::~CGroupEditBoxBase()
{
}
CGroupEditBoxBase::~CGroupEditBoxBase()
{
} }

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

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

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

File diff suppressed because it is too large Load Diff

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

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

@ -18,27 +18,32 @@
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h" #include "nel/gui/widget_manager.h"
CViewBase::~CViewBase() namespace NLGUI
{ {
CViewBase::~CViewBase()
{
CWidgetManager::getInstance()->removeRefOnView (this); CWidgetManager::getInstance()->removeRefOnView (this);
} }
// *************************************************************************** // ***************************************************************************
void CViewBase::dumpSize(uint depth /*=0*/) const void CViewBase::dumpSize(uint depth /*=0*/) const
{ {
std::string result; std::string result;
result.resize(depth * 4, ' '); result.resize(depth * 4, ' ');
std::string::size_type pos = _Id.find_last_of(':'); std::string::size_type pos = _Id.find_last_of(':');
std::string shortID = pos == std::string::npos ? _Id : _Id.substr(pos); 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); 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()); nlinfo(result.c_str());
} }
// *************************************************************************** // ***************************************************************************
void CViewBase::visit(CInterfaceElementVisitor *visitor) void CViewBase::visit(CInterfaceElementVisitor *visitor)
{ {
nlassert(visitor); nlassert(visitor);
visitor->visitView(this); visitor->visitView(this);
CInterfaceElement::visit(visitor); CInterfaceElement::visit(visitor);
}
} }

@ -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" #include "nel/gui/view_pointer_base.h"
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) : namespace NLGUI
CViewBase( param )
{ {
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) :
CViewBase( param )
{
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0; _PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
_PointerDown = false; _PointerDown = false;
_PointerVisible = true; _PointerVisible = true;
} }
CViewPointerBase::~CViewPointerBase() CViewPointerBase::~CViewPointerBase()
{ {
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerPos (sint32 x, sint32 y) void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
{ {
if (_PointerDown) if (_PointerDown)
{ {
if (!_PointerDrag) if (!_PointerDrag)
@ -32,26 +52,26 @@ void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
_PointerX = x; _PointerX = x;
_PointerY = y; _PointerY = y;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y) void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y)
{ {
setX (x); setX (x);
setY (y); setY (y);
updateCoords (); updateCoords ();
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::resetPointerPos () void CViewPointerBase::resetPointerPos ()
{ {
_PointerOldX = _PointerX; _PointerOldX = _PointerX;
_PointerOldY = _PointerY; _PointerOldY = _PointerY;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDown (bool pd) void CViewPointerBase::setPointerDown (bool pd)
{ {
_PointerDown = pd; _PointerDown = pd;
if (_PointerDown == true) if (_PointerDown == true)
@ -62,61 +82,61 @@ void CViewPointerBase::setPointerDown (bool pd)
if (_PointerDown == false) if (_PointerDown == false)
_PointerDrag = false; _PointerDrag = false;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDownString (const std::string &s) void CViewPointerBase::setPointerDownString (const std::string &s)
{ {
_PointerDownString = s; _PointerDownString = s;
} }
// +++ GET +++ // +++ GET +++
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y) void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y)
{ {
x = _PointerX; x = _PointerX;
y = _PointerY; y = _PointerY;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y) void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y)
{ {
x = getX(); x = getX();
y = getY(); y = getY();
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y) void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y)
{ {
x = _PointerOldX; x = _PointerOldX;
y = _PointerOldY; y = _PointerOldY;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y) void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
{ {
x = _PointerDownX; x = _PointerDownX;
y = _PointerDownY; y = _PointerDownY;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDown () bool CViewPointerBase::getPointerDown ()
{ {
return _PointerDown; return _PointerDown;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDrag () bool CViewPointerBase::getPointerDrag ()
{ {
return _PointerDrag; return _PointerDrag;
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
std::string CViewPointerBase::getPointerDownString () std::string CViewPointerBase::getPointerDownString ()
{ {
return _PointerDownString; return _PointerDownString;
} }
}

File diff suppressed because it is too large Load Diff

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

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

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

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

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

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

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

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

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

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

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

@ -21,7 +21,16 @@
#include "nel/misc/resource_ptr.h" #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 /** Interface element ptr
* This pointer uses the NLMISC::CResourcePtr * This pointer uses the NLMISC::CResourcePtr
@ -47,13 +56,12 @@ public:
}; };
// Some pointers // Some pointers
typedef CInterfacePtr<class CInterfaceElement>::TInterfacePtr CInterfaceElementPtr; typedef CInterfacePtr<CInterfaceElement>::TInterfacePtr CInterfaceElementPtr;
typedef CInterfacePtr<class CInterfaceGroup>::TInterfacePtr CInterfaceGroupPtr; typedef CInterfacePtr<CInterfaceGroup>::TInterfacePtr CInterfaceGroupPtr;
typedef CInterfacePtr<class CCtrlTextButton>::TInterfacePtr CCtrlTextButtonPtr; typedef CInterfacePtr<class CCtrlTextButton>::TInterfacePtr CCtrlTextButtonPtr;
typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr; typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr<CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<class CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<class CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr; typedef CInterfacePtr<class CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr;
typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr; typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr;

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

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

Loading…
Cancel
Save