//
//  YCKWhiteboardActionReport.h
//  YCKit
//
//  Created by 任佳杰 on 2021/10/13.
//  Copyright © 2021 徐家骏. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YCKWhiteboardCommand.h"
#import "YCKWhiteboardElement.h"

NS_ASSUME_NONNULL_BEGIN

@class YCKWhiteboard;
typedef NS_ENUM(int, YCKWhiteboardActionType) {
    YCKWhiteboardActionTypeNone,
    YCKWhiteboardActionTypeDrawBegin,
    YCKWhiteboardActionTypeDrawing,
    YCKWhiteboardActionTypeDrawEnd,
    YCKWhiteboardActionTypeDrawCancel,
    YCKWhiteboardActionTypeSelect,
    YCKWhiteboardActionTypeUnSelect,
    YCKWhiteboardActionTypeMoveBegin,
    YCKWhiteboardActionTypeMoving,
    YCKWhiteboardActionTypeMoveEnd,
    YCKWhiteboardActionTypeMoveCancel,
    YCKWhiteboardActionTypeZoomBegin,
    YCKWhiteboardActionTypeZooming,
    YCKWhiteboardActionTypeScrollBengin,
    YCKWhiteboardActionTypeScrolling,
    YCKWhiteboardActionTypeScrollEnd,
    YCKWhiteboardActionTypeSticker,
    YCKWhiteboardActionTypeEarser,
    YCKWhiteboardActionTypeUndo,
    YCKWhiteboardActionTypeRedo,
    YCKWhiteboardActionTypeSave,
    YCKWhiteboardActionTypeLoad,
    YCKWhiteboardActionTypeLock,
    YCKWhiteboardActionTypeUnlock,
    YCKWhiteboardActionTypeToTop,
    YCKWhiteboardActionTypeToBottom,
    YCKWhiteboardActionTypeClear,
    YCKWhiteboardActionTypeSyncAll,
    YCKWhiteboardActionTypeSyncData,
    YCKWhiteboardActionTypeSyncReplyAll,
    YCKWhiteboardActionTypeSyncReplyData,
    YCKWhiteboardActionTypeRotate,
    YCKWhiteboardActionTypeCombinate,
    YCKWhiteboardActionTypeDecombinate,
    YCKWhiteboardActionTypeCopy,
    YCKWhiteboardActionTypePaste
};

@interface YCKWhiteboardActionReportInfo : NSObject

+ (instancetype)create:(YCKWhiteboardActionType )type;
@property (nonatomic, readonly) YCKWhiteboardActionType actionType;
@property (nonatomic) YCKWhiteboardElementType elementType;
@property (nonatomic) int64_t to;
@property (nonatomic) int64_t from;
/// maybe zero
@property (nonatomic) CGPoint lastPoint;

@end

@protocol YCKWhiteboardActionReportDelegate <NSObject>
    /// each actionType call oce
- (void)whiteboard:(YCKWhiteboard *)whiteboard actionReport:(YCKWhiteboardActionReportInfo *)info;
    /// no actionType info
- (void)whiteboard:(YCKWhiteboard *)whiteboard actionReportLastPoint:(YCKWhiteboardActionReportInfo *)info;

@end

@interface YCKWhiteboardActionReport : NSObject

@property (nonatomic, weak) id<YCKWhiteboardActionReportDelegate> delegate;
@property (nonatomic, weak) YCKWhiteboard *whiteboard;

/** 通过截取到的 command 来分类动作 */
- (void)handleCommnd:(YCKWhiteboardCommand *)command to:(int64_t)to;
- (void)reportLastPoint:(YCKWhiteboardCommand *)command lastPoint:(CGPoint)lastPoint to:(int64_t)to;
- (void)handleLocalAction:(YCKWhiteboardActionType)actionType;

- (void)checkElementSelectOrUnSelect:(NSArray <YCKWhiteboardElement *>*)currentSelectElements;

@end

NS_ASSUME_NONNULL_END
