//
//  NvPIPOperationView.m
//  SDKDemo
//
//  Created by 刘东旭 on 2018/10/12.
 //
//

#import "NvPIPOperationView.h"
#import "NvCustomButton.h"

#import "NVDefineConfig.h"
#import "UIView+Dimension.h"
#import "NvUtils.h"

@interface NvPIPOperationView ()

@property (nonatomic, strong) NvCustomButton *replaceButton, *zoomInButton,*zoomOutButton,*rotationButton,*cutVideoButton;

@end

@implementation NvPIPOperationView


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithRed:77/255.0 green:79/255.0 blue:81/255.0 alpha:1];
        self.layer.cornerRadius = 8;
        
        self.replaceButton = [[NvCustomButton alloc] initWithFrame:CGRectMake(8*SCREANSCALE, 5*SCREANSCALE, 22*SCREANSCALE, 32*SCREANSCALE)];
        [self.replaceButton addTarget:self action:@selector(replaceClick) forControlEvents:UIControlEventTouchUpInside];
        self.replaceButton.image = [NvUtils imageWithName:@"pip-replace"];
        self.replaceButton.name = @"替换";
        self.replaceButton.fontSize = 9;
        self.replaceButton.verticalSpace = 0;
        [self addSubview:self.replaceButton];
        self.zoomInButton = [[NvCustomButton alloc] initWithFrame:CGRectMake(self.replaceButton.right + 16*SCREANSCALE, 5*SCREANSCALE, 22*SCREANSCALE, 32*SCREANSCALE)];
        [self.zoomInButton addTarget:self action:@selector(zoomInClick) forControlEvents:UIControlEventTouchUpInside];
        self.zoomInButton.image = [NvUtils imageWithName:@"pip-Magnifier-add"];
        self.zoomInButton.name = @"放大";
        self.zoomInButton.fontSize = 9;
        self.zoomInButton.verticalSpace = 0;
        [self addSubview:self.zoomInButton];
        self.zoomOutButton = [[NvCustomButton alloc] initWithFrame:CGRectMake(self.zoomInButton.right+16*SCREANSCALE, 5*SCREANSCALE, 22*SCREANSCALE, 32*SCREANSCALE)];
        [self.zoomOutButton addTarget:self action:@selector(zoomOutClick) forControlEvents:UIControlEventTouchUpInside];
        self.zoomOutButton.image = [NvUtils imageWithName:@"pip-Magnifier-remove"];
        self.zoomOutButton.name = @"缩小";
        self.zoomOutButton.fontSize = 9;
        self.zoomOutButton.verticalSpace = 0;
        [self addSubview:self.zoomOutButton];
        self.rotationButton = [[NvCustomButton alloc] initWithFrame:CGRectMake(self.zoomOutButton.right+16*SCREANSCALE, 5*SCREANSCALE, 22*SCREANSCALE, 32*SCREANSCALE)];
        [self.rotationButton addTarget:self action:@selector(rotationClick) forControlEvents:UIControlEventTouchUpInside];
        self.rotationButton.image = [NvUtils imageWithName:@"pip-rotation"];
        self.rotationButton.name = @"旋转";
        self.rotationButton.fontSize = 9;
        self.rotationButton.verticalSpace = 0;
        [self addSubview:self.rotationButton];
        self.cutVideoButton = [[NvCustomButton alloc] initWithFrame:CGRectMake(self.rotationButton.right+16*SCREANSCALE, 5*SCREANSCALE, 22*SCREANSCALE, 32*SCREANSCALE)];
        [self.cutVideoButton addTarget:self action:@selector(cutVideoClick) forControlEvents:UIControlEventTouchUpInside];
        self.cutVideoButton.image = [NvUtils imageWithName:@"NvPipCut"];
        self.cutVideoButton.name = @"裁剪";
        self.cutVideoButton.fontSize = 9;
        self.cutVideoButton.verticalSpace = 0;
        [self addSubview:self.cutVideoButton];
    }
    return self;
}

- (void)replaceClick {
    if ([self.delegate respondsToSelector:@selector(replace)]) {
        [self.delegate replace];
    }
}

- (void)zoomInClick {
    if ([self.delegate respondsToSelector:@selector(zoomIn)]) {
        [self.delegate zoomIn];
    }
}

- (void)zoomOutClick {
    if ([self.delegate respondsToSelector:@selector(zoomOut)]) {
        [self.delegate zoomOut];
    }
}

- (void)rotationClick {
    if ([self.delegate respondsToSelector:@selector(rotate)]) {
        [self.delegate rotate];
    }
}

- (void)cutVideoClick {
    if ([self.delegate respondsToSelector:@selector(cutVideo)]) {
        [self.delegate cutVideo];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
