OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 | 603 |
604 // Fill with the frame color first so we have a constant background for | 604 // Fill with the frame color first so we have a constant background for |
605 // areas not covered by the theme image. | 605 // areas not covered by the theme image. |
606 SkBitmap* theme_frame = GetFrameBitmap(); | 606 SkBitmap* theme_frame = GetFrameBitmap(); |
607 int top_area_height = theme_frame->height(); | 607 int top_area_height = theme_frame->height(); |
608 if (browser_view_->IsTabStripVisible()) { | 608 if (browser_view_->IsTabStripVisible()) { |
609 top_area_height = std::max(top_area_height, | 609 top_area_height = std::max(top_area_height, |
610 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); | 610 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); |
611 } | 611 } |
612 SkColor frame_color = GetFrameColor(); | 612 SkColor frame_color = GetFrameColor(); |
613 canvas->FillRectInt(frame_color, 0, 0, width(), top_area_height); | 613 canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height)); |
614 | 614 |
615 // Now fill down the sides. | 615 int remaining_height = height() - top_area_height; |
616 canvas->FillRectInt(frame_color, 0, top_area_height, left_edge->width(), | 616 if (remaining_height > 0) { |
617 height() - top_area_height); | 617 // Now fill down the sides. |
618 canvas->FillRectInt(frame_color, width() - right_edge->width(), | 618 canvas->FillRect(frame_color, |
619 top_area_height, right_edge->width(), | 619 gfx::Rect(0, top_area_height, left_edge->width(), |
620 height() - top_area_height); | 620 remaining_height)); |
621 // Now fill the bottom area. | 621 canvas->FillRect(frame_color, |
622 canvas->FillRectInt(frame_color, left_edge->width(), | 622 gfx::Rect(width() - right_edge->width(), |
623 height() - bottom_edge->height(), | 623 top_area_height, right_edge->width(), |
624 width() - left_edge->width() - right_edge->width(), | 624 remaining_height)); |
625 bottom_edge->height()); | 625 int center_width = width() - left_edge->width() - right_edge->width(); |
| 626 if (center_width > 0) { |
| 627 // Now fill the bottom area. |
| 628 canvas->FillRect(frame_color, |
| 629 gfx::Rect(left_edge->width(), |
| 630 height() - bottom_edge->height(), |
| 631 center_width, bottom_edge->height())); |
| 632 } |
| 633 } |
626 | 634 |
627 // Draw the theme frame. | 635 // Draw the theme frame. |
628 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); | 636 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); |
629 | 637 |
630 // Draw the theme frame overlay. | 638 // Draw the theme frame overlay. |
631 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 639 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
632 browser_view_->IsBrowserTypeNormal() && | 640 browser_view_->IsBrowserTypeNormal() && |
633 !browser_view_->IsOffTheRecord()) { | 641 !browser_view_->IsOffTheRecord()) { |
634 canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ? | 642 canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ? |
635 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0); | 643 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 692 |
685 // We will be painting from top_offset to top_offset + theme_frame_height. If | 693 // We will be painting from top_offset to top_offset + theme_frame_height. If |
686 // this is less than GetBoundsForTabStrip.bottom, we need to paint the frame | 694 // this is less than GetBoundsForTabStrip.bottom, we need to paint the frame |
687 // color. | 695 // color. |
688 SkBitmap* theme_frame = GetFrameBitmap(); | 696 SkBitmap* theme_frame = GetFrameBitmap(); |
689 int theme_frame_bottom = top_offset + theme_frame->height(); | 697 int theme_frame_bottom = top_offset + theme_frame->height(); |
690 int top_area_height = | 698 int top_area_height = |
691 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); | 699 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); |
692 if (top_area_height > theme_frame_bottom) { | 700 if (top_area_height > theme_frame_bottom) { |
693 SkColor frame_color = GetFrameColor(); | 701 SkColor frame_color = GetFrameColor(); |
694 canvas->FillRectInt(frame_color, 0, 0, width(), top_area_height); | 702 canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height)); |
695 } | 703 } |
696 | 704 |
697 // Draw the theme frame. It must be aligned with the tabstrip as if we were | 705 // Draw the theme frame. It must be aligned with the tabstrip as if we were |
698 // in restored mode. Note that the top of the tabstrip is | 706 // in restored mode. Note that the top of the tabstrip is |
699 // kTabstripTopShadowThickness px off the top of the screen. | 707 // kTabstripTopShadowThickness px off the top of the screen. |
700 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + | 708 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + |
701 kTabstripTopShadowThickness); | 709 kTabstripTopShadowThickness); |
702 int left_offset = 0, right_offset = 0; | 710 int left_offset = 0, right_offset = 0; |
703 | 711 |
704 if (left || right) { | 712 if (left || right) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 788 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
781 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 789 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
782 | 790 |
783 // Split our canvas out so we can mask out the corners of the toolbar | 791 // Split our canvas out so we can mask out the corners of the toolbar |
784 // without masking out the frame. | 792 // without masking out the frame. |
785 canvas->SaveLayerAlpha( | 793 canvas->SaveLayerAlpha( |
786 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, | 794 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, |
787 h)); | 795 h)); |
788 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 796 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
789 | 797 |
790 SkColor theme_toolbar_color = | 798 SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
791 tp->GetColor(ThemeService::COLOR_TOOLBAR); | 799 canvas->FillRect(theme_toolbar_color, |
792 canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); | 800 gfx::Rect(x, bottom_y, w, bottom_edge_height)); |
793 | 801 |
794 // Tile the toolbar image starting at the frame edge on the left and where the | 802 // Tile the toolbar image starting at the frame edge on the left and where the |
795 // horizontal tabstrip is (or would be) on the top. | 803 // horizontal tabstrip is (or would be) on the top. |
796 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 804 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); |
797 canvas->TileImageInt(*theme_toolbar, x, | 805 canvas->TileImageInt(*theme_toolbar, x, |
798 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, | 806 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, |
799 bottom_y, w, theme_toolbar->height()); | 807 bottom_y, w, theme_toolbar->height()); |
800 | 808 |
801 // Draw rounded corners for the tab. | 809 // Draw rounded corners for the tab. |
802 SkBitmap* toolbar_left_mask = | 810 SkBitmap* toolbar_left_mask = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 | 855 |
848 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); | 856 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); |
849 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), | 857 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), |
850 split_point, right_x, y, toolbar_right->width(), split_point, false); | 858 split_point, right_x, y, toolbar_right->width(), split_point, false); |
851 canvas->DrawBitmapInt(*toolbar_right, 0, | 859 canvas->DrawBitmapInt(*toolbar_right, 0, |
852 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 860 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
853 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 861 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
854 bottom_edge_height, false); | 862 bottom_edge_height, false); |
855 | 863 |
856 // Draw the content/toolbar separator. | 864 // Draw the content/toolbar separator. |
857 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, | 865 canvas->FillRect(ResourceBundle::toolbar_separator_color, |
858 x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness, | 866 gfx::Rect(x + kClientEdgeThickness, |
859 w - (2 * kClientEdgeThickness), kClientEdgeThickness); | 867 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 868 w - (2 * kClientEdgeThickness), |
| 869 kClientEdgeThickness)); |
860 } | 870 } |
861 | 871 |
862 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 872 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
863 ui::ThemeProvider* tp = GetThemeProvider(); | 873 ui::ThemeProvider* tp = GetThemeProvider(); |
864 int client_area_top = frame_->client_view()->y(); | 874 int client_area_top = frame_->client_view()->y(); |
865 int image_top = client_area_top; | 875 int image_top = client_area_top; |
866 | 876 |
867 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 877 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
868 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 878 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
869 | 879 |
(...skipping 18 matching lines...) Expand all Loading... |
888 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, | 898 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, |
889 client_area_bounds.x() - top_left->width(), top_edge_y, | 899 client_area_bounds.x() - top_left->width(), top_edge_y, |
890 top_left->width(), height, false); | 900 top_left->width(), height, false); |
891 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, | 901 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, |
892 client_area_bounds.width(), std::min(height, top_center->height())); | 902 client_area_bounds.width(), std::min(height, top_center->height())); |
893 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, | 903 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, |
894 client_area_bounds.right(), top_edge_y, | 904 client_area_bounds.right(), top_edge_y, |
895 top_right->width(), height, false); | 905 top_right->width(), height, false); |
896 | 906 |
897 // Draw the toolbar color across the top edge. | 907 // Draw the toolbar color across the top edge. |
898 canvas->FillRectInt(toolbar_color, | 908 canvas->FillRect( |
899 client_area_bounds.x() - kClientEdgeThickness, | 909 toolbar_color, |
900 client_area_top - kClientEdgeThickness, | 910 gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
901 client_area_bounds.width() + (2 * kClientEdgeThickness), | 911 client_area_top - kClientEdgeThickness, |
902 kClientEdgeThickness); | 912 client_area_bounds.width() + (2 * kClientEdgeThickness), |
| 913 kClientEdgeThickness)); |
903 } | 914 } |
904 | 915 |
905 int client_area_bottom = | 916 int client_area_bottom = |
906 std::max(client_area_top, height() - NonClientBorderThickness()); | 917 std::max(client_area_top, height() - NonClientBorderThickness()); |
907 int image_height = client_area_bottom - image_top; | 918 int image_height = client_area_bottom - image_top; |
908 | 919 |
909 // Draw the client edge images. | 920 // Draw the client edge images. |
910 // Draw the client edge images. | 921 // Draw the client edge images. |
911 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 922 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
912 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, | 923 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, |
(...skipping 10 matching lines...) Expand all Loading... |
923 canvas->DrawBitmapInt(*bottom_left, | 934 canvas->DrawBitmapInt(*bottom_left, |
924 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 935 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
925 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); | 936 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); |
926 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 937 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
927 image_top, left->width(), image_height); | 938 image_top, left->width(), image_height); |
928 | 939 |
929 // Draw the toolbar color so that the client edges show the right color even | 940 // Draw the toolbar color so that the client edges show the right color even |
930 // where not covered by the toolbar image. NOTE: We do this after drawing the | 941 // where not covered by the toolbar image. NOTE: We do this after drawing the |
931 // images because the images are meant to alpha-blend atop the frame whereas | 942 // images because the images are meant to alpha-blend atop the frame whereas |
932 // these rects are meant to be fully opaque, without anything overlaid. | 943 // these rects are meant to be fully opaque, without anything overlaid. |
933 canvas->FillRectInt(toolbar_color, | 944 canvas->FillRect( |
934 client_area_bounds.x() - kClientEdgeThickness, client_area_top, | 945 toolbar_color, |
935 kClientEdgeThickness, | 946 gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
936 client_area_bottom + kClientEdgeThickness - client_area_top); | 947 client_area_top, |
937 canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, | 948 kClientEdgeThickness, |
938 client_area_bounds.width(), kClientEdgeThickness); | 949 client_area_bottom + kClientEdgeThickness - client_area_top)); |
939 canvas->FillRectInt(toolbar_color, client_area_bounds.right(), | 950 canvas->FillRect(toolbar_color, |
940 client_area_top, kClientEdgeThickness, | 951 gfx::Rect(client_area_bounds.x(), client_area_bottom, |
941 client_area_bottom + kClientEdgeThickness - client_area_top); | 952 client_area_bounds.width(), kClientEdgeThickness)); |
| 953 canvas->FillRect( |
| 954 toolbar_color, |
| 955 gfx::Rect(client_area_bounds.right(), |
| 956 client_area_top, |
| 957 kClientEdgeThickness, |
| 958 client_area_bottom + kClientEdgeThickness - client_area_top)); |
942 } | 959 } |
943 | 960 |
944 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { | 961 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { |
945 bool is_incognito = browser_view_->IsOffTheRecord(); | 962 bool is_incognito = browser_view_->IsOffTheRecord(); |
946 int resource_id; | 963 int resource_id; |
947 if (browser_view_->IsBrowserTypeNormal()) { | 964 if (browser_view_->IsBrowserTypeNormal()) { |
948 if (ShouldPaintAsActive()) { | 965 if (ShouldPaintAsActive()) { |
949 resource_id = is_incognito ? | 966 resource_id = is_incognito ? |
950 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; | 967 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; |
951 } else { | 968 } else { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 ProfileInfoCache& cache = | 1158 ProfileInfoCache& cache = |
1142 g_browser_process->profile_manager()->GetProfileInfoCache(); | 1159 g_browser_process->profile_manager()->GetProfileInfoCache(); |
1143 Profile* profile = browser_view_->browser()->profile(); | 1160 Profile* profile = browser_view_->browser()->profile(); |
1144 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 1161 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
1145 if (index != std::string::npos) { | 1162 if (index != std::string::npos) { |
1146 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); | 1163 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); |
1147 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); | 1164 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); |
1148 } | 1165 } |
1149 } | 1166 } |
1150 } | 1167 } |
OLD | NEW |