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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 703 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
704 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 704 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
705 | 705 |
706 // Split our canvas out so we can mask out the corners of the toolbar | 706 // Split our canvas out so we can mask out the corners of the toolbar |
707 // without masking out the frame. | 707 // without masking out the frame. |
708 canvas->SaveLayerAlpha( | 708 canvas->SaveLayerAlpha( |
709 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, | 709 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, |
710 h)); | 710 h)); |
711 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 711 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
712 | 712 |
713 SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 713 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), |
714 canvas->FillRect(theme_toolbar_color, | 714 tp->GetColor(ThemeService::COLOR_TOOLBAR)); |
715 gfx::Rect(x, bottom_y, w, bottom_edge_height)); | |
716 | 715 |
717 // Tile the toolbar image starting at the frame edge on the left and where the | 716 // Tile the toolbar image starting at the frame edge on the left and where the |
718 // horizontal tabstrip is (or would be) on the top. | 717 // horizontal tabstrip is (or would be) on the top. |
719 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 718 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); |
720 canvas->TileImageInt(*theme_toolbar, x, | 719 canvas->TileImageInt(*theme_toolbar, x, |
721 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, | 720 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, |
722 bottom_y, w, theme_toolbar->height()); | 721 bottom_y, w, theme_toolbar->height()); |
723 | 722 |
724 // Draw rounded corners for the tab. | 723 // Draw rounded corners for the tab. |
725 SkBitmap* toolbar_left_mask = | 724 SkBitmap* toolbar_left_mask = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 | 769 |
771 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); | 770 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); |
772 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), | 771 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), |
773 split_point, right_x, y, toolbar_right->width(), split_point, false); | 772 split_point, right_x, y, toolbar_right->width(), split_point, false); |
774 canvas->DrawBitmapInt(*toolbar_right, 0, | 773 canvas->DrawBitmapInt(*toolbar_right, 0, |
775 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 774 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
776 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 775 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
777 bottom_edge_height, false); | 776 bottom_edge_height, false); |
778 | 777 |
779 // Draw the content/toolbar separator. | 778 // Draw the content/toolbar separator. |
780 canvas->FillRect(ResourceBundle::toolbar_separator_color, | 779 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, |
781 gfx::Rect(x + kClientEdgeThickness, | |
782 toolbar_bounds.bottom() - kClientEdgeThickness, | 780 toolbar_bounds.bottom() - kClientEdgeThickness, |
783 w - (2 * kClientEdgeThickness), | 781 w - (2 * kClientEdgeThickness), |
784 kClientEdgeThickness)); | 782 kClientEdgeThickness), |
| 783 ResourceBundle::toolbar_separator_color); |
785 } | 784 } |
786 | 785 |
787 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 786 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
788 ui::ThemeProvider* tp = GetThemeProvider(); | 787 ui::ThemeProvider* tp = GetThemeProvider(); |
789 int client_area_top = frame()->client_view()->y(); | 788 int client_area_top = frame()->client_view()->y(); |
790 int image_top = client_area_top; | 789 int image_top = client_area_top; |
791 | 790 |
792 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 791 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
793 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 792 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
794 | 793 |
(...skipping 18 matching lines...) Expand all Loading... |
813 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, | 812 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, |
814 client_area_bounds.x() - top_left->width(), top_edge_y, | 813 client_area_bounds.x() - top_left->width(), top_edge_y, |
815 top_left->width(), height, false); | 814 top_left->width(), height, false); |
816 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, | 815 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, |
817 client_area_bounds.width(), std::min(height, top_center->height())); | 816 client_area_bounds.width(), std::min(height, top_center->height())); |
818 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, | 817 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, |
819 client_area_bounds.right(), top_edge_y, | 818 client_area_bounds.right(), top_edge_y, |
820 top_right->width(), height, false); | 819 top_right->width(), height, false); |
821 | 820 |
822 // Draw the toolbar color across the top edge. | 821 // Draw the toolbar color across the top edge. |
823 canvas->FillRect( | 822 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
824 toolbar_color, | 823 client_area_top - kClientEdgeThickness, |
825 gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, | 824 client_area_bounds.width() + (2 * kClientEdgeThickness), |
826 client_area_top - kClientEdgeThickness, | 825 kClientEdgeThickness), toolbar_color); |
827 client_area_bounds.width() + (2 * kClientEdgeThickness), | |
828 kClientEdgeThickness)); | |
829 } | 826 } |
830 | 827 |
831 int client_area_bottom = | 828 int client_area_bottom = |
832 std::max(client_area_top, height() - NonClientBorderThickness()); | 829 std::max(client_area_top, height() - NonClientBorderThickness()); |
833 int image_height = client_area_bottom - image_top; | 830 int image_height = client_area_bottom - image_top; |
834 | 831 |
835 // Draw the client edge images. | 832 // Draw the client edge images. |
836 // Draw the client edge images. | 833 // Draw the client edge images. |
837 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 834 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
838 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, | 835 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, |
(...skipping 10 matching lines...) Expand all Loading... |
849 canvas->DrawBitmapInt(*bottom_left, | 846 canvas->DrawBitmapInt(*bottom_left, |
850 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 847 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
851 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); | 848 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); |
852 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 849 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
853 image_top, left->width(), image_height); | 850 image_top, left->width(), image_height); |
854 | 851 |
855 // Draw the toolbar color so that the client edges show the right color even | 852 // Draw the toolbar color so that the client edges show the right color even |
856 // where not covered by the toolbar image. NOTE: We do this after drawing the | 853 // where not covered by the toolbar image. NOTE: We do this after drawing the |
857 // images because the images are meant to alpha-blend atop the frame whereas | 854 // images because the images are meant to alpha-blend atop the frame whereas |
858 // these rects are meant to be fully opaque, without anything overlaid. | 855 // these rects are meant to be fully opaque, without anything overlaid. |
859 canvas->FillRect( | 856 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
860 toolbar_color, | 857 client_area_top, kClientEdgeThickness, |
861 gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, | 858 client_area_bottom + kClientEdgeThickness - client_area_top), |
862 client_area_top, | 859 toolbar_color); |
863 kClientEdgeThickness, | 860 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, |
864 client_area_bottom + kClientEdgeThickness - client_area_top)); | 861 client_area_bounds.width(), kClientEdgeThickness), |
865 canvas->FillRect(toolbar_color, | 862 toolbar_color); |
866 gfx::Rect(client_area_bounds.x(), client_area_bottom, | 863 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, |
867 client_area_bounds.width(), kClientEdgeThickness)); | 864 kClientEdgeThickness, |
868 canvas->FillRect( | 865 client_area_bottom + kClientEdgeThickness - client_area_top), |
869 toolbar_color, | 866 toolbar_color); |
870 gfx::Rect(client_area_bounds.right(), | |
871 client_area_top, | |
872 kClientEdgeThickness, | |
873 client_area_bottom + kClientEdgeThickness - client_area_top)); | |
874 } | 867 } |
875 | 868 |
876 SkColor OpaqueBrowserFrameView::GetFrameColor() const { | 869 SkColor OpaqueBrowserFrameView::GetFrameColor() const { |
877 bool is_incognito = browser_view()->IsOffTheRecord(); | 870 bool is_incognito = browser_view()->IsOffTheRecord(); |
878 if (browser_view()->IsBrowserTypeNormal()) { | 871 if (browser_view()->IsBrowserTypeNormal()) { |
879 if (ShouldPaintAsActive()) { | 872 if (ShouldPaintAsActive()) { |
880 return GetThemeProvider()->GetColor(is_incognito ? | 873 return GetThemeProvider()->GetColor(is_incognito ? |
881 ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); | 874 ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); |
882 } | 875 } |
883 return GetThemeProvider()->GetColor(is_incognito ? | 876 return GetThemeProvider()->GetColor(is_incognito ? |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 | 1061 |
1069 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1062 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1070 int height) const { | 1063 int height) const { |
1071 int top_height = NonClientTopBorderHeight(false); | 1064 int top_height = NonClientTopBorderHeight(false); |
1072 int border_thickness = NonClientBorderThickness(); | 1065 int border_thickness = NonClientBorderThickness(); |
1073 return gfx::Rect(border_thickness, top_height, | 1066 return gfx::Rect(border_thickness, top_height, |
1074 std::max(0, width - (2 * border_thickness)), | 1067 std::max(0, width - (2 * border_thickness)), |
1075 std::max(0, height - GetReservedHeight() - | 1068 std::max(0, height - GetReservedHeight() - |
1076 top_height - border_thickness)); | 1069 top_height - border_thickness)); |
1077 } | 1070 } |
OLD | NEW |