| // Copyright 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef IOS_CHROME_BROWSER_UI_UTIL_UI_UTIL_H_ |
| #define IOS_CHROME_BROWSER_UI_UTIL_UI_UTIL_H_ |
| |
| #include <CoreGraphics/CoreGraphics.h> |
| |
| // UI Util containing functions that do not require Objective-C. |
| |
| // Returns the height of the screen in the current orientation. |
| CGFloat CurrentScreenHeight(); |
| |
| // Returns the width of the screen in the current orientation. |
| CGFloat CurrentScreenWidth(); |
| |
| // Returns the approximate corner radius of the current device. |
| CGFloat DeviceCornerRadius(); |
| |
| // Returns the closest pixel-aligned value less than `value`, taking the scale |
| // factor into account. At a scale of 1, equivalent to floor(). |
| CGFloat AlignValueToPixel(CGFloat value); |
| |
| // Returns the point resulting from applying AlignValueToPixel() to both |
| // components. |
| CGPoint AlignPointToPixel(CGPoint point); |
| |
| // Returns the rectangle resulting from applying AlignPointToPixel() to the |
| // origin. |
| CGRect AlignRectToPixel(CGRect rect); |
| |
| // Returns the rectangle resulting from applying AlignPointToPixel() to the |
| // origin, and ui::AlignSizeToUpperPixel() to the size. |
| CGRect AlignRectOriginAndSizeToPixels(CGRect rect); |
| |
| // Returns a square CGRect centered at `x`, `y` with a width of `width`. |
| // Both the position and the size of the CGRect will be aligned to points. |
| CGRect CGRectMakeAlignedAndCenteredAt(CGFloat x, CGFloat y, CGFloat width); |
| |
| // Returns a rectangle of size `rectSize` centered inside `frameSize`. |
| CGRect CGRectMakeCenteredRectInFrame(CGSize frameSize, CGSize rectSize); |
| |
| // Returns whether `a` and `b` are within CGFloat's epsilon value. |
| bool AreCGFloatsEqual(CGFloat a, CGFloat b); |
| |
| #endif // IOS_CHROME_BROWSER_UI_UTIL_UI_UTIL_H_ |