| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" | 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/objc_property_releaser.h" | 10 #include "base/mac/objc_release_properties.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "ios/chrome/browser/ui/rtl_geometry.h" | 12 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 13 #include "ios/chrome/browser/ui/uikit_ui_util.h" | 13 #include "ios/chrome/browser/ui/uikit_ui_util.h" |
| 14 #include "ios/chrome/grit/ios_theme_resources.h" | 14 #include "ios/chrome/grit/ios_theme_resources.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 // Actions images. | 17 // Actions images. |
| 18 NSString* const kNewTabActionImage = @"ptr_new_tab"; | 18 NSString* const kNewTabActionImage = @"ptr_new_tab"; |
| 19 NSString* const kNewTabActionActiveImage = @"ptr_new_tab_active"; | 19 NSString* const kNewTabActionActiveImage = @"ptr_new_tab_active"; |
| 20 NSString* const kRefreshActionImage = @"ptr_reload"; | 20 NSString* const kRefreshActionImage = @"ptr_reload"; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Last recorded pull start absolute time. | 127 // Last recorded pull start absolute time. |
| 128 // Unit is in seconds. | 128 // Unit is in seconds. |
| 129 CFTimeInterval _pullStartTimeInSeconds; | 129 CFTimeInterval _pullStartTimeInSeconds; |
| 130 // Tap gesture recognizer that allow the user to tap on an action to activate | 130 // Tap gesture recognizer that allow the user to tap on an action to activate |
| 131 // it. | 131 // it. |
| 132 base::scoped_nsobject<UITapGestureRecognizer> _tapGesture; | 132 base::scoped_nsobject<UITapGestureRecognizer> _tapGesture; |
| 133 // Array of layers that will be centered vertically. | 133 // Array of layers that will be centered vertically. |
| 134 // The array is built the first time the method -layersToCenterVertically is | 134 // The array is built the first time the method -layersToCenterVertically is |
| 135 // called. | 135 // called. |
| 136 base::scoped_nsobject<NSArray> _layersToCenterVertically; | 136 base::scoped_nsobject<NSArray> _layersToCenterVertically; |
| 137 base::mac::ObjCPropertyReleaser _propertyReleaser_OverscrollActionsView; | |
| 138 } | 137 } |
| 139 | 138 |
| 140 // Redefined to readwrite. | 139 // Redefined to readwrite. |
| 141 @property(nonatomic, assign, readwrite) OverscrollAction selectedAction; | 140 @property(nonatomic, assign, readwrite) OverscrollAction selectedAction; |
| 142 | 141 |
| 143 // Actions image views. | 142 // Actions image views. |
| 144 @property(nonatomic, retain) UIImageView* addTabActionImageView; | 143 @property(nonatomic, retain) UIImageView* addTabActionImageView; |
| 145 @property(nonatomic, retain) UIImageView* refreshActionImageView; | 144 @property(nonatomic, retain) UIImageView* refreshActionImageView; |
| 146 @property(nonatomic, retain) UIImageView* closeTabActionImageView; | 145 @property(nonatomic, retain) UIImageView* closeTabActionImageView; |
| 147 | 146 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 @synthesize overscrollState = _overscrollState; | 234 @synthesize overscrollState = _overscrollState; |
| 236 @synthesize shadowView = _shadowView; | 235 @synthesize shadowView = _shadowView; |
| 237 @synthesize backgroundView = _backgroundView; | 236 @synthesize backgroundView = _backgroundView; |
| 238 @synthesize snapshotView = _snapshotView; | 237 @synthesize snapshotView = _snapshotView; |
| 239 @synthesize selectionCircleCroppingLayer = _selectionCircleCroppingLayer; | 238 @synthesize selectionCircleCroppingLayer = _selectionCircleCroppingLayer; |
| 240 @synthesize delegate = _delegate; | 239 @synthesize delegate = _delegate; |
| 241 | 240 |
| 242 - (instancetype)initWithFrame:(CGRect)frame { | 241 - (instancetype)initWithFrame:(CGRect)frame { |
| 243 self = [super initWithFrame:frame]; | 242 self = [super initWithFrame:frame]; |
| 244 if (self) { | 243 if (self) { |
| 245 _propertyReleaser_OverscrollActionsView.Init(self, | |
| 246 [OverscrollActionsView class]); | |
| 247 _deformationBehaviorEnabled = YES; | 244 _deformationBehaviorEnabled = YES; |
| 248 self.autoresizingMask = | 245 self.autoresizingMask = |
| 249 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 246 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 250 _selectionCircleLayer = [self newSelectionCircleLayer]; | 247 _selectionCircleLayer = [self newSelectionCircleLayer]; |
| 251 _selectionCircleMaskLayer = [self newSelectionCircleLayer]; | 248 _selectionCircleMaskLayer = [self newSelectionCircleLayer]; |
| 252 _selectionCircleMaskLayer.contentsGravity = kCAGravityCenter; | 249 _selectionCircleMaskLayer.contentsGravity = kCAGravityCenter; |
| 253 _selectionCircleCroppingLayer = [[CALayer alloc] init]; | 250 _selectionCircleCroppingLayer = [[CALayer alloc] init]; |
| 254 _selectionCircleCroppingLayer.frame = self.bounds; | 251 _selectionCircleCroppingLayer.frame = self.bounds; |
| 255 [_selectionCircleCroppingLayer setMasksToBounds:YES]; | 252 [_selectionCircleCroppingLayer setMasksToBounds:YES]; |
| 256 | 253 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 initWithTarget:self | 295 initWithTarget:self |
| 299 action:@selector(tapGesture:)]); | 296 action:@selector(tapGesture:)]); |
| 300 [_tapGesture setDelegate:self]; | 297 [_tapGesture setDelegate:self]; |
| 301 [self addGestureRecognizer:_tapGesture]; | 298 [self addGestureRecognizer:_tapGesture]; |
| 302 } | 299 } |
| 303 return self; | 300 return self; |
| 304 } | 301 } |
| 305 | 302 |
| 306 - (void)dealloc { | 303 - (void)dealloc { |
| 307 [self.snapshotView removeFromSuperview]; | 304 [self.snapshotView removeFromSuperview]; |
| 305 base::mac::ReleaseProperties(self); |
| 308 [super dealloc]; | 306 [super dealloc]; |
| 309 } | 307 } |
| 310 | 308 |
| 311 - (BOOL)selectionCroppingEnabled { | 309 - (BOOL)selectionCroppingEnabled { |
| 312 return [_selectionCircleCroppingLayer masksToBounds]; | 310 return [_selectionCircleCroppingLayer masksToBounds]; |
| 313 } | 311 } |
| 314 | 312 |
| 315 - (void)setSelectionCroppingEnabled:(BOOL)enableSelectionCropping { | 313 - (void)setSelectionCroppingEnabled:(BOOL)enableSelectionCropping { |
| 316 [_selectionCircleCroppingLayer setMasksToBounds:enableSelectionCropping]; | 314 [_selectionCircleCroppingLayer setMasksToBounds:enableSelectionCropping]; |
| 317 } | 315 } |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 CGPoint tapLocation = [tapRecognizer locationInView:self]; | 986 CGPoint tapLocation = [tapRecognizer locationInView:self]; |
| 989 OverscrollAction action = [self actionAtLocation:tapLocation]; | 987 OverscrollAction action = [self actionAtLocation:tapLocation]; |
| 990 if (action != OverscrollAction::NONE) { | 988 if (action != OverscrollAction::NONE) { |
| 991 [self updateSelectionForTouchedAction:action]; | 989 [self updateSelectionForTouchedAction:action]; |
| 992 [self setSelectedAction:action]; | 990 [self setSelectedAction:action]; |
| 993 [self.delegate overscrollActionsViewDidTapTriggerAction:self]; | 991 [self.delegate overscrollActionsViewDidTapTriggerAction:self]; |
| 994 } | 992 } |
| 995 } | 993 } |
| 996 | 994 |
| 997 @end | 995 @end |
| OLD | NEW |