OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
10 #include "ash/frame/default_header_painter.h" | 10 #include "ash/frame/default_header_painter.h" |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 if (toolbar_bounds.IsEmpty()) | 626 if (toolbar_bounds.IsEmpty()) |
627 return; | 627 return; |
628 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 628 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
629 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 629 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
630 toolbar_bounds.set_origin(toolbar_origin); | 630 toolbar_bounds.set_origin(toolbar_origin); |
631 | 631 |
632 int x = toolbar_bounds.x(); | 632 int x = toolbar_bounds.x(); |
633 int w = toolbar_bounds.width(); | 633 int w = toolbar_bounds.width(); |
634 int y = toolbar_bounds.y(); | 634 int y = toolbar_bounds.y(); |
635 int h = toolbar_bounds.height(); | 635 int h = toolbar_bounds.height(); |
636 | |
637 // Gross hack: We split the toolbar images into two pieces, since sometimes | |
638 // (popup mode) the toolbar isn't tall enough to show the whole image. The | |
639 // split happens between the top shadow section and the bottom gradient | |
640 // section so that we never break the gradient. | |
641 // NOTE(pkotwicz): If the computation for |bottom_y| is changed, Layout() must | |
642 // be changed as well. | |
643 int split_point = kFrameShadowThickness * 2; | |
644 int bottom_y = y + split_point; | |
645 ui::ThemeProvider* tp = GetThemeProvider(); | 636 ui::ThemeProvider* tp = GetThemeProvider(); |
646 int bottom_edge_height = h - split_point; | |
647 | |
648 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), | |
649 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); | |
650 | |
651 // Paint the main toolbar image. Since this image is also used to draw the | |
652 // tab background, we must use the tab strip offset to compute the image | |
653 // source y position. If you have to debug this code use an image editor | |
654 // to paint a diagonal line through the toolbar image and ensure it lines up | |
655 // across the tab and toolbar. | |
656 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | |
657 canvas->TileImageInt( | |
658 *theme_toolbar, | |
659 x + GetThemeBackgroundXInset(), | |
660 bottom_y - GetTopInset(), | |
661 x, bottom_y, | |
662 w, theme_toolbar->height()); | |
663 | 637 |
664 if (ui::MaterialDesignController::IsModeMaterial()) { | 638 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 639 // Paint the main toolbar image. Since this image is also used to draw the |
| 640 // tab background, we must use the tab strip offset to compute the image |
| 641 // source y position. If you have to debug this code use an image editor |
| 642 // to paint a diagonal line through the toolbar image and ensure it lines up |
| 643 // across the tab and toolbar. |
| 644 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 645 canvas->TileImageInt( |
| 646 *theme_toolbar, |
| 647 x + GetThemeBackgroundXInset(), |
| 648 y - GetTopInset(), |
| 649 x, y, |
| 650 w, theme_toolbar->height()); |
| 651 |
665 // Draw the content/toolbar separator. | 652 // Draw the content/toolbar separator. |
666 toolbar_bounds.Inset(kClientEdgeThickness, 0); | 653 toolbar_bounds.Inset(kClientEdgeThickness, 0); |
667 BrowserView::Paint1pxHorizontalLine( | 654 BrowserView::Paint1pxHorizontalLine( |
668 canvas, | 655 canvas, |
669 ThemeProperties::GetDefaultColor( | 656 ThemeProperties::GetDefaultColor( |
670 ThemeProperties::COLOR_TOOLBAR_SEPARATOR), | 657 ThemeProperties::COLOR_TOOLBAR_SEPARATOR), |
671 toolbar_bounds); | 658 toolbar_bounds); |
672 } else { | 659 } else { |
| 660 // Gross hack: We split the toolbar images into two pieces, since sometimes |
| 661 // (popup mode) the toolbar isn't tall enough to show the whole image. The |
| 662 // split happens between the top shadow section and the bottom gradient |
| 663 // section so that we never break the gradient. |
| 664 // NOTE(pkotwicz): If the computation for |bottom_y| is changed, Layout() |
| 665 // must be changed as well. |
| 666 int split_point = kFrameShadowThickness * 2; |
| 667 int bottom_y = y + split_point; |
| 668 int bottom_edge_height = h - split_point; |
| 669 |
| 670 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), |
| 671 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 672 |
| 673 // Paint the main toolbar image. Since this image is also used to draw the |
| 674 // tab background, we must use the tab strip offset to compute the image |
| 675 // source y position. If you have to debug this code use an image editor |
| 676 // to paint a diagonal line through the toolbar image and ensure it lines up |
| 677 // across the tab and toolbar. |
| 678 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 679 canvas->TileImageInt( |
| 680 *theme_toolbar, |
| 681 x + GetThemeBackgroundXInset(), |
| 682 bottom_y - GetTopInset(), |
| 683 x, bottom_y, |
| 684 w, theme_toolbar->height()); |
| 685 |
673 // The pre-material design content area line has a shadow that extends a | 686 // The pre-material design content area line has a shadow that extends a |
674 // couple of pixels above the toolbar bounds. | 687 // couple of pixels above the toolbar bounds. |
675 const int kContentShadowHeight = 2; | 688 const int kContentShadowHeight = 2; |
676 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); | 689 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); |
677 canvas->TileImageInt(*toolbar_top, | 690 canvas->TileImageInt(*toolbar_top, |
678 0, 0, | 691 0, 0, |
679 x, y - kContentShadowHeight, | 692 x, y - kContentShadowHeight, |
680 w, split_point + kContentShadowHeight + 1); | 693 w, split_point + kContentShadowHeight + 1); |
681 | 694 |
682 // Draw the "lightening" shade line around the edges of the toolbar. | 695 // Draw the "lightening" shade line around the edges of the toolbar. |
(...skipping 23 matching lines...) Expand all Loading... |
706 } | 719 } |
707 } | 720 } |
708 | 721 |
709 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 722 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
710 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); | 723 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
711 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 724 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
712 width(), kClientEdgeThickness), | 725 width(), kClientEdgeThickness), |
713 ThemeProperties::GetDefaultColor( | 726 ThemeProperties::GetDefaultColor( |
714 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 727 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
715 } | 728 } |
OLD | NEW |