diff options
author | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-01 00:39:50 +0000 |
---|---|---|
committer | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-01 00:39:50 +0000 |
commit | 8a6d7efe537c774349371c6634267e8a4c0c1730 (patch) | |
tree | 4b826e428661bddced76a68cb9cc7ba040acf3c3 /ui/views/view_targeter_delegate.h | |
parent | f0f8e0827a383da3385531262d98034627ac7da2 (diff) | |
download | chromium_src-8a6d7efe537c774349371c6634267e8a4c0c1730.zip chromium_src-8a6d7efe537c774349371c6634267e8a4c0c1730.tar.gz chromium_src-8a6d7efe537c774349371c6634267e8a4c0c1730.tar.bz2 |
Introduce ViewTargeterDelegate and MaskedTargeterDelegate
These two classes define the default hit-testing behaviour
for views with and without hit-test masks. Views wishing
to define their own hit-testing behaviour will extend
one of these classes.
BUG=388838
TEST=ViewTargeterTest.DoesIntersectRect
Review URL: https://codereview.chromium.org/336953005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/view_targeter_delegate.h')
-rw-r--r-- | ui/views/view_targeter_delegate.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ui/views/view_targeter_delegate.h b/ui/views/view_targeter_delegate.h new file mode 100644 index 0000000..134a879 --- /dev/null +++ b/ui/views/view_targeter_delegate.h @@ -0,0 +1,38 @@ +// Copyright 2014 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_VIEWS_VIEW_TARGETER_DELEGATE_H_ +#define UI_VIEWS_VIEW_TARGETER_DELEGATE_H_ + +#include "base/macros.h" +#include "ui/views/views_export.h" + +namespace gfx { +class Rect; +} + +namespace views { +class View; + +// Defines the default behaviour for hit-testing a rectangular region against +// the bounds of a View. Subclasses of View wishing to define custom +// hit-testing behaviour can extend this class. +class VIEWS_EXPORT ViewTargeterDelegate { + public: + ViewTargeterDelegate() {} + virtual ~ViewTargeterDelegate() {} + + // Returns true if the bounds of |target| intersects |rect|, where |rect| + // is in the local coodinate space of |target|. Overrides of this method by + // a View subclass should enforce DCHECK_EQ(this, target). + virtual bool DoesIntersectRect(const View* target, + const gfx::Rect& rect) const; + + private: + DISALLOW_COPY_AND_ASSIGN(ViewTargeterDelegate); +}; + +} // namespace views + +#endif // UI_VIEWS_VIEW_TARGETER_DELEGATE_H_ |