Chromium Code Reviews| Index: ui/views/rect_based_targeting_utils.h |
| diff --git a/ui/views/rect_based_targeting_utils.h b/ui/views/rect_based_targeting_utils.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..49d9b958e18468530222e1787389766c90f205e7 |
| --- /dev/null |
| +++ b/ui/views/rect_based_targeting_utils.h |
| @@ -0,0 +1,29 @@ |
| +// Copyright (c) 2013 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_RECT_BASED_TARGETING_UTILS_H_ |
|
sky
2013/10/08 20:01:12
Since this is all touch based, how about touch_tar
tdanderson
2013/10/09 21:42:06
My preference would be to use point/rect instead o
|
| +#define UI_RECT_BASED_TARGETING_UTILS_H_ |
| + |
| +#include "ui/gfx/point.h" |
| +#include "ui/gfx/rect.h" |
| +#include "ui/views/views_export.h" |
| + |
| +namespace views { |
| + |
| +// Returns true if |rect| is 1x1. |
| +VIEWS_EXPORT bool UsePointBasedTargeting(const gfx::Rect& rect); |
| + |
| +// Returns the percentage of |rect_1|'s area that is covered by |rect_2|. |
| +VIEWS_EXPORT float PercentCoveredBy(const gfx::Rect& rect_1, |
| + const gfx::Rect& rect_2); |
| + |
| +// Returns the square of the distance from |point| to the center line of |
| +// |rect|. The center line of a rectangle is obtained by repeatedly |
| +// stripping away 1px borders around the rectangle until a line remains. |
| +VIEWS_EXPORT int DistanceSquaredFromCenterLineToPoint(const gfx::Point& point, |
| + const gfx::Rect& rect); |
| + |
| +} // namespace views |
| + |
| +#endif // UI_RECT_BASED_TARGETING_UTILS_H_ |