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