| Index: ui/gfx/win/scaling_util.h
|
| diff --git a/ui/gfx/win/rect_util.h b/ui/gfx/win/scaling_util.h
|
| similarity index 51%
|
| rename from ui/gfx/win/rect_util.h
|
| rename to ui/gfx/win/scaling_util.h
|
| index 60c109d335bfc89b8352f65ac69fa2008baadae4..5f8168ca054031ca70281641ed302c1d057dce10 100644
|
| --- a/ui/gfx/win/rect_util.h
|
| +++ b/ui/gfx/win/scaling_util.h
|
| @@ -7,7 +7,10 @@
|
|
|
| #include <stdint.h>
|
|
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "ui/gfx/display_layout.h"
|
| #include "ui/gfx/gfx_export.h"
|
| +#include "ui/gfx/win/display_info.h"
|
|
|
| namespace gfx {
|
|
|
| @@ -15,80 +18,76 @@ class Rect;
|
|
|
| namespace win {
|
|
|
| -enum class RectEdge {
|
| - BOTTOM = 0,
|
| - LEFT = 1,
|
| - TOP = 2,
|
| - RIGHT = 3,
|
| - NONE = 4,
|
| -};
|
| +// Whether or not |a| shares and edge with |b|.
|
| +GFX_EXPORT bool DisplayInfosTouch(const gfx::win::DisplayInfo& a,
|
| + const gfx::win::DisplayInfo& b);
|
|
|
| -// Returns |ref|'s RectEdge touching |test|.
|
| -// Returns RectEdge::NONE if |ref| and |test| do not touch.
|
| -// At corners, the bottom corners are clamped to BOTTOM, the upper left corner
|
| -// is clamped to LEFT and the upper right corner is clamped to TOP.
|
| -GFX_EXPORT RectEdge FindTouchingRectEdge(const gfx::Rect& ref,
|
| - const gfx::Rect& test);
|
|
|
| -// Returns a scaled and position rect from |unscaled_rect|, positioned against
|
| -// |ref_scaled_rect| based off of the original edge positioning on
|
| -// |ref_unscaled_rect|, and downscaled by |unscaled_rect_scale_factor|.
|
| -// As such, |unscaled_rect| and |ref_unscaled_rect| must be touching rectangles.
|
| +// Returns a DisplayPlacement for |current| relative to |parent|.
|
| +// Note that DisplayPlacement's are always in DIPs, so this also performs the
|
| +// required scaling.
|
| //
|
| -// Examples:
|
| +// Examples (The offset is indicated by the arrow.):
|
| // Scaled and Unscaled Coordinates
|
| -// +--------------+ Since both rectangles are of the same scale
|
| -// | | factor, relative positions remain the same.
|
| -// | |
|
| -// | REF 1x +----------+
|
| +// +--------------+ + Since both DisplayInfos are of the same scale
|
| +// | | | factor, relative positions remain the same.
|
| +// | Parent | V
|
| +// | 1x +----------+
|
| // | | |
|
| -// +--------------+ 1x |
|
| -// | |
|
| +// +--------------+ Current |
|
| +// | 1x |
|
| // +----------+
|
| //
|
| // Unscaled Coordinates
|
| -// +--------------+ The 2x rectangle is scaled down while
|
| -// | | maintaining a similar neighboring relationship
|
| -// | | with the REF 1x rectangle.
|
| -// | REF 1x +----------+
|
| +// +--------------+ The 2x DisplayInfo is offset to maintain a
|
| +// | | similar neighboring relationship with the 1x
|
| +// | Parent | parent.
|
| +// | 1x +----------+
|
| // | | |
|
| -// +--------------+ 2x |
|
| -// | |
|
| +// +--------------+ Current |
|
| +// | 2x |
|
| // +----------+
|
| // Scaled Coordinates
|
| -// +--------------+
|
| -// | |
|
| -// | |
|
| -// | REF 1x |
|
| +// +--------------+ +
|
| +// | | |
|
| +// | Parent | |
|
| +// | 1x | V
|
| // | +-----+
|
| -// +--------------+ 2x |
|
| +// +--------------+ C 2x|
|
| // +-----+
|
| //
|
| // Unscaled Coordinates
|
| -// +--------------+ The reference rectangle has been scaled by 2x
|
| -// | | from |ref_unscaled_rect| to |ref_scaled_rect|.
|
| -// | | ScaleAndPositionRect maintains the same
|
| -// | REF 2x +----------+ relative positioning of the unscaled rect in
|
| -// | | | the scaled coordinate space.
|
| -// | | |
|
| +// +--------------+ The parent DisplayInfo has a 2x scale factor.
|
| +// | | The offset is adjusted to maintain the
|
| +// | | relative positioning of the 1x DisplayInfo in
|
| +// | Parent +----------+ the scaled coordinate space.
|
| +// | 2x | |
|
| +// | | Current |
|
| // | | 1x |
|
| // +--------------+ |
|
| // | |
|
| // +----------+
|
| // Scaled Coordinates
|
| -// +-------+
|
| -// | |
|
| -// | REF 2x+----------+
|
| -// | | |
|
| -// +-------+ |
|
| +// +-------+ +
|
| +// | | V
|
| +// | Parent+----------+
|
| +// | 2x | |
|
| +// +-------+ Current |
|
| // | 1x |
|
| // | |
|
| // | |
|
| // +----------+
|
| -GFX_EXPORT gfx::Rect ScaleAndPositionRect(const gfx::Rect& ref_scaled_rect,
|
| - const gfx::Rect& ref_unscaled_rect,
|
| - const gfx::Rect& unscaled_rect,
|
| - float unscaled_rect_scale_factor);
|
| +//
|
| +// Scaled and Unscaled Coordinates
|
| +// +--------+ If the two DisplayInfos are bottom aligned or
|
| +// | | right aligned, the DisplayPlacement will
|
| +// | +--------+ have an offset of 0 relative to the
|
| +// | | | bottom-right of the DisplayInfo.
|
| +// | | |
|
| +// +--------+--------+
|
| +GFX_EXPORT gfx::DisplayPlacement CalculateDisplayPlacement(
|
| + const gfx::win::DisplayInfo& parent,
|
| + const gfx::win::DisplayInfo& current);
|
|
|
| // Returns the squared distance between two rects.
|
| // The distance between two rects is the length of the shortest segment that can
|
|
|