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

Side by Side Diff: ui/gfx/win/rect_util.h

Issue 1679393002: Multiple DPI Tracking for ScreenWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback EXCEPT Filename Change Created 4 years, 10 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
(Empty)
1 // Copyright 2016 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 UI_GFX_WIN_RECT_UTIL_H_
6 #define UI_GFX_WIN_RECT_UTIL_H_
7
8 #include <stdint.h>
9
10 #include "ui/gfx/gfx_export.h"
11
12 namespace gfx {
13
14 class Rect;
15
16 namespace win {
17
18 enum class RectEdge {
19 BOTTOM = 0,
20 LEFT = 1,
21 TOP = 2,
22 RIGHT = 3,
23 NONE = 4,
24 };
25
26 // Returns |ref|'s RectEdge touching |test|.
27 // Returns RectEdge::NONE if |ref| and |test| do not touch.
28 // At corners, the bottom corners are clamped to BOTTOM, the upper left corner
29 // is clamped to LEFT and the upper right corner is clamped to TOP.
30 GFX_EXPORT RectEdge FindTouchingRectEdge(const gfx::Rect& ref,
31 const gfx::Rect& test);
32
33 // Returns a scaled and position rect from |unscaled_rect|, positioned against
34 // |ref_scaled_rect| based off of the original edge positioning on
35 // |ref_unscaled_rect|, and downscaled by |unscaled_rect_scale_factor|.
36 // As such, |unscaled_rect| and |ref_unscaled_rect| must be touching rectangles.
37 //
38 // Examples:
39 // Scaled and Unscaled Coordinates
40 // +--------------+ Since both rectangles are of the same scale
41 // | | factor, relative positions remain the same.
42 // | |
43 // | REF 1x +----------+
44 // | | |
45 // +--------------+ 1x |
46 // | |
47 // +----------+
48 //
49 // Unscaled Coordinates
50 // +--------------+ The 2x rectangle is scaled down while
51 // | | maintaining a similar neighboring relationship
52 // | | with the REF 1x rectangle.
53 // | REF 1x +----------+
54 // | | |
55 // +--------------+ 2x |
56 // | |
57 // +----------+
58 // Scaled Coordinates
59 // +--------------+
60 // | |
61 // | |
62 // | REF 1x |
63 // | +-----+
64 // +--------------+ 2x |
65 // +-----+
66 //
67 // Unscaled Coordinates
68 // +--------------+ The reference rectangle has been scaled by 2x
69 // | | from |ref_unscaled_rect| to |ref_scaled_rect|.
70 // | | ScaleAndPositionRect maintains the same
71 // | REF 2x +----------+ relative positioning of the unscaled rect in
72 // | | | the scaled coordinate space.
73 // | | |
74 // | | 1x |
75 // +--------------+ |
76 // | |
77 // +----------+
78 // Scaled Coordinates
79 // +-------+
80 // | |
81 // | REF 2x+----------+
82 // | | |
83 // +-------+ |
84 // | 1x |
85 // | |
86 // | |
87 // +----------+
88 GFX_EXPORT gfx::Rect ScaleAndPositionRect(const gfx::Rect& ref_scaled_rect,
sky 2016/02/18 17:02:58 Thanks for the comments. I think I understand what
robliao 2016/02/19 00:26:29 The sizing is straightforward. The positioning is
89 const gfx::Rect& ref_unscaled_rect,
90 const gfx::Rect& unscaled_rect,
91 float unscaled_rect_scale_factor);
92
93 // Returns the squared distance between two rects.
94 // The distance between two rects is the length of the shortest segment that can
95 // be drawn between two rectangles. This segment generally connects two opposing
96 // corners between rectangles like this...
97 //
98 // +----------+
99 // | |
100 // +----------+
101 // \ <--- Shortest Segment
102 // \
103 // +---+
104 // | |
105 // | |
106 // +---+
107 //
108 // For rectangles that share coordinates within the same axis, that generally
109 // means the segment is parallel to the axis and perpendicular to the edges.
110 //
111 // One of many shortest segments
112 // +----------+ / \ +--------+
113 // | | | \ | |
114 // | | V +---+ \ +--------+
115 // | |-----| | \-->|
116 // +----------+ | | +----+
117 // | | | |
118 // +---+ +----+
119 //
120 // For rectangles that intersect each other, the distance is 0.
121 //
122 // The squared distance is used to avoid taking the square root as the common
123 // usage is to compare distances greater than 1 unit.
124 GFX_EXPORT int64_t SquaredDistanceBetweenRects(const gfx::Rect& ref,
125 const gfx::Rect& rect);
126
127 } // namespace win
128 } // namespace gfx
129
130 #endif // UI_GFX_WIN_RECT_UTIL_H_
OLDNEW
« no previous file with comments | « ui/gfx/win/dpi.cc ('k') | ui/gfx/win/rect_util.cc » ('j') | ui/gfx/win/rect_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698