Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Unified Diff: ui/views/rect_based_targeting_utils.h

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed, moved fuzzing utility functions to new file Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698