| OLD | NEW |
| 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 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
| 9 #include "chrome/browser/themes/theme_service_factory.h" | 9 #include "chrome/browser/themes/theme_service_factory.h" |
| 10 #include "chrome/browser/ui/layout_constants.h" | 10 #include "chrome/browser/ui/layout_constants.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 /////////////////////////////////////////////////////////////////////////////// | 407 /////////////////////////////////////////////////////////////////////////////// |
| 408 // OpaqueBrowserFrameView, protected: | 408 // OpaqueBrowserFrameView, protected: |
| 409 | 409 |
| 410 // views::View: | 410 // views::View: |
| 411 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 411 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
| 412 if (frame()->IsFullscreen()) | 412 if (frame()->IsFullscreen()) |
| 413 return; // Nothing is visible, so don't bother to paint. | 413 return; // Nothing is visible, so don't bother to paint. |
| 414 | 414 |
| 415 frame_background_->set_frame_color(GetFrameColor()); |
| 416 frame_background_->set_is_active(ShouldPaintAsActive()); |
| 417 frame_background_->set_incognito(browser_view()->IsIncognito()); |
| 418 frame_background_->set_theme_image(GetFrameImage()); |
| 419 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
| 420 frame_background_->set_top_area_height(GetTopAreaHeight()); |
| 421 |
| 415 if (layout_->IsTitleBarCondensed()) | 422 if (layout_->IsTitleBarCondensed()) |
| 416 PaintMaximizedFrameBorder(canvas); | 423 PaintMaximizedFrameBorder(canvas); |
| 417 else | 424 else |
| 418 PaintRestoredFrameBorder(canvas); | 425 PaintRestoredFrameBorder(canvas); |
| 419 | 426 |
| 420 // The window icon and title are painted by their respective views. | 427 // The window icon and title are painted by their respective views. |
| 421 /* TODO(pkasting): If this window is active, we should also draw a drop | 428 /* TODO(pkasting): If this window is active, we should also draw a drop |
| 422 * shadow on the title. This is tricky, because we don't want to hardcode a | 429 * shadow on the title. This is tricky, because we don't want to hardcode a |
| 423 * shadow color (since we want to work with various themes), but we can't | 430 * shadow color (since we want to work with various themes), but we can't |
| 424 * alpha-blend either (since the Windows text APIs don't really do this). | 431 * alpha-blend either (since the Windows text APIs don't really do this). |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 501 |
| 495 // Do not show caption buttons if the window manager is forcefully providing a | 502 // Do not show caption buttons if the window manager is forcefully providing a |
| 496 // title bar (e.g., in Ubuntu Unity, if the window is maximized). | 503 // title bar (e.g., in Ubuntu Unity, if the window is maximized). |
| 497 if (!views::ViewsDelegate::GetInstance()) | 504 if (!views::ViewsDelegate::GetInstance()) |
| 498 return true; | 505 return true; |
| 499 return !views::ViewsDelegate::GetInstance()->WindowManagerProvidesTitleBar( | 506 return !views::ViewsDelegate::GetInstance()->WindowManagerProvidesTitleBar( |
| 500 IsMaximized()); | 507 IsMaximized()); |
| 501 } | 508 } |
| 502 | 509 |
| 503 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 510 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
| 504 // The top area height in dp (only used when there's no frame image). | |
| 505 // TODO(pkasting): investigate removing this constant. See crbug.com/590301 | |
| 506 const int kHeight = 64; | |
| 507 const gfx::ImageSkia frame_image = GetFrameImage(); | 511 const gfx::ImageSkia frame_image = GetFrameImage(); |
| 508 int top_area_height = frame_image.isNull() ? kHeight : frame_image.height(); | 512 int top_area_height = frame_image.height(); // Returns 0 if isNull() |
| 509 if (browser_view()->IsTabStripVisible()) { | 513 if (browser_view()->IsTabStripVisible()) { |
| 510 top_area_height = | 514 top_area_height = |
| 511 std::max(top_area_height, | 515 std::max(top_area_height, |
| 512 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 516 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
| 513 } | 517 } |
| 514 return top_area_height; | 518 return top_area_height; |
| 515 } | 519 } |
| 516 | 520 |
| 517 void OpaqueBrowserFrameView::PaintRestoredFrameBorder( | 521 void OpaqueBrowserFrameView::PaintRestoredFrameBorder( |
| 518 gfx::Canvas* canvas) const { | 522 gfx::Canvas* canvas) const { |
| 519 frame_background_->set_frame_color(GetFrameColor()); | |
| 520 frame_background_->set_theme_image(GetFrameImage()); | |
| 521 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | |
| 522 frame_background_->set_top_area_height(GetTopAreaHeight()); | |
| 523 | |
| 524 const ui::ThemeProvider* tp = GetThemeProvider(); | 523 const ui::ThemeProvider* tp = GetThemeProvider(); |
| 525 frame_background_->SetSideImages( | 524 frame_background_->SetSideImages( |
| 526 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 525 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
| 527 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 526 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
| 528 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), | 527 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), |
| 529 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); | 528 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); |
| 530 frame_background_->SetCornerImages( | 529 frame_background_->SetCornerImages( |
| 531 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), | 530 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), |
| 532 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), | 531 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), |
| 533 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), | 532 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), |
| 534 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); | 533 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); |
| 535 frame_background_->PaintRestored(canvas, this); | 534 frame_background_->PaintRestored(canvas, this); |
| 536 | 535 |
| 537 // Note: When we don't have a toolbar, we need to draw some kind of bottom | 536 // Note: When we don't have a toolbar, we need to draw some kind of bottom |
| 538 // edge here. Because the App Window graphics we use for this have an | 537 // edge here. Because the App Window graphics we use for this have an |
| 539 // attached client edge and their sizing algorithm is a little involved, we do | 538 // attached client edge and their sizing algorithm is a little involved, we do |
| 540 // all this in PaintRestoredClientEdge(). | 539 // all this in PaintRestoredClientEdge(). |
| 541 } | 540 } |
| 542 | 541 |
| 543 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder( | 542 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder( |
| 544 gfx::Canvas* canvas) const { | 543 gfx::Canvas* canvas) const { |
| 545 frame_background_->set_frame_color(GetFrameColor()); | |
| 546 frame_background_->set_theme_image(GetFrameImage()); | |
| 547 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | |
| 548 frame_background_->set_top_area_height(GetTopAreaHeight()); | |
| 549 frame_background_->set_maximized_top_inset( | 544 frame_background_->set_maximized_top_inset( |
| 550 GetTopInset(true) - GetTopInset(false)); | 545 GetTopInset(true) - GetTopInset(false)); |
| 551 frame_background_->PaintMaximized(canvas, this); | 546 frame_background_->PaintMaximized(canvas, this); |
| 552 } | 547 } |
| 553 | 548 |
| 554 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { | 549 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { |
| 555 // TODO(estade): can this be shared with OpaqueBrowserFrameView? | 550 // TODO(estade): can this be shared with OpaqueBrowserFrameView? |
| 556 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 551 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 557 if (toolbar_bounds.IsEmpty()) | 552 if (toolbar_bounds.IsEmpty()) |
| 558 return; | 553 return; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 gfx::Rect side(x, y, kClientEdgeThickness, h); | 661 gfx::Rect side(x, y, kClientEdgeThickness, h); |
| 667 canvas->FillRect(side, color); | 662 canvas->FillRect(side, color); |
| 668 if (draw_bottom) { | 663 if (draw_bottom) { |
| 669 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), | 664 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), |
| 670 kClientEdgeThickness), | 665 kClientEdgeThickness), |
| 671 color); | 666 color); |
| 672 } | 667 } |
| 673 side.Offset(w + kClientEdgeThickness, 0); | 668 side.Offset(w + kClientEdgeThickness, 0); |
| 674 canvas->FillRect(side, color); | 669 canvas->FillRect(side, color); |
| 675 } | 670 } |
| OLD | NEW |