diff --git a/include/eepp/scene.hpp b/include/eepp/scene.hpp index c117a52b6..3c86e352e 100644 --- a/include/eepp/scene.hpp +++ b/include/eepp/scene.hpp @@ -1,17 +1,7 @@ #ifndef EEPP_SCENE_HPP #define EEPP_SCENE_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include diff --git a/include/eepp/scene/actions/actions.hpp b/include/eepp/scene/actions/actions.hpp new file mode 100644 index 000000000..040f582fb --- /dev/null +++ b/include/eepp/scene/actions/actions.hpp @@ -0,0 +1,19 @@ +#ifndef EE_SCENE_ACTIONS_HPP +#define EE_SCENE_ACTIONS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif + diff --git a/include/eepp/scene/actions/close.hpp b/include/eepp/scene/actions/close.hpp index da0f855dc..98693bbc0 100644 --- a/include/eepp/scene/actions/close.hpp +++ b/include/eepp/scene/actions/close.hpp @@ -7,7 +7,7 @@ namespace EE { namespace Scene { namespace Actions { class EE_API Close : public Delay { public: - static Close * New( const Time& time ); + static Close * New( const Time& time = Seconds(0) ); void update( const Time& time ) override; @@ -16,7 +16,7 @@ class EE_API Close : public Delay { Action * reverse() const override; protected: - Close( const Time& time ); + explicit Close( const Time& time ); void onStart() override; diff --git a/include/eepp/scene/actions/disable.hpp b/include/eepp/scene/actions/disable.hpp new file mode 100644 index 000000000..f94a86055 --- /dev/null +++ b/include/eepp/scene/actions/disable.hpp @@ -0,0 +1,20 @@ +#ifndef EE_SCENE_ACTION_DISABLE_HPP +#define EE_SCENE_ACTION_DISABLE_HPP + +#include + +namespace EE { namespace Scene { namespace Actions { + +class EE_API Disable : public Enable { + public: + static Disable * New( const Time& time = Seconds(0) ); + + Action * clone() const override; + protected: + explicit Disable( const Time& time ); + +}; + +}}} + +#endif diff --git a/include/eepp/scene/actions/enable.hpp b/include/eepp/scene/actions/enable.hpp new file mode 100644 index 000000000..35f192fcc --- /dev/null +++ b/include/eepp/scene/actions/enable.hpp @@ -0,0 +1,31 @@ +#ifndef EE_SCENE_ACTION_ENABLE_HPP +#define EE_SCENE_ACTION_ENABLE_HPP + +#include + +namespace EE { namespace Scene { namespace Actions { + +class EE_API Enable : public Delay { + public: + static Enable * New( const Time& time = Seconds(0) ); + + static Enable * New( bool enable, const Time& time = Seconds(0) ); + + void update( const Time& time ) override; + + Action * clone() const override; + + Action * reverse() const override; + + protected: + bool mEnable; + + explicit Enable( bool enable, const Time& time ); + + void onStart() override; + +}; + +}}} + +#endif diff --git a/include/eepp/scene/actions/visible.hpp b/include/eepp/scene/actions/visible.hpp new file mode 100644 index 000000000..86541fd45 --- /dev/null +++ b/include/eepp/scene/actions/visible.hpp @@ -0,0 +1,29 @@ +#ifndef EE_SCENE_ACTION_VISIBLE_HPP +#define EE_SCENE_ACTION_VISIBLE_HPP + +#include + +namespace EE { namespace Scene { namespace Actions { + +class EE_API Visible : public Delay { + public: + static Visible * New( bool visible, const Time& time = Seconds(0) ); + + void update( const Time& time ) override; + + Action * clone() const override; + + Action * reverse() const override; + + protected: + bool mVisible; + + explicit Visible( bool visible, const Time& time ); + + void onStart() override; + +}; + +}}} + +#endif diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index c06c56348..f5303d758 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -166,37 +166,7 @@ class EE_API UINode : public Node { const Uint32& getDragButton() const; - bool isAnimating(); - - Interpolation1d * startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startTranslation( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation1d * startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation1d * startAlphaAnim( const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startTranslation( const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation1d * startRotation( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation1d * createFadeIn( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * createFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * closeFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * disableFadeOut( const Time & Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - bool isFadingOut(); + bool isActionManagerActive(); virtual void setFocus(); protected: diff --git a/projects/linux/ee.files b/projects/linux/ee.files index b5ddbfc15..0d8c53e6d 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -205,8 +205,11 @@ ../../include/eepp/scene/actionmanager.hpp ../../include/eepp/scene/actions/actioninterpolation1d.hpp ../../include/eepp/scene/actions/actioninterpolation2d.hpp +../../include/eepp/scene/actions/actions.hpp ../../include/eepp/scene/actions/close.hpp ../../include/eepp/scene/actions/delay.hpp +../../include/eepp/scene/actions/disable.hpp +../../include/eepp/scene/actions/enable.hpp ../../include/eepp/scene/actions/fade.hpp ../../include/eepp/scene/actions/marginmove.hpp ../../include/eepp/scene/actions/move.hpp @@ -214,6 +217,7 @@ ../../include/eepp/scene/actions/scale.hpp ../../include/eepp/scene/actions/sequence.hpp ../../include/eepp/scene/actions/spawn.hpp +../../include/eepp/scene/actions/visible.hpp ../../include/eepp/scene/event.hpp ../../include/eepp/scene/eventdispatcher.hpp ../../include/eepp/scene/keyevent.hpp @@ -616,6 +620,8 @@ ../../src/eepp/scene/actions/actioninterpolation2d.cpp ../../src/eepp/scene/actions/close.cpp ../../src/eepp/scene/actions/delay.cpp +../../src/eepp/scene/actions/disable.cpp +../../src/eepp/scene/actions/enable.cpp ../../src/eepp/scene/actions/fade.cpp ../../src/eepp/scene/actions/marginmove.cpp ../../src/eepp/scene/actions/move.cpp @@ -623,6 +629,7 @@ ../../src/eepp/scene/actions/scale.cpp ../../src/eepp/scene/actions/sequence.cpp ../../src/eepp/scene/actions/spawn.cpp +../../src/eepp/scene/actions/visible.cpp ../../src/eepp/scene/event.cpp ../../src/eepp/scene/eventdispatcher.cpp ../../src/eepp/scene/keyevent.cpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index 3ae535802..bdb00322a 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -7,6 +7,5 @@ ../../src/eepp/audio ../../include/eepp/audio /usr/include/freetype2/ -../../bin/assets/layouts -../../include/eepp/graphics -../../src/eepp/graphics +../../include/eepp/scene/actions +../../src/eepp/scene/actions diff --git a/src/eepp/scene/actions/disable.cpp b/src/eepp/scene/actions/disable.cpp new file mode 100644 index 000000000..9a33cf51e --- /dev/null +++ b/src/eepp/scene/actions/disable.cpp @@ -0,0 +1,18 @@ +#include +#include + +namespace EE { namespace Scene { namespace Actions { + +Disable * Disable::New(const Time & time) { + return eeNew( Disable, ( time ) ); +} + +Action *Disable::clone() const { + return New( mTime ); +} + +Disable::Disable(const Time & time) : + Enable( false, time ) +{} + +}}} diff --git a/src/eepp/scene/actions/enable.cpp b/src/eepp/scene/actions/enable.cpp new file mode 100644 index 000000000..bf44e9e6f --- /dev/null +++ b/src/eepp/scene/actions/enable.cpp @@ -0,0 +1,37 @@ +#include +#include + +namespace EE { namespace Scene { namespace Actions { + +Enable * Enable::New( const Time & time ) { + return eeNew( Enable, ( true, time ) ); +} + +Enable * Enable::New( bool enable, const Time & time) { + return eeNew( Enable, ( enable, time ) ); +} + +void Enable::update(const Time & time) { + if ( NULL != mNode && isDone() ) { + mNode->setEnabled( mEnable ); + } +} + +Action * Enable::clone() const { + return New( mEnable, mTime ); +} + +Action * Enable::reverse() const { + return NULL; // or a time machine +} + +Enable::Enable( bool enable, const Time & time) : + Delay( time ), + mEnable( enable ) +{} + +void Enable::onStart() { + update(Seconds(0)); +} + +}}} diff --git a/src/eepp/scene/actions/visible.cpp b/src/eepp/scene/actions/visible.cpp new file mode 100644 index 000000000..1fd9a69a4 --- /dev/null +++ b/src/eepp/scene/actions/visible.cpp @@ -0,0 +1,33 @@ +#include +#include + +namespace EE { namespace Scene { namespace Actions { + +Visible * Visible::New( bool visible, const Time & time) { + return eeNew( Visible, ( visible, time ) ); +} + +void Visible::update(const Time & time) { + if ( NULL != mNode && isDone() ) { + mNode->setVisible( mVisible ); + } +} + +Action * Visible::clone() const { + return New( mVisible, mTime ); +} + +Action * Visible::reverse() const { + return NULL; // or a time machine +} + +Visible::Visible( bool visible, const Time & time) : + Delay( time ), + mVisible( visible ) +{} + +void Visible::onStart() { + update(Seconds(0)); +} + +}}} diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 4fa6e7ba0..8e9b5a6c3 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include namespace EE { namespace UI { @@ -227,13 +228,16 @@ void UIDropDownList::show() { mListBox->setVisible( true ); if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - mListBox->startAlphaAnim( 255.f == mListBox->getAlpha() ? 0.f : mListBox->getAlpha(), 255.f, UIThemeManager::instance()->getControlsFadeInTime() ); + mListBox->runAction( Actions::Sequence::New( + Actions::Fade::New( 255.f == mListBox->getAlpha() ? 0.f : mListBox->getAlpha(), 255.f, UIThemeManager::instance()->getControlsFadeOutTime() ), + Actions::Spawn::New( Actions::Enable::New(), Actions::Visible::New( true ) ) ) ); } } void UIDropDownList::hide() { if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - mListBox->disableFadeOut( UIThemeManager::instance()->getControlsFadeOutTime() ); + mListBox->runAction( Actions::Sequence::New( Actions::FadeOut::New( UIThemeManager::instance()->getControlsFadeOutTime() ), + Actions::Spawn::New( Actions::Disable::New(), Actions::Visible::New( false ) ) ) ); } else { mListBox->setEnabled( false ); mListBox->setVisible( false ); diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 0c4451767..ca600a263 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -850,117 +850,10 @@ const Uint32& UINode::getDragButton() const { return mDragButton; } -bool UINode::isFadingOut() { - return 0 != ( mNodeFlags & NODE_FLAG_DISABLE_DELAYED ); -} - -bool UINode::isAnimating() { +bool UINode::isActionManagerActive() { return NULL != mActionManager && !mActionManager->isEmpty(); } -static void UINode_onFadeDone( Action * action, const Action::ActionType& actionType ) { - Node * node = action->getTarget(); - - if ( NULL != node ) { - if ( ( node->getNodeFlags() & NODE_FLAG_CLOSE_DELAYED ) ) - node->close(); - - if ( ( node->getNodeFlags() & NODE_FLAG_DISABLE_DELAYED ) ) { - node->setNodeFlags( node->getNodeFlags() & ~NODE_FLAG_DISABLE_DELAYED ); - - 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 ) { - Actions::Fade * action = Actions::Fade::New( From, To, TotalTime, Type, AlphaChilds ); - - action->getInterpolation()->setPathEndCallback( PathEndCallback ); - - action->addEventListener( Action::ActionType::OnDone, cb::Make2( &UINode_onFadeDone ) ); - - runAction( action ); - - return action->getInterpolation(); -} - -Interpolation2d * UINode::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - Actions::Scale * action = Actions::Scale::New( From, To, TotalTime, Type ); - - action->getInterpolation()->setPathEndCallback( PathEndCallback ); - - runAction( action ); - - return action->getInterpolation(); -} - -Interpolation2d * UINode::startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - return startScaleAnim( Vector2f( From, From ), Vector2f( To, To ), TotalTime, Type, PathEndCallback ); -} - -Interpolation2d * UINode::startTranslation( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - Actions::Move * action = Actions::Move::New( From, To, TotalTime, Type ); - - action->getInterpolation()->setPathEndCallback( PathEndCallback ); - - runAction( action ); - - return action->getInterpolation(); -} - -Interpolation1d * UINode::startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { - Actions::Rotate * action = Actions::Rotate::New( From, To, TotalTime, Type ); - - action->getInterpolation()->setPathEndCallback( PathEndCallback ); - - runAction( action ); - - return action->getInterpolation(); -} - -Interpolation1d * UINode::startAlphaAnim(const Float & To, const Time & TotalTime, const bool & alphaChilds, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { - return startAlphaAnim( mAlpha, To, TotalTime, alphaChilds, type, PathEndCallback ); -} - -Interpolation2d * UINode::startScaleAnim(const Vector2f & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { - return startScaleAnim( getScale(), To, TotalTime, type, PathEndCallback ); -} - -Interpolation2d * UINode::startScaleAnim(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { - return startScaleAnim( getScale(), Vector2f(To,To), TotalTime, type, PathEndCallback ); -} - -Interpolation2d * UINode::startTranslation(const Vector2f& To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { - return startTranslation( mDpPos, To, TotalTime, type, PathEndCallback ); -} - -Interpolation1d * UINode::startRotation(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { - return startRotation( getRotation(), To, TotalTime, type, PathEndCallback ); -} - -Interpolation1d * UINode::createFadeIn( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - return startAlphaAnim( mAlpha, 255.f, time, AlphaChilds, Type ); -} - -Interpolation1d * UINode::createFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - return startAlphaAnim( 255.f, mAlpha, time, AlphaChilds, Type ); -} - -Interpolation1d * UINode::closeFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - mNodeFlags |= NODE_FLAG_CLOSE_DELAYED; - - return startAlphaAnim( mAlpha, 0.f, time, AlphaChilds, Type ); -} - -Interpolation1d * UINode::disableFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - setEnabled( false ); - - mNodeFlags |= NODE_FLAG_DISABLE_DELAYED; - - return startAlphaAnim( mAlpha, 0.f, time, AlphaChilds, Type ); -} - void UINode::onWidgetFocusLoss() { sendCommonEvent( Event::OnWidgetFocusLoss ); invalidateDraw(); diff --git a/src/eepp/ui/uipopupmenu.cpp b/src/eepp/ui/uipopupmenu.cpp index 17f880ff0..b219bd476 100644 --- a/src/eepp/ui/uipopupmenu.cpp +++ b/src/eepp/ui/uipopupmenu.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace EE { namespace UI { @@ -46,7 +47,8 @@ bool UIPopUpMenu::show() { toFront(); if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - startAlphaAnim( 255.f == mAlpha ? 0.f : mAlpha, 255.f, UIThemeManager::instance()->getControlsFadeInTime() ); + runAction( Actions::Sequence::New( Actions::Fade::New( 255.f == mAlpha ? 0.f : mAlpha, 255.f, UIThemeManager::instance()->getControlsFadeOutTime() ), + Actions::Spawn::New( Actions::Enable::New(), Actions::Visible::New( true ) ) ) ); } setFocus(); @@ -59,7 +61,7 @@ bool UIPopUpMenu::show() { bool UIPopUpMenu::hide() { if ( isVisible() ) { - if ( !isFadingOut() ) { + if ( !isActionManagerActive() ) { if ( NULL != mItemSelected ) mItemSelected->unsetSkinState( UISkinState::StateSelected ); @@ -67,7 +69,8 @@ bool UIPopUpMenu::hide() { mItemSelectedIndex = eeINDEX_NOT_FOUND; if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - disableFadeOut( UIThemeManager::instance()->getControlsFadeOutTime() ); + runAction( Actions::Sequence::New( Actions::FadeOut::New( UIThemeManager::instance()->getControlsFadeOutTime() ), + Actions::Spawn::New( Actions::Disable::New(), Actions::Visible::New( false ) ) ) ); } else { setEnabled( false ); setVisible( false ); diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 0a667bfb3..37d422f09 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace EE { namespace UI { @@ -72,7 +73,8 @@ void UITooltip::show() { setVisible( true ); if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - startAlphaAnim( 255.f == mAlpha ? 0.f : mAlpha, 255.f, UIThemeManager::instance()->getControlsFadeInTime() ); + runAction( Actions::Sequence::New( Actions::Fade::New( 255.f == mAlpha ? 0.f : mAlpha, 255.f, UIThemeManager::instance()->getControlsFadeOutTime() ), + Actions::Spawn::New( Actions::Enable::New(), Actions::Visible::New( true ) ) ) ); } } } @@ -80,7 +82,7 @@ void UITooltip::show() { void UITooltip::hide() { if ( isVisible() ) { if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - disableFadeOut( UIThemeManager::instance()->getControlsFadeOutTime() ); + runAction( Actions::Sequence::New( Actions::FadeOut::New( UIThemeManager::instance()->getControlsFadeOutTime() ), Actions::Spawn::New( Actions::Disable::New(), Actions::Visible::New( false ) ) ) ); } else { setVisible( false ); } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index d08069801..f99c20a1c 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace EE { namespace UI { @@ -442,7 +443,7 @@ void UIWindow::closeWindow() { } if ( Time::Zero != UIThemeManager::instance()->getControlsFadeOutTime() ) - closeFadeOut( UIThemeManager::instance()->getControlsFadeOutTime() ); + runAction( Actions::Sequence::New( Actions::FadeOut::New( UIThemeManager::instance()->getControlsFadeOutTime() ), Actions::Close::New() ) ); else close(); } @@ -977,7 +978,7 @@ bool UIWindow::show() { setFocus(); - startAlphaAnim( mStyleConfig.BaseAlpha == getAlpha() ? 0.f : mAlpha, mStyleConfig.BaseAlpha, UIThemeManager::instance()->getControlsFadeInTime() ); + runAction( Actions::Fade::New( mStyleConfig.BaseAlpha == getAlpha() ? 0.f : mAlpha, mStyleConfig.BaseAlpha, UIThemeManager::instance()->getControlsFadeOutTime() ) ); if ( isModal() ) { createModalControl(); @@ -998,7 +999,7 @@ bool UIWindow::show() { bool UIWindow::hide() { if ( isVisible() ) { if ( UIThemeManager::instance()->getDefaultEffectsEnabled() ) { - disableFadeOut( UIThemeManager::instance()->getControlsFadeOutTime() ); + runAction( Actions::Sequence::New( Actions::FadeOut::New( UIThemeManager::instance()->getControlsFadeOutTime() ), Actions::Spawn::New( Actions::Disable::New(), Actions::Visible::New( false ) ) ) ); } else { setEnabled( false ); setVisible( false ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index cc95b0b51..e85a2c86f 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -951,13 +951,13 @@ void EETest::createCommonDialog() { static void onWinDragStart( const Event * event ) { UINode * ctrl = static_cast( event->getNode() ); UIWindow * window = ctrl->isType(UI_TYPE_WINDOW) ? static_cast( ctrl ) : static_cast( ctrl->getWindowContainer()->getParent() ); - window->startAlphaAnim( window->getAlpha(), 100, Seconds(0.2f) ); + window->runAction( Actions::Fade::New( window->getAlpha(), 100, Seconds(0.2f) ) ); } static void onWinDragStop( const Event * event ) { UINode * ctrl = static_cast( event->getNode() ); UIWindow * window = ctrl->isType(UI_TYPE_WINDOW) ? static_cast( ctrl ) : static_cast( ctrl->getWindowContainer()->getParent() ); - window->startAlphaAnim( window->getAlpha(), 255, Seconds(0.2f) ); + window->runAction( Actions::Fade::New( window->getAlpha(), 255, Seconds(0.2f) ) ); } void EETest::createDecoratedWindow() { @@ -1008,7 +1008,7 @@ void EETest::createDecoratedWindow() { win->setWinFlags( win->getWinFlags() & ~UI_WIN_NO_BORDER ); menuItem->setText( "Hide Border" ); } else if ( "Close" == txt ) { - win->closeFadeOut( Milliseconds(250) ); + win->closeWindow(); } } ); @@ -1094,13 +1094,20 @@ void EETest::onItemClick( const Event * Event ) { if ( Chk->isActive() ) { if ( C->getScale() == 1.f ) C->setScale( 0.f ); - C->startScaleAnim( C->getScale(), Vector2f::One, Milliseconds( 500.f ), Ease::SineOut ); - C->startAlphaAnim( C->getAlpha(), 255.f, Milliseconds( 500.f ) ); - C->startRotation( 0, 360, Milliseconds( 500.f ), Ease::SineOut ); + + C->runAction( Actions::Spawn::New( + Actions::Scale::New( C->getScale(), Vector2f::One, Milliseconds( 500.f ), Ease::SineOut ), + Actions::Fade::New( C->getAlpha(), 255.f, Milliseconds( 500.f ) ), + Actions::Rotate::New( 0, 360, Milliseconds( 500.f ), Ease::SineOut ) + ) + ); } else { - C->startScaleAnim( C->getScale(), Vector2f::Zero, Milliseconds( 500.f ), Ease::SineIn ); - C->disableFadeOut( Milliseconds( 500.f ) ); - C->startRotation( 0, 360, Milliseconds( 500.f ), Ease::SineIn ); + C->runAction( Actions::Spawn::New( + Actions::Scale::New( C->getScale(), Vector2f::Zero, Milliseconds( 500.f ), Ease::SineIn ), + Actions::Sequence::New( Actions::FadeOut::New( Milliseconds( 500 ) ), Actions::Disable::New() ), + Actions::Rotate::New( 0, 360, Milliseconds( 500.f ), Ease::SineIn ) + ) + ); } } else if ( "Show Window 2" == txt ) { if ( NULL == mUIWindow ) { @@ -1168,12 +1175,13 @@ void EETest::onButtonClick( const Event * event ) { UIImage * Gfx = UIImage::New(); Gfx->setDrawable( mTheme->getIconByName( "ok" ) ); Gfx->setEnabled( false ); - Gfx->runAction( Sequence::New( Scale::New( Vector2f(1.f,1.f), Vector2f(2.f,2.f), Seconds( 0.5f ) ), - Scale::New( Vector2f(2.f,2.f), Vector2f(1.f,1.f), Seconds( 0.5f ) ) + + Gfx->runAction( Spawn::New( + Move::New( Vector2f( Math::randi( 0, mWindow->getWidth() ), -64 ), Vector2f( Math::randi( 0, mWindow->getWidth() ), mWindow->getHeight() + 64 ), Milliseconds( 2500 ) ), + Rotate::New( 0.f, 2500.f, Milliseconds( 2500 ) ), + Sequence::New( Scale::New( Vector2f(1.f,1.f), Vector2f(2.f,2.f), Seconds( 0.5f ) ), Scale::New( Vector2f(2.f,2.f), Vector2f(1.f,1.f), Seconds( 0.5f ) ) ), + Sequence::New( FadeOut::New( Milliseconds( 3500 ) ), Close::New() ) ) ); - Gfx->startRotation( 0.f, 2500.f, Milliseconds( 2500 ) ); - Gfx->startTranslation( Vector2f( Math::randi( 0, mWindow->getWidth() ), -64 ), Vector2f( Math::randi( 0, mWindow->getWidth() ), mWindow->getHeight() + 64 ), Milliseconds( 2500 ) ); - Gfx->closeFadeOut( Milliseconds( 3500 ) ); } }