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 #include "ios/chrome/browser/ui/contextual_search/contextual_search_mask_view.h" | 5 #include "ios/chrome/browser/ui/contextual_search/contextual_search_mask_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_view.h" | 8 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_view.h" |
9 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
10 | 10 |
11 // Linearly map |delta| in the range [0, 1] to a value in [min, max]. | 11 // Linearly map |delta| in the range [0, 1] to a value in [min, max]. |
12 #define LERP(min, max, delta) (min * (1 - delta) + max * delta) | 12 #define LERP(min, max, delta) (min * (1 - delta) + max * delta) |
13 | 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." |
| 16 #endif |
| 17 |
14 namespace { | 18 namespace { |
15 const CGFloat kPhoneMaskLimit = 1.0; | 19 const CGFloat kPhoneMaskLimit = 1.0; |
16 const CGFloat kPadMaskLimit = 0.8; | 20 const CGFloat kPadMaskLimit = 0.8; |
17 } | 21 } |
18 | 22 |
19 @implementation ContextualSearchMaskView { | 23 @implementation ContextualSearchMaskView { |
20 CGFloat _maskLimit; | 24 CGFloat _maskLimit; |
21 } | 25 } |
22 | 26 |
23 - (instancetype)init { | 27 - (instancetype)init { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 ratio = LERP(0, _maskLimit, ratio); | 73 ratio = LERP(0, _maskLimit, ratio); |
70 | 74 |
71 self.alpha = ratio * ratio; | 75 self.alpha = ratio * ratio; |
72 } | 76 } |
73 | 77 |
74 - (void)panelWillPromote:(ContextualSearchPanelView*)panel { | 78 - (void)panelWillPromote:(ContextualSearchPanelView*)panel { |
75 [panel removeMotionObserver:self]; | 79 [panel removeMotionObserver:self]; |
76 } | 80 } |
77 | 81 |
78 @end | 82 @end |
OLD | NEW |