Chromium Code Reviews| Index: ui/gfx/win/rect_util.h |
| diff --git a/ui/gfx/win/rect_util.h b/ui/gfx/win/rect_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c6484af9a9e8c9e15fdaf2c2110192e4cbc85e4c |
| --- /dev/null |
| +++ b/ui/gfx/win/rect_util.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2016 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 UI_GFX_WIN_RECT_UTIL_H_ |
| +#define UI_GFX_WIN_RECT_UTIL_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include "ui/gfx/gfx_export.h" |
| + |
| +namespace gfx { |
| + |
| +class Rect; |
| + |
| +namespace win { |
| + |
| +enum class RectEdge { |
| + BOTTOM = 0, |
| + LEFT = 1, |
| + TOP = 2, |
| + RIGHT = 3, |
| + NONE = 4, |
| +}; |
| + |
| +// Returns |ref|'s RectEdge touching |test|. |
| +RectEdge GFX_EXPORT RectTouch(gfx::Rect ref, gfx::Rect test); |
|
scottmg
2016/02/09 20:21:36
"RectTouch" is a bit terse. Mostly, I'd expect it
scottmg
2016/02/09 20:21:36
The GFX_EXPORTs normally go before the return type
robliao
2016/02/10 22:50:03
Done and renamed to FindTouchingRectEdge.
|
| + |
| +// Returns a scaled and positioned rect based off of target_rect and context. |
| +// The reference rectangle and target rectangle may scale at different rates. |
| +// This function attempts to preserve the relative positioning of the target |
| +// rectangle with respect to the scaled rectangle in the face of differing |
| +// scale factors. |
| +// |
| +// Examples: |
| +// +--------------+ Since both rectangles are of the same |
| +// | | scale factor, positions and sizes |
| +// | | remain the same. |
| +// | REF 1x +----------+ |
| +// | | | |
| +// +--------------+ 1x | |
| +// | | |
| +// +----------+ |
| +// |
| +// Original |
| +// +--------------+ The 2x rectangle is scaled down while |
| +// | | maintaining a similar neighboring relationship |
| +// | | with the 1x rectangle. |
| +// | REF 1x +----------+ |
| +// | | | |
| +// +--------------+ 2x | |
| +// | | |
| +// +----------+ |
| +// Scaled |
| +// +--------------+ |
| +// | | |
| +// | | |
| +// | REF 1x | |
| +// | +-----+ |
| +// +--------------+ 2x | |
| +// +-----+ |
| +gfx::Rect GFX_EXPORT ScaleAndPositionRect(gfx::Rect ref_scaled_rect, |
| + gfx::Rect ref_original_rect, |
| + gfx::Rect target_rect, |
| + float target_scale_factor); |
| + |
| +// Returns the squared distance between two rects. |
|
scottmg
2016/02/09 20:21:36
A little more explanation here, it isn't obvious w
robliao
2016/02/10 22:50:03
Done and added some ASCII art.
|
| +int64_t GFX_EXPORT SquaredDistanceBetweenRects(gfx::Rect ref, gfx::Rect rect); |
| + |
| +} // namespace win |
| +} // namespace gfx |
| + |
| +#endif // UI_GFX_WIN_RECT_UTIL_H_ |