OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/views/frame/aero_glass_non_client_view.h" | 5 #include "chrome/browser/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/views/frame/browser_view.h" | 7 #include "chrome/browser/views/frame/browser_view.h" |
8 #include "chrome/browser/views/tabs/tab_strip.h" | 8 #include "chrome/browser/views/tabs/tab_strip.h" |
9 #include "chrome/common/resource_bundle.h" | 9 #include "chrome/common/resource_bundle.h" |
10 #include "chrome/views/client_view.h" | 10 #include "chrome/views/client_view.h" |
11 #include "chrome/views/window_resources.h" | 11 #include "chrome/views/window_resources.h" |
12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
13 | 13 |
14 // An enumeration of bitmap resources used by this window. | 14 // An enumeration of bitmap resources used by this window. |
15 enum { | 15 enum { |
16 // Client Edge Border. | 16 // Client Edge Border. |
17 FRAME_CLIENT_EDGE_TOP_LEFT, | 17 FRAME_CLIENT_EDGE_TOP_LEFT, |
18 FRAME_CLIENT_EDGE_TOP, | 18 FRAME_CLIENT_EDGE_TOP, |
19 FRAME_CLIENT_EDGE_TOP_RIGHT, | 19 FRAME_CLIENT_EDGE_TOP_RIGHT, |
20 FRAME_CLIENT_EDGE_RIGHT, | 20 FRAME_CLIENT_EDGE_RIGHT, |
21 FRAME_CLIENT_EDGE_BOTTOM_RIGHT, | 21 FRAME_CLIENT_EDGE_BOTTOM_RIGHT, |
22 FRAME_CLIENT_EDGE_BOTTOM, | 22 FRAME_CLIENT_EDGE_BOTTOM, |
23 FRAME_CLIENT_EDGE_BOTTOM_LEFT, | 23 FRAME_CLIENT_EDGE_BOTTOM_LEFT, |
24 FRAME_CLIENT_EDGE_LEFT, | 24 FRAME_CLIENT_EDGE_LEFT, |
25 | 25 |
26 FRAME_PART_BITMAP_COUNT // Must be last. | 26 FRAME_PART_BITMAP_COUNT // Must be last. |
27 }; | 27 }; |
28 | 28 |
29 class AeroGlassWindowResources { | 29 class GlassBrowserWindowResources { |
30 public: | 30 public: |
31 AeroGlassWindowResources() { | 31 GlassBrowserWindowResources() { |
32 InitClass(); | 32 InitClass(); |
33 } | 33 } |
34 virtual ~AeroGlassWindowResources() { } | 34 virtual ~GlassBrowserWindowResources() { } |
35 | 35 |
36 virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const { | 36 virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const { |
37 return standard_frame_bitmaps_[part]; | 37 return standard_frame_bitmaps_[part]; |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 static void InitClass() { | 41 static void InitClass() { |
42 static bool initialized = false; | 42 static bool initialized = false; |
43 if (!initialized) { | 43 if (!initialized) { |
44 static const int kFramePartBitmapIds[] = { | 44 static const int kFramePartBitmapIds[] = { |
45 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, | 45 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, |
46 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, | 46 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, |
47 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, | 47 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, |
48 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, | 48 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, |
49 }; | 49 }; |
50 | 50 |
51 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 51 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
52 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) | 52 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) |
53 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); | 53 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); |
54 | 54 |
55 initialized = true; | 55 initialized = true; |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; | 59 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; |
60 | 60 |
61 DISALLOW_EVIL_CONSTRUCTORS(AeroGlassWindowResources); | 61 DISALLOW_EVIL_CONSTRUCTORS(GlassBrowserWindowResources); |
62 }; | 62 }; |
63 | 63 |
64 // static | 64 // static |
65 SkBitmap* AeroGlassWindowResources::standard_frame_bitmaps_[]; | 65 SkBitmap* GlassBrowserWindowResources::standard_frame_bitmaps_[]; |
66 | 66 |
67 AeroGlassWindowResources* AeroGlassNonClientView::resources_ = NULL; | 67 GlassBrowserWindowResources* GlassBrowserFrameView::resources_ = NULL; |
68 SkBitmap* AeroGlassNonClientView::distributor_logo_ = NULL; | 68 SkBitmap* GlassBrowserFrameView::distributor_logo_ = NULL; |
| 69 HICON GlassBrowserFrameView::throbber_icons_[GlassBrowserFrameView::kThrobberIco
nCount]; |
69 | 70 |
70 namespace { | 71 namespace { |
71 // There are 3 px of client edge drawn inside the outer frame borders. | 72 // There are 3 px of client edge drawn inside the outer frame borders. |
72 const int kNonClientBorderThickness = 3; | 73 const int kNonClientBorderThickness = 3; |
73 // Besides the frame border, there's another 11 px of empty space atop the | 74 // Besides the frame border, there's another 11 px of empty space atop the |
74 // window in restored mode, to use to drag the window around. | 75 // window in restored mode, to use to drag the window around. |
75 const int kNonClientRestoredExtraThickness = 11; | 76 const int kNonClientRestoredExtraThickness = 11; |
76 // In the window corners, the resize areas don't actually expand bigger, but the | 77 // In the window corners, the resize areas don't actually expand bigger, but the |
77 // 16 px at the end of the top and bottom edges triggers diagonal resizing. | 78 // 16 px at the end of the top and bottom edges triggers diagonal resizing. |
78 const int kResizeAreaCornerSize = 16; | 79 const int kResizeAreaCornerSize = 16; |
(...skipping 16 matching lines...) Expand all Loading... |
95 // In maximized mode, where the New Tab button and the caption buttons are at | 96 // In maximized mode, where the New Tab button and the caption buttons are at |
96 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 97 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
97 // looking too cluttered. | 98 // looking too cluttered. |
98 const int kNewTabCaptionMaximizedSpacing = 16; | 99 const int kNewTabCaptionMaximizedSpacing = 16; |
99 // When there's a distributor logo, we leave a 7 px gap between it and the | 100 // When there's a distributor logo, we leave a 7 px gap between it and the |
100 // caption buttons. | 101 // caption buttons. |
101 const int kLogoCaptionSpacing = 7; | 102 const int kLogoCaptionSpacing = 7; |
102 } | 103 } |
103 | 104 |
104 /////////////////////////////////////////////////////////////////////////////// | 105 /////////////////////////////////////////////////////////////////////////////// |
105 // AeroGlassNonClientView, public: | 106 // GlassBrowserFrameView, public: |
106 | 107 |
107 AeroGlassNonClientView::AeroGlassNonClientView(AeroGlassFrame* frame, | 108 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, |
108 BrowserView* browser_view) | 109 BrowserView* browser_view) |
109 : frame_(frame), | 110 : BrowserNonClientFrameView(), |
110 browser_view_(browser_view) { | 111 frame_(frame), |
| 112 browser_view_(browser_view), |
| 113 throbber_running_(false), |
| 114 throbber_frame_(0) { |
111 InitClass(); | 115 InitClass(); |
| 116 if (frame_->window_delegate()->ShouldShowWindowIcon()) |
| 117 InitThrobberIcons(); |
112 } | 118 } |
113 | 119 |
114 AeroGlassNonClientView::~AeroGlassNonClientView() { | 120 GlassBrowserFrameView::~GlassBrowserFrameView() { |
115 } | 121 } |
116 | 122 |
117 gfx::Rect AeroGlassNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) { | 123 /////////////////////////////////////////////////////////////////////////////// |
| 124 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
| 125 |
| 126 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
| 127 TabStrip* tabstrip) const { |
118 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 128 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
119 (otr_avatar_bounds_.right() + kOTRSideSpacing) : | 129 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
120 NonClientBorderThickness(); | 130 NonClientBorderThickness(); |
121 int tabstrip_width = frame_->GetMinimizeButtonOffset() - tabstrip_x - | 131 int tabstrip_width = frame_->GetMinimizeButtonOffset() - tabstrip_x - |
122 (frame_->IsMaximized() ? | 132 (frame_->IsMaximized() ? |
123 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 133 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
124 return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(), | 134 return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(), |
125 std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); | 135 std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); |
126 } | 136 } |
127 | 137 |
| 138 void GlassBrowserFrameView::UpdateThrobber(bool running) { |
| 139 if (throbber_running_) { |
| 140 if (running) { |
| 141 DisplayNextThrobberFrame(); |
| 142 } else { |
| 143 StopThrobber(); |
| 144 } |
| 145 } else if (running) { |
| 146 StartThrobber(); |
| 147 } |
| 148 } |
| 149 |
128 /////////////////////////////////////////////////////////////////////////////// | 150 /////////////////////////////////////////////////////////////////////////////// |
129 // AeroGlassNonClientView, views::NonClientView implementation: | 151 // GlassBrowserFrameView, views::NonClientFrameView implementation: |
130 | 152 |
131 gfx::Rect AeroGlassNonClientView::CalculateClientAreaBounds(int width, | 153 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { |
132 int height) const { | 154 return client_view_bounds_; |
133 if (!browser_view_->IsTabStripVisible()) | 155 } |
134 return gfx::Rect(0, 0, this->width(), this->height()); | 156 |
| 157 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( |
| 158 const gfx::Rect& client_bounds) const { |
| 159 if (!browser_view_->IsTabStripVisible()) { |
| 160 // If we don't have a tabstrip, we're either a popup or an app window, in |
| 161 // which case we have a standard size non-client area and can just use |
| 162 // AdjustWindowRectEx to obtain it. |
| 163 RECT rect = client_bounds.ToRECT(); |
| 164 AdjustWindowRectEx(&rect, frame_->window_style(), FALSE, |
| 165 frame_->window_ex_style()); |
| 166 return gfx::Rect(rect); |
| 167 } |
135 | 168 |
136 int top_height = NonClientTopBorderHeight(); | 169 int top_height = NonClientTopBorderHeight(); |
137 int border_thickness = NonClientBorderThickness(); | 170 int border_thickness = NonClientBorderThickness(); |
138 return gfx::Rect(border_thickness, top_height, | 171 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
139 std::max(0, width - (2 * border_thickness)), | 172 std::max(0, client_bounds.y() - top_height), |
140 std::max(0, height - top_height - border_thickness)); | 173 client_bounds.width() + (2 * border_thickness), |
| 174 client_bounds.height() + top_height + border_thickness); |
141 } | 175 } |
142 | 176 |
143 gfx::Size AeroGlassNonClientView::CalculateWindowSizeForClientSize( | 177 gfx::Point GlassBrowserFrameView::GetSystemMenuPoint() const { |
144 int width, | |
145 int height) const { | |
146 int border_thickness = NonClientBorderThickness(); | |
147 return gfx::Size(width + (2 * border_thickness), | |
148 height + NonClientTopBorderHeight() + border_thickness); | |
149 } | |
150 | |
151 gfx::Point AeroGlassNonClientView::GetSystemMenuPoint() const { | |
152 gfx::Point system_menu_point; | 178 gfx::Point system_menu_point; |
153 if (browser_view_->IsBrowserTypeNormal()) { | 179 if (browser_view_->IsBrowserTypeNormal()) { |
154 // The maximized mode bit here is because in maximized mode the frame edge | 180 // The maximized mode bit here is because in maximized mode the frame edge |
155 // and the client edge are both offscreen, whereas in the opaque frame | 181 // and the client edge are both offscreen, whereas in the opaque frame |
156 // (where we don't do this trick) maximized windows have no client edge and | 182 // (where we don't do this trick) maximized windows have no client edge and |
157 // only the frame edge is offscreen. | 183 // only the frame edge is offscreen. |
158 system_menu_point.SetPoint(NonClientBorderThickness() - | 184 system_menu_point.SetPoint(NonClientBorderThickness() - |
159 (frame_->IsMaximized() ? 0 : kClientEdgeThickness), | 185 (frame_->IsMaximized() ? 0 : kClientEdgeThickness), |
160 NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() - | 186 NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() - |
161 kClientEdgeThickness); | 187 kClientEdgeThickness); |
162 } else { | 188 } else { |
163 system_menu_point.SetPoint(0, -kFrameShadowThickness); | 189 system_menu_point.SetPoint(0, -kFrameShadowThickness); |
164 } | 190 } |
165 ConvertPointToScreen(this, &system_menu_point); | 191 ConvertPointToScreen(this, &system_menu_point); |
166 return system_menu_point; | 192 return system_menu_point; |
167 } | 193 } |
168 | 194 |
169 int AeroGlassNonClientView::NonClientHitTest(const gfx::Point& point) { | 195 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
170 // If the browser isn't in normal mode, we haven't customized the frame, so | 196 // If the browser isn't in normal mode, we haven't customized the frame, so |
171 // Windows can figure this out. If the point isn't within our bounds, then | 197 // Windows can figure this out. If the point isn't within our bounds, then |
172 // it's in the native portion of the frame, so again Windows can figure it | 198 // it's in the native portion of the frame, so again Windows can figure it |
173 // out. | 199 // out. |
174 if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point)) | 200 if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point)) |
175 return HTNOWHERE; | 201 return HTNOWHERE; |
176 | 202 |
177 int frame_component = frame_->client_view()->NonClientHitTest(point); | 203 int frame_component = frame_->client_view()->NonClientHitTest(point); |
178 if (frame_component != HTNOWHERE) | 204 if (frame_component != HTNOWHERE) |
179 return frame_component; | 205 return frame_component; |
180 | 206 |
181 int border_thickness = FrameBorderThickness(); | 207 int border_thickness = FrameBorderThickness(); |
182 int window_component = GetHTComponentForFrame(point, border_thickness, | 208 int window_component = GetHTComponentForFrame(point, border_thickness, |
183 NonClientBorderThickness(), border_thickness, | 209 NonClientBorderThickness(), border_thickness, |
184 kResizeAreaCornerSize - border_thickness, | 210 kResizeAreaCornerSize - border_thickness, |
185 frame_->window_delegate()->CanResize()); | 211 frame_->window_delegate()->CanResize()); |
186 // Fall back to the caption if no other component matches. | 212 // Fall back to the caption if no other component matches. |
187 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 213 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
188 } | 214 } |
189 | 215 |
190 /////////////////////////////////////////////////////////////////////////////// | 216 /////////////////////////////////////////////////////////////////////////////// |
191 // AeroGlassNonClientView, views::View overrides: | 217 // GlassBrowserFrameView, views::View overrides: |
192 | 218 |
193 void AeroGlassNonClientView::Paint(ChromeCanvas* canvas) { | 219 void GlassBrowserFrameView::Paint(ChromeCanvas* canvas) { |
194 if (!browser_view_->IsTabStripVisible()) | 220 if (!browser_view_->IsTabStripVisible()) |
195 return; // Nothing is visible, so don't bother to paint. | 221 return; // Nothing is visible, so don't bother to paint. |
196 | 222 |
197 PaintDistributorLogo(canvas); | 223 PaintDistributorLogo(canvas); |
198 PaintToolbarBackground(canvas); | 224 PaintToolbarBackground(canvas); |
199 PaintOTRAvatar(canvas); | 225 PaintOTRAvatar(canvas); |
200 PaintClientEdge(canvas); | 226 PaintClientEdge(canvas); |
201 } | 227 } |
202 | 228 |
203 void AeroGlassNonClientView::Layout() { | 229 void GlassBrowserFrameView::Layout() { |
204 LayoutDistributorLogo(); | 230 LayoutDistributorLogo(); |
205 LayoutOTRAvatar(); | 231 LayoutOTRAvatar(); |
206 LayoutClientView(); | 232 LayoutClientView(); |
207 } | 233 } |
208 | 234 |
209 void AeroGlassNonClientView::ViewHierarchyChanged(bool is_add, | 235 /////////////////////////////////////////////////////////////////////////////// |
210 views::View* parent, | 236 // GlassBrowserFrameView, private: |
211 views::View* child) { | |
212 if (is_add && child == this) { | |
213 DCHECK(GetWidget()); | |
214 DCHECK(frame_->client_view()->GetParent() != this); | |
215 AddChildView(frame_->client_view()); | |
216 } | |
217 } | |
218 | 237 |
219 /////////////////////////////////////////////////////////////////////////////// | 238 int GlassBrowserFrameView::FrameBorderThickness() const { |
220 // AeroGlassNonClientView, private: | |
221 | |
222 int AeroGlassNonClientView::FrameBorderThickness() const { | |
223 return GetSystemMetrics(SM_CXSIZEFRAME); | 239 return GetSystemMetrics(SM_CXSIZEFRAME); |
224 } | 240 } |
225 | 241 |
226 int AeroGlassNonClientView::NonClientBorderThickness() const { | 242 int GlassBrowserFrameView::NonClientBorderThickness() const { |
227 return kNonClientBorderThickness; | 243 return kNonClientBorderThickness; |
228 } | 244 } |
229 | 245 |
230 int AeroGlassNonClientView::NonClientTopBorderHeight() const { | 246 int GlassBrowserFrameView::NonClientTopBorderHeight() const { |
231 return FrameBorderThickness() + | 247 return FrameBorderThickness() + |
232 (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); | 248 (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); |
233 } | 249 } |
234 | 250 |
235 void AeroGlassNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) { | 251 void GlassBrowserFrameView::PaintDistributorLogo(ChromeCanvas* canvas) { |
236 // The distributor logo is only painted when the frame is not maximized and | 252 // The distributor logo is only painted when the frame is not maximized and |
237 // when we actually have a logo. | 253 // when we actually have a logo. |
238 if (!frame_->IsMaximized() && distributor_logo_) { | 254 if (!frame_->IsMaximized() && distributor_logo_) { |
239 // NOTE: We don't mirror the logo placement here because the outer frame | 255 // NOTE: We don't mirror the logo placement here because the outer frame |
240 // itself isn't mirrored in RTL. This is a bug; if it is fixed, this should | 256 // itself isn't mirrored in RTL. This is a bug; if it is fixed, this should |
241 // be mirrored as in opaque_non_client_view.cc. | 257 // be mirrored as in opaque_non_client_view.cc. |
242 canvas->DrawBitmapInt(*distributor_logo_, logo_bounds_.x(), | 258 canvas->DrawBitmapInt(*distributor_logo_, logo_bounds_.x(), |
243 logo_bounds_.y()); | 259 logo_bounds_.y()); |
244 } | 260 } |
245 } | 261 } |
246 | 262 |
247 void AeroGlassNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { | 263 void GlassBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) { |
248 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 264 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
249 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 265 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
250 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); | 266 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); |
251 toolbar_bounds.set_origin(toolbar_origin); | 267 toolbar_bounds.set_origin(toolbar_origin); |
252 | 268 |
253 SkBitmap* toolbar_left = | 269 SkBitmap* toolbar_left = |
254 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); | 270 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); |
255 canvas->DrawBitmapInt(*toolbar_left, | 271 canvas->DrawBitmapInt(*toolbar_left, |
256 toolbar_bounds.x() - toolbar_left->width(), | 272 toolbar_bounds.x() - toolbar_left->width(), |
257 toolbar_bounds.y()); | 273 toolbar_bounds.y()); |
258 | 274 |
259 SkBitmap* toolbar_center = | 275 SkBitmap* toolbar_center = |
260 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); | 276 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); |
261 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(), | 277 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(), |
262 toolbar_bounds.width(), toolbar_center->height()); | 278 toolbar_bounds.width(), toolbar_center->height()); |
263 | 279 |
264 canvas->DrawBitmapInt(*resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT), | 280 canvas->DrawBitmapInt(*resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT), |
265 toolbar_bounds.right(), toolbar_bounds.y()); | 281 toolbar_bounds.right(), toolbar_bounds.y()); |
266 } | 282 } |
267 | 283 |
268 void AeroGlassNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) { | 284 void GlassBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) { |
269 if (!browser_view_->ShouldShowOffTheRecordAvatar()) | 285 if (!browser_view_->ShouldShowOffTheRecordAvatar()) |
270 return; | 286 return; |
271 | 287 |
272 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 288 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
273 canvas->DrawBitmapInt(otr_avatar_icon, 0, | 289 canvas->DrawBitmapInt(otr_avatar_icon, 0, |
274 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, | 290 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, |
275 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), | 291 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), |
276 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), | 292 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), |
277 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); | 293 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); |
278 } | 294 } |
279 | 295 |
280 void AeroGlassNonClientView::PaintClientEdge(ChromeCanvas* canvas) { | 296 void GlassBrowserFrameView::PaintClientEdge(ChromeCanvas* canvas) { |
281 // The client edges start below the toolbar upper corner images regardless | 297 // The client edges start below the toolbar upper corner images regardless |
282 // of how tall the toolbar itself is. | 298 // of how tall the toolbar itself is. |
283 int client_area_top = | 299 int client_area_top = |
284 frame_->client_view()->y() + browser_view_->GetToolbarBounds().y() + | 300 frame_->client_view()->y() + browser_view_->GetToolbarBounds().y() + |
285 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height(); | 301 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height(); |
286 | 302 |
287 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 303 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
288 int client_area_bottom = | 304 int client_area_bottom = |
289 std::max(client_area_top, height() - NonClientBorderThickness()); | 305 std::max(client_area_top, height() - NonClientBorderThickness()); |
290 int client_area_height = client_area_bottom - client_area_top; | 306 int client_area_height = client_area_bottom - client_area_top; |
(...skipping 13 matching lines...) Expand all Loading... |
304 SkBitmap* bottom_left = | 320 SkBitmap* bottom_left = |
305 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT); | 321 resources_->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT); |
306 canvas->DrawBitmapInt(*bottom_left, | 322 canvas->DrawBitmapInt(*bottom_left, |
307 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 323 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
308 | 324 |
309 SkBitmap* left = resources_->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT); | 325 SkBitmap* left = resources_->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT); |
310 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 326 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
311 client_area_top, left->width(), client_area_height); | 327 client_area_top, left->width(), client_area_height); |
312 } | 328 } |
313 | 329 |
314 void AeroGlassNonClientView::LayoutDistributorLogo() { | 330 void GlassBrowserFrameView::LayoutDistributorLogo() { |
315 if (distributor_logo_) { | 331 if (distributor_logo_) { |
316 logo_bounds_.SetRect(frame_->GetMinimizeButtonOffset() - | 332 logo_bounds_.SetRect(frame_->GetMinimizeButtonOffset() - |
317 distributor_logo_->width() - kLogoCaptionSpacing, kLogoTopSpacing, | 333 distributor_logo_->width() - kLogoCaptionSpacing, kLogoTopSpacing, |
318 distributor_logo_->width(), distributor_logo_->height()); | 334 distributor_logo_->width(), distributor_logo_->height()); |
319 } else { | 335 } else { |
320 logo_bounds_.SetRect(frame_->GetMinimizeButtonOffset(), kLogoTopSpacing, 0, | 336 logo_bounds_.SetRect(frame_->GetMinimizeButtonOffset(), kLogoTopSpacing, 0, |
321 0); | 337 0); |
322 } | 338 } |
323 } | 339 } |
324 | 340 |
325 void AeroGlassNonClientView::LayoutOTRAvatar() { | 341 void GlassBrowserFrameView::LayoutOTRAvatar() { |
326 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 342 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
327 int top_height = NonClientTopBorderHeight(); | 343 int top_height = NonClientTopBorderHeight(); |
328 int tabstrip_height, otr_height; | 344 int tabstrip_height, otr_height; |
329 if (browser_view_->IsTabStripVisible()) { | 345 if (browser_view_->IsTabStripVisible()) { |
330 tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; | 346 tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; |
331 otr_height = frame_->IsMaximized() ? | 347 otr_height = frame_->IsMaximized() ? |
332 (tabstrip_height - kOTRMaximizedTopSpacing) : | 348 (tabstrip_height - kOTRMaximizedTopSpacing) : |
333 otr_avatar_icon.height(); | 349 otr_avatar_icon.height(); |
334 } else { | 350 } else { |
335 tabstrip_height = otr_height = 0; | 351 tabstrip_height = otr_height = 0; |
336 } | 352 } |
337 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, | 353 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, |
338 top_height + tabstrip_height - otr_height, | 354 top_height + tabstrip_height - otr_height, |
339 otr_avatar_icon.width(), otr_height); | 355 otr_avatar_icon.width(), otr_height); |
340 } | 356 } |
341 | 357 |
342 void AeroGlassNonClientView::LayoutClientView() { | 358 void GlassBrowserFrameView::LayoutClientView() { |
343 frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(), | 359 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
344 height())); | 360 } |
| 361 |
| 362 gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width, |
| 363 int height) const { |
| 364 if (!browser_view_->IsTabStripVisible()) |
| 365 return gfx::Rect(0, 0, this->width(), this->height()); |
| 366 |
| 367 int top_height = NonClientTopBorderHeight(); |
| 368 int border_thickness = NonClientBorderThickness(); |
| 369 return gfx::Rect(border_thickness, top_height, |
| 370 std::max(0, width - (2 * border_thickness)), |
| 371 std::max(0, height - top_height - border_thickness)); |
| 372 } |
| 373 |
| 374 void GlassBrowserFrameView::StartThrobber() { |
| 375 if (!throbber_running_) { |
| 376 throbber_running_ = true; |
| 377 throbber_frame_ = 0; |
| 378 InitThrobberIcons(); |
| 379 SendMessage(frame_->GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL), |
| 380 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
| 381 } |
| 382 } |
| 383 |
| 384 void GlassBrowserFrameView::StopThrobber() { |
| 385 if (throbber_running_) |
| 386 throbber_running_ = false; |
| 387 } |
| 388 |
| 389 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
| 390 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
| 391 SendMessage(frame_->GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL), |
| 392 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
345 } | 393 } |
346 | 394 |
347 // static | 395 // static |
348 void AeroGlassNonClientView::InitClass() { | 396 void GlassBrowserFrameView::InitThrobberIcons() { |
349 static bool initialized = false; | 397 static bool initialized = false; |
350 if (!initialized) { | 398 if (!initialized) { |
351 resources_ = new AeroGlassWindowResources; | 399 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 400 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 401 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i); |
| 402 DCHECK(throbber_icons_[i]); |
| 403 } |
| 404 initialized = true; |
| 405 } |
| 406 } |
| 407 |
| 408 // static |
| 409 void GlassBrowserFrameView::InitClass() { |
| 410 static bool initialized = false; |
| 411 if (!initialized) { |
| 412 resources_ = new GlassBrowserWindowResources; |
352 | 413 |
353 #if defined(GOOGLE_CHROME_BUILD) | 414 #if defined(GOOGLE_CHROME_BUILD) |
354 distributor_logo_ = ResourceBundle::GetSharedInstance(). | 415 distributor_logo_ = ResourceBundle::GetSharedInstance(). |
355 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); | 416 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); |
356 #endif | 417 #endif |
357 | 418 |
358 initialized = true; | 419 initialized = true; |
359 } | 420 } |
360 } | 421 } |
361 | 422 |
OLD | NEW |