OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 Point; |
| 15 class Rect; |
| 16 |
| 17 namespace win { |
| 18 |
| 19 enum class RectEdge { |
| 20 BOTTOM = 0, |
| 21 LEFT = 1, |
| 22 TOP = 2, |
| 23 RIGHT = 3, |
| 24 NONE = 4, |
| 25 }; |
| 26 |
| 27 // Returns |ref|'s RectEdge touching |test|. |
| 28 RectEdge GFX_EXPORT RectTouch(gfx::Rect ref, gfx::Rect test); |
| 29 |
| 30 // Returns a scaled and positioned rect based off of target_rect and context. |
| 31 // The reference rectangle and target rectangle may scale at different rates. |
| 32 // This function attempts to preserve the relative positioning of the target |
| 33 // rectangle with respect to the scaled rectangle in the face of differing |
| 34 // scale factors. |
| 35 // |
| 36 // Examples: |
| 37 // +--------------+ Since both rectangles are of the same |
| 38 // | | scale factor, positions and sizes |
| 39 // | | remain the same. |
| 40 // | REF 1x +----------+ |
| 41 // | | | |
| 42 // +--------------+ 1x | |
| 43 // | | |
| 44 // +----------+ |
| 45 // |
| 46 // Original |
| 47 // +--------------+ The 2x rectangle is scaled down while |
| 48 // | | maintaining a similar neighboring relationship |
| 49 // | | with the 1x rectangle. |
| 50 // | REF 1x +----------+ |
| 51 // | | | |
| 52 // +--------------+ 2x | |
| 53 // | | |
| 54 // +----------+ |
| 55 // Scaled |
| 56 // +--------------+ |
| 57 // | | |
| 58 // | | |
| 59 // | REF 1x | |
| 60 // | +-----+ |
| 61 // +--------------+ 2x | |
| 62 // +-----+ |
| 63 gfx::Rect GFX_EXPORT ScaleAndPositionRect(gfx::Rect ref_scaled_rect, |
| 64 gfx::Rect ref_original_rect, |
| 65 gfx::Rect target_rect, |
| 66 float target_scale_factor); |
| 67 |
| 68 // Returns the squared distance between two rects. |
| 69 int64_t GFX_EXPORT SquaredDistanceBetweenRects(gfx::Rect ref, gfx::Rect rect); |
| 70 |
| 71 } // namespace win |
| 72 } // namespace gfx |
| 73 |
| 74 #endif // UI_GFX_WIN_RECT_UTIL_H_ |
OLD | NEW |