| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 return; | 659 return; |
| 660 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 660 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 661 ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 661 ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
| 662 toolbar_bounds.set_origin(toolbar_origin); | 662 toolbar_bounds.set_origin(toolbar_origin); |
| 663 | 663 |
| 664 int x = toolbar_bounds.x(); | 664 int x = toolbar_bounds.x(); |
| 665 int w = toolbar_bounds.width(); | 665 int w = toolbar_bounds.width(); |
| 666 int y = toolbar_bounds.y(); | 666 int y = toolbar_bounds.y(); |
| 667 int h = toolbar_bounds.height(); | 667 int h = toolbar_bounds.height(); |
| 668 | 668 |
| 669 const bool mode_material = ui::MaterialDesignController::IsModeMaterial(); |
| 670 |
| 669 // Gross hack: We split the toolbar images into two pieces, since sometimes | 671 // Gross hack: We split the toolbar images into two pieces, since sometimes |
| 670 // (popup mode) the toolbar isn't tall enough to show the whole image. The | 672 // (popup mode) the toolbar isn't tall enough to show the whole image. The |
| 671 // split happens between the top shadow section and the bottom gradient | 673 // split happens between the top shadow section and the bottom gradient |
| 672 // section so that we never break the gradient. | 674 // section so that we never break the gradient. |
| 673 int split_point = kFrameShadowThickness * 2; | 675 int split_point = kFrameShadowThickness * 2; |
| 674 int bottom_y = y + split_point; | 676 int bottom_y = y + split_point; |
| 675 ui::ThemeProvider* tp = GetThemeProvider(); | 677 ui::ThemeProvider* tp = GetThemeProvider(); |
| 676 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed( | 678 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed( |
| 677 IDR_CONTENT_TOP_LEFT_CORNER); | 679 IDR_CONTENT_TOP_LEFT_CORNER); |
| 678 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 680 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 canvas->Restore(); | 732 canvas->Restore(); |
| 731 | 733 |
| 732 canvas->DrawImageInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, | 734 canvas->DrawImageInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, |
| 733 left_x, y, toolbar_left->width(), split_point, false); | 735 left_x, y, toolbar_left->width(), split_point, false); |
| 734 canvas->DrawImageInt(*toolbar_left, 0, | 736 canvas->DrawImageInt(*toolbar_left, 0, |
| 735 toolbar_left->height() - bottom_edge_height, toolbar_left->width(), | 737 toolbar_left->height() - bottom_edge_height, toolbar_left->width(), |
| 736 bottom_edge_height, left_x, bottom_y, toolbar_left->width(), | 738 bottom_edge_height, left_x, bottom_y, toolbar_left->width(), |
| 737 bottom_edge_height, false); | 739 bottom_edge_height, false); |
| 738 | 740 |
| 739 gfx::ImageSkia* toolbar_center = | 741 gfx::ImageSkia* toolbar_center = |
| 740 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER); | 742 tp->GetImageSkiaNamed(mode_material ? |
| 743 IDR_THEME_TOOLBAR : IDR_CONTENT_TOP_CENTER); |
| 741 canvas->TileImageInt(*toolbar_center, 0, 0, left_x + toolbar_left->width(), | 744 canvas->TileImageInt(*toolbar_center, 0, 0, left_x + toolbar_left->width(), |
| 742 y, right_x - (left_x + toolbar_left->width()), | 745 y, right_x - (left_x + toolbar_left->width()), |
| 743 split_point); | 746 split_point); |
| 744 | 747 |
| 745 gfx::ImageSkia* toolbar_right = tp->GetImageSkiaNamed( | 748 gfx::ImageSkia* toolbar_right = tp->GetImageSkiaNamed( |
| 746 IDR_CONTENT_TOP_RIGHT_CORNER); | 749 IDR_CONTENT_TOP_RIGHT_CORNER); |
| 747 canvas->DrawImageInt(*toolbar_right, 0, 0, toolbar_right->width(), | 750 canvas->DrawImageInt(*toolbar_right, 0, 0, toolbar_right->width(), |
| 748 split_point, right_x, y, toolbar_right->width(), split_point, false); | 751 split_point, right_x, y, toolbar_right->width(), split_point, false); |
| 749 canvas->DrawImageInt(*toolbar_right, 0, | 752 canvas->DrawImageInt(*toolbar_right, 0, |
| 750 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 753 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
| 751 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 754 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
| 752 bottom_edge_height, false); | 755 bottom_edge_height, false); |
| 753 | 756 |
| 754 // Draw the content/toolbar separator. | 757 // Draw the content/toolbar separator. |
| 755 if (ui::MaterialDesignController::IsModeMaterial()) { | 758 if (mode_material) { |
| 756 toolbar_bounds.Inset(kClientEdgeThickness, 0); | 759 toolbar_bounds.Inset(kClientEdgeThickness, 0); |
| 757 BrowserView::Paint1pxHorizontalLine( | 760 BrowserView::Paint1pxHorizontalLine( |
| 758 canvas, | 761 canvas, |
| 759 ThemeProperties::GetDefaultColor( | 762 ThemeProperties::GetDefaultColor( |
| 760 ThemeProperties::COLOR_TOOLBAR_SEPARATOR), | 763 ThemeProperties::COLOR_TOOLBAR_SEPARATOR), |
| 761 toolbar_bounds); | 764 toolbar_bounds); |
| 762 } else { | 765 } else { |
| 763 canvas->FillRect( | 766 canvas->FillRect( |
| 764 gfx::Rect(x + kClientEdgeThickness, | 767 gfx::Rect(x + kClientEdgeThickness, |
| 765 toolbar_bounds.bottom() - kClientEdgeThickness, | 768 toolbar_bounds.bottom() - kClientEdgeThickness, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 client_area_bottom + kClientEdgeThickness - client_area_top), | 854 client_area_bottom + kClientEdgeThickness - client_area_top), |
| 852 toolbar_color); | 855 toolbar_color); |
| 853 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, | 856 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, |
| 854 client_area_bounds.width(), kClientEdgeThickness), | 857 client_area_bounds.width(), kClientEdgeThickness), |
| 855 toolbar_color); | 858 toolbar_color); |
| 856 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, | 859 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, |
| 857 kClientEdgeThickness, | 860 kClientEdgeThickness, |
| 858 client_area_bottom + kClientEdgeThickness - client_area_top), | 861 client_area_bottom + kClientEdgeThickness - client_area_top), |
| 859 toolbar_color); | 862 toolbar_color); |
| 860 } | 863 } |
| OLD | NEW |