//
//  Transition.hpp
//  Meteor
//
//  Created by Cesar Parent on 14/09/2015.
//  Copyright © 2015 Cesar Parent. All rights reserved.
//

#ifndef Transition_hpp
#define Transition_hpp

#include "../defines.h"
#include "../CPFoundation.h"
#include "../Graphics/Color.h"
#include "../Actions/Easing.h"
#include <functional>

NS_BEGIN
class Scene;


class Transition : public CPObject {
public:
    
    enum class Direction {
        Up,
        Down,
        Right,
        Left,
    };
    
    static ARC<Transition>
    fadeWithDuration(double duration,
                     Easing easing = Ease::inOutSine);
    
    static ARC<Transition>
    fadeWithColor(const Color& color,
                  double duration,
                  Easing easing = Ease::inOutSine);
    
    static ARC<Transition>
    crossFadeWithDuration(double duration,
                          Easing easing = Ease::inOutSine);
    
    static ARC<Transition>
    pushWithDirection(Direction direction,
                      double duration,
                      Easing easing = Ease::inOutSine);
    
    static ARC<Transition>
    revealWithDirection(Direction direction,
                        double duration,
                        Easing easing = Ease::inOutSine);
    
    static ARC<Transition>
    popOutWithDuration(double duration,
                       Easing easing = Ease::linear);
    
    Transition(std::function<void(ARC<Scene>, ARC<Scene>, float)> block,
               double duration,
               Easing easing = Ease::inOutSine);
    
    bool
    update(ARC<Scene> oldScene, ARC<Scene> newScene, double delta);
    
private:
    
    float       _duration;
    float       _elapsed;
    std::function<void(ARC<Scene>, ARC<Scene>, float)> _block;
    std::function<float(float)> _easing;
};



NS_END


#endif /* Transition_hpp */
