Experimental branch.

I want to add a Scene Manager that supports Nodes.
The UINode must inherit Scene::Node.

--HG--
branch : dev-scene
This commit is contained in:
Martín Lucas Golini
2018-01-31 23:24:59 -03:00
parent dd20e489f1
commit 9b09e0189e
36 changed files with 2050 additions and 402 deletions
@@ -1,5 +1,5 @@
#ifndef EE_UIACTION_HPP
#define EE_UIACTION_HPP
#ifndef EE_SCENEACTION_HPP
#define EE_SCENEACTION_HPP
#include <cstdlib>
#include <eepp/core.hpp>
@@ -7,10 +7,13 @@
using namespace EE::System;
namespace EE { namespace UI {
class UINode;
}}
using namespace EE::UI;
class EE_API UIAction {
namespace EE { namespace Scene {
class EE_API Action {
public:
enum ActionType
{
@@ -20,11 +23,11 @@ class EE_API UIAction {
OnStep
};
typedef cb::Callback2<void,UIAction*,const ActionType&> ActionCallback;
typedef cb::Callback2<void,Action*,const ActionType&> ActionCallback;
UIAction();
Action();
virtual ~UIAction();
virtual ~Action();
virtual void start() = 0;
@@ -34,9 +37,9 @@ class EE_API UIAction {
virtual bool isDone() = 0;
virtual UIAction * clone() const;
virtual Action * clone() const;
virtual UIAction * reverse() const;
virtual Action * reverse() const;
Uint32 getFlags() const;
+39
View File
@@ -0,0 +1,39 @@
#ifndef EE_SCENEACTIONMANAGER_HPP
#define EE_SCENEACTIONMANAGER_HPP
#include <list>
#include <eepp/config.hpp>
#include <eepp/system/time.hpp>
using namespace EE::System;
namespace EE { namespace Scene {
class Action;
class EE_API ActionManager {
public:
ActionManager();
~ActionManager();
void addAction( Action * action );
Action * getActionByTag( const Uint32& tag );
void removeActionByTag( const Uint32& tag );
void removeAction( Action * action );
void update( const Time& time );
std::size_t count() const;
bool isEmpty() const;
protected:
std::list<Action*> mActions;
};
}}
#endif
@@ -1,13 +1,13 @@
#ifndef EE_UI_ACTIONINTERPOLATION1D_HPP
#define EE_UI_ACTIONINTERPOLATION1D_HPP
#ifndef EE_SCENE_ACTIONINTERPOLATION1D_HPP
#define EE_SCENE_ACTIONINTERPOLATION1D_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/math/interpolation1d.hpp>
using namespace EE::Math;
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
class EE_API ActionInterpolation1d : public UIAction {
class EE_API ActionInterpolation1d : public Action {
public:
void start() override;
@@ -1,13 +1,13 @@
#ifndef EE_UI_ACTIONINTERPOLATION2D_HPP
#define EE_UI_ACTIONINTERPOLATION2D_HPP
#ifndef EE_SCENE_ACTIONINTERPOLATION2D_HPP
#define EE_SCENE_ACTIONINTERPOLATION2D_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/math/interpolation2d.hpp>
using namespace EE::Math;
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
class EE_API ActionInterpolation2d : public UIAction {
class EE_API ActionInterpolation2d : public Action {
public:
void start() override;
@@ -1,13 +1,13 @@
#ifndef EE_UI_ACTION_DELAY_HPP
#define EE_UI_ACTION_DELAY_HPP
#ifndef EE_SCENE_ACTION_DELAY_HPP
#define EE_SCENE_ACTION_DELAY_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/system/clock.hpp>
using namespace EE::System;
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
class EE_API Delay : public UIAction {
class EE_API Delay : public Action {
public:
static Delay * New( const Time& time );
@@ -19,9 +19,9 @@ class EE_API Delay : public UIAction {
bool isDone() override;
UIAction * clone() const override;
Action * clone() const override;
UIAction * reverse() const override;
Action * reverse() const override;
protected:
Clock mClock;
@@ -1,18 +1,18 @@
#ifndef EE_UI_ACTION_FADE_HPP
#define EE_UI_ACTION_FADE_HPP
#ifndef EE_SCENE_ACTION_FADE_HPP
#define EE_SCENE_ACTION_FADE_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/ui/actions/actioninterpolation1d.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/scene/actions/actioninterpolation1d.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
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 );
UIAction * clone() const override;
Action * clone() const override;
UIAction * reverse() const override;
Action * reverse() const override;
protected:
Fade( const Float & start, const Float & end, const Time & duration, const Ease::Interpolation & type, const bool& alphaChilds );
@@ -1,15 +1,15 @@
#ifndef EE_UI_ACTION_MARGINMOVE_HPP
#define EE_UI_ACTION_MARGINMOVE_HPP
#ifndef EE_SCENE_ACTION_MARGINMOVE_HPP
#define EE_SCENE_ACTION_MARGINMOVE_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/math/interpolation1d.hpp>
#include <eepp/math/rect.hpp>
using namespace EE::Math;
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
class EE_API MarginMove : public UIAction {
class EE_API MarginMove : public Action {
public:
static MarginMove * New( const Rect& start, const Rect& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear );
@@ -21,9 +21,9 @@ class EE_API MarginMove : public UIAction {
bool isDone() override;
UIAction * clone() const override;
Action * clone() const override;
UIAction * reverse() const override;
Action * reverse() const override;
Interpolation1d getInterpolationLeft() const;
@@ -1,18 +1,18 @@
#ifndef EE_UI_ACTION_MOVE_HPP
#define EE_UI_ACTION_MOVE_HPP
#ifndef EE_SCENE_ACTION_MOVE_HPP
#define EE_SCENE_ACTION_MOVE_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/ui/actions/actioninterpolation2d.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/scene/actions/actioninterpolation2d.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
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 );
UIAction * clone() const override;
Action * clone() const override;
UIAction * reverse() const override;
Action * reverse() const override;
protected:
Move( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type );
@@ -1,18 +1,18 @@
#ifndef EE_UI_ACTION_ROTATE_HPP
#define EE_UI_ACTION_ROTATE_HPP
#ifndef EE_SCENE_ACTION_ROTATE_HPP
#define EE_SCENE_ACTION_ROTATE_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/ui/actions/actioninterpolation1d.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/scene/actions/actioninterpolation1d.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
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 );
UIAction * clone() const override;
Action * clone() const override;
UIAction * reverse() const override;
Action * reverse() const override;
protected:
Rotate( const Float & start, const Float & end, const Time & duration, const Ease::Interpolation & type );
@@ -1,18 +1,18 @@
#ifndef EE_UI_ACTION_SCALE_HPP
#define EE_UI_ACTION_SCALE_HPP
#ifndef EE_SCENE_ACTION_SCALE_HPP
#define EE_SCENE_ACTION_SCALE_HPP
#include <eepp/ui/uiaction.hpp>
#include <eepp/ui/actions/actioninterpolation2d.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/scene/actions/actioninterpolation2d.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
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 );
UIAction * clone() const override;
Action * clone() const override;
UIAction * reverse() const override;
Action * reverse() const override;
protected:
Scale( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type );
+44
View File
@@ -0,0 +1,44 @@
#ifndef EE_SCENE_ACTION_SEQUENCE_HPP
#define EE_SCENE_ACTION_SEQUENCE_HPP
#include <eepp/scene/action.hpp>
namespace EE { namespace Scene { namespace Actions {
class EE_API Sequence : public Action {
public:
static Sequence * New( const std::vector<Action*> sequence );
static Sequence * New( Action * action, Action * action2 );
static Sequence * New( Action * action, Action * action2, Action * action3 );
static Sequence * New( Action * action, Action * action2, Action * action3, Action * action4 );
static Sequence * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5 );
static Sequence * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6 );
static Sequence * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7 );
static Sequence * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * action8 );
static Sequence * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * action8, Action * action9 );
void start() override;
void stop() override;
void update( const Time& time ) override;
bool isDone() override;
Action * clone() const override;
Action * reverse() const override;
virtual ~Sequence();
protected:
std::vector<Action*> mSequence;
Uint32 mCurPos;
Sequence( const std::vector<Action*> sequence );
};
}}}
#endif
+43
View File
@@ -0,0 +1,43 @@
#ifndef EE_SCENE_ACTION_SPAWN_HPP
#define EE_SCENE_ACTION_SPAWN_HPP
#include <eepp/scene/action.hpp>
namespace EE { namespace Scene { namespace Actions {
class EE_API Spawn : public Action {
public:
static Spawn * New( const std::vector<Action*> spawn );
static Spawn * New( Action * action, Action * action2 );
static Spawn * New( Action * action, Action * action2, Action * action3 );
static Spawn * New( Action * action, Action * action2, Action * action3, Action * action4 );
static Spawn * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5 );
static Spawn * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6 );
static Spawn * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7 );
static Spawn * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * action8 );
static Spawn * New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * action8, Action * action9 );
void start() override;
void stop() override;
void update( const Time& time ) override;
bool isDone() override;
Action * clone() const override;
Action * reverse() const override;
virtual ~Spawn();
protected:
std::vector<Action*> mSpawn;
bool mAllDone;
Spawn( const std::vector<Action*> spawn );
};
}}}
#endif
+396
View File
@@ -0,0 +1,396 @@
#ifndef EE_SCENE_NODE_HPP
#define EE_SCENE_NODE_HPP
#include <eepp/ui/base.hpp>
#include <eepp/ui/uihelper.hpp>
#include <eepp/ui/uimessage.hpp>
#include <eepp/ui/uievent.hpp>
#include <eepp/ui/uieventkey.hpp>
#include <eepp/ui/uieventmouse.hpp>
#include <eepp/math/transformable.hpp>
#include <eepp/graphics/blendmode.hpp>
using namespace EE::UI;
namespace EE { namespace Scene {
class Action;
class ActionManager;
}}
using namespace EE::Scene;
namespace EE { namespace UI {
class UIWindow;
class UIManager;
}}
namespace EE { namespace Scene {
class EE_API Node : public Transformable {
public:
static Node * New();
typedef cb::Callback1<void, const UIEvent*> UIEventCallback;
Node();
virtual ~Node();
void worldToNodeTranslation( Vector2f& position ) const;
void nodeToWorldTranslation( Vector2f& position ) const;
void worldToNode( Vector2i& pos );
void nodeToWorld( Vector2i& pos );
void worldToNode( Vector2f& pos );
void nodeToWorld( Vector2f& pos );
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
void messagePost( const UIMessage * Msg );
void setPosition( const Vector2f& Pos );
Node * setPosition( const Float& x, const Float& y );
virtual Node * setSize( const Sizef& size );
const Sizef& getSize();
Node * setVisible( const bool& visible );
bool isVisible() const;
bool isHided() const;
Node * setEnabled( const bool& enabled );
bool isEnabled() const;
bool isDisabled() const;
Node * getParent() const;
Node * setParent( Node * parent );
void centerHorizontal();
void centerVertical();
void center();
virtual void close();
virtual void draw();
virtual void update( const Time& time );
Node * getNextNode() const;
Node * getPrevNode() const;
Node * getNextNodeLoop() const;
Node * setData( const UintPtr& data );
const UintPtr& getData() const;
Node * setBlendMode( const BlendMode& blend );
BlendMode getBlendMode();
void toFront();
void toBack();
void toPosition( const Uint32& position );
const Uint32& getNodeFlags() const;
/** Use it at your own risk */
void setNodeFlags( const Uint32& flags );
Uint32 isWidget();
Uint32 isWindow();
Uint32 isClipped();
Uint32 isRotated();
Uint32 isScaled();
Uint32 isFrameBuffer();
bool isMouseOver();
bool isMouseOverMeOrChilds();
bool isMeOrParentTreeRotated();
bool isMeOrParentTreeScaled();
bool isMeOrParentTreeScaledOrRotated();
bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer();
Uint32 addEventListener( const Uint32& EventType, const UIEventCallback& Callback );
void removeEventListener( const Uint32& CallbackId );
Node * getFirstChild() const;
Node * getLastChild() const;
const Polygon2f& getWorldPolygon();
const Rectf& getWorldBounds();
bool isParentOf( Node * Ctrl );
void sendEvent( const UIEvent * Event );
void sendMouseEvent( const Uint32& Event, const Vector2i& position, const Uint32& flags );
void sendCommonEvent( const Uint32& Event );
void childsCloseAll();
std::string getId() const;
Node * setId( const std::string & id );
Uint32 getIdHash() const;
Node * find( const std::string& id );
template<typename T>
T * find( const std::string& id )
{
return reinterpret_cast<T*>( find( id ) );
}
template<typename T>
T * bind( const std::string& id, T*& ctrl )
{
ctrl = find<T>( id );
return ctrl;
}
bool isReverseDraw() const;
void setReverseDraw( bool reverseDraw );
void invalidateDraw();
void setClipEnabled();
void setClipDisabled();
void setRotation( float angle );
void setRotation( const Float& angle, const OriginPoint& center );
const OriginPoint& getRotationOriginPoint() const;
void setRotationOriginPoint( const OriginPoint& center );
Vector2f getRotationCenter();
void setScale( const Vector2f& scale );
void setScale( const Vector2f& scale, const OriginPoint& center );
void setScale( const Float& scale , const OriginPoint & center = OriginPoint::OriginCenter );
const OriginPoint& getScaleOriginPoint() const;
void setScaleOriginPoint( const OriginPoint& center );
Vector2f getScaleCenter();
virtual void setScale(float factorX, float factorY);
virtual void setScaleOrigin(float x, float y);
virtual void setRotationOrigin(float x, float y);
const Float& getAlpha() const;
virtual void setAlpha( const Float& alpha );
virtual void setChildsAlpha( const Float& alpha );
ActionManager * getActionManager();
void runAction( Action * action );
Transform getLocalTransform();
Transform getGlobalTransform();
Transform getNodeToWorldTransform();
Transform getWorldToNodeTransform();
Vector2f convertToNodeSpace(const Vector2f& worldPoint);
Vector2f convertToWorldSpace(const Vector2f& nodePoint);
Rectf getLocalBounds();
UIWindow * getOwnerWindow();
protected:
typedef std::map< Uint32, std::map<Uint32, UIEventCallback> > UIEventsMap;
friend class UIManager;
friend class UIWindow;
std::string mId;
Uint32 mIdHash;
Vector2f mScreenPos;
Vector2i mScreenPosi;
Sizef mSize;
UintPtr mData;
Node * mParentCtrl;
UIWindow * mParentWindowCtrl;
Node * mChild; //! Pointer to the first child of the node
Node * mChildLast; //! Pointer to the last child added
Node * mNext; //! Pointer to the next child of the father
Node * mPrev; //! Pointer to the prev child of the father
Uint32 mNodeFlags;
BlendMode mBlend;
Uint16 mNumCallBacks;
mutable Polygon2f mPoly;
mutable Rectf mWorldBounds;
Vector2f mCenter;
UIEventsMap mEvents;
bool mVisible;
bool mEnabled;
OriginPoint mRotationOriginPoint;
OriginPoint mScaleOriginPoint;
Float mAlpha;
ActionManager * mActionManager;
virtual Uint32 onMessage( const UIMessage * Msg );
virtual Uint32 onKeyDown( const UIEventKey& Event );
virtual Uint32 onKeyUp( const UIEventKey& Event );
virtual Uint32 onMouseMove( const Vector2i& position, const Uint32 flags );
virtual Uint32 onMouseDown( const Vector2i& position, const Uint32 flags );
virtual Uint32 onMouseClick( const Vector2i& position, const Uint32 flags );
virtual Uint32 onMouseDoubleClick( const Vector2i& position, const Uint32 flags );
virtual Uint32 onMouseUp( const Vector2i& position, const Uint32 flags );
virtual Uint32 onMouseEnter( const Vector2i& position, const Uint32 flags );
virtual Uint32 onMouseExit( const Vector2i& position, const Uint32 flags );
virtual void onClose();
virtual void onVisibilityChange();
virtual void onEnabledChange();
virtual void onPositionChange();
virtual void onSizeChange();
virtual void onParentSizeChange( const Vector2f& SizeChange );
virtual void onParentChange();
virtual void updateWorldPolygon();
virtual void updateCenter();
virtual void matrixSet();
virtual void matrixUnset();
virtual void drawChilds();
virtual void onChildCountChange();
virtual void onAngleChange();
virtual void onScaleChange();
virtual void onAlphaChange();
virtual Node * overFind( const Vector2f& Point );
virtual void onParentWindowChange();
virtual void clipMe();
void checkClose();
virtual void internalDraw();
void childDeleteAll();
void childAdd( Node * ChildCtrl );
void childAddAt( Node * ChildCtrl, Uint32 position );
void childRemove( Node * ChildCtrl );
bool isChild( Node * ChildCtrl ) const;
bool inParentTreeOf( Node * Child ) const;
Uint32 childCount() const;
Node * childAt( Uint32 Index ) const;
Node * childPrev( Node * Ctrl, bool Loop = false ) const;
Node * childNext( Node * Ctrl, bool Loop = false ) const;
virtual void clipDisable();
virtual void updateScreenPos();
void writeCtrlFlag( const Uint32& Flag, const Uint32& Val );
Rectf getScreenBounds();
void setInternalPosition( const Vector2f& Pos );
void setInternalSize(const Sizef& size );
void setInternalWidth(const Float& width );
void setInternalHeight( const Float& height );
Color getColor( const Color& Col );
Node * findIdHash( const Uint32& idHash );
UIWindow * getParentWindow();
void updateOriginPoint();
void setDirty();
void setChildsDirty();
};
}}
#endif
+13 -10
View File
@@ -58,15 +58,18 @@
#include <eepp/ui/uiwidgetcreator.hpp>
#include <eepp/ui/actions/actioninterpolation1d.hpp>
#include <eepp/ui/actions/actioninterpolation2d.hpp>
#include <eepp/ui/actions/move.hpp>
#include <eepp/ui/actions/rotate.hpp>
#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>
#include <eepp/scene/actions/actioninterpolation1d.hpp>
#include <eepp/scene/actions/actioninterpolation2d.hpp>
#include <eepp/scene/actions/move.hpp>
#include <eepp/scene/actions/rotate.hpp>
#include <eepp/scene/actions/scale.hpp>
#include <eepp/scene/actions/fade.hpp>
#include <eepp/scene/actions/marginmove.hpp>
#include <eepp/scene/actions/sequence.hpp>
#include <eepp/scene/actions/spawn.hpp>
#include <eepp/scene/actions/delay.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/scene/actionmanager.hpp>
using namespace EE::Scene;
#endif
-44
View File
@@ -1,44 +0,0 @@
#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 override;
UIAction * reverse() const override;
virtual ~Sequence();
protected:
std::vector<UIAction*> mSequence;
Uint32 mCurPos;
Sequence( const std::vector<UIAction*> sequence );
};
}}}
#endif
-43
View File
@@ -1,43 +0,0 @@
#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 override;
UIAction * reverse() const override;
virtual ~Spawn();
protected:
std::vector<UIAction*> mSpawn;
bool mAllDone;
Spawn( const std::vector<UIAction*> spawn );
};
}}}
#endif
-39
View File
@@ -1,39 +0,0 @@
#ifndef EE_UIActionManager_HPP
#define EE_UIActionManager_HPP
#include <list>
#include <eepp/config.hpp>
#include <eepp/system/time.hpp>
using namespace EE::System;
namespace EE { namespace UI {
class UIAction;
class EE_API 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<UIAction*> mActions;
};
}}
#endif
+9 -5
View File
@@ -16,13 +16,17 @@
#include <eepp/ui/uithememanager.hpp>
#include <eepp/math/transformable.hpp>
namespace EE { namespace Scene {
class Action;
class ActionManager;
}}
using namespace EE::Scene;
namespace EE { namespace UI {
class UITheme;
class UIWindow;
class UIManager;
class UIAction;
class UIActionManager;
class EE_API UINode : public Transformable {
public:
@@ -350,9 +354,9 @@ class EE_API UINode : public Transformable {
bool isFadingOut();
UIActionManager * getActionManager();
ActionManager * getActionManager();
void runAction( UIAction * action );
void runAction( Action * action );
Transform getLocalTransform();
@@ -414,7 +418,7 @@ class EE_API UINode : public Transformable {
OriginPoint mScaleOriginPoint;
Float mAlpha;
UIActionManager * mActionManager;
ActionManager * mActionManager;
virtual Uint32 onMessage( const UIMessage * Msg );
+2
View File
@@ -712,6 +712,8 @@ function build_eepp( build_name )
"src/eepp/window/platform/null/*.cpp",
"src/eepp/network/*.cpp",
"src/eepp/network/ssl/*.cpp",
"src/eepp/scene/*.cpp",
"src/eepp/scene/actions/*.cpp",
"src/eepp/ui/*.cpp",
"src/eepp/ui/actions/*.cpp",
"src/eepp/ui/tools/*.cpp",
+26 -24
View File
@@ -51,19 +51,21 @@
../../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/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/scene/node.hpp
../../src/eepp/scene/node.cpp
../../include/eepp/scene/actions/actioninterpolation1d.hpp
../../include/eepp/scene/actions/actioninterpolation2d.hpp
../../include/eepp/scene/actions/delay.hpp
../../include/eepp/scene/actions/fade.hpp
../../include/eepp/scene/actions/marginmove.hpp
../../include/eepp/scene/actions/move.hpp
../../include/eepp/scene/actions/rotate.hpp
../../include/eepp/scene/actions/scale.hpp
../../include/eepp/scene/actions/sequence.hpp
../../include/eepp/scene/actions/spawn.hpp
../../include/eepp/ui/marginmove/scale.hpp
../../include/eepp/ui/uiaction.hpp
../../include/eepp/ui/uiactionmanager.hpp
../../include/eepp/scene/action.hpp
../../include/eepp/scene/actionmanager.hpp
../../include/eepp/ui/uieventmouse.hpp
../../include/eepp/ui/uigridlayout.hpp
../../include/eepp/ui/uiimage.hpp
@@ -134,18 +136,18 @@
../../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/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/scene/actions/actioninterpolation1d.cpp
../../src/eepp/scene/actions/actioninterpolation2d.cpp
../../src/eepp/scene/actions/delay.cpp
../../src/eepp/scene/actions/fade.cpp
../../src/eepp/scene/actions/move.cpp
../../src/eepp/scene/actions/rotate.cpp
../../src/eepp/scene/actions/scale.cpp
../../src/eepp/scene/actions/marginmove.cpp
../../src/eepp/scene/actions/sequence.cpp
../../src/eepp/scene/actions/spawn.cpp
../../src/eepp/scene/action.cpp
../../src/eepp/scene/actionmanager.cpp
../../src/eepp/ui/uigridlayout.cpp
../../src/eepp/ui/uiimage.cpp
../../src/eepp/ui/uilayout.cpp
+83
View File
@@ -0,0 +1,83 @@
#include <eepp/scene/action.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace Scene {
Action::Action() :
mNode( NULL ),
mFlags( 0 ),
mTag( 0 ),
mNumCallBacks( 0 )
{
}
Action::~Action()
{}
Uint32 Action::getFlags() const {
return mFlags;
}
void Action::setFlags( const Uint32 & flags ) {
mFlags = flags;
}
Uint32 Action::getTag() const {
return mTag;
}
void Action::setTag( const Uint32 & tag ) {
mTag = tag;
}
void Action::setTarget( UINode * target ) {
mNode = target;
}
UINode * Action::getTarget() const {
return mNode;
}
Action * Action::clone() const {
return NULL;
}
Action * Action::reverse() const {
return NULL;
}
Uint32 Action::addEventListener( const ActionType& actionType, const ActionCallback& callback ) {
mNumCallBacks++;
mCallbacks[ actionType ][ mNumCallBacks ] = callback;
return mNumCallBacks;
}
void Action::removeEventListener( const Uint32& callbackId ) {
for ( auto it = mCallbacks.begin(); it != mCallbacks.end(); ++it ) {
std::map<Uint32, ActionCallback> event = it->second;
if ( event.erase( callbackId ) )
break;
}
}
void Action::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 );
}
}
}
void Action::onStart() {}
void Action::onStop() {}
void Action::onUpdate( const Time& time ) {}
}}
@@ -1,22 +1,22 @@
#include <eepp/ui/uiactionmanager.hpp>
#include <eepp/ui/uiaction.hpp>
#include <eepp/scene/actionmanager.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/core.hpp>
#include <algorithm>
namespace EE { namespace UI {
namespace EE { namespace Scene {
UIActionManager::UIActionManager() {
ActionManager::ActionManager() {
}
UIActionManager::~UIActionManager() {
ActionManager::~ActionManager() {
for ( auto it = mActions.begin(); it != mActions.end(); ++it ) {
UIAction * action = (*it);
Action * action = (*it);
eeSAFE_DELETE( action );
}
}
void UIActionManager::addAction( UIAction * action ) {
void ActionManager::addAction( Action * action ) {
bool found = (std::find(mActions.begin(), mActions.end(), action) != mActions.end());
if ( !found ) {
@@ -24,9 +24,9 @@ void UIActionManager::addAction( UIAction * action ) {
}
}
UIAction * UIActionManager::getActionByTag( const Uint32& tag ) {
Action * ActionManager::getActionByTag( const Uint32& tag ) {
for ( auto it = mActions.begin(); it != mActions.end(); ++it ) {
UIAction * action = (*it);
Action * action = (*it);
if ( action->getTag() == tag )
return action;
@@ -35,23 +35,23 @@ UIAction * UIActionManager::getActionByTag( const Uint32& tag ) {
return NULL;
}
void UIActionManager::removeActionByTag( const Uint32& tag ) {
void ActionManager::removeActionByTag( const Uint32& tag ) {
removeAction( getActionByTag( tag ) );
}
void UIActionManager::update( const Time& time ) {
void ActionManager::update( const Time& time ) {
if ( isEmpty() )
return;
std::list<UIAction*> removeList;
std::list<Action*> removeList;
for ( auto it = mActions.begin(); it != mActions.end(); ++it ) {
UIAction * action = (*it);
Action * action = (*it);
action->update( time );
if ( action->isDone() ) {
action->sendEvent( UIAction::ActionType::OnDone );
action->sendEvent( Action::ActionType::OnDone );
removeList.push_back( action );
}
@@ -61,15 +61,15 @@ void UIActionManager::update( const Time& time ) {
removeAction( (*it) );
}
std::size_t UIActionManager::count() const {
std::size_t ActionManager::count() const {
return mActions.size();
}
bool UIActionManager::isEmpty() const {
bool ActionManager::isEmpty() const {
return mActions.empty();
}
void UIActionManager::removeAction( UIAction * action ) {
void ActionManager::removeAction( Action * action ) {
if ( NULL != action ) {
mActions.remove( action );
@@ -1,7 +1,7 @@
#include <eepp/ui/actions/actioninterpolation1d.hpp>
#include <eepp/scene/actions/actioninterpolation1d.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
ActionInterpolation1d::ActionInterpolation1d()
{}
@@ -1,7 +1,7 @@
#include <eepp/ui/actions/actioninterpolation2d.hpp>
#include <eepp/scene/actions/actioninterpolation2d.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
ActionInterpolation2d::ActionInterpolation2d()
{}
@@ -1,6 +1,6 @@
#include <eepp/ui/actions/delay.hpp>
#include <eepp/scene/actions/delay.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
Delay * Delay::New(const Time & time) {
return eeNew( Delay, ( time ) );
@@ -24,11 +24,11 @@ bool Delay::isDone() {
return mClock.getElapsedTime() >= mTime;
}
UIAction *Delay::clone() const {
Action *Delay::clone() const {
return New( mTime );
}
UIAction *Delay::reverse() const {
Action *Delay::reverse() const {
return NULL; // or a time machine
}
@@ -1,7 +1,7 @@
#include <eepp/ui/actions/fade.hpp>
#include <eepp/scene/actions/fade.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
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 ) );
@@ -38,14 +38,14 @@ void Fade::onUpdate( const Time& time ) {
}
}
UIAction * Fade::clone() const {
Action * Fade::clone() const {
Fade * action = eeNew( Fade, () );
action->mAffectChilds = mAffectChilds;
action->setInterpolation( mInterpolation );
return action;
}
UIAction * Fade::reverse() const {
Action * Fade::reverse() const {
Fade * action = eeNew( Fade, () );
action->mAffectChilds = mAffectChilds;
action->setInterpolation( Interpolation1d( mInterpolation.getReversePoints() ) );
@@ -1,8 +1,8 @@
#include <eepp/ui/actions/marginmove.hpp>
#include <eepp/scene/actions/marginmove.hpp>
#include <eepp/ui/uinode.hpp>
#include <eepp/ui/uiwidget.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
MarginMove * MarginMove::New( const Rect & start, const Rect & end, const Time& duration, const Ease::Interpolation& type ) {
return eeNew( MarginMove, ( start, end, duration, type ) );
@@ -106,7 +106,7 @@ void MarginMove::onUpdate( const Time& time ) {
}
}
UIAction * MarginMove::clone() const {
Action * MarginMove::clone() const {
MarginMove * action = eeNew( MarginMove, () );
action->setInterpolationLeft( mInterpolationLeft );
action->setInterpolationRight( mInterpolationRight );
@@ -115,7 +115,7 @@ UIAction * MarginMove::clone() const {
return action;
}
UIAction * MarginMove::reverse() const {
Action * MarginMove::reverse() const {
return NULL;
}
@@ -1,7 +1,7 @@
#include <eepp/ui/actions/move.hpp>
#include <eepp/scene/actions/move.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
Move * Move::New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type ) {
return eeNew( Move, ( start, end, duration, type ) );
@@ -26,13 +26,13 @@ void Move::onUpdate( const Time& time ) {
}
}
UIAction * Move::clone() const {
Action * Move::clone() const {
Move * action = eeNew( Move, () );
action->setInterpolation( mInterpolation );
return action;
}
UIAction * Move::reverse() const {
Action * Move::reverse() const {
Move * action = eeNew( Move, () );
action->setInterpolation( Interpolation2d( mInterpolation.getReversePoints() ) );
return action;
@@ -1,7 +1,7 @@
#include <eepp/ui/actions/rotate.hpp>
#include <eepp/scene/actions/rotate.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
Rotate * Rotate::New( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type ) {
return eeNew( Rotate, ( start, end, duration, type ) );
@@ -26,13 +26,13 @@ void Rotate::onUpdate( const Time& time ) {
}
}
UIAction * Rotate::clone() const {
Action * Rotate::clone() const {
Rotate * action = eeNew( Rotate, () );
action->setInterpolation( mInterpolation );
return action;
}
UIAction * Rotate::reverse() const {
Action * Rotate::reverse() const {
Rotate * action = eeNew( Rotate, () );
action->setInterpolation( Interpolation1d( mInterpolation.getReversePoints() ) );
return action;
@@ -1,7 +1,7 @@
#include <eepp/ui/actions/scale.hpp>
#include <eepp/scene/actions/scale.hpp>
#include <eepp/ui/uinode.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
Scale * Scale::New( const Vector2f& start, const Vector2f& end, const Time& duration, const Ease::Interpolation& type ) {
return eeNew( Scale, ( start, end, duration, type ) );
@@ -26,13 +26,13 @@ void Scale::onUpdate( const Time& time ) {
}
}
UIAction * Scale::clone() const {
Action * Scale::clone() const {
Scale * action = eeNew( Scale, () );
action->setInterpolation( mInterpolation );
return action;
}
UIAction * Scale::reverse() const {
Action * Scale::reverse() const {
Scale * action = eeNew( Scale, () );
action->setInterpolation( mInterpolation.getReversePoints() );
return action;
@@ -1,40 +1,40 @@
#include <eepp/ui/actions/sequence.hpp>
#include <eepp/scene/actions/sequence.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
Sequence * Sequence::New( const std::vector<UIAction *> sequence ) {
Sequence * Sequence::New( const std::vector<Action *> sequence ) {
return eeNew( Sequence, ( sequence ) );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2 ) {
Sequence * Sequence::New( Action * action, Action * action2 ) {
return New( { action, action2 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3 ) {
return New( { action, action2, action3 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3, Action * action4 ) {
return New( { action, action2, action3, action4 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5 ) {
return New( { action, action2, action3, action4, action5 } );
}
Sequence * Sequence::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * 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 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * 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 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * 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 ) {
Sequence * Sequence::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * action8, Action * action9 ) {
return New( { action, action2, action3, action4, action5, action6, action7, action8, action9 } );
}
@@ -70,12 +70,12 @@ bool Sequence::isDone() {
return mCurPos == mSequence.size() - 1 && mSequence[ mCurPos ]->isDone();
}
UIAction * Sequence::clone() const {
Action * Sequence::clone() const {
return Sequence::New( mSequence );
}
UIAction * Sequence::reverse() const {
std::vector<UIAction*> reversed;
Action * Sequence::reverse() const {
std::vector<Action*> reversed;
for ( auto it = mSequence.rbegin(); it != mSequence.rend(); ++it ) {
reversed.push_back( *it );
@@ -86,12 +86,12 @@ UIAction * Sequence::reverse() const {
Sequence::~Sequence() {
for ( size_t i = 0; i < mSequence.size(); i++ ) {
UIAction * action = mSequence[ i ];
Action * action = mSequence[ i ];
eeSAFE_DELETE( action );
}
}
Sequence::Sequence( const std::vector<UIAction*> sequence ) :
Sequence::Sequence( const std::vector<Action*> sequence ) :
mSequence( sequence ),
mCurPos( 0 )
{}
@@ -1,40 +1,40 @@
#include <eepp/ui/actions/spawn.hpp>
#include <eepp/scene/actions/spawn.hpp>
namespace EE { namespace UI { namespace Action {
namespace EE { namespace Scene { namespace Actions {
Spawn * Spawn::New( const std::vector<UIAction *> spawn ) {
Spawn * Spawn::New( const std::vector<Action *> spawn ) {
return eeNew( Spawn, ( spawn ) );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2 ) {
Spawn * Spawn::New( Action * action, Action * action2 ) {
return New( { action, action2 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3 ) {
return New( { action, action2, action3 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3, Action * action4 ) {
return New( { action, action2, action3, action4 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5 ) {
return New( { action, action2, action3, action4, action5 } );
}
Spawn * Spawn::New( UIAction * action, UIAction * action2, UIAction * action3, UIAction * action4, UIAction * action5, UIAction * action6 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * 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 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * 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 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * 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 ) {
Spawn * Spawn::New( Action * action, Action * action2, Action * action3, Action * action4, Action * action5, Action * action6, Action * action7, Action * action8, Action * action9 ) {
return New( { action, action2, action3, action4, action5, action6, action7, action8, action9 } );
}
@@ -75,12 +75,12 @@ bool Spawn::isDone() {
return mAllDone;
}
UIAction * Spawn::clone() const {
Action * Spawn::clone() const {
return Spawn::New( mSpawn );
}
UIAction * Spawn::reverse() const {
std::vector<UIAction*> reversed;
Action * Spawn::reverse() const {
std::vector<Action*> reversed;
for ( auto it = mSpawn.rbegin(); it != mSpawn.rend(); ++it ) {
reversed.push_back( *it );
@@ -91,12 +91,12 @@ UIAction * Spawn::reverse() const {
Spawn::~Spawn() {
for ( size_t i = 0; i < mSpawn.size(); i++ ) {
UIAction * action = mSpawn[ i ];
Action * action = mSpawn[ i ];
eeSAFE_DELETE( action );
}
}
Spawn::Spawn( const std::vector<UIAction*> spawn ) :
Spawn::Spawn( const std::vector<Action*> spawn ) :
mSpawn( spawn )
{}
File diff suppressed because it is too large Load Diff
-83
View File
@@ -1,83 +0,0 @@
#include <eepp/ui/uiaction.hpp>
#include <eepp/ui/uinode.hpp>
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<Uint32, ActionCallback> 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 );
}
}
}
void UIAction::onStart() {}
void UIAction::onStop() {}
void UIAction::onUpdate( const Time& time ) {}
}}
+15 -15
View File
@@ -2,8 +2,8 @@
#include <eepp/ui/uitheme.hpp>
#include <eepp/ui/uiwindow.hpp>
#include <eepp/ui/uimanager.hpp>
#include <eepp/ui/uiactionmanager.hpp>
#include <eepp/ui/uiaction.hpp>
#include <eepp/scene/actionmanager.hpp>
#include <eepp/scene/action.hpp>
#include <eepp/graphics/primitives.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/graphics/renderer/renderer.hpp>
@@ -11,10 +11,10 @@
#include <eepp/graphics/font.hpp>
#include <eepp/window/engine.hpp>
#include <eepp/ui/actions/fade.hpp>
#include <eepp/ui/actions/scale.hpp>
#include <eepp/ui/actions/rotate.hpp>
#include <eepp/ui/actions/move.hpp>
#include <eepp/scene/actions/fade.hpp>
#include <eepp/scene/actions/scale.hpp>
#include <eepp/scene/actions/rotate.hpp>
#include <eepp/scene/actions/move.hpp>
namespace EE { namespace UI {
@@ -1803,7 +1803,7 @@ bool UINode::isAnimating() {
return NULL != mActionManager && !mActionManager->isEmpty();
}
static void UINode_onFadeDone( UIAction * action, const UIAction::ActionType& actionType ) {
static void UINode_onFadeDone( Action * action, const Action::ActionType& actionType ) {
UINode * node = action->getTarget();
if ( NULL != node ) {
@@ -1819,11 +1819,11 @@ static void UINode_onFadeDone( UIAction * action, const UIAction::ActionType& ac
}
Interpolation1d * UINode::startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) {
Action::Fade * action = Action::Fade::New( From, To, TotalTime, Type );
Actions::Fade * action = Actions::Fade::New( From, To, TotalTime, Type );
action->getInterpolation()->setPathEndCallback( PathEndCallback );
action->addEventListener( UIAction::ActionType::OnDone, cb::Make2( &UINode_onFadeDone ) );
action->addEventListener( Action::ActionType::OnDone, cb::Make2( &UINode_onFadeDone ) );
runAction( action );
@@ -1831,7 +1831,7 @@ Interpolation1d * UINode::startAlphaAnim( const Float& From, const Float& To, co
}
Interpolation2d * UINode::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) {
Action::Scale * action = Action::Scale::New( From, To, TotalTime, Type );
Actions::Scale * action = Actions::Scale::New( From, To, TotalTime, Type );
action->getInterpolation()->setPathEndCallback( PathEndCallback );
@@ -1845,7 +1845,7 @@ Interpolation2d * UINode::startScaleAnim( const Float& From, const Float& To, co
}
Interpolation2d * UINode::startTranslation( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) {
Action::Move * action = Action::Move::New( From, To, TotalTime, Type );
Actions::Move * action = Actions::Move::New( From, To, TotalTime, Type );
action->getInterpolation()->setPathEndCallback( PathEndCallback );
@@ -1855,7 +1855,7 @@ Interpolation2d * UINode::startTranslation( const Vector2f& From, const Vector2f
}
Interpolation1d * UINode::startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) {
Action::Rotate * action = Action::Rotate::New( From, To, TotalTime, Type );
Actions::Rotate * action = Actions::Rotate::New( From, To, TotalTime, Type );
action->getInterpolation()->setPathEndCallback( PathEndCallback );
@@ -2014,14 +2014,14 @@ void UINode::setChildsAlpha( const Float &alpha ) {
}
}
UIActionManager * UINode::getActionManager() {
ActionManager * UINode::getActionManager() {
if ( NULL == mActionManager )
mActionManager = eeNew( UIActionManager, () );
mActionManager = eeNew( ActionManager, () );
return mActionManager;
}
void UINode::runAction( UIAction * action ) {
void UINode::runAction( Action * action ) {
if ( NULL != action ) {
action->setTarget( this );
+1 -1
View File
@@ -1123,7 +1123,7 @@ void EETest::onMainClick( const UIEvent * Event ) {
}
}
using namespace EE::UI::Action;
using namespace EE::Scene::Actions;
void EETest::onButtonClick( const UIEvent * Event ) {
const UIEventMouse * MouseEvent = reinterpret_cast<const UIEventMouse*> ( Event );