//
//  NvsTimelineEditor.h
//  NvsTimelineEditor
//
//  Created by LionLee on 2017/8/29.
//  Copyright © 2017年 CDV. All rights reserved.
//

#ifndef NvsCTimelineEditor_h
#define NvsCTimelineEditor_h


#pragma once

#import <UIKit/UIKit.h>
#import "NvsCTimelineTimeSpan.h"


@interface NvsCTimelineEditorInfo : NSObject

@property (nonatomic, strong) NSString* mediaFilePath;
@property (nonatomic, assign) int64_t inPoint;
@property (nonatomic, assign) int64_t outPoint;
@property (nonatomic, assign) int64_t trimIn;
@property (nonatomic, assign) int64_t trimOut;
@property (nonatomic, assign) bool stillImageHint;

@end

@protocol NvsCTimelineEditorDelegate <NSObject>

@optional

- (void)timelineEditor:(id)timelineEditor dragHandleStarted:(int64_t)timestamp isInPoint:(bool)isInPoint;

- (void)timelineEditor:(id)timelineEditor draggingHandle:(int64_t)timestamp isInPoint:(bool)isInPoint;

- (void)timelineEditor:(id)timelineEditor dragHandleEnded:(int64_t)timestamp isInPoint:(bool)isInPoint;

- (void)timelineEditor:(id)timelineEditor dragScrollingTimeline:(int64_t)timestamp;

- (void)timelineEditor:(id)timelineEditor dragScrollTimelineEnded:(int64_t)timestamp;
@end


@interface NvsCTimelineEditor : UIView

@property (nonatomic, weak) id <NvsCTimelineEditorDelegate> delegate;
@property (nonatomic, assign) bool canOverlapTimeSpan;
@property (nonatomic, assign) bool caneditTimeSpan;
@property (nonatomic, assign) int64_t timelinePosition;


- (instancetype)init;
- (instancetype)initWithFrame:(CGRect)frame;
- (instancetype)initWithCoder:(NSCoder *)aDecoder;

- (void) initTimelineEditor:(NSArray*) timelineEditorInfos timelineDuration:(int64_t)timelineDuration;
- (NvsCTimelineTimeSpan*) addTimeSpan:(int64_t)inPoint outPoint:(int64_t)outPoint;
- (void) deleteSelectedTimeSpan;
- (void) deleteAllTimeSpan;
- (void) selectTimeSpan:(NvsCTimelineTimeSpan*)timeSpan;
- (void) updateSelectedItem;
- (void)zoomIn;
- (void)zoomOut;
- (void)selectTimeSpan:(int64_t)inPoint outPoint:(int64_t)outPoint;
- (void)deleteTimeSpan:(int64_t)inPoint outPoint:(int64_t)outPoint;
- (void)clearTimeSpanSelection;
- (bool)isInTimespan:(int64_t)position;
- (void)selectTimeSpanByPosition:(int64_t)position;

@end


#endif /* NvsTimelineEditor_h */
