IMapControlInterface.h 3.06 KB
//
//  IMapControlInterface.h
//  SteveMaggieCpp
//
//  Created by Katarzyna Kalinowska-Górska on 17.05.2017.
//
//

#ifndef IMapControlInterface_h
#define IMapControlInterface_h

#include "cocos2d.h"

class IMapControl;

class IMapControlInterface {
    friend class IMapControl;
    
public:
    struct IMapControlEventData {
        IMapControlEventData(int p_eventId) : eventId(p_eventId){};
        int eventId {-1};
    };
    
    struct IMapControlSingleXYEventData : IMapControlEventData {
        IMapControlSingleXYEventData(int p_eventId, cocos2d::Point p_touchPoint, cocos2d::Point p_previousTouchPoint, cocos2d::Point p_initialPoint) : IMapControlEventData(p_eventId), screenPointPrevious(p_previousTouchPoint), screenPointCurrent(p_touchPoint), screenPointInitial(p_initialPoint){}
        cocos2d::Point screenPointPrevious;
        cocos2d::Point screenPointCurrent;
        cocos2d::Point screenPointInitial;
    };
    
    typedef int IMapControlSwipeDirection;
    
    struct IMapControlSwipeEventData : IMapControlEventData {
        IMapControlSwipeEventData(int p_eventId, cocos2d::Point p_startLocation, cocos2d::Point p_endLocation, cocos2d::Vec2 p_speed, IMapControlSwipeDirection p_directionX, IMapControlSwipeDirection p_directionY) : IMapControlEventData(p_eventId), startLocation(p_startLocation), endLocation(p_endLocation), speed(p_speed), directionX(p_directionX), directionY(p_directionY){}
        
        cocos2d::Point startLocation;
        cocos2d::Point endLocation;
        cocos2d::Vec2 speed;
        IMapControlSwipeDirection directionX; // > 0 for right
        IMapControlSwipeDirection directionY; // > 0 for up
    };
    
    virtual void handleCommandSingleXYPress(const IMapControlSingleXYEventData& eventData) = 0;
    virtual void handleCommandSingleXYMove(const IMapControlSingleXYEventData& eventData) = 0;
    virtual void handleCommandSingleXYRelease(const IMapControlSingleXYEventData& eventData) = 0;
    
    virtual void handleCommandMultipleXYPress(const std::vector<IMapControlSingleXYEventData>& eventData) = 0;
    virtual void handleCommandMultipleXYMove(const std::vector<IMapControlSingleXYEventData>& eventData) = 0;
    virtual void handleCommandMultipleXYRelease(const std::vector<IMapControlSingleXYEventData>& eventData) = 0;
    
    virtual void handleCommandSingleXYLongPress(const IMapControlSingleXYEventData& eventData) = 0;
    virtual void handleCommandSingleXYTap(const IMapControlSingleXYEventData& eventData) = 0;
    virtual void handleCommandFastSwipe(const IMapControlSwipeEventData& eventData) = 0;
    virtual void handleCommandTicklingStarted() = 0;
    virtual void handleCommandTicklingContinued() = 0;
    virtual void handleCommandTicklingEnded() = 0;
    
    virtual ~IMapControlInterface(){};
    
protected:
    IMapControl* m_mapControl {nullptr};
};

using IMapControlEventData = IMapControlInterface::IMapControlEventData;
using IMapControlSingleXYEventData = IMapControlInterface::IMapControlSingleXYEventData;
using IMapControlSwipeEventData = IMapControlInterface::IMapControlSwipeEventData;

#endif /* IMapControlInterface_h */