Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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); |
| 69 | 70 |
| 70 enum PaintState { | 71 enum PaintState { |
| 71 NOT_PAINTED, | 72 NOT_PAINTED, |
| 72 PAINT_AS_INACTIVE, | 73 PAINT_AS_INACTIVE, |
| 73 PAINT_AS_ACTIVE | 74 PAINT_AS_ACTIVE |
| 74 }; | 75 }; |
| 75 | 76 |
| 77 class MouseWatcher : public MessageLoopForUI::Observer { | |
|
jennb
2011/05/20 23:13:12
Did you look at using views/mouse_watcher.h? Mous
jianli
2011/05/23 21:21:03
Yes, I've looked at views/mouse_watcher.* to see i
| |
| 78 public: | |
| 79 explicit MouseWatcher(PanelBrowserFrameView* view); | |
| 80 virtual ~MouseWatcher(); | |
| 81 | |
| 82 virtual bool IsCursorInViewBounds() const; | |
| 83 | |
| 84 #if defined(OS_WIN) | |
| 85 virtual void WillProcessMessage(const MSG& msg) OVERRIDE { } | |
| 86 virtual void DidProcessMessage(const MSG& msg) OVERRIDE; | |
| 87 #else | |
| 88 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE { } | |
| 89 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE; | |
| 90 #endif | |
| 91 | |
| 92 private: | |
| 93 void HandleGlobalMouseMoveEvent(); | |
| 94 | |
| 95 PanelBrowserFrameView* view_; | |
| 96 bool in_view_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(MouseWatcher); | |
| 99 }; | |
| 100 | |
| 76 // Returns the thickness of the entire nonclient left, right, and bottom | 101 // Returns the thickness of the entire nonclient left, right, and bottom |
| 77 // borders, including both the window frame and any client edge. | 102 // borders, including both the window frame and any client edge. |
| 78 int NonClientBorderThickness() const; | 103 int NonClientBorderThickness() const; |
| 79 | 104 |
| 80 // Returns the height of the entire nonclient top border, including the window | 105 // Returns the height of the entire nonclient top border, including the window |
| 81 // frame, any title area, and any connected client edge. | 106 // frame, any title area, and any connected client edge. |
| 82 int NonClientTopBorderHeight() const; | 107 int NonClientTopBorderHeight() const; |
| 83 | 108 |
| 84 // Update control styles to indicate if the title bar is active or not. | 109 // Update control styles to indicate if the title bar is active or not. |
| 85 void UpdateControlStyles(PaintState paint_state); | 110 void UpdateControlStyles(PaintState paint_state); |
| 86 | 111 |
| 87 // Custom draw the frame. | 112 // Custom draw the frame. |
| 88 void PaintFrameBorder(gfx::Canvas* canvas); | 113 void PaintFrameBorder(gfx::Canvas* canvas); |
| 89 void PaintClientEdge(gfx::Canvas* canvas); | 114 void PaintClientEdge(gfx::Canvas* canvas); |
| 90 | 115 |
| 116 // Called by MouseWatcher to notify if the mouse enters or leaves the window. | |
| 117 void OnMouseEnterOrLeaveWindow(bool mouse_entered); | |
| 118 | |
| 119 // Make info button visible if either of the conditions is met: | |
| 120 // 1) The panel is active, i.e. having focus. | |
| 121 // 2) The mouse is over the panel. | |
| 122 void UpdateInfoButtonVisibility(bool active, bool cursor_in_view); | |
| 123 | |
| 124 #ifdef UNIT_TEST | |
| 125 void set_mouse_watcher(MouseWatcher* mouse_watcher) { | |
| 126 mouse_watcher_.reset(mouse_watcher); | |
| 127 } | |
| 128 #endif | |
| 129 | |
| 91 // The frame that hosts this view. This is a weak reference such that frame_ | 130 // 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. | 131 // will always be valid in the lifetime of this view. |
| 93 BrowserFrame* frame_; | 132 BrowserFrame* frame_; |
| 94 | 133 |
| 95 // The client view hosted within this non-client frame view that is | 134 // The client view hosted within this non-client frame view that is |
| 96 // guaranteed to be freed before the client view. | 135 // guaranteed to be freed before the client view. |
| 97 // (see comments about view hierarchies in non_client_view.h) | 136 // (see comments about view hierarchies in non_client_view.h) |
| 98 PanelBrowserView* browser_view_; | 137 PanelBrowserView* browser_view_; |
| 99 | 138 |
| 100 PaintState paint_state_; | 139 PaintState paint_state_; |
| 101 views::ImageButton* info_button_; | 140 views::ImageButton* info_button_; |
| 102 views::ImageButton* close_button_; | 141 views::ImageButton* close_button_; |
| 103 TabIconView* title_icon_; | 142 TabIconView* title_icon_; |
| 104 views::Label* title_label_; | 143 views::Label* title_label_; |
| 105 gfx::Rect client_view_bounds_; | 144 gfx::Rect client_view_bounds_; |
| 145 scoped_ptr<MouseWatcher> mouse_watcher_; | |
| 106 | 146 |
| 107 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); | 147 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); |
| 108 }; | 148 }; |
| 109 | 149 |
| 110 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ | 150 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ |
| OLD | NEW |