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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 } | 429 } |
430 | 430 |
431 bool OpaqueBrowserFrameView::IsFullscreen() const { | 431 bool OpaqueBrowserFrameView::IsFullscreen() const { |
432 return frame()->IsFullscreen(); | 432 return frame()->IsFullscreen(); |
433 } | 433 } |
434 | 434 |
435 bool OpaqueBrowserFrameView::IsTabStripVisible() const { | 435 bool OpaqueBrowserFrameView::IsTabStripVisible() const { |
436 return browser_view()->IsTabStripVisible(); | 436 return browser_view()->IsTabStripVisible(); |
437 } | 437 } |
438 | 438 |
439 bool OpaqueBrowserFrameView::IsToolbarVisible() const { | |
440 return browser_view()->IsToolbarVisible() && | |
441 !browser_view()->GetToolbarBounds().IsEmpty(); | |
sky
2015/11/18 17:00:34
It seems like this is called from code from layout
Peter Kasting
2015/11/18 19:46:24
I think you're right. I changed this to use the t
| |
442 } | |
443 | |
439 int OpaqueBrowserFrameView::GetTabStripHeight() const { | 444 int OpaqueBrowserFrameView::GetTabStripHeight() const { |
440 return browser_view()->GetTabStripHeight(); | 445 return browser_view()->GetTabStripHeight(); |
441 } | 446 } |
442 | 447 |
443 gfx::Size OpaqueBrowserFrameView::GetTabstripPreferredSize() const { | 448 gfx::Size OpaqueBrowserFrameView::GetTabstripPreferredSize() const { |
444 gfx::Size s = browser_view()->tabstrip()->GetPreferredSize(); | 449 gfx::Size s = browser_view()->tabstrip()->GetPreferredSize(); |
445 return s; | 450 return s; |
446 } | 451 } |
447 | 452 |
448 /////////////////////////////////////////////////////////////////////////////// | 453 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 10 matching lines...) Expand all Loading... | |
459 PaintRestoredFrameBorder(canvas); | 464 PaintRestoredFrameBorder(canvas); |
460 | 465 |
461 // The window icon and title are painted by their respective views. | 466 // The window icon and title are painted by their respective views. |
462 /* TODO(pkasting): If this window is active, we should also draw a drop | 467 /* TODO(pkasting): If this window is active, we should also draw a drop |
463 * shadow on the title. This is tricky, because we don't want to hardcode a | 468 * shadow on the title. This is tricky, because we don't want to hardcode a |
464 * shadow color (since we want to work with various themes), but we can't | 469 * shadow color (since we want to work with various themes), but we can't |
465 * alpha-blend either (since the Windows text APIs don't really do this). | 470 * alpha-blend either (since the Windows text APIs don't really do this). |
466 * So we'd need to sample the background color at the right location and | 471 * So we'd need to sample the background color at the right location and |
467 * synthesize a good shadow color. */ | 472 * synthesize a good shadow color. */ |
468 | 473 |
469 if (browser_view()->IsToolbarVisible()) | 474 if (IsToolbarVisible()) |
470 PaintToolbarBackground(canvas); | 475 PaintToolbarBackground(canvas); |
471 if (!layout_->IsTitleBarCondensed()) | 476 PaintClientEdge(canvas); |
472 PaintRestoredClientEdge(canvas); | |
473 } | 477 } |
474 | 478 |
475 // BrowserNonClientFrameView: | 479 // BrowserNonClientFrameView: |
476 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { | 480 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { |
477 // Theme app and popup windows if |platform_observer_| wants it. | 481 // Theme app and popup windows if |platform_observer_| wants it. |
478 return browser_view()->IsBrowserTypeNormal() || | 482 return browser_view()->IsBrowserTypeNormal() || |
479 platform_observer_->IsUsingSystemTheme(); | 483 platform_observer_->IsUsingSystemTheme(); |
480 } | 484 } |
481 | 485 |
482 void OpaqueBrowserFrameView::UpdateNewAvatarButtonImpl() { | 486 void OpaqueBrowserFrameView::UpdateNewAvatarButtonImpl() { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 canvas->FillRect( | 770 canvas->FillRect( |
767 gfx::Rect(x + kClientEdgeThickness, | 771 gfx::Rect(x + kClientEdgeThickness, |
768 toolbar_bounds.bottom() - kClientEdgeThickness, | 772 toolbar_bounds.bottom() - kClientEdgeThickness, |
769 w - (2 * kClientEdgeThickness), | 773 w - (2 * kClientEdgeThickness), |
770 kClientEdgeThickness), | 774 kClientEdgeThickness), |
771 ThemeProperties::GetDefaultColor( | 775 ThemeProperties::GetDefaultColor( |
772 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 776 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
773 } | 777 } |
774 } | 778 } |
775 | 779 |
776 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 780 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) { |
777 ui::ThemeProvider* tp = GetThemeProvider(); | 781 ui::ThemeProvider* tp = GetThemeProvider(); |
778 int client_area_top = frame()->client_view()->y(); | 782 int client_area_top = frame()->client_view()->y(); |
779 int image_top = client_area_top; | 783 int image_top = client_area_top; |
780 | 784 |
781 gfx::Rect client_area_bounds = | 785 gfx::Rect client_area_bounds = |
782 layout_->CalculateClientAreaBounds(width(), height()); | 786 layout_->CalculateClientAreaBounds(width(), height()); |
783 SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); | 787 SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); |
784 | 788 |
785 if (browser_view()->IsToolbarVisible()) { | 789 if (IsToolbarVisible()) { |
786 // The client edge images start below the toolbar. | 790 // The client edge images start below the toolbar. |
787 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 791 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
788 client_area_top += toolbar_bounds.bottom(); | 792 client_area_top += toolbar_bounds.bottom(); |
789 image_top = client_area_top; | 793 image_top = client_area_top; |
790 } else if (!browser_view()->IsTabStripVisible()) { | 794 } else { |
791 // The toolbar isn't going to draw a client edge for us, so draw one | 795 // The toolbar isn't going to draw a top edge for us, so draw one ourselves. |
792 // ourselves. | |
793 gfx::ImageSkia* top_left = tp->GetImageSkiaNamed(IDR_APP_TOP_LEFT); | 796 gfx::ImageSkia* top_left = tp->GetImageSkiaNamed(IDR_APP_TOP_LEFT); |
794 gfx::ImageSkia* top_center = tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER); | 797 gfx::ImageSkia* top_center = tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER); |
795 gfx::ImageSkia* top_right = tp->GetImageSkiaNamed(IDR_APP_TOP_RIGHT); | 798 gfx::ImageSkia* top_right = tp->GetImageSkiaNamed(IDR_APP_TOP_RIGHT); |
796 int top_edge_y = client_area_top - top_center->height(); | 799 int top_edge_y = client_area_top - top_center->height(); |
797 int height = client_area_top - top_edge_y; | 800 int height = client_area_top - top_edge_y; |
798 | 801 |
799 canvas->DrawImageInt(*top_left, 0, 0, top_left->width(), height, | 802 canvas->DrawImageInt(*top_left, 0, 0, top_left->width(), height, |
800 client_area_bounds.x() - top_left->width(), top_edge_y, | 803 client_area_bounds.x() - top_left->width(), top_edge_y, |
801 top_left->width(), height, false); | 804 top_left->width(), height, false); |
802 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, | 805 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, |
803 client_area_bounds.width(), std::min(height, top_center->height())); | 806 client_area_bounds.width(), std::min(height, top_center->height())); |
804 canvas->DrawImageInt(*top_right, 0, 0, top_right->width(), height, | 807 canvas->DrawImageInt(*top_right, 0, 0, top_right->width(), height, |
805 client_area_bounds.right(), top_edge_y, | 808 client_area_bounds.right(), top_edge_y, |
806 top_right->width(), height, false); | 809 top_right->width(), height, false); |
807 | 810 |
808 // Draw the toolbar color across the top edge. | 811 // Draw the toolbar color across the top edge. |
809 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, | 812 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
810 client_area_top - kClientEdgeThickness, | 813 client_area_top - kClientEdgeThickness, |
811 client_area_bounds.width() + (2 * kClientEdgeThickness), | 814 client_area_bounds.width() + (2 * kClientEdgeThickness), |
812 kClientEdgeThickness), toolbar_color); | 815 kClientEdgeThickness), toolbar_color); |
813 } | 816 } |
814 | 817 |
818 // In maximized mode, the only edge to draw is the top one, so we're done. | |
819 if (layout_->IsTitleBarCondensed()) | |
820 return; | |
821 | |
815 int client_area_bottom = | 822 int client_area_bottom = |
816 std::max(client_area_top, height() - NonClientBorderThickness()); | 823 std::max(client_area_top, height() - NonClientBorderThickness()); |
817 int image_height = client_area_bottom - image_top; | 824 int image_height = client_area_bottom - image_top; |
818 | 825 |
819 // Draw the client edge images. | 826 // Draw the client edge images. |
820 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); | 827 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); |
821 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, | 828 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, |
822 right->width(), image_height); | 829 right->width(), image_height); |
823 canvas->DrawImageInt( | 830 canvas->DrawImageInt( |
824 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 831 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
(...skipping 19 matching lines...) Expand all Loading... | |
844 client_area_bottom + kClientEdgeThickness - client_area_top), | 851 client_area_bottom + kClientEdgeThickness - client_area_top), |
845 toolbar_color); | 852 toolbar_color); |
846 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, | 853 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, |
847 client_area_bounds.width(), kClientEdgeThickness), | 854 client_area_bounds.width(), kClientEdgeThickness), |
848 toolbar_color); | 855 toolbar_color); |
849 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, | 856 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, |
850 kClientEdgeThickness, | 857 kClientEdgeThickness, |
851 client_area_bottom + kClientEdgeThickness - client_area_top), | 858 client_area_bottom + kClientEdgeThickness - client_area_top), |
852 toolbar_color); | 859 toolbar_color); |
853 } | 860 } |
OLD | NEW |