Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: weak -> assign Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/side_swipe/side_swipe_navigation_view.h" 5 #import "ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h"
6 6
7 #include <cmath> 7 #include <cmath>
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 "base/metrics/user_metrics.h" 12 #include "base/metrics/user_metrics.h"
13 #include "base/metrics/user_metrics_action.h" 13 #include "base/metrics/user_metrics_action.h"
14 #import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h" 14 #import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h"
15 #import "ios/chrome/browser/ui/side_swipe_gesture_recognizer.h" 15 #import "ios/chrome/browser/ui/side_swipe_gesture_recognizer.h"
16 #include "ios/chrome/browser/ui/ui_util.h" 16 #include "ios/chrome/browser/ui/ui_util.h"
17 #import "ios/chrome/browser/ui/uikit_ui_util.h" 17 #import "ios/chrome/browser/ui/uikit_ui_util.h"
18 #import "ios/chrome/common/material_timing.h" 18 #import "ios/chrome/common/material_timing.h"
19 19
20 namespace { 20 namespace {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // The selection bubble. 73 // The selection bubble.
74 CAShapeLayer* selectionCircleLayer_; 74 CAShapeLayer* selectionCircleLayer_;
75 75
76 // If |NO| this is an edge gesture and navigation isn't possible. Don't show 76 // If |NO| this is an edge gesture and navigation isn't possible. Don't show
77 // arrows and bubbles and don't allow navigate. 77 // arrows and bubbles and don't allow navigate.
78 BOOL canNavigate_; 78 BOOL canNavigate_;
79 79
80 // If |YES| arrowView_ is directionnal and must be rotated 180 degreed for the 80 // If |YES| arrowView_ is directionnal and must be rotated 180 degreed for the
81 // forward panes. 81 // forward panes.
82 BOOL rotateForward_; 82 BOOL rotateForward_;
83
84 base::mac::ObjCPropertyReleaser _propertyReleaser_SideSwipeNavigationView;
85 } 83 }
86 // Returns a newly allocated and configured selection circle shape. 84 // Returns a newly allocated and configured selection circle shape.
87 - (CAShapeLayer*)newSelectionCircleLayer; 85 - (CAShapeLayer*)newSelectionCircleLayer;
88 // Pushes the touch towards the edge because it's difficult to touch the very 86 // Pushes the touch towards the edge because it's difficult to touch the very
89 // edge of the screen (touches tend to sit near x ~ 4). 87 // edge of the screen (touches tend to sit near x ~ 4).
90 - (CGPoint)adjustPointToEdge:(CGPoint)point; 88 - (CGPoint)adjustPointToEdge:(CGPoint)point;
91 @end 89 @end
92 90
93 @implementation SideSwipeNavigationView 91 @implementation SideSwipeNavigationView
94 92
95 @synthesize targetView = targetView_; 93 @synthesize targetView = targetView_;
96 94
97 - (instancetype)initWithFrame:(CGRect)frame 95 - (instancetype)initWithFrame:(CGRect)frame
98 withDirection:(UISwipeGestureRecognizerDirection)direction 96 withDirection:(UISwipeGestureRecognizerDirection)direction
99 canNavigate:(BOOL)canNavigate 97 canNavigate:(BOOL)canNavigate
100 image:(UIImage*)image 98 image:(UIImage*)image
101 rotateForward:(BOOL)rotateForward { 99 rotateForward:(BOOL)rotateForward {
102 self = [super initWithFrame:frame]; 100 self = [super initWithFrame:frame];
103 if (self) { 101 if (self) {
104 _propertyReleaser_SideSwipeNavigationView.Init(
105 self, [SideSwipeNavigationView class]);
106 self.backgroundColor = [UIColor colorWithWhite:90.0 / 256 alpha:1.0]; 102 self.backgroundColor = [UIColor colorWithWhite:90.0 / 256 alpha:1.0];
107 103
108 canNavigate_ = canNavigate; 104 canNavigate_ = canNavigate;
109 rotateForward_ = rotateForward; 105 rotateForward_ = rotateForward;
110 if (canNavigate) { 106 if (canNavigate) {
111 image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 107 image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
112 const CGRect imageSize = CGRectMake(0, 0, 24, 24); 108 const CGRect imageSize = CGRectMake(0, 0, 24, 24);
113 arrowView_.reset([[UIImageView alloc] initWithImage:image]); 109 arrowView_.reset([[UIImageView alloc] initWithImage:image]);
114 [arrowView_ setTintColor:[UIColor whiteColor]]; 110 [arrowView_ setTintColor:[UIColor whiteColor]];
115 selectionCircleLayer_ = [self newSelectionCircleLayer]; 111 selectionCircleLayer_ = [self newSelectionCircleLayer];
(...skipping 17 matching lines...) Expand all
133 [border setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; 129 [border setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
134 } 130 }
135 131
136 [self.layer addSublayer:selectionCircleLayer_]; 132 [self.layer addSublayer:selectionCircleLayer_];
137 [self setClipsToBounds:YES]; 133 [self setClipsToBounds:YES];
138 [self addSubview:arrowView_]; 134 [self addSubview:arrowView_];
139 } 135 }
140 return self; 136 return self;
141 } 137 }
142 138
139 - (void)dealloc {
140 base::mac::ReleaseProperties(self);
141 [super dealloc];
142 }
143
143 - (CGPoint)adjustPointToEdge:(CGPoint)currentPoint { 144 - (CGPoint)adjustPointToEdge:(CGPoint)currentPoint {
144 CGFloat width = CGRectGetWidth(self.targetView.bounds); 145 CGFloat width = CGRectGetWidth(self.targetView.bounds);
145 CGFloat half = floor(width / 2); 146 CGFloat half = floor(width / 2);
146 CGFloat padding = floor(std::abs(currentPoint.x - half) / half); 147 CGFloat padding = floor(std::abs(currentPoint.x - half) / half);
147 148
148 // Push towards the edges. 149 // Push towards the edges.
149 if (currentPoint.x > half) 150 if (currentPoint.x > half)
150 currentPoint.x += padding; 151 currentPoint.x += padding;
151 else 152 else
152 currentPoint.x -= padding; 153 currentPoint.x -= padding;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 selectionCircleLayer.opacity = 0; 416 selectionCircleLayer.opacity = 0;
416 selectionCircleLayer.transform = 417 selectionCircleLayer.transform =
417 CATransform3DMakeScale(kSelectionDownScale, kSelectionDownScale, 1); 418 CATransform3DMakeScale(kSelectionDownScale, kSelectionDownScale, 1);
418 selectionCircleLayer.path = 419 selectionCircleLayer.path =
419 [[UIBezierPath bezierPathWithOvalInRect:bounds] CGPath]; 420 [[UIBezierPath bezierPathWithOvalInRect:bounds] CGPath];
420 421
421 return selectionCircleLayer; 422 return selectionCircleLayer;
422 } 423 }
423 424
424 @end 425 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698