| 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_->UseVerticalTabs()) { | 86 if (browser_view_->UsingSideTabs()) { |
| 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 | |
| 126 ThemeProvider* tp = GetThemeProvider(); | 123 ThemeProvider* tp = GetThemeProvider(); |
| 127 SkBitmap* shadow_top = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_TOP); | 124 SkBitmap* shadow_top = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_TOP); |
| 128 SkBitmap* shadow_middle = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_MIDDLE); | 125 SkBitmap* shadow_middle = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_MIDDLE); |
| 129 SkBitmap* shadow_bottom = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_BOTTOM); | 126 SkBitmap* shadow_bottom = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_BOTTOM); |
| 130 | 127 |
| 131 gfx::Rect bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); | 128 gfx::Rect bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); |
| 132 canvas->DrawBitmapInt(*shadow_top, bounds.right() - 2 * shadow_top->width(), | 129 canvas->DrawBitmapInt(*shadow_top, bounds.right() - 2 * shadow_top->width(), |
| 133 bounds.y()); | 130 bounds.y()); |
| 134 canvas->TileImageInt( | 131 canvas->TileImageInt( |
| 135 *shadow_middle, bounds.right() - 2 * shadow_middle->width(), | 132 *shadow_middle, bounds.right() - 2 * shadow_middle->width(), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return (window->IsMaximized() || window->IsFullscreen()) ? | 235 return (window->IsMaximized() || window->IsFullscreen()) ? |
| 239 0 : kNonClientBorderThickness; | 236 0 : kNonClientBorderThickness; |
| 240 } | 237 } |
| 241 | 238 |
| 242 int GlassBrowserFrameView::NonClientTopBorderHeight() const { | 239 int GlassBrowserFrameView::NonClientTopBorderHeight() const { |
| 243 if (frame_->GetWindow()->IsFullscreen()) | 240 if (frame_->GetWindow()->IsFullscreen()) |
| 244 return 0; | 241 return 0; |
| 245 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 242 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass |
| 246 // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border | 243 // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border |
| 247 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 244 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
| 248 const int kRestoredHeight = browser_view_->UseVerticalTabs() ? | 245 const int kRestoredHeight = browser_view_->UsingSideTabs() ? |
| 249 -2 : kNonClientRestoredExtraThickness; | 246 -2 : kNonClientRestoredExtraThickness; |
| 250 return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? | 247 return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? |
| 251 -kTabstripTopShadowThickness : kRestoredHeight); | 248 -kTabstripTopShadowThickness : kRestoredHeight); |
| 252 } | 249 } |
| 253 | 250 |
| 254 void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) { | 251 void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) { |
| 255 // 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 |
| 256 // when we actually have a logo. | 253 // when we actually have a logo. |
| 257 if (!frame_->GetWindow()->IsMaximized() && distributor_logo_ && | 254 if (!frame_->GetWindow()->IsMaximized() && distributor_logo_ && |
| 258 browser_view_->ShouldShowDistributorLogo()) { | 255 browser_view_->ShouldShowDistributorLogo()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 270 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 267 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 271 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 268 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 272 View::ConvertPointToView(frame_->GetWindow()->GetClientView(), | 269 View::ConvertPointToView(frame_->GetWindow()->GetClientView(), |
| 273 this, &toolbar_origin); | 270 this, &toolbar_origin); |
| 274 toolbar_bounds.set_origin(toolbar_origin); | 271 toolbar_bounds.set_origin(toolbar_origin); |
| 275 | 272 |
| 276 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 273 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); |
| 277 | 274 |
| 278 // Draw the toolbar background, setting src_y of the paint to the tab | 275 // Draw the toolbar background, setting src_y of the paint to the tab |
| 279 // strip height as the toolbar background begins at the top of the tabs. | 276 // strip height as the toolbar background begins at the top of the tabs. |
| 280 int src_y = browser_view_->UseVerticalTabs() | 277 int src_y = browser_view_->UsingSideTabs() |
| 281 ? TabRenderer::GetMinimumUnselectedSize().height() | 278 ? TabRenderer::GetMinimumUnselectedSize().height() |
| 282 : browser_view_->GetTabStripHeight() - 1; | 279 : browser_view_->GetTabStripHeight() - 1; |
| 283 canvas->TileImageInt(*theme_toolbar, 0, src_y, | 280 canvas->TileImageInt(*theme_toolbar, 0, src_y, |
| 284 toolbar_bounds.x() - 1, toolbar_bounds.y() + 2, | 281 toolbar_bounds.x() - 1, toolbar_bounds.y() + 2, |
| 285 toolbar_bounds.width() + 2, theme_toolbar->height()); | 282 toolbar_bounds.width() + 2, theme_toolbar->height()); |
| 286 | 283 |
| 287 SkBitmap* toolbar_left = | 284 SkBitmap* toolbar_left = |
| 288 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 285 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
| 289 canvas->DrawBitmapInt(*toolbar_left, | 286 canvas->DrawBitmapInt(*toolbar_left, |
| 290 toolbar_bounds.x() - toolbar_left->width(), | 287 toolbar_bounds.x() - toolbar_left->width(), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 320 ThemeProvider* tp = GetThemeProvider(); | 317 ThemeProvider* tp = GetThemeProvider(); |
| 321 | 318 |
| 322 // The client edges start below the toolbar upper corner images regardless | 319 // The client edges start below the toolbar upper corner images regardless |
| 323 // of how tall the toolbar itself is. | 320 // of how tall the toolbar itself is. |
| 324 int client_area_top = | 321 int client_area_top = |
| 325 frame_->GetWindow()->GetClientView()->y() + | 322 frame_->GetWindow()->GetClientView()->y() + |
| 326 browser_view_->GetToolbarBounds().y() + | 323 browser_view_->GetToolbarBounds().y() + |
| 327 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); | 324 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
| 328 | 325 |
| 329 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 326 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 330 if (browser_view_->UseVerticalTabs()) { | 327 if (browser_view_->UsingSideTabs()) { |
| 331 client_area_bounds.Inset( | 328 client_area_bounds.Inset( |
| 332 GetBoundsForTabStrip(browser_view_->tabstrip()).width() - 4, 0, 0, 0); | 329 GetBoundsForTabStrip(browser_view_->tabstrip()).width() - 4, 0, 0, 0); |
| 333 } | 330 } |
| 334 | 331 |
| 335 int client_area_bottom = | 332 int client_area_bottom = |
| 336 std::max(client_area_top, height() - NonClientBorderThickness()); | 333 std::max(client_area_top, height() - NonClientBorderThickness()); |
| 337 int client_area_height = client_area_bottom - client_area_top; | 334 int client_area_height = client_area_bottom - client_area_top; |
| 338 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 335 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
| 339 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, | 336 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, |
| 340 right->width(), client_area_height); | 337 right->width(), client_area_height); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 static bool initialized = false; | 481 static bool initialized = false; |
| 485 if (!initialized) { | 482 if (!initialized) { |
| 486 #if defined(GOOGLE_CHROME_BUILD) | 483 #if defined(GOOGLE_CHROME_BUILD) |
| 487 distributor_logo_ = ResourceBundle::GetSharedInstance(). | 484 distributor_logo_ = ResourceBundle::GetSharedInstance(). |
| 488 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); | 485 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); |
| 489 #endif | 486 #endif |
| 490 | 487 |
| 491 initialized = true; | 488 initialized = true; |
| 492 } | 489 } |
| 493 } | 490 } |
| OLD | NEW |