OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_QR_SCANNER_QR_SCANNER_VIEW_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_QR_SCANNER_QR_SCANNER_VIEW_H_ |
| 7 |
| 8 #import <AVFoundation/AVFoundation.h> |
| 9 #import <UIKit/UIKit.h> |
| 10 |
| 11 @protocol QRScannerViewDelegate |
| 12 |
| 13 // Called when the close button is pressed. |
| 14 - (void)dismissQRScannerView:(id)sender; |
| 15 // Called when the torch button is pressed. |
| 16 - (void)toggleTorch:(id)sender; |
| 17 |
| 18 @end |
| 19 |
| 20 // The view rendering the QR Scanner UI. The view contains the camera preview, |
| 21 // a semi-transparent overlay with a transparent viewport, border around the |
| 22 // viewport, the close and flash controls, and a label instructing the user to |
| 23 // correctly position the scanned code. |
| 24 @interface QRScannerView : UIView |
| 25 |
| 26 // The delegate which receives button events. |
| 27 @property(nonatomic, assign) id<QRScannerViewDelegate> delegate; |
| 28 |
| 29 - (instancetype)initWithFrame:(CGRect)frame |
| 30 delegate:(id<QRScannerViewDelegate>)delegate |
| 31 NS_DESIGNATED_INITIALIZER; |
| 32 |
| 33 - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; |
| 34 |
| 35 - (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE; |
| 36 |
| 37 // Returns the displayed preview layer. |
| 38 - (AVCaptureVideoPreviewLayer*)getPreviewLayer; |
| 39 |
| 40 // Sets the state of the torch button to enabled or disabled according to the |
| 41 // value of |torchIsAvailable|. |
| 42 - (void)enableTorchButton:(BOOL)torchIsAvailable; |
| 43 |
| 44 // Sets the torch button icon to on or off based on the value of |torchIsOn|. |
| 45 - (void)setTorchButtonTo:(BOOL)torchIsOn; |
| 46 |
| 47 // Resets the frame of the preview layer to a CGRect with origin (0, 0) and |
| 48 // size equal to |size|. |
| 49 - (void)resetPreviewFrame:(CGSize)size; |
| 50 |
| 51 // Rotates the preview layer by |angle|. Used for a transform which prevents the |
| 52 // preview layer from rotating with the rest of the interface. |
| 53 - (void)rotatePreviewByAngle:(CGFloat)angle; |
| 54 |
| 55 // Rounds the parameters of the preview layer's transform. |
| 56 - (void)finishPreviewRotation; |
| 57 |
| 58 // Returns the rectangle in camera coordinates in which codes should be |
| 59 // recognized. |
| 60 - (CGRect)viewportRectOfInterest; |
| 61 |
| 62 // Display a flash animation when a result is scanned. |
| 63 - (void)animateScanningResultWithCompletion:(void (^)(void))completion; |
| 64 |
| 65 @end |
| 66 |
| 67 #endif // IOS_CHROME_BROWSER_UI_QR_SCANNER_QR_SCANNER_VIEW_H_ |
OLD | NEW |