OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glass_browser_frame_view.h" | 5 #include "chrome/browser/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "app/theme_provider.h" | 9 #include "app/theme_provider.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 GlassBrowserFrameView::~GlassBrowserFrameView() { | 78 GlassBrowserFrameView::~GlassBrowserFrameView() { |
79 } | 79 } |
80 | 80 |
81 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
82 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 82 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
83 | 83 |
84 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 84 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
85 BaseTabStrip* tabstrip) const { | 85 BaseTabStrip* tabstrip) const { |
86 if (browser_view_->UsingSideTabs()) { | 86 if (browser_view_->UseVerticalTabs()) { |
87 gfx::Size ps = tabstrip->GetPreferredSize(); | 87 gfx::Size ps = tabstrip->GetPreferredSize(); |
88 return gfx::Rect(0, NonClientTopBorderHeight(), ps.width(), | 88 return gfx::Rect(0, NonClientTopBorderHeight(), ps.width(), |
89 browser_view_->height()); | 89 browser_view_->height()); |
90 } | 90 } |
91 int minimize_button_offset = frame_->GetMinimizeButtonOffset(); | 91 int minimize_button_offset = frame_->GetMinimizeButtonOffset(); |
92 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 92 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
93 (otr_avatar_bounds_.right() + kOTRSideSpacing) : | 93 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
94 NonClientBorderThickness(); | 94 NonClientBorderThickness(); |
95 // minimize_button_offset assumes LTR layout since the window controls | 95 // minimize_button_offset assumes LTR layout since the window controls |
96 // themselves are not flipped, so we need to adjust the tabstrip's x | 96 // themselves are not flipped, so we need to adjust the tabstrip's x |
(...skipping 16 matching lines...) Expand all Loading... |
113 DisplayNextThrobberFrame(); | 113 DisplayNextThrobberFrame(); |
114 } else { | 114 } else { |
115 StopThrobber(); | 115 StopThrobber(); |
116 } | 116 } |
117 } else if (running) { | 117 } else if (running) { |
118 StartThrobber(); | 118 StartThrobber(); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 void GlassBrowserFrameView::PaintTabStripShadow(gfx::Canvas* canvas) { | 122 void GlassBrowserFrameView::PaintTabStripShadow(gfx::Canvas* canvas) { |
| 123 if (!browser_view_->UseVerticalTabs()) |
| 124 return; |
| 125 |
123 ThemeProvider* tp = GetThemeProvider(); | 126 ThemeProvider* tp = GetThemeProvider(); |
124 SkBitmap* shadow_top = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_TOP); | 127 SkBitmap* shadow_top = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_TOP); |
125 SkBitmap* shadow_middle = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_MIDDLE); | 128 SkBitmap* shadow_middle = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_MIDDLE); |
126 SkBitmap* shadow_bottom = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_BOTTOM); | 129 SkBitmap* shadow_bottom = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_BOTTOM); |
127 | 130 |
128 gfx::Rect bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); | 131 gfx::Rect bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); |
129 canvas->DrawBitmapInt(*shadow_top, bounds.right() - 2 * shadow_top->width(), | 132 canvas->DrawBitmapInt(*shadow_top, bounds.right() - 2 * shadow_top->width(), |
130 bounds.y()); | 133 bounds.y()); |
131 canvas->TileImageInt( | 134 canvas->TileImageInt( |
132 *shadow_middle, bounds.right() - 2 * shadow_middle->width(), | 135 *shadow_middle, bounds.right() - 2 * shadow_middle->width(), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 return (window->IsMaximized() || window->IsFullscreen()) ? | 238 return (window->IsMaximized() || window->IsFullscreen()) ? |
236 0 : kNonClientBorderThickness; | 239 0 : kNonClientBorderThickness; |
237 } | 240 } |
238 | 241 |
239 int GlassBrowserFrameView::NonClientTopBorderHeight() const { | 242 int GlassBrowserFrameView::NonClientTopBorderHeight() const { |
240 if (frame_->GetWindow()->IsFullscreen()) | 243 if (frame_->GetWindow()->IsFullscreen()) |
241 return 0; | 244 return 0; |
242 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 245 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass |
243 // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border | 246 // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border |
244 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 247 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
245 const int kRestoredHeight = browser_view_->UsingSideTabs() ? | 248 const int kRestoredHeight = browser_view_->UseVerticalTabs() ? |
246 -2 : kNonClientRestoredExtraThickness; | 249 -2 : kNonClientRestoredExtraThickness; |
247 return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? | 250 return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? |
248 -kTabstripTopShadowThickness : kRestoredHeight); | 251 -kTabstripTopShadowThickness : kRestoredHeight); |
249 } | 252 } |
250 | 253 |
251 void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) { | 254 void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) { |
252 // The distributor logo is only painted when the frame is not maximized and | 255 // The distributor logo is only painted when the frame is not maximized and |
253 // when we actually have a logo. | 256 // when we actually have a logo. |
254 if (!frame_->GetWindow()->IsMaximized() && distributor_logo_ && | 257 if (!frame_->GetWindow()->IsMaximized() && distributor_logo_ && |
255 browser_view_->ShouldShowDistributorLogo()) { | 258 browser_view_->ShouldShowDistributorLogo()) { |
(...skipping 11 matching lines...) Expand all Loading... |
267 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 270 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
268 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 271 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
269 View::ConvertPointToView(frame_->GetWindow()->GetClientView(), | 272 View::ConvertPointToView(frame_->GetWindow()->GetClientView(), |
270 this, &toolbar_origin); | 273 this, &toolbar_origin); |
271 toolbar_bounds.set_origin(toolbar_origin); | 274 toolbar_bounds.set_origin(toolbar_origin); |
272 | 275 |
273 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 276 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); |
274 | 277 |
275 // Draw the toolbar background, setting src_y of the paint to the tab | 278 // Draw the toolbar background, setting src_y of the paint to the tab |
276 // strip height as the toolbar background begins at the top of the tabs. | 279 // strip height as the toolbar background begins at the top of the tabs. |
277 int src_y = browser_view_->UsingSideTabs() | 280 int src_y = browser_view_->UseVerticalTabs() |
278 ? TabRenderer::GetMinimumUnselectedSize().height() | 281 ? TabRenderer::GetMinimumUnselectedSize().height() |
279 : browser_view_->GetTabStripHeight() - 1; | 282 : browser_view_->GetTabStripHeight() - 1; |
280 canvas->TileImageInt(*theme_toolbar, 0, src_y, | 283 canvas->TileImageInt(*theme_toolbar, 0, src_y, |
281 toolbar_bounds.x() - 1, toolbar_bounds.y() + 2, | 284 toolbar_bounds.x() - 1, toolbar_bounds.y() + 2, |
282 toolbar_bounds.width() + 2, theme_toolbar->height()); | 285 toolbar_bounds.width() + 2, theme_toolbar->height()); |
283 | 286 |
284 SkBitmap* toolbar_left = | 287 SkBitmap* toolbar_left = |
285 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 288 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
286 canvas->DrawBitmapInt(*toolbar_left, | 289 canvas->DrawBitmapInt(*toolbar_left, |
287 toolbar_bounds.x() - toolbar_left->width(), | 290 toolbar_bounds.x() - toolbar_left->width(), |
(...skipping 29 matching lines...) Expand all Loading... |
317 ThemeProvider* tp = GetThemeProvider(); | 320 ThemeProvider* tp = GetThemeProvider(); |
318 | 321 |
319 // The client edges start below the toolbar upper corner images regardless | 322 // The client edges start below the toolbar upper corner images regardless |
320 // of how tall the toolbar itself is. | 323 // of how tall the toolbar itself is. |
321 int client_area_top = | 324 int client_area_top = |
322 frame_->GetWindow()->GetClientView()->y() + | 325 frame_->GetWindow()->GetClientView()->y() + |
323 browser_view_->GetToolbarBounds().y() + | 326 browser_view_->GetToolbarBounds().y() + |
324 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); | 327 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
325 | 328 |
326 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 329 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
327 if (browser_view_->UsingSideTabs()) { | 330 if (browser_view_->UseVerticalTabs()) { |
328 client_area_bounds.Inset( | 331 client_area_bounds.Inset( |
329 GetBoundsForTabStrip(browser_view_->tabstrip()).width() - 4, 0, 0, 0); | 332 GetBoundsForTabStrip(browser_view_->tabstrip()).width() - 4, 0, 0, 0); |
330 } | 333 } |
331 | 334 |
332 int client_area_bottom = | 335 int client_area_bottom = |
333 std::max(client_area_top, height() - NonClientBorderThickness()); | 336 std::max(client_area_top, height() - NonClientBorderThickness()); |
334 int client_area_height = client_area_bottom - client_area_top; | 337 int client_area_height = client_area_bottom - client_area_top; |
335 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 338 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
336 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, | 339 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, |
337 right->width(), client_area_height); | 340 right->width(), client_area_height); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 static bool initialized = false; | 484 static bool initialized = false; |
482 if (!initialized) { | 485 if (!initialized) { |
483 #if defined(GOOGLE_CHROME_BUILD) | 486 #if defined(GOOGLE_CHROME_BUILD) |
484 distributor_logo_ = ResourceBundle::GetSharedInstance(). | 487 distributor_logo_ = ResourceBundle::GetSharedInstance(). |
485 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); | 488 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); |
486 #endif | 489 #endif |
487 | 490 |
488 initialized = true; | 491 initialized = true; |
489 } | 492 } |
490 } | 493 } |
OLD | NEW |