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

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

Issue 9956145: Remove wrench button from panel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 8 years, 8 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) 2012 The Chromium Authors. All rights reserved. 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 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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #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"
13 #include "chrome/browser/ui/views/tab_icon_view.h" 13 #include "chrome/browser/ui/views/tab_icon_view.h"
14 #include "ui/base/animation/animation_delegate.h"
15 #include "ui/views/controls/button/button.h" 14 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/button/menu_button_listener.h"
17 15
18 class Extension; 16 class Extension;
19 class PanelBrowserView; 17 class PanelBrowserView;
20 class PanelSettingsMenuModel;
21 class SkPaint; 18 class SkPaint;
22 namespace gfx { 19 namespace gfx {
23 class Font; 20 class Font;
24 } 21 }
25 namespace ui { 22 namespace ui {
26 class LinearAnimation; 23 class LinearAnimation;
27 } 24 }
28 namespace views { 25 namespace views {
29 class ImageButton; 26 class ImageButton;
30 class Label; 27 class Label;
31 class MenuButton;
32 class MenuItemView;
33 class MenuModelAdapter;
34 class MenuRunner;
35 } 28 }
36 29
37 class PanelBrowserFrameView : public BrowserNonClientFrameView, 30 class PanelBrowserFrameView : public BrowserNonClientFrameView,
38 public views::ButtonListener, 31 public views::ButtonListener,
39 public views::MenuButtonListener, 32 public TabIconView::TabIconViewModel {
40 public TabIconView::TabIconViewModel,
41 public ui::AnimationDelegate {
42 public: 33 public:
43 PanelBrowserFrameView(BrowserFrame* frame, PanelBrowserView* browser_view); 34 PanelBrowserFrameView(BrowserFrame* frame, PanelBrowserView* browser_view);
44 virtual ~PanelBrowserFrameView(); 35 virtual ~PanelBrowserFrameView();
45 36
46 void UpdateTitleBar(); 37 void UpdateTitleBar();
47 void OnFocusChanged(bool focused);
48 38
49 // Returns the height of the entire nonclient top border, including the window 39 // Returns the height of the entire nonclient top border, including the window
50 // frame, any title area, and any connected client edge. 40 // frame, any title area, and any connected client edge.
51 int NonClientTopBorderHeight() const; 41 int NonClientTopBorderHeight() const;
52 42
53 // Returns the size of the non-client area, that is, the window size minus 43 // Returns the size of the non-client area, that is, the window size minus
54 // the size of the client area. 44 // the size of the client area.
55 gfx::Size NonClientAreaSize() const; 45 gfx::Size NonClientAreaSize() const;
56 46
57 // Returns the size of the non-client area upon which only the title icon 47 // Returns the size of the non-client area upon which only the title icon
(...skipping 25 matching lines...) Expand all
83 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 73 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
84 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; 74 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
85 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; 75 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
86 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; 76 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
87 virtual void OnMouseCaptureLost() OVERRIDE; 77 virtual void OnMouseCaptureLost() OVERRIDE;
88 78
89 // Overridden from views::ButtonListener: 79 // Overridden from views::ButtonListener:
90 virtual void ButtonPressed(views::Button* sender, const views::Event& event) 80 virtual void ButtonPressed(views::Button* sender, const views::Event& event)
91 OVERRIDE; 81 OVERRIDE;
92 82
93 // Overridden from views::MenuButtonListener:
94 virtual void OnMenuButtonClicked(views::View* source,
95 const gfx::Point& point) OVERRIDE;
96
97 // Overridden from TabIconView::TabIconViewModel: 83 // Overridden from TabIconView::TabIconViewModel:
98 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; 84 virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
99 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE; 85 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE;
100 86
101 // Overridden from AnimationDelegate:
102 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
103 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
104 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
105
106 private: 87 private:
107 friend class PanelBrowserViewTest; 88 friend class PanelBrowserViewTest;
108 friend class NativePanelTestingWin; 89 friend class NativePanelTestingWin;
109 90
110 enum PaintState { 91 enum PaintState {
111 NOT_PAINTED, 92 NOT_PAINTED,
112 PAINT_AS_INACTIVE, 93 PAINT_AS_INACTIVE,
113 PAINT_AS_ACTIVE, 94 PAINT_AS_ACTIVE,
114 PAINT_FOR_ATTENTION 95 PAINT_FOR_ATTENTION
115 }; 96 };
116 97
117 class MouseWatcher : public MessageLoopForUI::Observer {
118 public:
119 explicit MouseWatcher(PanelBrowserFrameView* view);
120 virtual ~MouseWatcher();
121
122 virtual bool IsCursorInViewBounds() const;
123
124 #if defined(OS_WIN) || defined(USE_AURA)
125 virtual base::EventStatus WillProcessEvent(
126 const base::NativeEvent& event) OVERRIDE;
127 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
128 #elif defined(TOOLKIT_GTK)
129 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE;
130 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE;
131 #endif
132
133 private:
134 void HandleGlobalMouseMoveEvent();
135
136 PanelBrowserFrameView* view_;
137 bool is_mouse_within_;
138
139 DISALLOW_COPY_AND_ASSIGN(MouseWatcher);
140 };
141
142 // Returns the thickness of the entire nonclient left, right, and bottom 98 // Returns the thickness of the entire nonclient left, right, and bottom
143 // borders, including both the window frame and any client edge. 99 // borders, including both the window frame and any client edge.
144 int NonClientBorderThickness() const; 100 int NonClientBorderThickness() const;
145 101
146 // Returns the width of the panel that is showing only an icon. 102 // Returns the width of the panel that is showing only an icon.
147 int IconOnlyWidth() const; 103 int IconOnlyWidth() const;
148 104
149 // Update control styles to indicate if the titlebar is active or not. 105 // Update control styles to indicate if the titlebar is active or not.
150 void UpdateControlStyles(PaintState paint_state); 106 void UpdateControlStyles(PaintState paint_state);
151 107
152 // Custom draw the frame. 108 // Custom draw the frame.
153 void PaintFrameBackground(gfx::Canvas* canvas); 109 void PaintFrameBackground(gfx::Canvas* canvas);
154 void PaintFrameEdge(gfx::Canvas* canvas); 110 void PaintFrameEdge(gfx::Canvas* canvas);
155 void PaintClientEdge(gfx::Canvas* canvas); 111 void PaintClientEdge(gfx::Canvas* canvas);
156 112
157 // Called by MouseWatcher to notify if the mouse enters or leaves the window.
158 void OnMouseEnterOrLeaveWindow(bool mouse_entered);
159
160 // Retrieves the drawing metrics based on the current painting state. 113 // Retrieves the drawing metrics based on the current painting state.
161 SkColor GetTitleColor(PaintState paint_state) const; 114 SkColor GetTitleColor(PaintState paint_state) const;
162 SkBitmap* GetFrameTheme(PaintState paint_state) const; 115 SkBitmap* GetFrameTheme(PaintState paint_state) const;
163 116
164 // Make settings button visible if either of the conditions is met:
165 // 1) The panel is active, i.e. having focus.
166 // 2) The mouse is over the panel.
167 void UpdateSettingsButtonVisibility(bool active, bool cursor_in_view);
168
169 bool UsingDefaultTheme(PaintState paint_state) const; 117 bool UsingDefaultTheme(PaintState paint_state) const;
170 118
171 const Extension* GetExtension() const; 119 const Extension* GetExtension() const;
172 120
173 bool EnsureSettingsMenuCreated();
174
175 string16 GetTitleText() const; 121 string16 GetTitleText() const;
176 122
177 bool CanResize() const; 123 bool CanResize() const;
178 124
179 #ifdef UNIT_TEST
180 PanelSettingsMenuModel* settings_menu_model() const {
181 return settings_menu_model_.get();
182 }
183
184 void set_mouse_watcher(MouseWatcher* mouse_watcher) {
185 mouse_watcher_.reset(mouse_watcher);
186 }
187 #endif
188
189 // The client view hosted within this non-client frame view that is 125 // The client view hosted within this non-client frame view that is
190 // guaranteed to be freed before the client view. 126 // guaranteed to be freed before the client view.
191 // (see comments about view hierarchies in non_client_view.h) 127 // (see comments about view hierarchies in non_client_view.h)
192 PanelBrowserView* panel_browser_view_; 128 PanelBrowserView* panel_browser_view_;
193 129
194 PaintState paint_state_; 130 PaintState paint_state_;
195 views::MenuButton* settings_button_;
196 views::ImageButton* close_button_; 131 views::ImageButton* close_button_;
197 TabIconView* title_icon_; 132 TabIconView* title_icon_;
198 views::Label* title_label_; 133 views::Label* title_label_;
199 gfx::Rect client_view_bounds_; 134 gfx::Rect client_view_bounds_;
200 scoped_ptr<MouseWatcher> mouse_watcher_;
201 scoped_ptr<PanelSettingsMenuModel> settings_menu_model_;
202 scoped_ptr<views::MenuModelAdapter> settings_menu_adapter_;
203 views::MenuItemView* settings_menu_; // Owned by |settings_menu_runner_|.
204 scoped_ptr<views::MenuRunner> settings_menu_runner_;
205
206 // Used to animate the visibility change of settings button.
207 scoped_ptr<ui::LinearAnimation> settings_button_animator_;
208 gfx::Rect settings_button_full_bounds_;
209 gfx::Rect settings_button_zero_bounds_;
210 bool is_settings_button_visible_;
211
212 // On Aura popups are displayed in panels. If this panel is not opened by an
213 // app, it won't have a settings button.
214 const bool has_settings_button_;
215 135
216 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); 136 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView);
217 }; 137 };
218 138
219 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 139 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698