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

Side by Side Diff: ios/chrome/browser/ui/ui_util.h

Issue 802633007: Upstream iOS UI utilities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove rand() Created 5 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
« no previous file with comments | « ios/chrome/browser/ui/snapshots_util_unittest.mm ('k') | ios/chrome/browser/ui/ui_util.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_UI_UI_UTIL_H_
6 #define IOS_CHROME_BROWSER_UI_UI_UTIL_H_
7
8 #include <CoreGraphics/CoreGraphics.h>
9
10 // UI Util containing functions that do not require Objective-C.
11
12 // Running on an iPad?
13 bool IsIPadIdiom();
14
15 // Is the screen of the device a high resolution screen, i.e. Retina Display.
16 bool IsHighResScreen();
17
18 // Returns true if the device is in portrait orientation or if interface
19 // orientation is unknown.
20 bool IsPortrait();
21
22 // Returns true if the device is in landscape orientation.
23 bool IsLandscape();
24
25 // Returns the height of the screen in the current orientation.
26 CGFloat CurrentScreenHeight();
27
28 // Returns the width of the screen in the current orientation.
29 CGFloat CurrentScreenWidth();
30
31 // Returns the height of the status bar, accounting for orientation.
32 CGFloat StatusBarHeight();
33
34 // Returns the closest pixel-aligned value less than |value|, taking the scale
35 // factor into account. At a scale of 1, equivalent to floor().
36 CGFloat AlignValueToPixel(CGFloat value);
37
38 // Returns the point resulting from applying AlignValueToPixel() to both
39 // components.
40 CGPoint AlignPointToPixel(CGPoint point);
41
42 // Returns the rectangle resulting from applying AlignPointToPixel() to the
43 // origin.
44 CGRect AlignRectToPixel(CGRect rect);
45
46 // Returns the rectangle resulting from applying AlignPointToPixel() to the
47 // origin, and ui::AlignSizeToUpperPixel() to the size.
48 CGRect AlignRectOriginAndSizeToPixels(CGRect rect);
49
50 // Makes a copy of |rect| with a new origin specified by |x| and |y|.
51 CGRect CGRectCopyWithOrigin(CGRect rect, CGFloat x, CGFloat y);
52
53 // Returns a square CGRect centered at |x|, |y| with a width of |width|.
54 // Both the position and the size of the CGRect will be aligned to points.
55 CGRect CGRectMakeAlignedAndCenteredAt(CGFloat x, CGFloat y, CGFloat width);
56
57 // This function is used to figure out how to resize an image from an
58 // |originalSize| to a |targetSize|. It returns the final size of the resized
59 // image and |projectTo| that is used to select which part of the original image
60 // to scale into the destination.
61 //
62 // If |preserveAspectRatio| is YES, the original image aspect ratio is
63 // preserved.
64 //
65 // When |preserveAspectRatio| is YES and if |targetSize|'s aspect ratio
66 // is different from the image, the resulting image will be shrunken to
67 // a size that is within |targetSize|.
68 //
69 // To preserve the |targetSize| when |preserveAspectRatio| is YES, set
70 // |trimToFit| to YES. The resulting image will be the largest proportion
71 // of the receiver that fits in the targetSize, aligned to center of the image.
72 void CalculateProjection(CGSize originalSize,
73 CGSize targetSize,
74 bool preserveAspectRatio,
75 bool trimToFit,
76 CGSize& revisedTargetSize,
77 CGRect& projectTo);
78
79 #endif // IOS_CHROME_BROWSER_UI_UI_UTIL_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/snapshots_util_unittest.mm ('k') | ios/chrome/browser/ui/ui_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698