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

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.h

Issue 23531006: Factor out the layout code from OpaqueBrowserFrameView for testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add string casts to make MSVS happy. Created 7 years, 3 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_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/frame/browser_frame.h" 10 #include "chrome/browser/ui/views/frame/browser_frame.h"
10 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" 11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
12 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_delegat e.h"
11 #include "chrome/browser/ui/views/tab_icon_view_model.h" 13 #include "chrome/browser/ui/views/tab_icon_view_model.h"
12 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
14 #include "ui/views/controls/button/button.h" 16 #include "ui/views/controls/button/button.h"
15 #include "ui/views/window/non_client_view.h" 17 #include "ui/views/window/non_client_view.h"
16 18
17 class BrowserView; 19 class BrowserView;
20 class OpaqueBrowserFrameViewLayout;
18 class TabIconView; 21 class TabIconView;
19 22
20 namespace views { 23 namespace views {
21 class ImageButton; 24 class ImageButton;
22 class FrameBackground; 25 class FrameBackground;
23 class Label; 26 class Label;
24 } 27 }
25 28
26 class OpaqueBrowserFrameView : public BrowserNonClientFrameView, 29 class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
27 public content::NotificationObserver, 30 public content::NotificationObserver,
28 public views::ButtonListener, 31 public views::ButtonListener,
29 public chrome::TabIconViewModel { 32 public chrome::TabIconViewModel,
33 public OpaqueBrowserFrameViewLayoutDelegate {
30 public: 34 public:
31 // Constructs a non-client view for an BrowserFrame. 35 // Constructs a non-client view for an BrowserFrame.
32 OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); 36 OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
33 virtual ~OpaqueBrowserFrameView(); 37 virtual ~OpaqueBrowserFrameView();
34 38
35 // Overridden from BrowserNonClientFrameView: 39 // Overridden from BrowserNonClientFrameView:
36 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 40 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
37 virtual TabStripInsets GetTabStripInsets(bool restored) const OVERRIDE; 41 virtual TabStripInsets GetTabStripInsets(bool restored) const OVERRIDE;
38 virtual int GetThemeBackgroundXInset() const OVERRIDE; 42 virtual int GetThemeBackgroundXInset() const OVERRIDE;
39 virtual void UpdateThrobber(bool running) OVERRIDE; 43 virtual void UpdateThrobber(bool running) OVERRIDE;
40 virtual gfx::Size GetMinimumSize() OVERRIDE; 44 virtual gfx::Size GetMinimumSize() OVERRIDE;
41 45
42 protected: 46 protected:
43 views::ImageButton* minimize_button() const { return minimize_button_; } 47 views::ImageButton* minimize_button() const { return minimize_button_; }
44 views::ImageButton* maximize_button() const { return maximize_button_; } 48 views::ImageButton* maximize_button() const { return maximize_button_; }
45 views::ImageButton* restore_button() const { return restore_button_; } 49 views::ImageButton* restore_button() const { return restore_button_; }
46 views::ImageButton* close_button() const { return close_button_; } 50 views::ImageButton* close_button() const { return close_button_; }
47 51
48 // Used to allow subclasses to reserve height for other components they
49 // will add. The space is reserved below the ClientView.
50 virtual int GetReservedHeight() const;
51 virtual gfx::Rect GetBoundsForReservedArea() const;
52
53 // Returns the height of the entire nonclient top border, including the window
54 // frame, any title area, and any connected client edge. If |restored| is
55 // true, acts as if the window is restored regardless of the real mode.
56 int NonClientTopBorderHeight(bool restored) const;
57
58 // Overridden from views::NonClientFrameView: 52 // Overridden from views::NonClientFrameView:
59 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 53 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
60 virtual gfx::Rect GetWindowBoundsForClientBounds( 54 virtual gfx::Rect GetWindowBoundsForClientBounds(
61 const gfx::Rect& client_bounds) const OVERRIDE; 55 const gfx::Rect& client_bounds) const OVERRIDE;
62 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 56 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
63 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) 57 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask)
64 OVERRIDE; 58 OVERRIDE;
65 virtual void ResetWindowControls() OVERRIDE; 59 virtual void ResetWindowControls() OVERRIDE;
66 virtual void UpdateWindowIcon() OVERRIDE; 60 virtual void UpdateWindowIcon() OVERRIDE;
67 virtual void UpdateWindowTitle() OVERRIDE; 61 virtual void UpdateWindowTitle() OVERRIDE;
68 62
69 // Overridden from views::View: 63 // Overridden from views::View:
70 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 64 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
71 virtual void Layout() OVERRIDE;
72 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; 65 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
73 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 66 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
74 67
75 // Overridden from views::ButtonListener: 68 // Overridden from views::ButtonListener:
76 virtual void ButtonPressed(views::Button* sender, const ui::Event& event) 69 virtual void ButtonPressed(views::Button* sender, const ui::Event& event)
77 OVERRIDE; 70 OVERRIDE;
78 71
79 // Overridden from chrome::TabIconViewModel: 72 // Overridden from chrome::TabIconViewModel:
80 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; 73 virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
81 virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE; 74 virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
82 75
83 // content::NotificationObserver implementation: 76 // content::NotificationObserver implementation:
84 virtual void Observe(int type, 77 virtual void Observe(int type,
85 const content::NotificationSource& source, 78 const content::NotificationSource& source,
86 const content::NotificationDetails& details) OVERRIDE; 79 const content::NotificationDetails& details) OVERRIDE;
87 80
81 // OpaqueBrowserFrameViewLayoutDelegate implementation:
82 virtual bool ShouldShowWindowIcon() const OVERRIDE;
83 virtual bool ShouldShowWindowTitle() const OVERRIDE;
84 virtual string16 GetWindowTitle() const OVERRIDE;
85 virtual int GetIconSize() const OVERRIDE;
86 virtual bool ShouldLeaveOffsetNearTopBorder() const OVERRIDE;
87 virtual gfx::Size GetBrowserViewMinimumSize() const OVERRIDE;
88 virtual bool ShouldShowAvatar() const OVERRIDE;
89 virtual gfx::ImageSkia GetOTRAvatarIcon() const OVERRIDE;
90 virtual bool IsMaximized() const OVERRIDE;
91 virtual bool IsMinimized() const OVERRIDE;
92 virtual bool IsFullscreen() const OVERRIDE;
93 virtual bool IsTabStripVisible() const OVERRIDE;
94 virtual int GetTabStripHeight() const OVERRIDE;
95 virtual int GetAdditionalReservedSpaceInTabStrip() const OVERRIDE;
96 virtual gfx::Size GetTabstripPreferredSize() const OVERRIDE;
97
88 private: 98 private:
89 // Creates, adds and returns a new image button with |this| as its listener. 99 // Creates, adds and returns a new image button with |this| as its listener.
90 // Memory is owned by the caller. 100 // Memory is owned by the caller.
91 views::ImageButton* InitWindowCaptionButton(int normal_image_id, 101 views::ImageButton* InitWindowCaptionButton(int normal_image_id,
92 int hot_image_id, 102 int hot_image_id,
93 int pushed_image_id, 103 int pushed_image_id,
94 int mask_image_id, 104 int mask_image_id,
95 int accessibility_string_id); 105 int accessibility_string_id,
106 ViewID view_id);
96 107
97 // Returns the thickness of the border that makes up the window frame edges. 108 // Returns the thickness of the border that makes up the window frame edges.
98 // This does not include any client edge. If |restored| is true, acts as if 109 // This does not include any client edge. If |restored| is true, acts as if
99 // the window is restored regardless of the real mode. 110 // the window is restored regardless of the real mode.
100 int FrameBorderThickness(bool restored) const; 111 int FrameBorderThickness(bool restored) const;
101 112
102 // Returns the height of the top resize area. This is smaller than the frame 113 // Returns the height of the top resize area. This is smaller than the frame
103 // border height in order to increase the window draggable area. 114 // border height in order to increase the window draggable area.
104 int TopResizeHeight() const; 115 int TopResizeHeight() const;
105 116
106 // Returns the thickness of the entire nonclient left, right, and bottom 117 // Returns the thickness of the entire nonclient left, right, and bottom
107 // borders, including both the window frame and any client edge. 118 // borders, including both the window frame and any client edge.
108 int NonClientBorderThickness() const; 119 int NonClientBorderThickness() const;
109 120
110 // Returns the y-coordinate of the caption buttons. If |restored| is true,
111 // acts as if the window is restored regardless of the real mode.
112 int CaptionButtonY(bool restored) const;
113
114 // Returns the thickness of the 3D edge along the bottom of the titlebar. If
115 // |restored| is true, acts as if the window is restored regardless of the
116 // real mode.
117 int TitlebarBottomThickness(bool restored) const;
118
119 // Returns the size of the titlebar icon. This is used even when the icon is
120 // not shown, e.g. to set the titlebar height.
121 int IconSize() const;
122
123 // Returns the bounds of the titlebar icon (or where the icon would be if 121 // Returns the bounds of the titlebar icon (or where the icon would be if
124 // there was one). 122 // there was one).
125 gfx::Rect IconBounds() const; 123 gfx::Rect IconBounds() const;
126 124
127 // Returns the combined bounds for the tab strip and avatar area.
128 gfx::Rect GetBoundsForTabStripAndAvatarArea(views::View* tabstrip) const;
129
130 // Paint various sub-components of this view. The *FrameBorder() functions 125 // Paint various sub-components of this view. The *FrameBorder() functions
131 // also paint the background of the titlebar area, since the top frame border 126 // also paint the background of the titlebar area, since the top frame border
132 // and titlebar background are a contiguous component. 127 // and titlebar background are a contiguous component.
133 void PaintRestoredFrameBorder(gfx::Canvas* canvas); 128 void PaintRestoredFrameBorder(gfx::Canvas* canvas);
134 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); 129 void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
135 void PaintToolbarBackground(gfx::Canvas* canvas); 130 void PaintToolbarBackground(gfx::Canvas* canvas);
136 void PaintRestoredClientEdge(gfx::Canvas* canvas); 131 void PaintRestoredClientEdge(gfx::Canvas* canvas);
137 132
138 // Compute aspects of the frame needed to paint the frame background. 133 // Compute aspects of the frame needed to paint the frame background.
139 SkColor GetFrameColor() const; 134 SkColor GetFrameColor() const;
140 gfx::ImageSkia* GetFrameImage() const; 135 gfx::ImageSkia* GetFrameImage() const;
141 gfx::ImageSkia* GetFrameOverlayImage() const; 136 gfx::ImageSkia* GetFrameOverlayImage() const;
142 int GetTopAreaHeight() const; 137 int GetTopAreaHeight() const;
143 138
144 // Layout various sub-components of this view.
145 void LayoutWindowControls();
146 void LayoutTitleBar();
147 void LayoutAvatar();
148
149 // Returns the bounds of the client area for the specified view size. 139 // Returns the bounds of the client area for the specified view size.
150 gfx::Rect CalculateClientAreaBounds(int width, int height) const; 140 gfx::Rect CalculateClientAreaBounds(int width, int height) const;
151 141
152 // The layout rect of the avatar icon, if visible. 142 // Our layout manager also calculates various bounds.
153 gfx::Rect avatar_bounds_; 143 OpaqueBrowserFrameViewLayout* layout_;
154 144
155 // Window controls. 145 // Window controls.
156 views::ImageButton* minimize_button_; 146 views::ImageButton* minimize_button_;
157 views::ImageButton* maximize_button_; 147 views::ImageButton* maximize_button_;
158 views::ImageButton* restore_button_; 148 views::ImageButton* restore_button_;
159 views::ImageButton* close_button_; 149 views::ImageButton* close_button_;
160 150
161 // The window icon and title. 151 // The window icon and title.
162 TabIconView* window_icon_; 152 TabIconView* window_icon_;
163 views::Label* window_title_; 153 views::Label* window_title_;
164 154
165 // The bounds of the ClientView.
166 gfx::Rect client_view_bounds_;
167
168 content::NotificationRegistrar registrar_; 155 content::NotificationRegistrar registrar_;
169 156
170 // Background painter for the window frame. 157 // Background painter for the window frame.
171 scoped_ptr<views::FrameBackground> frame_background_; 158 scoped_ptr<views::FrameBackground> frame_background_;
172 159
173 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView); 160 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView);
174 }; 161 };
175 162
176 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ 163 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698