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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_frame_view.h

Issue 7055001: Make info button appear only when mouse is over the panel or the panel has focus. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/message_loop.h"
10 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" 12 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
12 #include "chrome/browser/ui/views/tab_icon_view.h" 13 #include "chrome/browser/ui/views/tab_icon_view.h"
13 #include "views/controls/button/button.h" 14 #include "views/controls/button/button.h"
14 15
15 class PanelBrowserView; 16 class PanelBrowserView;
16 namespace views { 17 namespace views {
17 class ImageButton; 18 class ImageButton;
18 class Label; 19 class Label;
19 } 20 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 virtual void ButtonPressed(views::Button* sender, const views::Event& event) 60 virtual void ButtonPressed(views::Button* sender, const views::Event& event)
60 OVERRIDE; 61 OVERRIDE;
61 62
62 // Overridden from TabIconView::TabIconViewModel: 63 // Overridden from TabIconView::TabIconViewModel:
63 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; 64 virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
64 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE; 65 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE;
65 66
66 private: 67 private:
67 friend class PanelBrowserViewTest; 68 friend class PanelBrowserViewTest;
68 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel); 69 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel);
70 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, ShowOrHideInfoButton);
69 71
70 enum PaintState { 72 enum PaintState {
71 NOT_PAINTED, 73 NOT_PAINTED,
72 PAINT_AS_INACTIVE, 74 PAINT_AS_INACTIVE,
73 PAINT_AS_ACTIVE 75 PAINT_AS_ACTIVE
74 }; 76 };
75 77
78 class MouseWatcher : public MessageLoopForUI::Observer {
79 public:
80 explicit MouseWatcher(PanelBrowserFrameView* view);
81 virtual ~MouseWatcher();
82
83 virtual bool IsCursorInViewBounds() const;
84
85 #if defined(OS_WIN)
86 virtual void WillProcessMessage(const MSG& msg) OVERRIDE { }
87 virtual void DidProcessMessage(const MSG& msg) OVERRIDE;
88 #else
89 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE { }
90 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE;
91 #endif
92
93 private:
94 void HandleGlobalMouseMoveEvent();
95
96 PanelBrowserFrameView* view_;
97 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.
98
99 DISALLOW_COPY_AND_ASSIGN(MouseWatcher);
100 };
101
76 // Returns the thickness of the entire nonclient left, right, and bottom 102 // Returns the thickness of the entire nonclient left, right, and bottom
77 // borders, including both the window frame and any client edge. 103 // borders, including both the window frame and any client edge.
78 int NonClientBorderThickness() const; 104 int NonClientBorderThickness() const;
79 105
80 // Returns the height of the entire nonclient top border, including the window 106 // Returns the height of the entire nonclient top border, including the window
81 // frame, any title area, and any connected client edge. 107 // frame, any title area, and any connected client edge.
82 int NonClientTopBorderHeight() const; 108 int NonClientTopBorderHeight() const;
83 109
84 // Update control styles to indicate if the title bar is active or not. 110 // Update control styles to indicate if the title bar is active or not.
85 void UpdateControlStyles(PaintState paint_state); 111 void UpdateControlStyles(PaintState paint_state);
86 112
87 // Custom draw the frame. 113 // Custom draw the frame.
88 void PaintFrameBorder(gfx::Canvas* canvas); 114 void PaintFrameBorder(gfx::Canvas* canvas);
89 void PaintClientEdge(gfx::Canvas* canvas); 115 void PaintClientEdge(gfx::Canvas* canvas);
90 116
117 // Called by MouseWatcher to notify if the mouse enters or leaves the window.
118 void OnMouseEnterOrLeaveWindow(bool mouse_entered);
119
120 // Make info button visible if either of the conditions is met:
121 // 1) The panel is active, i.e. having focus.
122 // 2) The mouse is over the panel.
123 void UpdateInfoButtonVisibility(bool active, bool cursor_in_view);
124
125 #ifdef UNIT_TEST
126 void set_mouse_watcher(MouseWatcher* mouse_watcher) {
127 mouse_watcher_.reset(mouse_watcher);
128 }
129 #endif
130
91 // The frame that hosts this view. This is a weak reference such that frame_ 131 // The frame that hosts this view. This is a weak reference such that frame_
92 // will always be valid in the lifetime of this view. 132 // will always be valid in the lifetime of this view.
93 BrowserFrame* frame_; 133 BrowserFrame* frame_;
94 134
95 // The client view hosted within this non-client frame view that is 135 // The client view hosted within this non-client frame view that is
96 // guaranteed to be freed before the client view. 136 // guaranteed to be freed before the client view.
97 // (see comments about view hierarchies in non_client_view.h) 137 // (see comments about view hierarchies in non_client_view.h)
98 PanelBrowserView* browser_view_; 138 PanelBrowserView* browser_view_;
99 139
100 PaintState paint_state_; 140 PaintState paint_state_;
101 views::ImageButton* info_button_; 141 views::ImageButton* info_button_;
102 views::ImageButton* close_button_; 142 views::ImageButton* close_button_;
103 TabIconView* title_icon_; 143 TabIconView* title_icon_;
104 views::Label* title_label_; 144 views::Label* title_label_;
105 gfx::Rect client_view_bounds_; 145 gfx::Rect client_view_bounds_;
146 scoped_ptr<MouseWatcher> mouse_watcher_;
106 147
107 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); 148 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView);
108 }; 149 };
109 150
110 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 151 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698