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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "ui/views/window/window_shape.h" | 54 #include "ui/views/window/window_shape.h" |
55 | 55 |
56 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
57 #include "ui/views/controls/menu/menu_runner.h" | 57 #include "ui/views/controls/menu/menu_runner.h" |
58 #endif | 58 #endif |
59 | 59 |
60 using content::WebContents; | 60 using content::WebContents; |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
| 64 const int kContentEdgeShadowThickness = |
| 65 OpaqueBrowserFrameViewLayout::kContentEdgeShadowThickness; |
| 66 |
64 // In the window corners, the resize areas don't actually expand bigger, but the | 67 // In the window corners, the resize areas don't actually expand bigger, but the |
65 // 16 px at the end of each edge triggers diagonal resizing. | 68 // 16 px at the end of each edge triggers diagonal resizing. |
66 const int kResizeAreaCornerSize = 16; | 69 const int kResizeAreaCornerSize = 16; |
67 | 70 |
68 // The content edge images have a shadow built into them. | |
69 const int kContentEdgeShadowThickness = 2; | |
70 | |
71 #if !defined(OS_WIN) | 71 #if !defined(OS_WIN) |
72 // The icon never shrinks below 16 px on a side. | 72 // The icon never shrinks below 16 px on a side. |
73 const int kIconMinimumSize = 16; | 73 const int kIconMinimumSize = 16; |
74 #endif | 74 #endif |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 /////////////////////////////////////////////////////////////////////////////// | 78 /////////////////////////////////////////////////////////////////////////////// |
79 // OpaqueBrowserFrameView, public: | 79 // OpaqueBrowserFrameView, public: |
80 | 80 |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 } | 722 } |
723 } | 723 } |
724 | 724 |
725 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const { | 725 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const { |
726 gfx::Rect client_bounds = | 726 gfx::Rect client_bounds = |
727 layout_->CalculateClientAreaBounds(width(), height()); | 727 layout_->CalculateClientAreaBounds(width(), height()); |
728 const int x = client_bounds.x(); | 728 const int x = client_bounds.x(); |
729 int y = client_bounds.y(); | 729 int y = client_bounds.y(); |
730 const int w = client_bounds.width(); | 730 const int w = client_bounds.width(); |
731 const int right = client_bounds.right(); | 731 const int right = client_bounds.right(); |
732 const bool normal_mode = browser_view()->IsTabStripVisible(); | 732 const bool tabstrip_visible = browser_view()->IsTabStripVisible(); |
733 const bool md = ui::MaterialDesignController::IsModeMaterial(); | 733 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
734 const ui::ThemeProvider* tp = GetThemeProvider(); | 734 const ui::ThemeProvider* tp = GetThemeProvider(); |
735 const SkColor toolbar_color = | 735 const SkColor toolbar_color = |
736 normal_mode | 736 tabstrip_visible |
737 ? tp->GetColor(ThemeProperties::COLOR_TOOLBAR) | 737 ? tp->GetColor(ThemeProperties::COLOR_TOOLBAR) |
738 : ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, | 738 : ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, |
739 browser_view()->IsOffTheRecord()); | 739 browser_view()->IsOffTheRecord()); |
740 | 740 |
741 const gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 741 const gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
742 int img_y_offset = 0; | 742 int img_y_offset = 0; |
743 if (normal_mode) { | 743 if (tabstrip_visible) { |
744 // Pre-Material Design, the client edge images start below the toolbar. In | 744 // Pre-Material Design, the client edge images start below the toolbar. In |
745 // MD the client edge images start at the top of the toolbar. | 745 // MD the client edge images start at the top of the toolbar. |
746 y += md ? toolbar_bounds.y() : toolbar_bounds.bottom(); | 746 y += md ? toolbar_bounds.y() : toolbar_bounds.bottom(); |
747 } else { | 747 } else { |
748 // The toolbar isn't going to draw a top edge for us, so draw one ourselves. | 748 // The toolbar isn't going to draw a top edge for us, so draw one ourselves. |
749 if (IsToolbarVisible()) { | 749 if (IsToolbarVisible()) { |
750 y += toolbar_bounds.y() + kContentEdgeShadowThickness + | 750 y += toolbar_bounds.y() + kClientEdgeThickness; |
751 kClientEdgeThickness; | |
752 } | 751 } |
753 client_bounds.set_y(y); | 752 client_bounds.set_y(y); |
754 client_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness, | 753 client_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness, |
755 -kClientEdgeThickness, client_bounds.height()); | 754 -kClientEdgeThickness, client_bounds.height()); |
756 if (md) { | 755 if (md) { |
757 img_y_offset = -kClientEdgeThickness; | 756 img_y_offset = -kClientEdgeThickness; |
758 | 757 |
759 // Edge. | 758 // Edge. |
760 BrowserView::Paint1pxHorizontalLine(canvas, toolbar_color, client_bounds, | 759 BrowserView::Paint1pxHorizontalLine(canvas, toolbar_color, client_bounds, |
761 false); | 760 false); |
(...skipping 20 matching lines...) Expand all Loading... |
782 img_w, height, right, top_y, img_w, height, false); | 781 img_w, height, right, top_y, img_w, height, false); |
783 } | 782 } |
784 } | 783 } |
785 | 784 |
786 // In maximized mode, the only edge to draw is the top one, so we're done. | 785 // In maximized mode, the only edge to draw is the top one, so we're done. |
787 if (layout_->IsTitleBarCondensed()) | 786 if (layout_->IsTitleBarCondensed()) |
788 return; | 787 return; |
789 | 788 |
790 const int img_y = y + img_y_offset; | 789 const int img_y = y + img_y_offset; |
791 const int bottom = std::max(y, height() - NonClientBorderThickness()); | 790 const int bottom = std::max(y, height() - NonClientBorderThickness()); |
792 int height = bottom - img_y; | 791 const int height = bottom - y; |
| 792 const int img_h = bottom - img_y; |
793 | 793 |
794 // Draw the client edge images. For non-MD, we fill the toolbar color | 794 // Draw the client edge images. For non-MD, we fill the toolbar color |
795 // underneath these images so they will lighten/darken it appropriately to | 795 // underneath these images so they will lighten/darken it appropriately to |
796 // create a "3D shaded" effect. For MD, where we want a flatter appearance, | 796 // create a "3D shaded" effect. For MD, where we want a flatter appearance, |
797 // we do the filling afterwards so the user sees the unmodified toolbar color. | 797 // we do the filling afterwards so the user sees the unmodified toolbar color. |
798 if (!md) | 798 if (!md) |
799 FillClientEdgeRects(x, y, right, bottom, toolbar_color, canvas); | 799 FillClientEdgeRects(x, y, w, height, toolbar_color, canvas); |
800 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); | 800 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); |
801 const int img_w = right_image->width(); | 801 const int img_w = right_image->width(); |
802 canvas->TileImageInt(*right_image, right, img_y, img_w, height); | 802 canvas->TileImageInt(*right_image, right, img_y, img_w, img_h); |
803 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 803 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
804 right, bottom); | 804 right, bottom); |
805 gfx::ImageSkia* bottom_image = | 805 gfx::ImageSkia* bottom_image = |
806 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); | 806 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); |
807 canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height()); | 807 canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height()); |
808 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER), | 808 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER), |
809 x - img_w, bottom); | 809 x - img_w, bottom); |
810 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE), x - img_w, | 810 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE), x - img_w, |
811 img_y, img_w, height); | 811 img_y, img_w, img_h); |
812 if (md) | 812 if (md) |
813 FillClientEdgeRects(x, y, right, bottom, toolbar_color, canvas); | 813 FillClientEdgeRects(x, y, w, height, toolbar_color, canvas); |
814 } | 814 } |
815 | 815 |
816 void OpaqueBrowserFrameView::FillClientEdgeRects(int x, | 816 void OpaqueBrowserFrameView::FillClientEdgeRects(int x, |
817 int y, | 817 int y, |
818 int right, | 818 int w, |
819 int bottom, | 819 int h, |
820 SkColor color, | 820 SkColor color, |
821 gfx::Canvas* canvas) const { | 821 gfx::Canvas* canvas) const { |
822 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, | 822 x -= kClientEdgeThickness; |
823 bottom + kClientEdgeThickness - y); | 823 gfx::Rect side(x, y, kClientEdgeThickness, h); |
824 canvas->FillRect(side, color); | 824 canvas->FillRect(side, color); |
825 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), | 825 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), |
| 826 kClientEdgeThickness), |
826 color); | 827 color); |
827 side.set_x(right); | 828 side.Offset(w + kClientEdgeThickness, 0); |
828 canvas->FillRect(side, color); | 829 canvas->FillRect(side, color); |
829 } | 830 } |
OLD | NEW |