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

#import <Foundation/Foundation.h>
#import "NXWhiteboardCommand.h"
#import "NXWhiteboardElement.h"

NS_ASSUME_NONNULL_BEGIN

@class NXWhiteboard;
typedef NS_ENUM(int, NXWhiteboardActionType) {
    NXWhiteboardActionTypeNone,
    NXWhiteboardActionTypeDrawBegin,
    NXWhiteboardActionTypeDrawing,
    NXWhiteboardActionTypeDrawEnd,
    NXWhiteboardActionTypeDrawCancel,
    NXWhiteboardActionTypeSelect,
    NXWhiteboardActionTypeUnSelect,
    NXWhiteboardActionTypeMoveBegin,
    NXWhiteboardActionTypeMoving,
    NXWhiteboardActionTypeMoveEnd,
    NXWhiteboardActionTypeMoveCancel,
    NXWhiteboardActionTypeZoomBegin,
    NXWhiteboardActionTypeZooming,
    NXWhiteboardActionTypeScrollBengin,
    NXWhiteboardActionTypeScrolling,
    NXWhiteboardActionTypeScrollEnd,
    NXWhiteboardActionTypeSticker,
    NXWhiteboardActionTypeEarser,
    NXWhiteboardActionTypeUndo,
    NXWhiteboardActionTypeRedo,
    NXWhiteboardActionTypeSave,
    NXWhiteboardActionTypeLoad,
    NXWhiteboardActionTypeLock,
    NXWhiteboardActionTypeUnlock,
    NXWhiteboardActionTypeToTop,
    NXWhiteboardActionTypeToBottom,
    NXWhiteboardActionTypeClear,
    NXWhiteboardActionTypeSyncAll,
    NXWhiteboardActionTypeSyncData,
    NXWhiteboardActionTypeSyncReplyAll,
    NXWhiteboardActionTypeSyncReplyData,
    NXWhiteboardActionTypeRotate,
    NXWhiteboardActionTypeCombinate,
    NXWhiteboardActionTypeDecombinate,
    NXWhiteboardActionTypeCopy,
    NXWhiteboardActionTypePaste
};

@interface NXWhiteboardActionReportInfo : NSObject

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

@end

@protocol NXWhiteboardActionReportDelegate <NSObject>
    /// each actionType call oce
- (void)whiteboard:(NXWhiteboard *)whiteboard actionReport:(NXWhiteboardActionReportInfo *)info;
    /// no actionType info
- (void)whiteboard:(NXWhiteboard *)whiteboard actionReportLastPoint:(NXWhiteboardActionReportInfo *)info;

@end

@interface NXWhiteboardActionReport : NSObject

@property (nonatomic, weak) id<NXWhiteboardActionReportDelegate> delegate;
@property (nonatomic, weak) NXWhiteboard *whiteboard;

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

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

@end

NS_ASSUME_NONNULL_END
