Added Actions: Dealy, Sequence, Spawn.

Fixed several minor bugs in Actions.

--HG--
branch : dev-2.1
This commit is contained in:
Martí­n Lucas Golini
2018-01-13 19:29:59 -03:00
parent c5c97c0ff7
commit a89b0a78bd
30 changed files with 489 additions and 54 deletions

View File

@@ -25,6 +25,8 @@ class EE_API Interpolation1d {
public:
Interpolation1d();
Interpolation1d( std::vector<Point1d> points );
~Interpolation1d();
typedef cb::Callback1<void,Interpolation1d&> OnPathEndCallback;
@@ -99,6 +101,9 @@ class EE_API Interpolation1d {
/** @return the vector of points */
const std::vector<Point1d>& getPoints() const;
/** @return the vector of points reversed */
std::vector<Point1d> getReversePoints();
/** @return The Current Node */
Point1d* getCurrentActual() const;

View File

@@ -26,6 +26,8 @@ class EE_API Interpolation2d {
public:
Interpolation2d();
Interpolation2d( std::vector<Point2d> points );
~Interpolation2d();
typedef cb::Callback1<void,Interpolation2d&> OnPathEndCallback;
@@ -101,6 +103,9 @@ class EE_API Interpolation2d {
/** @return the vector of waypoints */
const std::vector<Point2d>& getPoints() const;
/** @return the vector of waypoints reversed */
std::vector<Point2d> getReversePoints();
/** Set the current interpolation speed ( This will destroy the time of the interpolation and create one depending on the speed ) ( pixels per second ) */
Interpolation2d& setSpeed( const Float& speed );

View File

@@ -65,5 +65,8 @@
#include <eepp/ui/actions/scale.hpp>
#include <eepp/ui/actions/fade.hpp>
#include <eepp/ui/actions/marginmove.hpp>
#include <eepp/ui/actions/sequence.hpp>
#include <eepp/ui/actions/spawn.hpp>
#include <eepp/ui/actions/delay.hpp>
#endif

View File

@@ -7,7 +7,7 @@ using namespace EE::Math;
namespace EE { namespace UI { namespace Action {
class ActionInterpolation1d : public UIAction {
class EE_API ActionInterpolation1d : public UIAction {
public:
void start() override;
@@ -19,7 +19,7 @@ class ActionInterpolation1d : public UIAction {
Interpolation1d * getInterpolation();
protected:
Interpolation1d mInterpolation;
mutable Interpolation1d mInterpolation;
ActionInterpolation1d();

View File

@@ -7,7 +7,7 @@ using namespace EE::Math;
namespace EE { namespace UI { namespace Action {
class ActionInterpolation2d : public UIAction {
class EE_API ActionInterpolation2d : public UIAction {
public:
void start() override;
@@ -19,7 +19,7 @@ class ActionInterpolation2d : public UIAction {
Interpolation2d * getInterpolation();
protected:
Interpolation2d mInterpolation;
mutable Interpolation2d mInterpolation;
ActionInterpolation2d();

View File

@@ -0,0 +1,36 @@
#ifndef EE_UI_ACTION_DELAY_HPP
#define EE_UI_ACTION_DELAY_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/system/clock.hpp>
using namespace EE::System;
namespace EE { namespace UI { namespace Action {
class EE_API Delay : public UIAction {
public:
static Delay * New( const Time& time );
void start() override;
void stop() override;
void update( const Time& time ) override;
bool isDone() override;
UIAction * clone() const;
UIAction * reverse() const;
protected:
Clock mClock;
Time mTime;
Delay( const Time& time );
};
}}}
#endif

View File

@@ -6,7 +6,7 @@
namespace EE { namespace UI { namespace Action {
class Fade : public ActionInterpolation1d {
class EE_API 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 );

View File

@@ -9,7 +9,7 @@ using namespace EE::Math;
namespace EE { namespace UI { namespace Action {
class MarginMove : public UIAction {
class EE_API MarginMove : public UIAction {
public:
static MarginMove * New( const Rect& start, const Rect& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear );

View File

@@ -6,7 +6,7 @@
namespace EE { namespace UI { namespace Action {
class Move : public ActionInterpolation2d {
class EE_API Move : public ActionInterpolation2d {
public:
static Move * New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear );

View File

@@ -6,7 +6,7 @@
namespace EE { namespace UI { namespace Action {
class Rotate : public ActionInterpolation1d {
class EE_API Rotate : public ActionInterpolation1d {
public:
static Rotate * New( const Float& start, const Float& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear );

View File

@@ -6,7 +6,7 @@
namespace EE { namespace UI { namespace Action {
class Scale : public ActionInterpolation2d {
class EE_API Scale : public ActionInterpolation2d {
public:
static Scale * New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear );

View File

@@ -0,0 +1,44 @@
#ifndef EE_UI_ACTION_SEQUENCE_HPP
#define EE_UI_ACTION_SEQUENCE_HPP
#include <eepp/ui/uiaction.hpp>
namespace EE { namespace UI { namespace Action {
class EE_API Sequence : public UIAction {
public:
static Sequence * New( const std::vector<UIAction*> sequence );
static Sequence * New( UIAction * action, UIAction * action2 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8 );
static Sequence * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8, UIAction * action9 );
void start() override;
void stop() override;
void update( const Time& time ) override;
bool isDone() override;
UIAction * clone() const;
UIAction * reverse() const;
virtual ~Sequence();
protected:
std::vector<UIAction*> mSequence;
Uint32 mCurPos;
Sequence( const std::vector<UIAction*> sequence );
};
}}}
#endif

View File

@@ -0,0 +1,43 @@
#ifndef EE_UI_ACTION_SPAWN_HPP
#define EE_UI_ACTION_SPAWN_HPP
#include <eepp/ui/uiaction.hpp>
namespace EE { namespace UI { namespace Action {
class EE_API Spawn : public UIAction {
public:
static Spawn * New( const std::vector<UIAction*> spawn );
static Spawn * New( UIAction * action, UIAction * action2 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8 );
static Spawn * New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8, UIAction * action9 );
void start() override;
void stop() override;
void update( const Time& time ) override;
bool isDone() override;
UIAction * clone() const;
UIAction * reverse() const;
virtual ~Spawn();
protected:
std::vector<UIAction*> mSpawn;
bool mAllDone;
Spawn( const std::vector<UIAction*> spawn );
};
}}}
#endif

View File

@@ -10,13 +10,14 @@ namespace EE { namespace UI {
class UINode;
class UIAction {
class EE_API UIAction {
public:
enum ActionType
{
OnStart,
OnStop,
OnDone
OnDone,
OnStep
};
typedef cb::Callback2<void,UIAction*,const ActionType&> ActionCallback;
@@ -53,7 +54,7 @@ class UIAction {
void sendEvent( const ActionType & actionType );
UINode * getNode() const;
void setTarget( UINode * target );
protected:
friend class UINode;
typedef std::map< ActionType, std::map<Uint32, ActionCallback> > ActionCallbackMap;
@@ -64,8 +65,6 @@ class UIAction {
Uint32 mNumCallBacks;
ActionCallbackMap mCallbacks;
void setTarget( UINode * target );
virtual void onStart();
virtual void onStop();

View File

@@ -10,7 +10,7 @@ namespace EE { namespace UI {
class UIAction;
class UIActionManager {
class EE_API UIActionManager {
public:
UIActionManager();

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.4.0, 2017-12-30T14:09:54. -->
<!-- Written by QtCreator 4.4.0, 2018-01-13T19:28:42. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{d43f4693-30c1-436c-b1d1-498aab2c2f8c}</value>
<value type="QByteArray">{b6114084-39c2-4cd0-b9e2-d8803dc6b446}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -63,7 +63,7 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6d057187-158a-4883-8d5b-d470a6b6b025}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{388e5431-b31b-42b3-b9ad-9002d279d75d}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">10</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>

View File

@@ -39,10 +39,14 @@
../../include/eepp/system/virtualfilesystem.hpp
../../include/eepp/ui/actions/actioninterpolation1d.hpp
../../include/eepp/ui/actions/actioninterpolation2d.hpp
../../include/eepp/ui/actions/delay.hpp
../../include/eepp/ui/actions/fade.hpp
../../include/eepp/ui/actions/marginmove.hpp
../../include/eepp/ui/actions/move.hpp
../../include/eepp/ui/actions/rotate.hpp
../../include/eepp/ui/actions/scale.hpp
../../include/eepp/ui/actions/sequence.hpp
../../include/eepp/ui/actions/spawn.hpp
../../include/eepp/ui/marginmove/scale.hpp
../../include/eepp/ui/uiaction.hpp
../../include/eepp/ui/uiactionmanager.hpp
@@ -103,11 +107,14 @@
../../src/eepp/system/virtualfilesystem.cpp
../../src/eepp/ui/actions/actioninterpolation1d.cpp
../../src/eepp/ui/actions/actioninterpolation2d.cpp
../../src/eepp/ui/actions/delay.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/actions/marginmove.cpp
../../src/eepp/ui/actions/sequence.cpp
../../src/eepp/ui/actions/spawn.cpp
../../src/eepp/ui/uiaction.cpp
../../src/eepp/ui/uiactionmanager.cpp
../../src/eepp/ui/uigridlayout.cpp

View File

@@ -23,6 +23,26 @@ Interpolation1d::Interpolation1d() :
{
}
Interpolation1d::Interpolation1d( std::vector<Point1d> points ) :
mData(0),
mType(Ease::Linear),
mEnable(false),
mUpdate(true),
mLoop(false),
mEnded(false),
mTotDist(0.f),
mCurPos(0.f),
mCurPoint(0),
mCurTime(Time::Zero),
mSpeed(1.3f),
mActP(NULL),
mNexP(NULL),
mPoints(points),
mOnPathEndCallback(),
mOnStepCallback()
{
}
Interpolation1d::~Interpolation1d() {
}
@@ -302,6 +322,16 @@ const std::vector<Point1d>& Interpolation1d::getPoints() const {
return mPoints;
}
std::vector<Point1d> Interpolation1d::getReversePoints() {
std::vector<Point1d> reversed;
for ( auto it = mPoints.rbegin(); it != mPoints.rend(); ++it ) {
reversed.push_back( *it );
}
return reversed;
}
const Float& Interpolation1d::getSpeed() const {
return mSpeed;
}

View File

@@ -20,6 +20,23 @@ Interpolation2d::Interpolation2d() :
{
}
Interpolation2d::Interpolation2d( std::vector<Point2d> points ) :
mData(0),
mType(Ease::Linear),
mEnable(false),
mUpdate(true),
mLoop(false),
mEnded(false),
mTotDist(0.f),
mCurPoint(0),
mCurTime(Time::Zero),
mSpeed(1.3f),
mPoints(points),
mOnPathEndCallback(),
mOnStepCallback()
{
}
Interpolation2d::~Interpolation2d() {
}
@@ -300,6 +317,16 @@ const std::vector<Point2d>& Interpolation2d::getPoints() const {
return mPoints;
}
std::vector<Point2d> Interpolation2d::getReversePoints() {
std::vector<Point2d> reversed;
for ( auto it = mPoints.rbegin(); it != mPoints.rend(); ++it ) {
reversed.push_back( *it );
}
return reversed;
}
const Float& Interpolation2d::getSpeed() const {
return mSpeed;
}

View File

@@ -0,0 +1,39 @@
#include <eepp/ui/actions/delay.hpp>
namespace EE { namespace UI { namespace Action {
Delay * Delay::New(const Time & time) {
return eeNew( Delay, ( time ) );
}
void Delay::start() {
mClock.restart();
sendEvent( ActionType::OnStart );
}
void Delay::stop() {
// 'Cause none of them can stop the time
sendEvent( ActionType::OnStop );
}
void Delay::update(const Time & time)
{}
bool Delay::isDone() {
return mClock.getElapsedTime() >= mTime;
}
UIAction *Delay::clone() const {
return New( mTime );
}
UIAction *Delay::reverse() const {
return NULL; // or a time machine
}
Delay::Delay(const Time & time) :
mTime( time )
{}
}}}

View File

@@ -46,7 +46,10 @@ UIAction * Fade::clone() const {
}
UIAction * Fade::reverse() const {
return NULL;
Fade * action = eeNew( Fade, () );
action->mAffectChilds = mAffectChilds;
action->setInterpolation( Interpolation1d( mInterpolation.getReversePoints() ) );
return action;
}
}}}

View File

@@ -11,48 +11,39 @@ MarginMove * MarginMove::New( const Rect & start, const Rect & end, const Time&
MarginMove::MarginMove()
{}
Interpolation1d MarginMove::getInterpolationBottom() const
{
Interpolation1d MarginMove::getInterpolationBottom() const {
return mInterpolationBottom;
}
void MarginMove::setInterpolationBottom(const Interpolation1d & interpolationBottom)
{
void MarginMove::setInterpolationBottom(const Interpolation1d & interpolationBottom) {
mInterpolationBottom = interpolationBottom;
}
Interpolation1d MarginMove::getInterpolationTop() const
{
Interpolation1d MarginMove::getInterpolationTop() const {
return mInterpolationTop;
}
void MarginMove::setInterpolationTop(const Interpolation1d & interpolationTop)
{
void MarginMove::setInterpolationTop(const Interpolation1d & interpolationTop) {
mInterpolationTop = interpolationTop;
}
Interpolation1d MarginMove::getInterpolationRight() const
{
Interpolation1d MarginMove::getInterpolationRight() const {
return mInterpolationRight;
}
void MarginMove::setInterpolationRight(const Interpolation1d & interpolationRight)
{
void MarginMove::setInterpolationRight(const Interpolation1d & interpolationRight) {
mInterpolationRight = interpolationRight;
}
Interpolation1d MarginMove::getInterpolationLeft() const
{
Interpolation1d MarginMove::getInterpolationLeft() const {
return mInterpolationLeft;
}
void MarginMove::setInterpolationLeft(const Interpolation1d & interpolationLeft)
{
void MarginMove::setInterpolationLeft(const Interpolation1d & interpolationLeft) {
mInterpolationLeft = interpolationLeft;
}
MarginMove::MarginMove( const Rect& start, const Rect & end, const Time& duration, const Ease::Interpolation& type )
{
MarginMove::MarginMove( const Rect& start, const Rect & end, const Time& duration, const Ease::Interpolation& type ) {
mInterpolationLeft.clear().add( start.Left, duration ).add( end.Left ).setType( type );
mInterpolationRight.clear().add( start.Right, duration ).add( end.Right ).setType( type );
mInterpolationTop.clear().add( start.Top, duration ).add( end.Top ).setType( type );

View File

@@ -10,8 +10,7 @@ Move * Move::New( const Vector2f& start, const Vector2f& end, const Time& durati
Move::Move()
{}
Move::Move( const Vector2f & start, const Vector2f & end, const Time& duration, const Ease::Interpolation& type )
{
Move::Move( const Vector2f & start, const Vector2f & end, const Time& duration, const Ease::Interpolation& type ) {
mInterpolation.clear().add( start, duration ).add( end ).setType( type );
}
@@ -34,7 +33,9 @@ UIAction * Move::clone() const {
}
UIAction * Move::reverse() const {
return NULL;
Move * action = eeNew( Move, () );
action->setInterpolation( Interpolation2d( mInterpolation.getReversePoints() ) );
return action;
}
}}}

View File

@@ -10,8 +10,7 @@ Rotate * Rotate::New( const Float & start, const Float & end, const Time& durati
Rotate::Rotate()
{}
Rotate::Rotate( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type )
{
Rotate::Rotate( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type ) {
mInterpolation.clear().add( start, duration ).add( end ).setType( type );
}
@@ -34,7 +33,9 @@ UIAction * Rotate::clone() const {
}
UIAction * Rotate::reverse() const {
return NULL;
Rotate * action = eeNew( Rotate, () );
action->setInterpolation( Interpolation1d( mInterpolation.getReversePoints() ) );
return action;
}
}}}

View File

@@ -10,8 +10,7 @@ Scale * Scale::New( const Vector2f& start, const Vector2f& end, const Time& dura
Scale::Scale()
{}
Scale::Scale( const Vector2f & start, const Vector2f & end, const Time& duration, const Ease::Interpolation& type )
{
Scale::Scale( const Vector2f & start, const Vector2f & end, const Time& duration, const Ease::Interpolation& type ) {
mInterpolation.clear().add( start, duration ).add( end ).setType( type );
}
@@ -34,7 +33,9 @@ UIAction * Scale::clone() const {
}
UIAction * Scale::reverse() const {
return NULL;
Scale * action = eeNew( Scale, () );
action->setInterpolation( mInterpolation.getReversePoints() );
return action;
}
}}}

View File

@@ -0,0 +1,99 @@
#include <eepp/ui/actions/sequence.hpp>
namespace EE { namespace UI { namespace Action {
Sequence * Sequence::New( const std::vector<UIAction *> sequence ) {
return eeNew( Sequence, ( sequence ) );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2 ) {
return New( { action, action2 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3 ) {
return New( { action, action2, action3 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4 ) {
return New( { action, action2, action3, action4 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5 ) {
return New( { action, action2, action3, action4, action5 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6 ) {
return New( { action, action2, action3, action4, action5, action6 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7 ) {
return New( { action, action2, action3, action4, action5, action6, action7 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8 ) {
return New( { action, action2, action3, action4, action5, action6, action7, action8 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8, UIAction * action9 ) {
return New( { action, action2, action3, action4, action5, action6, action7, action8, action9 } );
}
void Sequence::start() {
for ( size_t i = 0; i < mSequence.size(); i++ ) {
mSequence[ i ]->setTarget( getTarget() );
}
mSequence[ mCurPos ]->start();
sendEvent( ActionType::OnStart );
}
void Sequence::stop() {
mSequence[ mCurPos ]->stop();
sendEvent( ActionType::OnStop );
}
void Sequence::update( const Time & time ) {
if ( isDone() )
return;
mSequence[ mCurPos ]->update( time );
if ( mSequence[ mCurPos ]->isDone() && mCurPos + 1 < mSequence.size() ) {
mCurPos++;
mSequence[ mCurPos ]->start();
sendEvent( ActionType::OnStep );
}
}
bool Sequence::isDone() {
return mCurPos == mSequence.size() - 1 && mSequence[ mCurPos ]->isDone();
}
UIAction * Sequence::clone() const {
return Sequence::New( mSequence );
}
UIAction * Sequence::reverse() const {
std::vector<UIAction*> reversed;
for ( auto it = mSequence.rbegin(); it != mSequence.rend(); ++it ) {
reversed.push_back( *it );
}
return Sequence::New( reversed );
}
Sequence::~Sequence() {
for ( size_t i = 0; i < mSequence.size(); i++ ) {
UIAction * action = mSequence[ i ];
eeSAFE_DELETE( action );
}
}
Sequence::Sequence( const std::vector<UIAction*> sequence ) :
mSequence( sequence ),
mCurPos( 0 )
{}
}}}

View File

@@ -0,0 +1,103 @@
#include <eepp/ui/actions/spawn.hpp>
namespace EE { namespace UI { namespace Action {
Spawn * Spawn::New( const std::vector<UIAction *> spawn ) {
return eeNew( Spawn, ( spawn ) );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2 ) {
return New( { action, action2 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3 ) {
return New( { action, action2, action3 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4 ) {
return New( { action, action2, action3, action4 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5 ) {
return New( { action, action2, action3, action4, action5 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6 ) {
return New( { action, action2, action3, action4, action5, action6 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7 ) {
return New( { action, action2, action3, action4, action5, action6, action7 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8 ) {
return New( { action, action2, action3, action4, action5, action6, action7, action8 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6, UIAction * action7, UIAction * action8, UIAction * action9 ) {
return New( { action, action2, action3, action4, action5, action6, action7, action8, action9 } );
}
void Spawn::start() {
for ( size_t i = 0; i < mSpawn.size(); i++ ) {
mSpawn[ i ]->setTarget( getTarget() );
mSpawn[ i ]->start();
}
sendEvent( ActionType::OnStart );
}
void Spawn::stop() {
for ( size_t i = 0; i < mSpawn.size(); i++ )
mSpawn[ i ]->stop();
sendEvent( ActionType::OnStop );
}
void Spawn::update( const Time & time ) {
if ( isDone() )
return;
bool allDone = true;
for ( size_t i = 0; i < mSpawn.size(); i++ ) {
mSpawn[ i ]->update( time );
if ( !mSpawn[i]->isDone() ) {
allDone = false;
}
}
mAllDone = allDone;
}
bool Spawn::isDone() {
return mAllDone;
}
UIAction * Spawn::clone() const {
return Spawn::New( mSpawn );
}
UIAction * Spawn::reverse() const {
std::vector<UIAction*> reversed;
for ( auto it = mSpawn.rbegin(); it != mSpawn.rend(); ++it ) {
reversed.push_back( *it );
}
return Spawn::New( reversed );
}
Spawn::~Spawn() {
for ( size_t i = 0; i < mSpawn.size(); i++ ) {
UIAction * action = mSpawn[ i ];
eeSAFE_DELETE( action );
}
}
Spawn::Spawn( const std::vector<UIAction*> spawn ) :
mSpawn( spawn )
{}
}}}

View File

@@ -74,10 +74,6 @@ void UIAction::sendEvent( const ActionType& actionType ) {
}
}
UINode * UIAction::getNode() const {
return mNode;
}
void UIAction::onStart() {}
void UIAction::onStop() {}

View File

@@ -1868,7 +1868,7 @@ bool UINode::isAnimating() {
}
static void UINode_onFadeDone( UIAction * action, const UIAction::ActionType& actionType ) {
UINode * node = action->getNode();
UINode * node = action->getTarget();
if ( NULL != node ) {
if ( ( node->getNodeFlags() & UI_CTRL_FLAG_CLOSE_FO ) )

View File

@@ -1106,6 +1106,8 @@ void EETest::onMainClick( const UIEvent * Event ) {
}
}
using namespace EE::UI::Action;
void EETest::onButtonClick( const UIEvent * Event ) {
const UIEventMouse * MouseEvent = reinterpret_cast<const UIEventMouse*> ( Event );
@@ -1113,12 +1115,12 @@ void EETest::onButtonClick( const UIEvent * 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->startRotation( 0, 2500, Milliseconds( 2500 ) );
Gfx->startTranslation( Vector2i( Math::randi( 0, mWindow->getWidth() ), -64 ), Vector2i( Math::randi( 0, mWindow->getWidth() ), mWindow->getHeight() + 64 ), Milliseconds( 2500 ) );
Gfx->closeFadeOut( Milliseconds( 3500 ) );
//mListBox->addListBoxItem( "Test ListBox " + String::toStr( mListBox->getCount() + 1 ) + " testing it right now!" );
}
}