diff --git a/include/eepp/ui/actions/actioninterpolation1d.hpp b/include/eepp/ui/actions/actioninterpolation1d.hpp new file mode 100644 index 000000000..b1e1a6e51 --- /dev/null +++ b/include/eepp/ui/actions/actioninterpolation1d.hpp @@ -0,0 +1,32 @@ +#ifndef EE_UI_ACTIONINTERPOLATION1D_HPP +#define EE_UI_ACTIONINTERPOLATION1D_HPP + +#include +#include +using namespace EE::Math; + +namespace EE { namespace UI { namespace Action { + +class ActionInterpolation1d : public UIAction { + public: + void start() override; + + void stop() override; + + void update( const Time& time ) override; + + bool isDone() override; + + Interpolation1d * getInterpolation(); + protected: + Interpolation1d mInterpolation; + + ActionInterpolation1d(); + + void setInterpolation( Interpolation1d interpolation ); +}; + +}}} + +#endif + diff --git a/include/eepp/ui/actions/actioninterpolation2d.hpp b/include/eepp/ui/actions/actioninterpolation2d.hpp new file mode 100644 index 000000000..b4fec4cc5 --- /dev/null +++ b/include/eepp/ui/actions/actioninterpolation2d.hpp @@ -0,0 +1,32 @@ +#ifndef EE_UI_ACTIONINTERPOLATION2D_HPP +#define EE_UI_ACTIONINTERPOLATION2D_HPP + +#include +#include +using namespace EE::Math; + +namespace EE { namespace UI { namespace Action { + +class ActionInterpolation2d : public UIAction { + public: + void start() override; + + void stop() override; + + void update( const Time& time ) override; + + bool isDone() override; + + Interpolation2d * getInterpolation(); + protected: + Interpolation2d mInterpolation; + + ActionInterpolation2d(); + + void setInterpolation( Interpolation2d interpolation ); +}; + +}}} + +#endif + diff --git a/include/eepp/ui/actions/fade.hpp b/include/eepp/ui/actions/fade.hpp new file mode 100644 index 000000000..40c16552a --- /dev/null +++ b/include/eepp/ui/actions/fade.hpp @@ -0,0 +1,31 @@ +#ifndef EE_UI_ACTION_FADE_HPP +#define EE_UI_ACTION_FADE_HPP + +#include +#include + +namespace EE { namespace UI { namespace Action { + +class Fade : public ActionInterpolation1d { + public: + static Fade * New( const Float& start, const Float& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear, const bool& alphaChilds = true ); + + UIAction * clone() const; + + UIAction * reverse() const; + protected: + Fade( const Float & start, const Float & end, const Time & duration, const Ease::Interpolation & type, const bool& alphaChilds ); + + void onStart(); + + void onUpdate( const Time& time ); + + bool mAffectChilds; + private: + Fade(); +}; + +}}} + +#endif + diff --git a/include/eepp/ui/actions/move.hpp b/include/eepp/ui/actions/move.hpp new file mode 100644 index 000000000..47319fbd7 --- /dev/null +++ b/include/eepp/ui/actions/move.hpp @@ -0,0 +1,29 @@ +#ifndef EE_UI_ACTION_MOVE_HPP +#define EE_UI_ACTION_MOVE_HPP + +#include +#include + +namespace EE { namespace UI { namespace Action { + +class Move : public ActionInterpolation2d { + public: + static Move * New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear ); + + UIAction * clone() const; + + UIAction * reverse() const; + protected: + Move( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type ); + + void onStart(); + + void onUpdate( const Time& time ); + private: + Move(); +}; + +}}} + +#endif + diff --git a/include/eepp/ui/actions/rotate.hpp b/include/eepp/ui/actions/rotate.hpp new file mode 100644 index 000000000..5305a34eb --- /dev/null +++ b/include/eepp/ui/actions/rotate.hpp @@ -0,0 +1,29 @@ +#ifndef EE_UI_ACTION_ROTATE_HPP +#define EE_UI_ACTION_ROTATE_HPP + +#include +#include + +namespace EE { namespace UI { namespace Action { + +class Rotate : public ActionInterpolation1d { + public: + static Rotate * New( const Float& start, const Float& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear ); + + UIAction * clone() const; + + UIAction * reverse() const; + protected: + Rotate( const Float & start, const Float & end, const Time & duration, const Ease::Interpolation & type ); + + void onStart(); + + void onUpdate( const Time& time ); + private: + Rotate(); +}; + +}}} + +#endif + diff --git a/include/eepp/ui/actions/scale.hpp b/include/eepp/ui/actions/scale.hpp new file mode 100644 index 000000000..4b76624a2 --- /dev/null +++ b/include/eepp/ui/actions/scale.hpp @@ -0,0 +1,29 @@ +#ifndef EE_UI_ACTION_SCALE_HPP +#define EE_UI_ACTION_SCALE_HPP + +#include +#include + +namespace EE { namespace UI { namespace Action { + +class Scale : public ActionInterpolation2d { + public: + static Scale * New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear ); + + UIAction * clone() const; + + UIAction * reverse() const; + protected: + Scale( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type ); + + void onStart(); + + void onUpdate( const Time& time ); + private: + Scale(); +}; + +}}} + +#endif + diff --git a/include/eepp/ui/uiaction.hpp b/include/eepp/ui/uiaction.hpp new file mode 100644 index 000000000..1719da66d --- /dev/null +++ b/include/eepp/ui/uiaction.hpp @@ -0,0 +1,78 @@ +#ifndef EE_UIACTION_HPP +#define EE_UIACTION_HPP + +#include +#include +#include +using namespace EE::System; + +namespace EE { namespace UI { + +class UINode; + +class UIAction { + public: + enum ActionType + { + OnStart, + OnStop, + OnDone + }; + + typedef cb::Callback2 ActionCallback; + + UIAction(); + + virtual ~UIAction(); + + virtual void start() = 0; + + virtual void stop() = 0; + + virtual void update( const Time& time ) = 0; + + virtual bool isDone() = 0; + + virtual UIAction * clone() const; + + virtual UIAction * reverse() const; + + Uint32 getFlags() const; + + void setFlags( const Uint32 & flags ); + + Uint32 getTag() const; + + void setTag(const Uint32 & tag); + + UINode * getTarget() const; + + Uint32 addEventListener( const ActionType & actionType, const ActionCallback & callback ); + + void removeEventListener( const Uint32 & callbackId ); + + void sendEvent( const ActionType & actionType ); + + UINode * getNode() const; + protected: + friend class UINode; + typedef std::map< ActionType, std::map > ActionCallbackMap; + + UINode * mNode; + Uint32 mFlags; + Uint32 mTag; + Uint32 mNumCallBacks; + ActionCallbackMap mCallbacks; + + void setTarget( UINode * target ); + + virtual void onStart(); + + virtual void onStop(); + + virtual void onUpdate( const Time& time ); +}; + +}} + +#endif diff --git a/include/eepp/ui/uiactionmanager.hpp b/include/eepp/ui/uiactionmanager.hpp new file mode 100644 index 000000000..e302b7dc0 --- /dev/null +++ b/include/eepp/ui/uiactionmanager.hpp @@ -0,0 +1,39 @@ +#ifndef EE_UIActionManager_HPP +#define EE_UIActionManager_HPP + +#include +#include +#include +using namespace EE::System; + +namespace EE { namespace UI { + +class UIAction; + +class UIActionManager { + public: + UIActionManager(); + + ~UIActionManager(); + + void addAction( UIAction * action ); + + UIAction * getActionByTag( const Uint32& tag ); + + void removeActionByTag( const Uint32& tag ); + + void removeAction( UIAction * action ); + + void update( const Time& time ); + + std::size_t count() const; + + bool isEmpty() const; + protected: + std::list mActions; +}; + +}} + +#endif + diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index a38ce1d1a..1b53b0384 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -14,12 +14,13 @@ #include #include #include - namespace EE { namespace UI { class UITheme; class UIWindow; class UIManager; +class UIAction; +class UIActionManager; class EE_API UINode { public: @@ -31,13 +32,13 @@ class EE_API UINode { virtual ~UINode(); - void screenToControl( Vector2i& position ) const; + void screenToNode( Vector2i& position ) const; - void controlToScreen( Vector2i& position ) const; + void nodeToScreen( Vector2i& position ) const; - void worldToControl( Vector2i& pos ) const; + void worldToNode( Vector2i& pos ) const; - void controlToWorld( Vector2i& pos ) const; + void nodeToWorld( Vector2i& pos ) const; virtual Uint32 getType() const; @@ -47,6 +48,8 @@ class EE_API UINode { UINode * setPosition( const Vector2i& position ); + UINode * setPosition(const Vector2f & Pos); + UINode * setPosition( const Int32& x, const Int32& y ); void setPixelsPosition( const Vector2i& position ); @@ -113,11 +116,11 @@ class EE_API UINode { UIBorder * setBorderEnabled( bool enabled ); - UINode * getNextControl() const; + UINode * getNextNode() const; - UINode * getPrevControl() const; + UINode * getPrevNode() const; - UINode * getNextControlLoop() const; + UINode * getNextNodeLoop() const; UINode * setData( const UintPtr& data ); @@ -143,10 +146,10 @@ class EE_API UINode { void toPosition( const Uint32& position ); - const Uint32& getControlFlags() const; + const Uint32& getNodeFlags() const; /** Use it at your own risk */ - void setControlFlags( const Uint32& flags ); + void setNodeFlags( const Uint32& flags ); Uint32 isWidget(); @@ -343,15 +346,11 @@ class EE_API UINode { Interpolation1d * disableFadeOut( const Time & Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - Interpolation1d * getRotationInterpolation(); - - Interpolation2d * getScaleInterpolation(); - - Interpolation1d * getAlphaInterpolation(); - - Interpolation2d * getTranslationInterpolation(); - bool isFadingOut(); + + UIActionManager * getActionManager(); + + void runAction( UIAction * action ); protected: typedef std::map< Uint32, std::map > UIEventsMap; friend class UIManager; @@ -371,16 +370,16 @@ class EE_API UINode { UINode * mParentCtrl; UIWindow * mParentWindowCtrl; - UINode * mChild; //! Pointer to the first child of the control - UINode * mChildLast; //! Pointer to the last child added + UINode * mChild; //! Pointer to the first child of the node + UINode * mChildLast; //! Pointer to the last child added UINode * mNext; //! Pointer to the next child of the father - UINode * mPrev; //! Pointer to the prev child of the father + UINode * mPrev; //! Pointer to the prev child of the father UISkinState * mSkinState; UIBackground * mBackground; UIBorder * mBorder; - Uint32 mControlFlags; + Uint32 mNodeFlags; BlendMode mBlend; Uint16 mNumCallBacks; @@ -403,9 +402,10 @@ class EE_API UINode { Interpolation1d * mAngleAnim; Interpolation2d * mScaleAnim; - Interpolation1d * mAlphaAnim; Interpolation2d * mMoveAnim; + UIActionManager * mActionManager; + virtual Uint32 onMessage( const UIMessage * Msg ); virtual Uint32 onKeyDown( const UIEventKey& Event ); @@ -480,7 +480,7 @@ class EE_API UINode { virtual UINode * overFind( const Vector2f& Point ); - virtual void onParentWindowControlChange(); + virtual void onParentWindowChange(); virtual void clipMe(); @@ -538,7 +538,7 @@ class EE_API UINode { void drawHighlightFocus(); - void drawOverControl(); + void drawOverNode(); void drawDebugData(); diff --git a/premake4.lua b/premake4.lua index 998ebd61b..6b5fa6d45 100644 --- a/premake4.lua +++ b/premake4.lua @@ -713,6 +713,7 @@ function build_eepp( build_name ) "src/eepp/network/*.cpp", "src/eepp/network/ssl/*.cpp", "src/eepp/ui/*.cpp", + "src/eepp/ui/actions/*.cpp", "src/eepp/ui/tools/*.cpp", "src/eepp/physics/*.cpp", "src/eepp/physics/constraints/*.cpp", diff --git a/projects/android-project-ant/jni/eepp.mk b/projects/android-project-ant/jni/eepp.mk index 74cdff700..d7b36b9a4 100644 --- a/projects/android-project-ant/jni/eepp.mk +++ b/projects/android-project-ant/jni/eepp.mk @@ -68,6 +68,7 @@ CODE_SRCS := \ physics/*.cpp \ physics/constraints/*.cpp \ ui/*.cpp \ + ui/actions/*.cpp \ ui/tools/*.cpp \ maps/*.cpp \ maps/mapeditor/*.cpp diff --git a/projects/android-project/app/jni/eepp.mk b/projects/android-project/app/jni/eepp.mk index 04d783c0f..34102efd5 100644 --- a/projects/android-project/app/jni/eepp.mk +++ b/projects/android-project/app/jni/eepp.mk @@ -68,6 +68,7 @@ CODE_SRCS := \ physics/*.cpp \ physics/constraints/*.cpp \ ui/*.cpp \ + ui/actions/*.cpp \ ui/tools/*.cpp \ maps/*.cpp \ maps/mapeditor/*.cpp diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 483336681..6f189d7ce 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -37,6 +37,14 @@ ../../include/eepp/system/iostreamzip.hpp ../../include/eepp/system/translator.hpp ../../include/eepp/system/virtualfilesystem.hpp +../../include/eepp/ui/actions/actioninterpolation1d.hpp +../../include/eepp/ui/actions/actioninterpolation2d.hpp +../../include/eepp/ui/actions/fade.hpp +../../include/eepp/ui/actions/move.hpp +../../include/eepp/ui/actions/rotate.hpp +../../include/eepp/ui/actions/scale.hpp +../../include/eepp/ui/uiaction.hpp +../../include/eepp/ui/uiactionmanager.hpp ../../include/eepp/ui/uieventmouse.hpp ../../include/eepp/ui/uigridlayout.hpp ../../include/eepp/ui/uiimage.hpp @@ -92,6 +100,14 @@ ../../src/eepp/system/iostreamzip.cpp ../../src/eepp/system/translator.cpp ../../src/eepp/system/virtualfilesystem.cpp +../../src/eepp/ui/actions/actioninterpolation1d.cpp +../../src/eepp/ui/actions/actioninterpolation2d.cpp +../../src/eepp/ui/actions/fade.cpp +../../src/eepp/ui/actions/move.cpp +../../src/eepp/ui/actions/rotate.cpp +../../src/eepp/ui/actions/scale.cpp +../../src/eepp/ui/uiaction.cpp +../../src/eepp/ui/uiactionmanager.cpp ../../src/eepp/ui/uigridlayout.cpp ../../src/eepp/ui/uiimage.cpp ../../src/eepp/ui/uilayout.cpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index 630938ff1..5deffa21f 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -2,3 +2,7 @@ ../../include/ ../../src/thirdparty ../../include/eepp/thirdparty +../../src/eepp/ui +../../include/eepp/ui +../../src/eepp/ui/actions +../../include/eepp/ui/actions diff --git a/src/eepp/ui/actions/actioninterpolation1d.cpp b/src/eepp/ui/actions/actioninterpolation1d.cpp new file mode 100644 index 000000000..d5c3b91d8 --- /dev/null +++ b/src/eepp/ui/actions/actioninterpolation1d.cpp @@ -0,0 +1,43 @@ +#include +#include + +namespace EE { namespace UI { namespace Action { + +ActionInterpolation1d::ActionInterpolation1d() +{} + +void ActionInterpolation1d::setInterpolation( Interpolation1d interpolation ) { + mInterpolation = interpolation; +} + +void ActionInterpolation1d::start() { + mInterpolation.start(); + + onStart(); + + sendEvent( ActionType::OnStart ); +} + +void ActionInterpolation1d::stop() { + mInterpolation.stop(); + + onStop(); + + sendEvent( ActionType::OnStop ); +} + +void ActionInterpolation1d::update( const Time& time ) { + mInterpolation.update( time ); + + onUpdate( time ); +} + +bool ActionInterpolation1d::isDone() { + return mInterpolation.ended(); +} + +Interpolation1d * ActionInterpolation1d::getInterpolation() { + return &mInterpolation; +} + +}}} diff --git a/src/eepp/ui/actions/actioninterpolation2d.cpp b/src/eepp/ui/actions/actioninterpolation2d.cpp new file mode 100644 index 000000000..ff1a62fb6 --- /dev/null +++ b/src/eepp/ui/actions/actioninterpolation2d.cpp @@ -0,0 +1,43 @@ +#include +#include + +namespace EE { namespace UI { namespace Action { + +ActionInterpolation2d::ActionInterpolation2d() +{} + +void ActionInterpolation2d::setInterpolation( Interpolation2d interpolation ) { + mInterpolation = interpolation; +} + +void ActionInterpolation2d::start() { + mInterpolation.start(); + + onStart(); + + sendEvent( ActionType::OnStart ); +} + +void ActionInterpolation2d::stop() { + mInterpolation.stop(); + + onStop(); + + sendEvent( ActionType::OnStop ); +} + +void ActionInterpolation2d::update( const Time& time ) { + mInterpolation.update( time ); + + onUpdate( time ); +} + +bool ActionInterpolation2d::isDone() { + return mInterpolation.ended(); +} + +Interpolation2d * ActionInterpolation2d::getInterpolation() { + return &mInterpolation; +} + +}}} diff --git a/src/eepp/ui/actions/fade.cpp b/src/eepp/ui/actions/fade.cpp new file mode 100644 index 000000000..a0576b351 --- /dev/null +++ b/src/eepp/ui/actions/fade.cpp @@ -0,0 +1,52 @@ +#include +#include + +namespace EE { namespace UI { namespace Action { + +Fade * Fade::New( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type, const bool& alphaChilds ) { + return eeNew( Fade, ( start, end, duration, type, alphaChilds ) ); +} + +Fade::Fade() : + mAffectChilds( true ) +{} + +Fade::Fade( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type, const bool& alphaChilds ) : + mAffectChilds( alphaChilds ) +{ + mInterpolation.clear().add( start, duration ).add( end ).setType( type ); +} + +void Fade::onStart() { + if ( NULL != mNode ) { + mNode->setAlpha( mInterpolation.getPosition() ); + + if ( mAffectChilds ) { + UINode * CurChild = mNode->getFirstChild(); + + while ( NULL != CurChild ) { + CurChild->runAction( clone() ); + CurChild = CurChild->getNextNode(); + } + } + } +} + +void Fade::onUpdate( const Time& time ) { + if ( NULL != mNode ) { + mNode->setAlpha( mInterpolation.getPosition() ); + } +} + +UIAction * Fade::clone() const { + Fade * action = eeNew( Fade, () ); + action->mAffectChilds = mAffectChilds; + action->setInterpolation( mInterpolation ); + return action; +} + +UIAction * Fade::reverse() const { + return NULL; +} + +}}} diff --git a/src/eepp/ui/actions/move.cpp b/src/eepp/ui/actions/move.cpp new file mode 100644 index 000000000..f34a6476f --- /dev/null +++ b/src/eepp/ui/actions/move.cpp @@ -0,0 +1,40 @@ +#include +#include + +namespace EE { namespace UI { namespace Action { + +Move * Move::New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type ) { + return eeNew( Move, ( start, end, duration, type ) ); +} + +Move::Move() +{} + +Move::Move( const Vector2f & start, const Vector2f & end, const Time& duration, const Ease::Interpolation& type ) +{ + mInterpolation.clear().add( start, duration ).add( end ).setType( type ); +} + +void Move::onStart() { + if ( NULL != mNode ) { + mNode->setPosition( mInterpolation.getPosition() ); + } +} + +void Move::onUpdate( const Time& time ) { + if ( NULL != mNode ) { + mNode->setPosition( mInterpolation.getPosition() ); + } +} + +UIAction * Move::clone() const { + Move * action = eeNew( Move, () ); + action->setInterpolation( mInterpolation ); + return action; +} + +UIAction * Move::reverse() const { + return NULL; +} + +}}} diff --git a/src/eepp/ui/actions/rotate.cpp b/src/eepp/ui/actions/rotate.cpp new file mode 100644 index 000000000..a741d1aa9 --- /dev/null +++ b/src/eepp/ui/actions/rotate.cpp @@ -0,0 +1,40 @@ +#include +#include + +namespace EE { namespace UI { namespace Action { + +Rotate * Rotate::New( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type ) { + return eeNew( Rotate, ( start, end, duration, type ) ); +} + +Rotate::Rotate() +{} + +Rotate::Rotate( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type ) +{ + mInterpolation.clear().add( start, duration ).add( end ).setType( type ); +} + +void Rotate::onStart() { + if ( NULL != mNode ) { + mNode->setRotation( mInterpolation.getPosition() ); + } +} + +void Rotate::onUpdate( const Time& time ) { + if ( NULL != mNode ) { + mNode->setRotation( mInterpolation.getPosition() ); + } +} + +UIAction * Rotate::clone() const { + Rotate * action = eeNew( Rotate, () ); + action->setInterpolation( mInterpolation ); + return action; +} + +UIAction * Rotate::reverse() const { + return NULL; +} + +}}} diff --git a/src/eepp/ui/actions/scale.cpp b/src/eepp/ui/actions/scale.cpp new file mode 100644 index 000000000..61f65c625 --- /dev/null +++ b/src/eepp/ui/actions/scale.cpp @@ -0,0 +1,40 @@ +#include +#include + +namespace EE { namespace UI { namespace Action { + +Scale * Scale::New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type ) { + return eeNew( Scale, ( start, end, duration, type ) ); +} + +Scale::Scale() +{} + +Scale::Scale( const Vector2f & start, const Vector2f & end, const Time& duration, const Ease::Interpolation& type ) +{ + mInterpolation.clear().add( start, duration ).add( end ).setType( type ); +} + +void Scale::onStart() { + if ( NULL != mNode ) { + mNode->setScale( mInterpolation.getPosition() ); + } +} + +void Scale::onUpdate( const Time& time ) { + if ( NULL != mNode ) { + mNode->setScale( mInterpolation.getPosition() ); + } +} + +UIAction * Scale::clone() const { + Scale * action = eeNew( Scale, () ); + action->setInterpolation( mInterpolation ); + return action; +} + +UIAction * Scale::reverse() const { + return NULL; +} + +}}} diff --git a/src/eepp/ui/uiaction.cpp b/src/eepp/ui/uiaction.cpp new file mode 100644 index 000000000..225531d51 --- /dev/null +++ b/src/eepp/ui/uiaction.cpp @@ -0,0 +1,87 @@ +#include +#include + +namespace EE { namespace UI { + +UIAction::UIAction() : + mNode( NULL ), + mFlags( 0 ), + mTag( 0 ), + mNumCallBacks( 0 ) +{ +} + +UIAction::~UIAction() +{} + +Uint32 UIAction::getFlags() const { + return mFlags; +} + +void UIAction::setFlags( const Uint32 & flags ) { + mFlags = flags; +} + +Uint32 UIAction::getTag() const { + return mTag; +} + +void UIAction::setTag( const Uint32 & tag ) { + mTag = tag; +} + +void UIAction::setTarget( UINode * target ) { + mNode = target; +} + +UINode * UIAction::getTarget() const { + return mNode; +} + +UIAction * UIAction::clone() const { + return NULL; +} + +UIAction * UIAction::reverse() const { + return NULL; +} + +Uint32 UIAction::addEventListener( const ActionType& actionType, const ActionCallback& callback ) { + mNumCallBacks++; + + mCallbacks[ actionType ][ mNumCallBacks ] = callback; + + return mNumCallBacks; +} + +void UIAction::removeEventListener( const Uint32& callbackId ) { + for ( auto it = mCallbacks.begin(); it != mCallbacks.end(); ++it ) { + std::map event = it->second; + + if ( event.erase( callbackId ) ) + break; + } +} + +void UIAction::sendEvent( const ActionType& actionType ) { + if ( 0 != mCallbacks.count( actionType ) ) { + auto event = mCallbacks[ actionType ]; + + if ( !event.empty() ) { + for ( auto it = event.begin(); it != event.end(); ++it ) + it->second( this, actionType ); + } + } +} + +UINode * UIAction::getNode() const { + return mNode; +} + +void UIAction::onStart() {} + +void UIAction::onStop() {} + +void UIAction::onUpdate( const Time& time ) {} + +}} diff --git a/src/eepp/ui/uiactionmanager.cpp b/src/eepp/ui/uiactionmanager.cpp new file mode 100644 index 000000000..14752b54b --- /dev/null +++ b/src/eepp/ui/uiactionmanager.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include + +namespace EE { namespace UI { + +UIActionManager::UIActionManager() { +} + +UIActionManager::~UIActionManager() { + for ( auto it = mActions.begin(); it != mActions.end(); ++it ) { + UIAction * action = (*it); + + eeSAFE_DELETE( action ); + } +} + +void UIActionManager::addAction( UIAction * action ) { + bool found = (std::find(mActions.begin(), mActions.end(), action) != mActions.end()); + + if ( !found ) { + mActions.push_back( action ); + } +} + +UIAction * UIActionManager::getActionByTag( const Uint32& tag ) { + for ( auto it = mActions.begin(); it != mActions.end(); ++it ) { + UIAction * action = (*it); + + if ( action->getTag() == tag ) + return action; + } + + return NULL; +} + +void UIActionManager::removeActionByTag( const Uint32& tag ) { + removeAction( getActionByTag( tag ) ); +} + +void UIActionManager::update( const Time& time ) { + if ( isEmpty() ) + return; + + std::list removeList; + + for ( auto it = mActions.begin(); it != mActions.end(); ++it ) { + UIAction * action = (*it); + + action->update( time ); + + if ( action->isDone() ) { + action->sendEvent( UIAction::ActionType::OnDone ); + + removeList.push_back( action ); + } + } + + for ( auto it = removeList.begin(); it != removeList.end(); ++it ) + removeAction( (*it) ); +} + +std::size_t UIActionManager::count() const { + return mActions.size(); +} + +bool UIActionManager::isEmpty() const { + return mActions.empty(); +} + +void UIActionManager::removeAction( UIAction * action ) { + if ( NULL != action ) { + mActions.remove( action ); + + eeSAFE_DELETE( action ); + } +} + +}} diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 70999b65e..7017fef18 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -111,7 +111,7 @@ void UIDropDownList::showList() { Vector2i Pos( mPos.x, mPos.y + mSize.getHeight() ); if ( mStyleConfig.PopUpToMainControl ) { - getParent()->controlToWorld( Pos ); + getParent()->nodeToWorld( Pos ); Pos = PixelDensity::pxToDpI( Pos ); } else if ( NULL != mFriendCtrl ) { Pos = Vector2i( mFriendCtrl->getPosition().x, mFriendCtrl->getPosition().y + mFriendCtrl->getSize().getHeight() ); @@ -146,7 +146,7 @@ void UIDropDownList::showList() { Pos = Vector2i( mPos.x, mPos.y ); if ( mStyleConfig.PopUpToMainControl ) { - getParent()->controlToWorld( Pos ); + getParent()->nodeToWorld( Pos ); Pos = PixelDensity::pxToDpI( Pos ); } else if ( NULL != mFriendCtrl ) { Pos = Vector2i( mFriendCtrl->getPosition().x, mFriendCtrl->getPosition().y + mFriendCtrl->getSize().getHeight() ); diff --git a/src/eepp/ui/uigridlayout.cpp b/src/eepp/ui/uigridlayout.cpp index 842cc74cf..140296f63 100644 --- a/src/eepp/ui/uigridlayout.cpp +++ b/src/eepp/ui/uigridlayout.cpp @@ -175,7 +175,7 @@ void UIGridLayout::pack() { } } - ChildLoop = ChildLoop->getNextControl(); + ChildLoop = ChildLoop->getNextNode(); } if ( getLayoutHeightRules() == WRAP_CONTENT ) { diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index 78b351d7d..31e5d7faa 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -146,7 +146,7 @@ void UIImage::autoAlign() { } void UIImage::safeDeleteDrawable() { - if ( NULL != mDrawable && ( mControlFlags & UI_CTRL_FLAG_DRAWABLE_OWNER ) ) { + if ( NULL != mDrawable && ( mNodeFlags & UI_CTRL_FLAG_DRAWABLE_OWNER ) ) { if ( mDrawable->getDrawableType() == Drawable::SPRITE ) { Sprite * spr = reinterpret_cast( mDrawable ); eeSAFE_DELETE( spr ); diff --git a/src/eepp/ui/uilinearlayout.cpp b/src/eepp/ui/uilinearlayout.cpp index e6571003b..8b9f147b1 100644 --- a/src/eepp/ui/uilinearlayout.cpp +++ b/src/eepp/ui/uilinearlayout.cpp @@ -113,7 +113,7 @@ void UILinearLayout::packVertical() { } } - ChildLoop = ChildLoop->getNextControl(); + ChildLoop = ChildLoop->getNextNode(); } Int32 curY = 0; @@ -158,7 +158,7 @@ void UILinearLayout::packVertical() { maxX = eemax( maxX, (Int32)( widget->getSize().getWidth() + widget->getLayoutMargin().Left + widget->getLayoutMargin().Right ) ); } - ChildLoop = ChildLoop->getNextControl(); + ChildLoop = ChildLoop->getNextNode(); } if ( getLayoutHeightRules() == WRAP_CONTENT ) { @@ -227,7 +227,7 @@ void UILinearLayout::packHorizontal() { } } - ChildLoop = ChildLoop->getNextControl(); + ChildLoop = ChildLoop->getNextNode(); } Int32 curX = 0; @@ -272,7 +272,7 @@ void UILinearLayout::packHorizontal() { maxY = eemax( maxY, (Int32)( widget->getSize().getHeight() + widget->getLayoutMargin().Top + widget->getLayoutMargin().Bottom ) ); } - ChildLoop = ChildLoop->getNextControl(); + ChildLoop = ChildLoop->getNextNode(); } if ( getLayoutWidthRules() == WRAP_CONTENT ) { @@ -322,7 +322,7 @@ Sizei UILinearLayout::getTotalUsedSize() { } } - ChildLoop = ChildLoop->getNextControl(); + ChildLoop = ChildLoop->getNextNode(); } return size; diff --git a/src/eepp/ui/uilistboxitem.cpp b/src/eepp/ui/uilistboxitem.cpp index 796349026..8ecac108e 100644 --- a/src/eepp/ui/uilistboxitem.cpp +++ b/src/eepp/ui/uilistboxitem.cpp @@ -50,26 +50,26 @@ Uint32 UIListBoxItem::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { void UIListBoxItem::select() { UIListBox * LBParent = reinterpret_cast ( getParent()->getParent() ); - bool wasSelected = 0 != ( mControlFlags & UI_CTRL_FLAG_SELECTED ); + bool wasSelected = 0 != ( mNodeFlags & UI_CTRL_FLAG_SELECTED ); if ( LBParent->isMultiSelect() ) { if ( !wasSelected ) { setSkinState( UISkinState::StateSelected ); - mControlFlags |= UI_CTRL_FLAG_SELECTED; + mNodeFlags |= UI_CTRL_FLAG_SELECTED; LBParent->mSelected.push_back( LBParent->getItemIndex( this ) ); LBParent->onSelected(); } else { - mControlFlags &= ~UI_CTRL_FLAG_SELECTED; + mNodeFlags &= ~UI_CTRL_FLAG_SELECTED; LBParent->mSelected.remove( LBParent->getItemIndex( this ) ); } } else { setSkinState( UISkinState::StateSelected ); - mControlFlags |= UI_CTRL_FLAG_SELECTED; + mNodeFlags |= UI_CTRL_FLAG_SELECTED; LBParent->mSelected.clear(); LBParent->mSelected.push_back( LBParent->getItemIndex( this ) ); @@ -98,21 +98,21 @@ void UIListBoxItem::update() { Uint32 UIListBoxItem::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { UINode::onMouseExit( Pos, Flags ); - if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) + if ( mNodeFlags & UI_CTRL_FLAG_SELECTED ) setSkinState( UISkinState::StateSelected ); return 1; } void UIListBoxItem::unselect() { - if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) - mControlFlags &= ~UI_CTRL_FLAG_SELECTED; + if ( mNodeFlags & UI_CTRL_FLAG_SELECTED ) + mNodeFlags &= ~UI_CTRL_FLAG_SELECTED; setSkinState( UISkinState::StateNormal ); } bool UIListBoxItem::isSelected() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_SELECTED ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_SELECTED ); } void UIListBoxItem::onStateChange() { diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index b042410fd..8e233b3d5 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -596,10 +596,10 @@ void UIMenu::fixMenuPos( Vector2i& Pos, UIMenu * Menu, UIMenu * Parent, UIMenuSu } Vector2i sPos = SubMenu->getRealPosition(); - SubMenu->controlToScreen( sPos ); + SubMenu->nodeToScreen( sPos ); Vector2i pPos = Parent->getRealPosition(); - Parent->controlToScreen( pPos ); + Parent->nodeToScreen( pPos ); Rectf qParent( pPos.x, pPos.y, pPos.x + Parent->getRealSize().getWidth(), pPos.y + Parent->getRealSize().getHeight() ); diff --git a/src/eepp/ui/uimenusubmenu.cpp b/src/eepp/ui/uimenusubmenu.cpp index 3e51532f8..2efa09f54 100644 --- a/src/eepp/ui/uimenusubmenu.cpp +++ b/src/eepp/ui/uimenusubmenu.cpp @@ -101,12 +101,12 @@ void UIMenuSubMenu::showSubMenu() { mSubMenu->setParent( getParent()->getParent() ); Vector2i Pos = this->getRealPosition(); - controlToScreen( Pos ); + nodeToScreen( Pos ); Pos.x += mRealSize.getWidth() + reinterpret_cast ( getParent() )->getPadding().Right; UIMenu::fixMenuPos( Pos, mSubMenu, reinterpret_cast ( getParent() ), this ); - mSubMenu->getParent()->worldToControl( Pos ); + mSubMenu->getParent()->worldToNode( Pos ); mSubMenu->setPosition( Pos ); if ( !mSubMenu->isVisible() ) { diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 59d4b2f62..11263854f 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include #include @@ -9,6 +11,11 @@ #include #include +#include +#include +#include +#include + namespace EE { namespace UI { UINode * UINode::New() { @@ -32,7 +39,7 @@ UINode::UINode() : mSkinState( NULL ), mBackground( NULL ), mBorder( NULL ), - mControlFlags( 0 ), + mNodeFlags( 0 ), mBlend( BlendAlpha ), mNumCallBacks( 0 ), mVisible( true ), @@ -41,10 +48,7 @@ UINode::UINode() : mAngle(0.f), mScale(1.f,1.f), mAlpha(255.f), - mAngleAnim(NULL), - mScaleAnim(NULL), - mAlphaAnim(NULL), - mMoveAnim(NULL) + mActionManager(NULL) { if ( NULL == mParentCtrl && NULL != UIManager::instance()->getMainControl() ) { mParentCtrl = UIManager::instance()->getMainControl(); @@ -63,10 +67,7 @@ UINode::~UINode() { removeSkin(); eeSAFE_DELETE( mBackground ); eeSAFE_DELETE( mBorder ); - eeSAFE_DELETE( mAlphaAnim ); - eeSAFE_DELETE( mAngleAnim ); - eeSAFE_DELETE( mScaleAnim ); - eeSAFE_DELETE( mMoveAnim ); + eeSAFE_DELETE( mActionManager ); childDeleteAll(); @@ -82,7 +83,7 @@ UINode::~UINode() { } } -void UINode::screenToControl( Vector2i& Pos ) const { +void UINode::screenToNode( Vector2i& Pos ) const { UINode * ParentLoop = mParentCtrl; Pos.x -= mRealPos.x; @@ -98,7 +99,7 @@ void UINode::screenToControl( Vector2i& Pos ) const { } } -void UINode::controlToScreen( Vector2i& Pos ) const { +void UINode::nodeToScreen( Vector2i& Pos ) const { UINode * ParentLoop = mParentCtrl; while ( NULL != ParentLoop ) { @@ -141,6 +142,10 @@ void UINode::setInternalPosition( const Vector2i& Pos ) { updateChildsScreenPos(); } +UINode * UINode::setPosition( const Vector2f& Pos ) { + return setPosition( Vector2i( Pos.x, Pos.y ) ); +} + UINode * UINode::setPosition( const Vector2i& Pos ) { if ( Pos != mPos ) { setInternalPosition( Pos ); @@ -316,7 +321,7 @@ UINode * UINode::setParent( UINode * parent ) { onParentChange(); if ( mParentWindowCtrl != getParentWindow() ) - onParentWindowControlChange(); + onParentWindowChange(); return this; } @@ -356,7 +361,7 @@ void UINode::center() { } void UINode::close() { - mControlFlags |= UI_CTRL_FLAG_CLOSE; + mNodeFlags |= UI_CTRL_FLAG_CLOSE; UIManager::instance()->addToCloseQueue( this ); } @@ -372,7 +377,7 @@ void UINode::drawHighlightFocus() { } } -void UINode::drawOverControl() { +void UINode::drawOverNode() { if ( UIManager::instance()->getHighlightOver() && UIManager::instance()->getOverControl() == this ) { Primitives P; P.setFillMode( DRAW_LINE ); @@ -437,7 +442,7 @@ void UINode::draw() { drawHighlightFocus(); - drawOverControl(); + drawOverNode(); drawDebugData(); @@ -446,46 +451,11 @@ void UINode::draw() { } void UINode::update() { - if ( NULL != mMoveAnim && mMoveAnim->isEnabled() ) { - mMoveAnim->update( getElapsed() ); - setPosition( (int)mMoveAnim->getPosition().x, (int)mMoveAnim->getPosition().y ); + if ( NULL != mActionManager ) { + mActionManager->update( getElapsed() ); - if ( mMoveAnim->ended() ) - eeSAFE_DELETE( mMoveAnim ); - } - - if ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) { - mAlphaAnim->update( getElapsed() ); - setAlpha( mAlphaAnim->getPosition() ); - - if ( mAlphaAnim->ended() ) { - if ( ( mControlFlags & UI_CTRL_FLAG_CLOSE_FO ) ) - close(); - - if ( ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ) ) { - mControlFlags &= ~UI_CTRL_FLAG_DISABLE_FADE_OUT; - - setVisible( false ); - } - - eeSAFE_DELETE( mAlphaAnim ); - } - } - - if ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) { - mScaleAnim->update( getElapsed() ); - setScale( mScaleAnim->getPosition() ); - - if ( mScaleAnim->ended() ) - eeSAFE_DELETE( mScaleAnim ); - } - - if ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) { - mAngleAnim->update( getElapsed() ); - setRotation( mAngleAnim->getPosition() ); - - if ( mAngleAnim->ended() ) - eeSAFE_DELETE( mAngleAnim ); + if ( mActionManager->isEmpty() ) + eeSAFE_DELETE( mActionManager ); } if ( isDragEnabled() && isDragging() ) { @@ -522,7 +492,7 @@ void UINode::update() { ChildLoop = ChildLoop->mNext; } - if ( mControlFlags & UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD ) + if ( mNodeFlags & UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD ) writeCtrlFlag( UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD, 0 ); } @@ -582,11 +552,11 @@ Uint32 UINode::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { } bool UINode::isMouseOver() { - return 0 != ( mControlFlags & UI_CTRL_FLAG_MOUSEOVER ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_MOUSEOVER ); } bool UINode::isMouseOverMeOrChilds() { - return 0 != ( mControlFlags & UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD ); } Uint32 UINode::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { @@ -615,7 +585,7 @@ Uint32 UINode::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { } Uint32 UINode::onFocus() { - mControlFlags |= UI_CTRL_FLAG_HAS_FOCUS; + mNodeFlags |= UI_CTRL_FLAG_HAS_FOCUS; sendCommonEvent( UIEvent::OnFocus ); @@ -625,7 +595,7 @@ Uint32 UINode::onFocus() { } Uint32 UINode::onFocusLoss() { - mControlFlags &= ~UI_CTRL_FLAG_HAS_FOCUS; + mNodeFlags &= ~UI_CTRL_FLAG_HAS_FOCUS; sendCommonEvent( UIEvent::OnFocusLoss ); @@ -640,7 +610,7 @@ void UINode::onWidgetFocusLoss() { } bool UINode::hasFocus() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_HAS_FOCUS ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_HAS_FOCUS ); } Uint32 UINode::onValueChange() { @@ -713,15 +683,15 @@ UIBorder * UINode::setBorderEnabled( bool enabled ) { return mBorder; } -UINode * UINode::getNextControl() const { +UINode * UINode::getNextNode() const { return mNext; } -UINode * UINode::getPrevControl() const { +UINode * UINode::getPrevNode() const { return mPrev; } -UINode * UINode::getNextControlLoop() const { +UINode * UINode::getNextNodeLoop() const { if ( NULL == mNext ) return getParent()->getFirstChild(); else @@ -845,12 +815,12 @@ void UINode::drawBorder() { } } -const Uint32& UINode::getControlFlags() const { - return mControlFlags; +const Uint32& UINode::getNodeFlags() const { + return mNodeFlags; } -void UINode::setControlFlags( const Uint32& Flags ) { - mControlFlags = Flags; +void UINode::setNodeFlags( const Uint32& Flags ) { + mNodeFlags = Flags; } void UINode::drawChilds() { @@ -1182,13 +1152,13 @@ UINode * UINode::overFind( const Vector2f& Point ) { return pOver; } -void UINode::onParentWindowControlChange() { +void UINode::onParentWindowChange() { mParentWindowCtrl = getParentWindow(); UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { - ChildLoop->onParentWindowControlChange(); + ChildLoop->onParentWindowChange(); ChildLoop = ChildLoop->mNext; } } @@ -1214,11 +1184,11 @@ UINode * UINode::childGetAt( Vector2i CtrlPos, unsigned int RecursiveLevel ) { } Uint32 UINode::isWidget() { - return mControlFlags & UI_CTRL_FLAG_WIDGET; + return mNodeFlags & UI_CTRL_FLAG_WIDGET; } Uint32 UINode::isWindow() { - return mControlFlags & UI_CTRL_FLAG_WINDOW; + return mNodeFlags & UI_CTRL_FLAG_WINDOW; } Uint32 UINode::isClipped() { @@ -1226,15 +1196,15 @@ Uint32 UINode::isClipped() { } Uint32 UINode::isRotated() { - return mControlFlags & UI_CTRL_FLAG_ROTATED; + return mNodeFlags & UI_CTRL_FLAG_ROTATED; } Uint32 UINode::isScaled() { - return mControlFlags & UI_CTRL_FLAG_SCALED; + return mNodeFlags & UI_CTRL_FLAG_SCALED; } Uint32 UINode::isFrameBuffer() { - return mControlFlags & UI_CTRL_FLAG_FRAME_BUFFER; + return mNodeFlags & UI_CTRL_FLAG_FRAME_BUFFER; } bool UINode::isMeOrParentTreeRotated() { @@ -1442,7 +1412,7 @@ UINode * UINode::setSkin( UISkin * skin ) { } void UINode::removeSkin() { - if ( NULL != mSkinState && ( mControlFlags & UI_CTRL_FLAG_SKIN_OWNER ) ) { + if ( NULL != mSkinState && ( mNodeFlags & UI_CTRL_FLAG_SKIN_OWNER ) ) { UISkin * tSkin = mSkinState->getSkin(); eeSAFE_DELETE( tSkin ); @@ -1504,7 +1474,7 @@ void UINode::updateChildsScreenPos() { void UINode::updateScreenPos() { Vector2i Pos( mRealPos ); - controlToScreen( Pos ); + nodeToScreen( Pos ); mScreenPos = Pos; mScreenPosf = Vector2f( Pos.x, Pos.y ); @@ -1520,7 +1490,7 @@ UISkin * UINode::getSkin() { } void UINode::writeCtrlFlag( const Uint32& Flag, const Uint32& Val ) { - BitOp::setBitFlagValue( &mControlFlags, Flag, Val ); + BitOp::setBitFlagValue( &mNodeFlags, Flag, Val ); } void UINode::writeFlag( const Uint32& Flag, const Uint32& Val ) { @@ -1657,7 +1627,7 @@ void UINode::onChildCountChange() { invalidateDraw(); } -void UINode::worldToControl( Vector2i& pos ) const { +void UINode::worldToNode( Vector2i& pos ) const { Vector2f Pos( pos.x, pos.y ); std::list parents; @@ -1698,7 +1668,7 @@ void UINode::worldToControl( Vector2i& pos ) const { pos = Vector2i( Pos.x / PixelDensity::getPixelDensity(), Pos.y / PixelDensity::getPixelDensity() ); } -void UINode::controlToWorld( Vector2i& pos ) const { +void UINode::nodeToWorld( Vector2i& pos ) const { Vector2f Pos( (Float)pos.x * PixelDensity::getPixelDensity(), (Float)pos.y * PixelDensity::getPixelDensity() ); std::list parents; @@ -1760,7 +1730,7 @@ UIWindow * UINode::getParentWindow() { } bool UINode::isReverseDraw() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_REVERSE_DRAW ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_REVERSE_DRAW ); } void UINode::setReverseDraw( bool reverseDraw ) { @@ -1819,7 +1789,7 @@ void UINode::setDragEnabled( const bool& enable ) { } bool UINode::isDragging() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_DRAGGING ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_DRAGGING ); } void UINode::setDragging( const bool& dragging ) { @@ -1870,34 +1840,6 @@ void UINode::updateOriginPoint() { } } -Interpolation1d * UINode::getRotationInterpolation() { - if ( NULL == mAngleAnim ) - mAngleAnim = eeNew( Interpolation1d, () ); - - return mAngleAnim; -} - -Interpolation2d * UINode::getScaleInterpolation() { - if ( NULL == mScaleAnim ) - mScaleAnim = eeNew( Interpolation2d, () ); - - return mScaleAnim; -} - -Interpolation1d * UINode::getAlphaInterpolation() { - if ( NULL == mAlphaAnim ) - mAlphaAnim = eeNew( Interpolation1d, () ); - - return mAlphaAnim; -} - -Interpolation2d * UINode::getTranslationInterpolation() { - if ( NULL == mMoveAnim ) - mMoveAnim = eeNew( Interpolation2d, () ); - - return mMoveAnim; -} - void UINode::onAngleChange() { sendCommonEvent( UIEvent::OnAngleChange ); invalidateDraw(); @@ -1918,42 +1860,48 @@ Color UINode::getColor( const Color& Col ) { } bool UINode::isFadingOut() { - return 0 != ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ); } bool UINode::isAnimating() { - return ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) || ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) || ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) || ( NULL != mMoveAnim && mMoveAnim->isEnabled() ); + return NULL != mActionManager && !mActionManager->isEmpty(); +} + +static void UINode_onFadeDone( UIAction * action, const UIAction::ActionType& actionType ) { + UINode * node = action->getNode(); + + if ( NULL != node ) { + if ( ( node->getNodeFlags() & UI_CTRL_FLAG_CLOSE_FO ) ) + node->close(); + + if ( ( node->getNodeFlags() & UI_CTRL_FLAG_DISABLE_FADE_OUT ) ) { + node->setNodeFlags( node->getNodeFlags() & ~UI_CTRL_FLAG_DISABLE_FADE_OUT ); + + node->setVisible( false ); + } + } } Interpolation1d * UINode::startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mAlphaAnim ) - mAlphaAnim = eeNew( Interpolation1d, () ); + Action::Fade * action = Action::Fade::New( From, To, TotalTime, Type ); - mAlphaAnim->clear().add( From, TotalTime ).add( To ).setType( Type ).start( PathEndCallback ); + action->getInterpolation()->setPathEndCallback( PathEndCallback ); - setAlpha( From ); + action->addEventListener( UIAction::ActionType::OnDone, cb::Make2( &UINode_onFadeDone ) ); - if ( AlphaChilds ) { - UINode * CurChild = mChild; + runAction( action ); - while ( NULL != CurChild ) { - CurChild->startAlphaAnim( From, To, TotalTime, AlphaChilds ); - CurChild = CurChild->getNextControl(); - } - } - - return mAlphaAnim; + return action->getInterpolation(); } Interpolation2d * UINode::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mScaleAnim ) - mScaleAnim = eeNew( Interpolation2d, () ); + Action::Scale * action = Action::Scale::New( From, To, TotalTime, Type ); - mScaleAnim->clear().add( From ).add( To ).setDuration( TotalTime ).setType( Type ).start( PathEndCallback ); + action->getInterpolation()->setPathEndCallback( PathEndCallback ); - setScale( From ); + runAction( action ); - return mScaleAnim; + return action->getInterpolation(); } Interpolation2d * UINode::startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { @@ -1961,25 +1909,23 @@ Interpolation2d * UINode::startScaleAnim( const Float& From, const Float& To, co } Interpolation2d * UINode::startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mMoveAnim ) - mMoveAnim = eeNew( Interpolation2d, () ); + Action::Move * action = Action::Move::New( Vector2f( From.x, From.y ), Vector2f( To.x, To.y ), TotalTime, Type ); - mMoveAnim->clear().add( Vector2f( (Float)From.x, (Float)From.y ) ).add( Vector2f( (Float)To.x, (Float)To.y ) ).setType( Type ).setDuration( TotalTime ).start( PathEndCallback ); + action->getInterpolation()->setPathEndCallback( PathEndCallback ); - setPosition( From ); + runAction( action ); - return mMoveAnim; + return action->getInterpolation(); } Interpolation1d * UINode::startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mAngleAnim ) - mAngleAnim = eeNew( Interpolation1d, () ); + Action::Rotate * action = Action::Rotate::New( From, To, TotalTime, Type ); - mAngleAnim->clear().add( From ).add( To ).setDuration( TotalTime ).setType( Type ).start( PathEndCallback ); + action->getInterpolation()->setPathEndCallback( PathEndCallback ); - setRotation( From ); + runAction( action ); - return mAngleAnim; + return action->getInterpolation(); } Interpolation1d * UINode::startAlphaAnim(const Float & To, const Time & TotalTime, const bool & alphaChilds, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { @@ -2011,19 +1957,17 @@ Interpolation1d * UINode::createFadeOut( const Time& time, const bool& AlphaChil } Interpolation1d * UINode::closeFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); - mControlFlags |= UI_CTRL_FLAG_CLOSE_FO; - return mAlphaAnim; + mNodeFlags |= UI_CTRL_FLAG_CLOSE_FO; + + return startAlphaAnim( mAlpha, 0.f, time, AlphaChilds, Type ); } Interpolation1d * UINode::disableFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { setEnabled( false ); - startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); + mNodeFlags |= UI_CTRL_FLAG_DISABLE_FADE_OUT; - mControlFlags |= UI_CTRL_FLAG_DISABLE_FADE_OUT; - - return mAlphaAnim; + return startAlphaAnim( mAlpha, 0.f, time, AlphaChilds, Type ); } const Float& UINode::getRotation() const { @@ -2051,10 +1995,10 @@ void UINode::setRotation( const Float& angle ) { mAngle = angle; if ( mAngle != 0.f ) { - mControlFlags |= UI_CTRL_FLAG_ROTATED; + mNodeFlags |= UI_CTRL_FLAG_ROTATED; } else { - if ( mControlFlags & UI_CTRL_FLAG_ROTATED ) - mControlFlags &= ~UI_CTRL_FLAG_ROTATED; + if ( mNodeFlags & UI_CTRL_FLAG_ROTATED ) + mNodeFlags &= ~UI_CTRL_FLAG_ROTATED; } onAngleChange(); @@ -2074,10 +2018,10 @@ void UINode::setScale( const Vector2f & scale ) { mScale = scale; if ( mScale != 1.f ) { - mControlFlags |= UI_CTRL_FLAG_SCALED; + mNodeFlags |= UI_CTRL_FLAG_SCALED; } else { - if ( mControlFlags & UI_CTRL_FLAG_SCALED ) - mControlFlags &= ~UI_CTRL_FLAG_SCALED; + if ( mNodeFlags & UI_CTRL_FLAG_SCALED ) + mNodeFlags &= ~UI_CTRL_FLAG_SCALED; } onScaleChange(); @@ -2125,7 +2069,24 @@ void UINode::setChildsAlpha( const Float &alpha ) { while ( NULL != CurChild ) { CurChild->setAlpha( alpha ); CurChild->setChildsAlpha( alpha ); - CurChild = CurChild->getNextControl(); + CurChild = CurChild->getNextNode(); + } +} + +UIActionManager * UINode::getActionManager() { + if ( NULL == mActionManager ) + mActionManager = eeNew( UIActionManager, () ); + + return mActionManager; +} + +void UINode::runAction( UIAction * action ) { + if ( NULL != action ) { + action->setTarget( this ); + + action->start(); + + getActionManager()->addAction( action ); } } diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index 3750bf2f2..22606fd21 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -51,7 +51,7 @@ UIPushButton::UIPushButton() : mTextBox->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER ); if ( mStyleConfig.IconAutoMargin ) - mControlFlags |= UI_CTRL_FLAG_FREE_USE; + mNodeFlags |= UI_CTRL_FLAG_FREE_USE; onSizeChange(); @@ -133,7 +133,7 @@ void UIPushButton::onThemeLoaded() { if ( NULL != mTextBox && NULL == mTextBox->getFont() && NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont() ) mTextBox->setFont( mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont() ); - if ( mControlFlags & UI_CTRL_FLAG_FREE_USE ) { + if ( mNodeFlags & UI_CTRL_FLAG_FREE_USE ) { Rect RMargin = makePadding( true, false, false, false, true ); mStyleConfig.IconHorizontalMargin = RMargin.Left; } diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index fd41b6fb4..68312032e 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -149,7 +149,7 @@ void UIRadioButton::setActive( const bool& active ) { } } - tChild = tChild->getNextControl(); + tChild = tChild->getNextNode(); } } } @@ -168,7 +168,7 @@ bool UIRadioButton::checkActives() { } } - tChild = tChild->getNextControl(); + tChild = tChild->getNextNode(); } } @@ -192,7 +192,7 @@ void UIRadioButton::autoActivate() { } } - tChild = tChild->getNextControl(); + tChild = tChild->getNextNode(); } } diff --git a/src/eepp/ui/uirelativelayout.cpp b/src/eepp/ui/uirelativelayout.cpp index edaa57e4b..2160f05b3 100644 --- a/src/eepp/ui/uirelativelayout.cpp +++ b/src/eepp/ui/uirelativelayout.cpp @@ -60,7 +60,7 @@ void UIRelativeLayout::fixChilds() { fixChildPos( widget ); } - child = child->getNextControl(); + child = child->getNextNode(); } } diff --git a/src/eepp/ui/uiscrollview.cpp b/src/eepp/ui/uiscrollview.cpp index 095649742..9608e6596 100644 --- a/src/eepp/ui/uiscrollview.cpp +++ b/src/eepp/ui/uiscrollview.cpp @@ -65,7 +65,7 @@ void UIScrollView::onChildCountChange() { break; } - child = child->getNextControl(); + child = child->getNextNode(); } if ( found ) { diff --git a/src/eepp/ui/uiselectbutton.cpp b/src/eepp/ui/uiselectbutton.cpp index 880bdad23..7b8d2f073 100644 --- a/src/eepp/ui/uiselectbutton.cpp +++ b/src/eepp/ui/uiselectbutton.cpp @@ -29,7 +29,7 @@ void UISelectButton::select() { setSkinState( UISkinState::StateSelected ); - mControlFlags |= UI_CTRL_FLAG_SELECTED; + mNodeFlags |= UI_CTRL_FLAG_SELECTED; if ( !wasSelected ) { UIMessage tMsg( this, UIMessage::Selected, 0 ); @@ -38,14 +38,14 @@ void UISelectButton::select() { } void UISelectButton::unselect() { - if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) - mControlFlags &= ~UI_CTRL_FLAG_SELECTED; + if ( mNodeFlags & UI_CTRL_FLAG_SELECTED ) + mNodeFlags &= ~UI_CTRL_FLAG_SELECTED; setSkinState( UISkinState::StateNormal ); } bool UISelectButton::selected() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_SELECTED ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_SELECTED ); } void UISelectButton::onStateChange() { diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 825eedb28..37cc96980 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -316,7 +316,7 @@ Uint32 UISlider::onKeyDown( const UIEventKey &Event ) { void UISlider::manageClick( const Uint32& Flags ) { if ( Flags ) { Vector2i ControlPos = UIManager::instance()->getMousePos(); - mSlider->worldToControl( ControlPos ); + mSlider->worldToNode( ControlPos ); if ( Flags & EE_BUTTON_LMASK && !mSlider->isMouseOver() ) { if ( UI_HORIZONTAL == mOrientation ) { diff --git a/src/eepp/ui/uisprite.cpp b/src/eepp/ui/uisprite.cpp index 44c04f807..73d53c5f6 100644 --- a/src/eepp/ui/uisprite.cpp +++ b/src/eepp/ui/uisprite.cpp @@ -32,7 +32,7 @@ bool UISprite::isType( const Uint32& type ) const { } Uint32 UISprite::deallocSprite() { - return mControlFlags & UI_CTRL_FLAG_FREE_USE; + return mNodeFlags & UI_CTRL_FLAG_FREE_USE; } void UISprite::setSprite( Graphics::Sprite * sprite ) { @@ -166,7 +166,7 @@ void UISprite::setDeallocSprite( const bool& dealloc ) { } bool UISprite::getDeallocSprite() { - return 0 != ( mControlFlags & UI_CTRL_FLAG_FREE_USE ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_FREE_USE ); } void UISprite::onSizeChange() { diff --git a/src/eepp/ui/uitablecell.cpp b/src/eepp/ui/uitablecell.cpp index 163726842..d460e6a2b 100644 --- a/src/eepp/ui/uitablecell.cpp +++ b/src/eepp/ui/uitablecell.cpp @@ -101,11 +101,11 @@ void UITableCell::select() { if ( NULL != MyParent->getItemSelected() ) MyParent->getItemSelected()->unselect(); - bool wasSelected = 0 != ( mControlFlags & UI_CTRL_FLAG_SELECTED ); + bool wasSelected = 0 != ( mNodeFlags & UI_CTRL_FLAG_SELECTED ); setSkinState( UISkinState::StateSelected ); - mControlFlags |= UI_CTRL_FLAG_SELECTED; + mNodeFlags |= UI_CTRL_FLAG_SELECTED; MyParent->mSelected = MyParent->getItemIndex( this ); @@ -116,20 +116,20 @@ void UITableCell::select() { } void UITableCell::unselect() { - if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) - mControlFlags &= ~UI_CTRL_FLAG_SELECTED; + if ( mNodeFlags & UI_CTRL_FLAG_SELECTED ) + mNodeFlags &= ~UI_CTRL_FLAG_SELECTED; setSkinState( UISkinState::StateNormal ); } bool UITableCell::isSelected() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_SELECTED ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_SELECTED ); } Uint32 UITableCell::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { UINode::onMouseExit( Pos, Flags ); - if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) + if ( mNodeFlags & UI_CTRL_FLAG_SELECTED ) setSkinState( UISkinState::StateSelected ); return 1; diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 7c56b7b00..21381d48c 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -720,7 +720,7 @@ void UITabWidget::onChildCountChange() { break; } - child = child->getNextControl(); + child = child->getNextNode(); } if ( found ) { diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index a9c9025f2..56f9b3f4d 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -266,7 +266,7 @@ void UITextInput::updateText() { Uint32 UITextInput::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { if ( Flags & EE_BUTTON_LMASK ) { Vector2i controlPos( Pos ); - worldToControl( controlPos ); + worldToNode( controlPos ); controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mRealAlignOffset.x, (Int32)mRealAlignOffset.y ); Int32 curPos = mTextCache->findCharacterFromPos( controlPos ); diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index 2a4eea79c..6dcf44522 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -338,7 +338,7 @@ const Vector2i& UITextView::getAlignOffset() const { Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) ) { Vector2i controlPos( Pos ); - worldToControl( controlPos ); + worldToNode( controlPos ); controlPos = PixelDensity::dpToPxI( controlPos ); Int32 curPos = mTextCache->findCharacterFromPos( controlPos ); @@ -351,7 +351,7 @@ Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) selCurInit( tSelCurInit ); selCurEnd( tSelCurEnd ); - mControlFlags &= ~UI_CTRL_FLAG_SELECTING; + mNodeFlags &= ~UI_CTRL_FLAG_SELECTING; } } @@ -365,7 +365,7 @@ Uint32 UITextView::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { selCurEnd( -1 ); } - mControlFlags &= ~UI_CTRL_FLAG_SELECTING; + mNodeFlags &= ~UI_CTRL_FLAG_SELECTING; } return UIWidget::onMouseClick( Pos, Flags ); @@ -374,13 +374,13 @@ Uint32 UITextView::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) && UIManager::instance()->getDownControl() == this ) { Vector2i controlPos( Pos ); - worldToControl( controlPos ); + worldToNode( controlPos ); controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mRealAlignOffset.x, (Int32)mRealAlignOffset.y ); Int32 curPos = mTextCache->findCharacterFromPos( controlPos ); if ( -1 != curPos ) { - if ( -1 == selCurInit() || !( mControlFlags & UI_CTRL_FLAG_SELECTING ) ) { + if ( -1 == selCurInit() || !( mNodeFlags & UI_CTRL_FLAG_SELECTING ) ) { selCurInit( curPos ); selCurEnd( curPos ); } else { @@ -388,7 +388,7 @@ Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { } } - mControlFlags |= UI_CTRL_FLAG_SELECTING; + mNodeFlags |= UI_CTRL_FLAG_SELECTING; } return UIWidget::onMouseDown( Pos, Flags ); diff --git a/src/eepp/ui/uitouchdragablewidget.cpp b/src/eepp/ui/uitouchdragablewidget.cpp index f0375f03e..6375e81af 100644 --- a/src/eepp/ui/uitouchdragablewidget.cpp +++ b/src/eepp/ui/uitouchdragablewidget.cpp @@ -31,7 +31,7 @@ UITouchDragableWidget * UITouchDragableWidget::setTouchDragEnabled( const bool& } bool UITouchDragableWidget::isTouchDragging() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_TOUCH_DRAGGING ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_TOUCH_DRAGGING ); } UITouchDragableWidget * UITouchDragableWidget::setTouchDragging( const bool& dragging ) { @@ -54,7 +54,7 @@ void UITouchDragableWidget::update() { UIManager * manager = UIManager::instance(); Uint32 Press = manager->getPressTrigger(); - if ( ( mControlFlags & UI_CTRL_FLAG_TOUCH_DRAGGING ) ) { + if ( ( mNodeFlags & UI_CTRL_FLAG_TOUCH_DRAGGING ) ) { // Mouse Not Down if ( !( Press & EE_BUTTON_LMASK ) ) { writeCtrlFlag( UI_CTRL_FLAG_TOUCH_DRAGGING, 0 ); diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 3a46397bc..8309f0f3c 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -22,7 +22,7 @@ UIWidget::UIWidget() : mLayoutPositionRuleWidget(NULL), mPropertiesTransactionCount(0) { - mControlFlags |= UI_CTRL_FLAG_WIDGET; + mNodeFlags |= UI_CTRL_FLAG_WIDGET; updateAnchorsDistances(); } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 1381fa252..c302a32b8 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -43,7 +43,7 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const UIWindowStyleC mMinimizeListener(0), mFrameBufferBound( false ) { - mControlFlags |= UI_CTRL_FLAG_WINDOW; + mNodeFlags |= UI_CTRL_FLAG_WINDOW; setHorizontalAlign( UI_HALIGN_CENTER ); @@ -279,7 +279,7 @@ void UIWindow::drawFrameBuffer() { } void UIWindow::drawHighlightInvalidation() { - if ( ( mControlFlags & UI_CTRL_FLAG_NEEDS_REDRAW ) && UIManager::instance()->getHighlightInvalidation() ) { + if ( ( mNodeFlags & UI_CTRL_FLAG_NEEDS_REDRAW ) && UIManager::instance()->getHighlightInvalidation() ) { UIWidget::matrixSet(); Primitives P; @@ -362,13 +362,13 @@ void UIWindow::enableByModal() { { if ( CtrlChild != mModalCtrl && CtrlChild != this && - CtrlChild->getControlFlags() & UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW ) + CtrlChild->getNodeFlags() & UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW ) { CtrlChild->setEnabled( true ); CtrlChild->writeCtrlFlag( UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW, 0 ); } - CtrlChild = CtrlChild->getNextControl(); + CtrlChild = CtrlChild->getNextNode(); } } } @@ -387,7 +387,7 @@ void UIWindow::disableByModal() { CtrlChild->writeCtrlFlag( UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW, 1 ); } - CtrlChild = CtrlChild->getNextControl(); + CtrlChild = CtrlChild->getNextNode(); } } } @@ -721,7 +721,7 @@ void UIWindow::doResize ( const UIMessage * Msg ) { void UIWindow::decideResizeType( UINode * Control ) { Vector2i Pos = UIManager::instance()->getMousePos(); - worldToControl( Pos ); + worldToNode( Pos ); if ( Control == this ) { if ( Pos.x <= mBorderLeft->getSize().getWidth() ) { @@ -768,7 +768,7 @@ void UIWindow::tryResize( const UI_RESIZE_TYPE& Type ) { Vector2i Pos = UIManager::instance()->getMousePos(); - worldToControl( Pos ); + worldToNode( Pos ); mResizeType = Type; @@ -842,7 +842,7 @@ void UIWindow::updateResize() { Vector2i Pos = UIManager::instance()->getMousePos(); - worldToControl( Pos ); + worldToNode( Pos ); Pos = PixelDensity::dpToPxI( Pos ); @@ -999,7 +999,7 @@ void UIWindow::onAlphaChange() { while ( NULL != CurChild ) { CurChild->setAlpha( mAlpha ); - CurChild = CurChild->getNextControl(); + CurChild = CurChild->getNextNode(); } } @@ -1014,12 +1014,12 @@ void UIWindow::onChildCountChange() { bool found = false; while ( NULL != child ) { - if ( !( child->getControlFlags() & UI_CTRL_FLAG_OWNED_BY_WINDOW ) ) { + if ( !( child->getNodeFlags() & UI_CTRL_FLAG_OWNED_BY_WINDOW ) ) { found = true; break; } - child = child->getNextControl(); + child = child->getNextNode(); } if ( found ) { @@ -1163,7 +1163,7 @@ FrameBuffer * UIWindow::getFrameBuffer() const { } bool UIWindow::invalidated() { - return 0 != ( mControlFlags & UI_CTRL_FLAG_NEEDS_REDRAW ); + return 0 != ( mNodeFlags & UI_CTRL_FLAG_NEEDS_REDRAW ); } void UIWindow::matrixSet() { @@ -1322,7 +1322,7 @@ void UIWindow::resizeCursor() { Vector2i Pos = Man->getMousePos(); - worldToControl( Pos ); + worldToNode( Pos ); const UINode * Control = Man->getOverControl();