OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui_util.h" | 5 #include "ios/chrome/browser/ui/ui_util.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/ios/ios_util.h" | |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
11 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 10 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
12 #include "ui/gfx/ios/uikit_util.h" | 11 #include "ui/gfx/ios/uikit_util.h" |
13 | 12 |
14 bool IsIPadIdiom() { | 13 bool IsIPadIdiom() { |
15 UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom]; | 14 UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom]; |
16 return idiom == UIUserInterfaceIdiomPad; | 15 return idiom == UIUserInterfaceIdiomPad; |
17 } | 16 } |
18 | 17 |
19 const CGFloat kPortraitWidth[INTERFACE_IDIOM_COUNT] = { | 18 const CGFloat kPortraitWidth[INTERFACE_IDIOM_COUNT] = { |
(...skipping 15 matching lines...) Expand all Loading... | |
35 return UIInterfaceOrientationIsPortrait(orient) || | 34 return UIInterfaceOrientationIsPortrait(orient) || |
36 orient == UIInterfaceOrientationUnknown; | 35 orient == UIInterfaceOrientationUnknown; |
37 #endif // SDK | 36 #endif // SDK |
38 } | 37 } |
39 | 38 |
40 bool IsLandscape() { | 39 bool IsLandscape() { |
41 return UIInterfaceOrientationIsLandscape(GetInterfaceOrientation()); | 40 return UIInterfaceOrientationIsLandscape(GetInterfaceOrientation()); |
42 } | 41 } |
43 | 42 |
44 CGFloat CurrentScreenHeight() { | 43 CGFloat CurrentScreenHeight() { |
45 CGSize screenSize = [UIScreen mainScreen].bounds.size; | 44 CGSize screenSize = [UIScreen mainScreen].bounds.size; |
justincohen
2016/10/18 10:59:20
return [UIScreen mainScreen].bounds.size.height ?
pkl (ping after 24h if needed)
2016/10/19 18:47:32
Done.
| |
46 if (base::ios::IsRunningOnIOS8OrLater()) { | 45 return screenSize.height; |
47 return screenSize.height; | |
48 } else { | |
49 return IsPortrait() ? screenSize.height : screenSize.width; | |
50 } | |
51 } | 46 } |
52 | 47 |
53 CGFloat CurrentScreenWidth() { | 48 CGFloat CurrentScreenWidth() { |
54 CGSize screenSize = [UIScreen mainScreen].bounds.size; | 49 CGSize screenSize = [UIScreen mainScreen].bounds.size; |
justincohen
2016/10/18 10:59:20
return [UIScreen mainScreen].bounds.size.width ?
pkl (ping after 24h if needed)
2016/10/19 18:47:32
Done.
| |
55 if (base::ios::IsRunningOnIOS8OrLater()) { | 50 return screenSize.width; |
56 return screenSize.width; | |
57 } else { | |
58 return IsPortrait() ? screenSize.width : screenSize.height; | |
59 } | |
60 } | 51 } |
61 | 52 |
62 CGFloat StatusBarHeight() { | 53 CGFloat StatusBarHeight() { |
63 // Checking [UIApplication sharedApplication].statusBarFrame will return the | 54 // Checking [UIApplication sharedApplication].statusBarFrame will return the |
64 // wrong offset when the application is started while in a phone call, so | 55 // wrong offset when the application is started while in a phone call, so |
65 // simply return 20 here. | 56 // simply return 20 here. |
66 return 20; | 57 return 20; |
67 } | 58 } |
68 | 59 |
69 CGFloat AlignValueToPixel(CGFloat value) { | 60 CGFloat AlignValueToPixel(CGFloat value) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 projectTo.size = targetSize; | 146 projectTo.size = targetSize; |
156 break; | 147 break; |
157 } | 148 } |
158 | 149 |
159 projectTo = CGRectIntegral(projectTo); | 150 projectTo = CGRectIntegral(projectTo); |
160 // There's no CGSizeIntegral, faking one instead. | 151 // There's no CGSizeIntegral, faking one instead. |
161 CGRect integralRect = CGRectZero; | 152 CGRect integralRect = CGRectZero; |
162 integralRect.size = targetSize; | 153 integralRect.size = targetSize; |
163 targetSize = CGRectIntegral(integralRect).size; | 154 targetSize = CGRectIntegral(integralRect).size; |
164 } | 155 } |
OLD | NEW |