Index: chrome/browser/ui/panels/panel_browser_frame_view.h |
=================================================================== |
--- chrome/browser/ui/panels/panel_browser_frame_view.h (revision 86006) |
+++ chrome/browser/ui/panels/panel_browser_frame_view.h (working copy) |
@@ -7,6 +7,7 @@ |
#pragma once |
#include "base/gtest_prod_util.h" |
+#include "base/message_loop.h" |
#include "base/scoped_ptr.h" |
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
#include "chrome/browser/ui/views/tab_icon_view.h" |
@@ -66,6 +67,7 @@ |
private: |
friend class PanelBrowserViewTest; |
FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel); |
+ FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, ShowOrHideInfoButton); |
enum PaintState { |
NOT_PAINTED, |
@@ -73,6 +75,30 @@ |
PAINT_AS_ACTIVE |
}; |
+ class MouseWatcher : public MessageLoopForUI::Observer { |
+ public: |
+ explicit MouseWatcher(PanelBrowserFrameView* view); |
+ virtual ~MouseWatcher(); |
+ |
+ virtual bool IsCursorInViewBounds() const; |
+ |
+ #if defined(OS_WIN) |
+ virtual void WillProcessMessage(const MSG& msg) OVERRIDE { } |
+ virtual void DidProcessMessage(const MSG& msg) OVERRIDE; |
+ #else |
+ virtual void WillProcessEvent(GdkEvent* event) OVERRIDE { } |
+ virtual void DidProcessEvent(GdkEvent* event) OVERRIDE; |
+ #endif |
+ |
+ private: |
+ void HandleGlobalMouseMoveEvent(); |
+ |
+ PanelBrowserFrameView* view_; |
+ bool in_view_; |
Dmitry Titov
2011/05/24 20:21:56
I saw often in the past the suggestion to keep nam
jianli
2011/05/24 21:58:56
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(MouseWatcher); |
+ }; |
+ |
// Returns the thickness of the entire nonclient left, right, and bottom |
// borders, including both the window frame and any client edge. |
int NonClientBorderThickness() const; |
@@ -88,6 +114,20 @@ |
void PaintFrameBorder(gfx::Canvas* canvas); |
void PaintClientEdge(gfx::Canvas* canvas); |
+ // Called by MouseWatcher to notify if the mouse enters or leaves the window. |
+ void OnMouseEnterOrLeaveWindow(bool mouse_entered); |
+ |
+ // Make info button visible if either of the conditions is met: |
+ // 1) The panel is active, i.e. having focus. |
+ // 2) The mouse is over the panel. |
+ void UpdateInfoButtonVisibility(bool active, bool cursor_in_view); |
+ |
+#ifdef UNIT_TEST |
+ void set_mouse_watcher(MouseWatcher* mouse_watcher) { |
+ mouse_watcher_.reset(mouse_watcher); |
+ } |
+#endif |
+ |
// The frame that hosts this view. This is a weak reference such that frame_ |
// will always be valid in the lifetime of this view. |
BrowserFrame* frame_; |
@@ -103,6 +143,7 @@ |
TabIconView* title_icon_; |
views::Label* title_label_; |
gfx::Rect client_view_bounds_; |
+ scoped_ptr<MouseWatcher> mouse_watcher_; |
DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); |
}; |