mouse_watcher_view_host.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2012 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. #ifndef UI_VIEWS_MOUSE_WATCHER_VIEW_HOST_H_
  5. #define UI_VIEWS_MOUSE_WATCHER_VIEW_HOST_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "ui/views/mouse_watcher.h"
  8. namespace views {
  9. class View;
  10. class VIEWS_EXPORT MouseWatcherViewHost : public MouseWatcherHost {
  11. public:
  12. // Creates a new MouseWatcherViewHost. |hot_zone_insets| is added to the
  13. // bounds of the view to determine the active zone. For example, if
  14. // |hot_zone_insets.bottom()| is 10, then the listener is not notified if
  15. // the y coordinate is between the origin of the view and height of the view
  16. // plus 10.
  17. MouseWatcherViewHost(View* view, const gfx::Insets& hot_zone_insets);
  18. MouseWatcherViewHost(const MouseWatcherViewHost&) = delete;
  19. MouseWatcherViewHost& operator=(const MouseWatcherViewHost&) = delete;
  20. ~MouseWatcherViewHost() override;
  21. // MouseWatcherHost.
  22. bool Contains(const gfx::Point& screen_point, EventType type) override;
  23. private:
  24. bool IsCursorInViewZone(const gfx::Point& screen_point);
  25. bool IsMouseOverWindow();
  26. // View we're listening for events over.
  27. raw_ptr<View> view_;
  28. // Insets added to the bounds of the view.
  29. const gfx::Insets hot_zone_insets_;
  30. };
  31. } // namespace views
  32. #endif // UI_VIEWS_MOUSE_WATCHER_VIEW_HOST_H_