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

Side by Side Diff: ios/chrome/browser/ui/stack_view/page_animation_util.mm

Issue 2944443003: [ObjC ARC] Converts ios/chrome/browser/ui/stack_view:stack_view to ARC. (Closed)
Patch Set: Add and use explicit disconnect in CardSet. Created 3 years, 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/stack_view/page_animation_util.h" 5 #import "ios/chrome/browser/ui/stack_view/page_animation_util.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #import "base/mac/scoped_nsobject.h"
11 #import "ios/chrome/browser/ui/animation_util.h" 10 #import "ios/chrome/browser/ui/animation_util.h"
12 #include "ios/chrome/browser/ui/rtl_geometry.h" 11 #include "ios/chrome/browser/ui/rtl_geometry.h"
13 #import "ios/chrome/browser/ui/stack_view/card_view.h" 12 #import "ios/chrome/browser/ui/stack_view/card_view.h"
14 #import "ios/chrome/common/material_timing.h" 13 #import "ios/chrome/common/material_timing.h"
15 14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
16 using ios::material::TimingFunction; 19 using ios::material::TimingFunction;
17 20
18 namespace { 21 namespace {
19 22
20 const NSTimeInterval kAnimationDuration = 0.25; 23 const NSTimeInterval kAnimationDuration = 0.25;
21 const NSTimeInterval kAnimationHesitation = 0.2; 24 const NSTimeInterval kAnimationHesitation = 0.2;
22 25
23 // Constants used for rotating/translating in in transition-in animations and 26 // Constants used for rotating/translating in in transition-in animations and
24 // rotating/translating out in transition-out animations. 27 // rotating/translating out in transition-out animations.
25 const CGFloat kDefaultRotation = 0.2094; // 12 degrees. 28 const CGFloat kDefaultRotation = 0.2094; // 12 degrees.
(...skipping 23 matching lines...) Expand all
49 @end 52 @end
50 53
51 @implementation PaperView 54 @implementation PaperView
52 55
53 - (id)initWithFrame:(CGRect)frame { 56 - (id)initWithFrame:(CGRect)frame {
54 self = [super initWithFrame:frame]; 57 self = [super initWithFrame:frame];
55 if (self) { 58 if (self) {
56 const UIEdgeInsets kShadowStretchInsets = {28.0, 28.0, 28.0, 28.0}; 59 const UIEdgeInsets kShadowStretchInsets = {28.0, 28.0, 28.0, 28.0};
57 const UIEdgeInsets kShadowLayoutOutset = {-10.0, -11.0, -12.0, -11.0}; 60 const UIEdgeInsets kShadowLayoutOutset = {-10.0, -11.0, -12.0, -11.0};
58 CGRect shadowFrame = UIEdgeInsetsInsetRect(frame, kShadowLayoutOutset); 61 CGRect shadowFrame = UIEdgeInsetsInsetRect(frame, kShadowLayoutOutset);
59 base::scoped_nsobject<UIImageView> frameShadowImageView( 62 UIImageView* frameShadowImageView =
60 [[UIImageView alloc] initWithFrame:shadowFrame]); 63 [[UIImageView alloc] initWithFrame:shadowFrame];
61 [frameShadowImageView 64 [frameShadowImageView
62 setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | 65 setAutoresizingMask:(UIViewAutoresizingFlexibleWidth |
63 UIViewAutoresizingFlexibleHeight)]; 66 UIViewAutoresizingFlexibleHeight)];
64 [self addSubview:frameShadowImageView]; 67 [self addSubview:frameShadowImageView];
65 68
66 UIImage* image = [UIImage imageNamed:@"popup_background"]; 69 UIImage* image = [UIImage imageNamed:@"popup_background"];
67 image = [image resizableImageWithCapInsets:kShadowStretchInsets]; 70 image = [image resizableImageWithCapInsets:kShadowStretchInsets];
68 [frameShadowImageView setImage:image]; 71 [frameShadowImageView setImage:image];
69 } 72 }
70 return self; 73 return self;
(...skipping 25 matching lines...) Expand all
96 BOOL isOffTheRecord, 99 BOOL isOffTheRecord,
97 void (^extraAnimation)(void), 100 void (^extraAnimation)(void),
98 void (^completion)(void)) { 101 void (^completion)(void)) {
99 CGRect endFrame = view.frame; 102 CGRect endFrame = view.frame;
100 UIView* parent = [view superview]; 103 UIView* parent = [view superview];
101 NSInteger index = [[parent subviews] indexOfObject:view]; 104 NSInteger index = [[parent subviews] indexOfObject:view];
102 105
103 // Create paper background. 106 // Create paper background.
104 CGRect paperFrame = CGRectOffset(endFrame, 0, paperOffset); 107 CGRect paperFrame = CGRectOffset(endFrame, 0, paperOffset);
105 paperFrame.size.height -= paperOffset; 108 paperFrame.size.height -= paperOffset;
106 base::scoped_nsobject<PaperView> paper( 109 PaperView* paper = [[PaperView alloc] initWithFrame:paperFrame];
107 [[PaperView alloc] initWithFrame:paperFrame]);
108 [parent insertSubview:paper belowSubview:view]; 110 [parent insertSubview:paper belowSubview:view];
109 [paper addSubview:view]; 111 [paper addSubview:view];
110 [paper setBackgroundColor:isOffTheRecord 112 [paper setBackgroundColor:isOffTheRecord
111 ? [UIColor colorWithWhite:34 / 255 alpha:1] 113 ? [UIColor colorWithWhite:34 / 255 alpha:1]
112 : [UIColor whiteColor]]; 114 : [UIColor whiteColor]];
113 115
114 [CATransaction begin]; 116 [CATransaction begin];
115 [CATransaction setCompletionBlock:^{ 117 [CATransaction setCompletionBlock:^{
116 118
117 // Put view back where it belongs, with its original frame. 119 // Put view back where it belongs, with its original frame.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (completion) 204 if (completion)
203 completion(); 205 completion();
204 }]; 206 }];
205 } 207 }
206 208
207 void AnimateNewBackgroundPageWithCompletion(CardView* currentPageCard, 209 void AnimateNewBackgroundPageWithCompletion(CardView* currentPageCard,
208 CGRect displayFrame, 210 CGRect displayFrame,
209 BOOL isPortrait, 211 BOOL isPortrait,
210 void (^completion)(void)) { 212 void (^completion)(void)) {
211 // Create paper background. 213 // Create paper background.
212 base::scoped_nsobject<PaperView> paper( 214 PaperView* paper = [[PaperView alloc] initWithFrame:CGRectZero];
213 [[PaperView alloc] initWithFrame:CGRectZero]);
214 UIView* parent = [currentPageCard superview]; 215 UIView* parent = [currentPageCard superview];
215 [parent insertSubview:paper aboveSubview:currentPageCard]; 216 [parent insertSubview:paper aboveSubview:currentPageCard];
216 CGRect pageBounds = currentPageCard.bounds; 217 CGRect pageBounds = currentPageCard.bounds;
217 [paper setCenter:CGPointMake(CGRectGetMidX(pageBounds), 218 [paper setCenter:CGPointMake(CGRectGetMidX(pageBounds),
218 CGRectGetMidY(pageBounds))]; 219 CGRectGetMidY(pageBounds))];
219 [paper setBackgroundColor:[UIColor whiteColor]]; 220 [paper setBackgroundColor:[UIColor whiteColor]];
220 [paper setAlpha:0.0]; 221 [paper setAlpha:0.0];
221 222
222 CGSize pageSize = currentPageCard.bounds.size; 223 CGSize pageSize = currentPageCard.bounds.size;
223 CGRect paperFrame = 224 CGRect paperFrame =
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 return transform; 466 return transform;
466 } 467 }
467 468
468 CGFloat AnimateOutTransformBreadth() { 469 CGFloat AnimateOutTransformBreadth() {
469 return kDefaultShortSideAxisTranslation; 470 return kDefaultShortSideAxisTranslation;
470 } 471 }
471 472
472 } // namespace page_animation_util 473 } // namespace page_animation_util
473 474
474 } // namespace ios_internal 475 } // namespace ios_internal
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/stack_view/close_button.mm ('k') | ios/chrome/browser/ui/stack_view/stack_card.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698