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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 #endif | 58 #endif |
59 | 59 |
60 using content::WebContents; | 60 using content::WebContents; |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
64 // In the window corners, the resize areas don't actually expand bigger, but the | 64 // 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. | 65 // 16 px at the end of each edge triggers diagonal resizing. |
66 const int kResizeAreaCornerSize = 16; | 66 const int kResizeAreaCornerSize = 16; |
67 | 67 |
68 // The content edge images have a shadow built into them. | |
69 const int kContentEdgeShadowThickness = 2; | |
70 | |
71 #if !defined(OS_WIN) | 68 #if !defined(OS_WIN) |
72 // The icon never shrinks below 16 px on a side. | 69 // The icon never shrinks below 16 px on a side. |
73 const int kIconMinimumSize = 16; | 70 const int kIconMinimumSize = 16; |
74 #endif | 71 #endif |
75 | 72 |
76 } // namespace | 73 } // namespace |
77 | 74 |
78 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
79 // OpaqueBrowserFrameView, public: | 76 // OpaqueBrowserFrameView, public: |
80 | 77 |
78 // static | |
79 int OpaqueBrowserFrameView::kContentEdgeShadowThickness = 2; | |
80 | |
81 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, | 81 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, |
82 BrowserView* browser_view) | 82 BrowserView* browser_view) |
83 : BrowserNonClientFrameView(frame, browser_view), | 83 : BrowserNonClientFrameView(frame, browser_view), |
84 layout_(new OpaqueBrowserFrameViewLayout(this)), | 84 layout_(new OpaqueBrowserFrameViewLayout(this)), |
85 minimize_button_(nullptr), | 85 minimize_button_(nullptr), |
86 maximize_button_(nullptr), | 86 maximize_button_(nullptr), |
87 restore_button_(nullptr), | 87 restore_button_(nullptr), |
88 close_button_(nullptr), | 88 close_button_(nullptr), |
89 window_icon_(nullptr), | 89 window_icon_(nullptr), |
90 window_title_(nullptr), | 90 window_title_(nullptr), |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 } | 711 } |
712 } | 712 } |
713 | 713 |
714 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const { | 714 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const { |
715 gfx::Rect client_bounds = | 715 gfx::Rect client_bounds = |
716 layout_->CalculateClientAreaBounds(width(), height()); | 716 layout_->CalculateClientAreaBounds(width(), height()); |
717 const int x = client_bounds.x(); | 717 const int x = client_bounds.x(); |
718 int y = client_bounds.y(); | 718 int y = client_bounds.y(); |
719 const int w = client_bounds.width(); | 719 const int w = client_bounds.width(); |
720 const int right = client_bounds.right(); | 720 const int right = client_bounds.right(); |
721 const bool normal_mode = browser_view()->IsTabStripVisible(); | 721 const bool tabstrip_visible = browser_view()->IsTabStripVisible(); |
722 const bool md = ui::MaterialDesignController::IsModeMaterial(); | 722 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
723 const ui::ThemeProvider* tp = GetThemeProvider(); | 723 const ui::ThemeProvider* tp = GetThemeProvider(); |
724 const SkColor toolbar_color = | 724 const SkColor toolbar_color = |
725 normal_mode | 725 tabstrip_visible |
726 ? tp->GetColor(ThemeProperties::COLOR_TOOLBAR) | 726 ? tp->GetColor(ThemeProperties::COLOR_TOOLBAR) |
727 : ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, | 727 : ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, |
728 browser_view()->IsOffTheRecord()); | 728 browser_view()->IsOffTheRecord()); |
729 | 729 |
730 const gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 730 const gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
731 int img_y_offset = 0; | 731 int img_y_offset = 0; |
732 if (normal_mode) { | 732 if (tabstrip_visible) { |
733 // Pre-Material Design, the client edge images start below the toolbar. In | 733 // Pre-Material Design, the client edge images start below the toolbar. In |
734 // MD the client edge images start at the top of the toolbar. | 734 // MD the client edge images start at the top of the toolbar. |
735 y += md ? toolbar_bounds.y() : toolbar_bounds.bottom(); | 735 y += md ? toolbar_bounds.y() : toolbar_bounds.bottom(); |
736 } else { | 736 } else { |
737 // The toolbar isn't going to draw a top edge for us, so draw one ourselves. | 737 // The toolbar isn't going to draw a top edge for us, so draw one ourselves. |
738 if (IsToolbarVisible()) { | 738 if (IsToolbarVisible()) { |
739 y += toolbar_bounds.y() + kContentEdgeShadowThickness + | 739 y += toolbar_bounds.y() + kContentEdgeShadowThickness + |
740 kClientEdgeThickness; | 740 kClientEdgeThickness; |
741 } | 741 } |
742 client_bounds.set_y(y); | 742 client_bounds.set_y(y); |
(...skipping 28 matching lines...) Expand all Loading... | |
771 img_w, height, right, top_y, img_w, height, false); | 771 img_w, height, right, top_y, img_w, height, false); |
772 } | 772 } |
773 } | 773 } |
774 | 774 |
775 // In maximized mode, the only edge to draw is the top one, so we're done. | 775 // In maximized mode, the only edge to draw is the top one, so we're done. |
776 if (layout_->IsTitleBarCondensed()) | 776 if (layout_->IsTitleBarCondensed()) |
777 return; | 777 return; |
778 | 778 |
779 const int img_y = y + img_y_offset; | 779 const int img_y = y + img_y_offset; |
780 const int bottom = std::max(y, height() - NonClientBorderThickness()); | 780 const int bottom = std::max(y, height() - NonClientBorderThickness()); |
781 int height = bottom - img_y; | 781 const int height = bottom - y; |
782 int img_h = bottom - img_y; | |
sky
2016/02/10 17:22:35
nit: const to be consistent with the others.
Peter Kasting
2016/02/11 06:02:32
Done.
| |
782 | 783 |
783 // Draw the client edge images. For non-MD, we fill the toolbar color | 784 // Draw the client edge images. For non-MD, we fill the toolbar color |
784 // underneath these images so they will lighten/darken it appropriately to | 785 // underneath these images so they will lighten/darken it appropriately to |
785 // create a "3D shaded" effect. For MD, where we want a flatter appearance, | 786 // create a "3D shaded" effect. For MD, where we want a flatter appearance, |
786 // we do the filling afterwards so the user sees the unmodified toolbar color. | 787 // we do the filling afterwards so the user sees the unmodified toolbar color. |
787 if (!md) | 788 if (!md) |
788 FillClientEdgeRects(x, y, right, bottom, toolbar_color, canvas); | 789 FillClientEdgeRects(x, y, w, height, toolbar_color, canvas); |
789 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); | 790 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); |
790 const int img_w = right_image->width(); | 791 const int img_w = right_image->width(); |
791 canvas->TileImageInt(*right_image, right, img_y, img_w, height); | 792 canvas->TileImageInt(*right_image, right, img_y, img_w, img_h); |
792 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 793 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
793 right, bottom); | 794 right, bottom); |
794 gfx::ImageSkia* bottom_image = | 795 gfx::ImageSkia* bottom_image = |
795 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); | 796 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); |
796 canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height()); | 797 canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height()); |
797 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER), | 798 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER), |
798 x - img_w, bottom); | 799 x - img_w, bottom); |
799 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE), x - img_w, | 800 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE), x - img_w, |
800 img_y, img_w, height); | 801 img_y, img_w, img_h); |
801 if (md) | 802 if (md) |
802 FillClientEdgeRects(x, y, right, bottom, toolbar_color, canvas); | 803 FillClientEdgeRects(x, y, w, height, toolbar_color, canvas); |
803 } | 804 } |
804 | 805 |
805 void OpaqueBrowserFrameView::FillClientEdgeRects(int x, | 806 void OpaqueBrowserFrameView::FillClientEdgeRects(int x, |
806 int y, | 807 int y, |
807 int right, | 808 int w, |
808 int bottom, | 809 int height, |
809 SkColor color, | 810 SkColor color, |
810 gfx::Canvas* canvas) const { | 811 gfx::Canvas* canvas) const { |
811 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, | 812 x -= kClientEdgeThickness; |
812 bottom + kClientEdgeThickness - y); | 813 gfx::Rect side(x, y, kClientEdgeThickness, height); |
813 canvas->FillRect(side, color); | 814 canvas->FillRect(side, color); |
814 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), | 815 canvas->FillRect(gfx::Rect(x, y + height, w + (2 * kClientEdgeThickness), |
sky
2016/02/10 17:22:35
Isn't this different than the old because you've m
Peter Kasting
2016/02/11 06:02:32
Yes, and this is intentional. I'm still drawing o
| |
816 kClientEdgeThickness), | |
815 color); | 817 color); |
816 side.set_x(right); | 818 side.Offset(w + kClientEdgeThickness, 0); |
817 canvas->FillRect(side, color); | 819 canvas->FillRect(side, color); |
818 } | 820 } |
OLD | NEW |