CHANGED: #1471 Moved some code from CGroupContainer to CGroupContainerBase. CAHManager now depends on CGroupContainerBase instead of CGroupContainer.

This commit is contained in:
dfighter1985 2012-06-08 04:41:33 +02:00
parent 3a99551784
commit 7ddc76cc85
5 changed files with 112 additions and 116 deletions

View file

@ -15,7 +15,9 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_handler.h" #include "action_handler.h"
#include "group_container.h" //#include "group_container.h"
#include "group_container_base.h"
#include "nel/gui/interface_property.h"
#include "nel/gui/interface_expr.h" #include "nel/gui/interface_expr.h"
#include "nel/gui/db_manager.h" #include "nel/gui/db_manager.h"
#include "interface_link.h" #include "interface_link.h"
@ -481,7 +483,7 @@ REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w");
//////////////////////////////// ////////////////////////////////
// the container whose alpha is being edited // the container whose alpha is being edited
static CGroupContainer *AlphaChooserTarget = NULL; static CGroupContainerBase *AlphaChooserTarget = NULL;
static bool OldUseGlobalAlpha; static bool OldUseGlobalAlpha;
static uint8 OldContentAlpha; static uint8 OldContentAlpha;
static uint8 OldBgAlpha; static uint8 OldBgAlpha;
@ -518,11 +520,11 @@ class CAHChooseUIAlpha : public IActionHandler
public: public:
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
{ {
CGroupContainer *gc = NULL; CGroupContainerBase *gc = NULL;
CCtrlBase *cb = pCaller; CCtrlBase *cb = pCaller;
while (cb) while (cb)
{ {
gc = dynamic_cast<CGroupContainer *>(cb); gc = dynamic_cast<CGroupContainerBase*>(cb);
if (gc) break; if (gc) break;
cb = cb->getParent(); cb = cb->getParent();
} }
@ -635,11 +637,11 @@ class CAHLockUnlock : public IActionHandler
{ {
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
{ {
CGroupContainer *gc = NULL; CGroupContainerBase *gc = NULL;
CCtrlBase *cb = pCaller; CCtrlBase *cb = pCaller;
while (cb) while (cb)
{ {
gc = dynamic_cast<CGroupContainer *>(cb); gc = dynamic_cast< CGroupContainerBase* >(cb);
if (gc) break; if (gc) break;
cb = cb->getParent(); cb = cb->getParent();
} }
@ -655,7 +657,7 @@ class CAHSetTransparent : public IActionHandler
{ {
virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params)
{ {
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId(Params)); CGroupContainerBase *pGC = dynamic_cast< CGroupContainerBase* >(CWidgetManager::getInstance()->getElementFromId(Params));
if (pGC != NULL) if (pGC != NULL)
{ {
pGC->setUseGlobalAlpha(false); pGC->setUseGlobalAlpha(false);
@ -678,7 +680,7 @@ class CAHSetAlpha : public IActionHandler
uint8 alpha; uint8 alpha;
fromString(getParam (Params, "alpha"), alpha); fromString(getParam (Params, "alpha"), alpha);
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId(ui)); CGroupContainerBase *pGC = dynamic_cast<CGroupContainerBase*>(CWidgetManager::getInstance()->getElementFromId(ui));
if (pGC != NULL) if (pGC != NULL)
{ {
pGC->setUseGlobalAlpha(false); pGC->setUseGlobalAlpha(false);

View file

@ -1200,10 +1200,6 @@ CGroupContainer::CGroupContainer(const TCtorParam &param)
// faster than a virual call // faster than a virual call
_IsGroupContainer = true; _IsGroupContainer = true;
_ContentAlpha = 255;
_ContainerAlpha = 255;
_RolloverAlphaContainer = 0;
_RolloverAlphaContent = 0;
_CurrentContainerAlpha = 255; _CurrentContainerAlpha = 255;
_CurrentContentAlpha = 255; _CurrentContentAlpha = 255;
_CurrentRolloverAlphaContainer = 0.f; _CurrentRolloverAlphaContainer = 0.f;
@ -1250,7 +1246,6 @@ CGroupContainer::CGroupContainer(const TCtorParam &param)
_OpenAtStart = false; _OpenAtStart = false;
_OpenedBeforePopup = false; _OpenedBeforePopup = false;
_Locked = false;
_Lockable = true; _Lockable = true;
_EnabledResizer = true; _EnabledResizer = true;
@ -1265,7 +1260,6 @@ CGroupContainer::CGroupContainer(const TCtorParam &param)
_MovingInParentList = false; _MovingInParentList = false;
_ActiveSavable = true; _ActiveSavable = true;
_Savable = true; _Savable = true;
_UseGlobalAlpha = true;
_TitleClass = TitleText; _TitleClass = TitleText;
_TouchFlag = false; _TouchFlag = false;
_PositionBackuped = false; _PositionBackuped = false;
@ -4028,52 +4022,3 @@ void CGroupContainer::setContentYOffset(sint32 value)
} }
// ***************************************************************************
void CGroupContainer::triggerAlphaSettingsChangedAH()
{
if (_AHOnAlphaSettingsChanged != NULL)
{
CInterfaceManager *im = CInterfaceManager::getInstance();
CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams);
}
}
// ***************************************************************************
void CGroupContainer::setUseGlobalAlpha(bool use)
{
_UseGlobalAlpha = use;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainer::setContainerAlpha(uint8 alpha)
{
_ContainerAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainer::setContentAlpha(uint8 alpha)
{
_ContentAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainer::setRolloverAlphaContent(uint8 alpha)
{
_RolloverAlphaContent = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainer::setRolloverAlphaContainer(uint8 alpha)
{
_RolloverAlphaContainer = alpha;
triggerAlphaSettingsChangedAH();
}

View file

@ -289,13 +289,7 @@ public:
REFLECT_BOOL("opened", isOpen, setOpen); REFLECT_BOOL("opened", isOpen, setOpen);
REFLECT_BOOL("lockable", isLockable, setLockable); REFLECT_BOOL("lockable", isLockable, setLockable);
REFLECT_BOOL("locked", isLocked, setLocked); REFLECT_BOOL("locked", isLocked, setLocked);
REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha);
REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha);
REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent);
REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer);
REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha);
REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged);
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive);
REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled);
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -372,33 +366,8 @@ public:
sint32 getRefW() const { return _RefW; } sint32 getRefW() const { return _RefW; }
// alpha for content / container
void setUseGlobalAlpha(bool use);
void setContainerAlpha(uint8 alpha);
void setContentAlpha(uint8 alpha);
void setRolloverAlphaContent(uint8 alpha);
void setRolloverAlphaContainer(uint8 alpha);
// sin32 versions for export
void setContainerAlpha(sint32 alpha) { setContainerAlpha((uint8) alpha); }
void setContentAlpha(sint32 alpha) { setContentAlpha((uint8) alpha); }
void setRolloverAlphaContent(sint32 alpha) { setRolloverAlphaContent((uint8) alpha); }
void setRolloverAlphaContainer(sint32 alpha) { setRolloverAlphaContainer((uint8) alpha); }
bool isUsingGlobalAlpha() const { return _UseGlobalAlpha; }
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getCurrentContainerAlpha() const { return _CurrentContainerAlpha; } uint8 getCurrentContainerAlpha() const { return _CurrentContainerAlpha; }
uint8 getCurrentContentAlpha() const { return _CurrentContentAlpha; } uint8 getCurrentContentAlpha() const { return _CurrentContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
// for export
sint32 getContainerAlphaAsSInt32() const { return (sint32) _ContainerAlpha; }
sint32 getContentAlphaAsSInt32() const { return (sint32) _ContentAlpha; }
sint32 getRolloverAlphaContentAsSInt32() const { return (sint32) _RolloverAlphaContent; }
sint32 getRolloverAlphaContainerAsSInt32() const { return (sint32) _RolloverAlphaContainer; }
/** Increase the rollover alpha for the current frame. /** Increase the rollover alpha for the current frame.
* Example of use : an edit box that has focus in a group container * Example of use : an edit box that has focus in a group container
@ -413,7 +382,6 @@ public:
void setLockable(bool lockable); void setLockable(bool lockable);
bool isLockable() const { return _Lockable; } bool isLockable() const { return _Lockable; }
void setLocked(bool locked); void setLocked(bool locked);
bool isLocked() const { return _Locked; }
// to be called by the 'deactive check' handler // to be called by the 'deactive check' handler
static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; } static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; }
@ -439,17 +407,6 @@ public:
void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); } void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); }
void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; } void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; }
std::string getAHOnAlphaSettingsChanged() const { return CAHManager::getInstance()->getAHName(_AHOnAlphaSettingsChanged); }
std::string getAHOnAlphaSettingsChangedParams() const { return _AHOnAlphaSettingsChangedParams; }
void setAHOnAlphaSettingsChanged(const std::string &h) { _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH(h, _AHOnAlphaSettingsChangedParams); }
void setAHOnAlphaSettingsChangedParams(const std::string &p) { _AHOnAlphaSettingsChangedParams = p; }
void setModalParentList (const std::string &name); void setModalParentList (const std::string &name);
bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window)
bool isGrayed() const; bool isGrayed() const;
@ -506,13 +463,9 @@ public:
sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; } sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; }
protected: protected:
uint8 _ContainerAlpha;
uint8 _ContentAlpha;
uint8 _CurrentContainerAlpha; uint8 _CurrentContainerAlpha;
uint8 _CurrentContentAlpha; uint8 _CurrentContentAlpha;
uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it
uint8 _ICurrentRolloverAlphaContainer; uint8 _ICurrentRolloverAlphaContainer;
uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it
uint8 _HighLightedAlpha; uint8 _HighLightedAlpha;
float _CurrentRolloverAlphaContainer; float _CurrentRolloverAlphaContainer;
float _CurrentRolloverAlphaContent; float _CurrentRolloverAlphaContent;
@ -585,8 +538,6 @@ protected:
CStringShared _AHOnMoveParams; CStringShared _AHOnMoveParams;
IActionHandler *_AHOnResize; IActionHandler *_AHOnResize;
CStringShared _AHOnResizeParams; CStringShared _AHOnResizeParams;
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
IActionHandler *_AHOnBeginMove; IActionHandler *_AHOnBeginMove;
CStringShared _AHOnBeginMoveParams; CStringShared _AHOnBeginMoveParams;
@ -612,7 +563,6 @@ protected:
// Move management // Move management
bool _Movable : 1; // Is the container movable ? bool _Movable : 1; // Is the container movable ?
bool _MovableInParentList: 1; bool _MovableInParentList: 1;
bool _Locked : 1; // Is the container locked (ie override movable, openable ...)
bool _Lockable : 1; bool _Lockable : 1;
bool _MovingInParentList : 1; // Mgt : currently moving ? bool _MovingInParentList : 1; // Mgt : currently moving ?
@ -628,7 +578,6 @@ protected:
bool _Savable : 1; bool _Savable : 1;
bool _ActiveSavable : 1; bool _ActiveSavable : 1;
bool _UseGlobalAlpha : 1;
// Display title background or not // Display title background or not
bool _HeaderActive : 1; bool _HeaderActive : 1;
@ -694,7 +643,6 @@ private:
enum {NumLayerName=10}; enum {NumLayerName=10};
static const std::string _OptionLayerName[NumLayerName]; static const std::string _OptionLayerName[NumLayerName];
void triggerAlphaSettingsChangedAH();
public: public:
// for use by CCtrlMover // for use by CCtrlMover
// Tell that this group is moving in its parent list // Tell that this group is moving in its parent list

View file

@ -20,6 +20,12 @@
CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam &param ) : CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam &param ) :
CInterfaceGroup( param ) CInterfaceGroup( param )
{ {
_ContentAlpha = 255;
_ContainerAlpha = 255;
_RolloverAlphaContainer = 0;
_RolloverAlphaContent = 0;
_Locked = false;
_UseGlobalAlpha = true;
} }
CGroupContainerBase::~CGroupContainerBase() CGroupContainerBase::~CGroupContainerBase()
@ -41,3 +47,46 @@ void CGroupContainerBase::setLocked( bool locked )
} }
// ***************************************************************************
void CGroupContainerBase::triggerAlphaSettingsChangedAH()
{
if (_AHOnAlphaSettingsChanged != NULL)
CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams);
}
// ***************************************************************************
void CGroupContainerBase::setUseGlobalAlpha(bool use)
{
_UseGlobalAlpha = use;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setContainerAlpha(uint8 alpha)
{
_ContainerAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setContentAlpha(uint8 alpha)
{
_ContentAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha)
{
_RolloverAlphaContent = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha)
{
_RolloverAlphaContainer = alpha;
triggerAlphaSettingsChangedAH();
}

View file

@ -20,20 +20,72 @@
#include "interface_group.h" #include "interface_group.h"
class CGroupContainerBase : public CInterfaceGroup class CGroupContainerBase : public CInterfaceGroup
{ {
public: public:
DECLARE_UI_CLASS( CGroupContainerBase ) DECLARE_UI_CLASS( CGroupContainerBase )
CGroupContainerBase( const TCtorParam &param ); CGroupContainerBase( const TCtorParam &param );
virtual ~CGroupContainerBase(); virtual ~CGroupContainerBase();
virtual void removeAllContainers(); virtual void removeAllContainers();
virtual void setLocked( bool locked ); virtual void setLocked( bool locked );
bool isLocked() const { return _Locked; }
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
void setContainerAlpha( uint8 alpha );
void setContentAlpha( uint8 alpha );
void setRolloverAlphaContent( uint8 alpha );
void setRolloverAlphaContainer( uint8 alpha );
// for export
sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; }
sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; }
sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; }
sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; }
// sin32 versions for export
void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); }
void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); }
void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); }
void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); }
void setUseGlobalAlpha( bool use );
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup ) REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup )
REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha);
REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha);
REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent);
REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer);
REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha);
REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged);
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
REFLECT_EXPORT_END REFLECT_EXPORT_END
protected: protected:
void triggerAlphaSettingsChangedAH();
uint8 _ContainerAlpha;
uint8 _ContentAlpha;
uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it
uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it
bool _Locked : 1; // Is the container locked (ie override movable, openable ...)
bool _UseGlobalAlpha : 1;
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
private: private: