| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // In the window corners, the resize areas don't actually expand bigger, but the | 70 // In the window corners, the resize areas don't actually expand bigger, but the |
| 71 // 16 px at the end of each edge triggers diagonal resizing. | 71 // 16 px at the end of each edge triggers diagonal resizing. |
| 72 const int kResizeAreaCornerSize = 16; | 72 const int kResizeAreaCornerSize = 16; |
| 73 | 73 |
| 74 #if !defined(OS_WIN) | 74 #if !defined(OS_WIN) |
| 75 // The icon never shrinks below 16 px on a side. | 75 // The icon never shrinks below 16 px on a side. |
| 76 const int kIconMinimumSize = 16; | 76 const int kIconMinimumSize = 16; |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 // This draws button that look like win10 window caption buttons. The | 79 // This draws buttons that look like win10 window caption buttons. The |
| 80 // foreground colour is taken from the theme itself, so that it is guaranteed | 80 // foreground colour is taken from the theme itself, to provide good contrast |
| 81 // to provide good contrast with the background. | 81 // with the background. |
| 82 class OpaqueWin10CaptionButton : public views::CustomButton { | 82 class OpaqueWin10CaptionButton : public views::CustomButton { |
| 83 public: | 83 public: |
| 84 OpaqueWin10CaptionButton(OpaqueBrowserFrameView* parent, ViewID view_id); | 84 OpaqueWin10CaptionButton(OpaqueBrowserFrameView* parent, ViewID view_id); |
| 85 | 85 |
| 86 // The width and height of a caption button. The button is slightly shorter | 86 // The width and height of a caption button. The button is slightly shorter |
| 87 // when the browser window is maximized since there is less vertical space. | 87 // when the browser window is maximized since there is less vertical space. |
| 88 const int kWidth = 46; | 88 const int kWidth = 46; |
| 89 const int kHeightNormal = 28; | 89 const int kHeightNormal = 28; |
| 90 const int kHeightMaximized = 20; | 90 const int kHeightMaximized = 20; |
| 91 | 91 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 470 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 471 } | 471 } |
| 472 | 472 |
| 473 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, | 473 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, |
| 474 gfx::Path* window_mask) { | 474 gfx::Path* window_mask) { |
| 475 DCHECK(window_mask); | 475 DCHECK(window_mask); |
| 476 | 476 |
| 477 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) | 477 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) |
| 478 return; | 478 return; |
| 479 | 479 |
| 480 #if defined(OS_WIN) |
| 481 // On windows 10, windows should not have rounded frames in restored mode. |
| 482 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { |
| 483 window_mask->moveTo(0, 0); |
| 484 window_mask->lineTo(size.width(), 0); |
| 485 window_mask->lineTo(size.width(), size.height()); |
| 486 window_mask->lineTo(0, size.height()); |
| 487 window_mask->close(); |
| 488 return; |
| 489 } |
| 490 #endif |
| 491 |
| 480 views::GetDefaultWindowMask( | 492 views::GetDefaultWindowMask( |
| 481 size, frame()->GetCompositor()->device_scale_factor(), window_mask); | 493 size, frame()->GetCompositor()->device_scale_factor(), window_mask); |
| 482 } | 494 } |
| 483 | 495 |
| 484 void OpaqueBrowserFrameView::ResetWindowControls() { | 496 void OpaqueBrowserFrameView::ResetWindowControls() { |
| 485 restore_button_->SetState(views::CustomButton::STATE_NORMAL); | 497 restore_button_->SetState(views::CustomButton::STATE_NORMAL); |
| 486 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); | 498 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); |
| 487 maximize_button_->SetState(views::CustomButton::STATE_NORMAL); | 499 maximize_button_->SetState(views::CustomButton::STATE_NORMAL); |
| 488 // The close button isn't affected by this constraint. | 500 // The close button isn't affected by this constraint. |
| 489 } | 501 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 } | 662 } |
| 651 | 663 |
| 652 /////////////////////////////////////////////////////////////////////////////// | 664 /////////////////////////////////////////////////////////////////////////////// |
| 653 // OpaqueBrowserFrameView, protected: | 665 // OpaqueBrowserFrameView, protected: |
| 654 | 666 |
| 655 // views::View: | 667 // views::View: |
| 656 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 668 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
| 657 if (frame()->IsFullscreen()) | 669 if (frame()->IsFullscreen()) |
| 658 return; // Nothing is visible, so don't bother to paint. | 670 return; // Nothing is visible, so don't bother to paint. |
| 659 | 671 |
| 660 if (layout_->IsTitleBarCondensed()) | 672 const bool draw_as_maximized = layout_->IsTitleBarCondensed(); |
| 673 if (draw_as_maximized) |
| 661 PaintMaximizedFrameBorder(canvas); | 674 PaintMaximizedFrameBorder(canvas); |
| 662 else | 675 else |
| 663 PaintRestoredFrameBorder(canvas); | 676 PaintRestoredFrameBorder(canvas); |
| 664 | 677 |
| 665 // The window icon and title are painted by their respective views. | 678 // The window icon and title are painted by their respective views. |
| 666 /* TODO(pkasting): If this window is active, we should also draw a drop | 679 /* TODO(pkasting): If this window is active, we should also draw a drop |
| 667 * shadow on the title. This is tricky, because we don't want to hardcode a | 680 * shadow on the title. This is tricky, because we don't want to hardcode a |
| 668 * shadow color (since we want to work with various themes), but we can't | 681 * shadow color (since we want to work with various themes), but we can't |
| 669 * alpha-blend either (since the Windows text APIs don't really do this). | 682 * alpha-blend either (since the Windows text APIs don't really do this). |
| 670 * So we'd need to sample the background color at the right location and | 683 * So we'd need to sample the background color at the right location and |
| 671 * synthesize a good shadow color. */ | 684 * synthesize a good shadow color. */ |
| 672 | 685 |
| 673 if (IsToolbarVisible() && IsTabStripVisible()) | 686 if (IsToolbarVisible() && IsTabStripVisible()) |
| 674 PaintToolbarBackground(canvas); | 687 PaintToolbarBackground(canvas); |
| 675 PaintClientEdge(canvas); | 688 if (!draw_as_maximized) |
| 689 PaintClientEdge(canvas); |
| 676 } | 690 } |
| 677 | 691 |
| 678 // BrowserNonClientFrameView: | 692 // BrowserNonClientFrameView: |
| 679 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { | 693 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { |
| 680 // Theme app and popup windows if |platform_observer_| wants it. | 694 // Theme app and popup windows if |platform_observer_| wants it. |
| 681 return browser_view()->IsBrowserTypeNormal() || | 695 return browser_view()->IsBrowserTypeNormal() || |
| 682 platform_observer_->IsUsingSystemTheme(); | 696 platform_observer_->IsUsingSystemTheme(); |
| 683 } | 697 } |
| 684 | 698 |
| 685 void OpaqueBrowserFrameView::UpdateAvatar() { | 699 void OpaqueBrowserFrameView::UpdateAvatar() { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 return top_area_height; | 831 return top_area_height; |
| 818 } | 832 } |
| 819 | 833 |
| 820 void OpaqueBrowserFrameView::PaintRestoredFrameBorder( | 834 void OpaqueBrowserFrameView::PaintRestoredFrameBorder( |
| 821 gfx::Canvas* canvas) const { | 835 gfx::Canvas* canvas) const { |
| 822 frame_background_->set_frame_color(GetFrameColor()); | 836 frame_background_->set_frame_color(GetFrameColor()); |
| 823 frame_background_->set_theme_image(GetFrameImage()); | 837 frame_background_->set_theme_image(GetFrameImage()); |
| 824 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | 838 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
| 825 frame_background_->set_top_area_height(GetTopAreaHeight()); | 839 frame_background_->set_top_area_height(GetTopAreaHeight()); |
| 826 | 840 |
| 827 const ui::ThemeProvider* tp = GetThemeProvider(); | 841 #if defined(OS_WIN) |
| 828 frame_background_->SetSideImages( | 842 // On windows 10 the frame has square corners, so no need for corner images. |
| 829 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 843 const bool set_corners = base::win::GetVersion() < base::win::VERSION_WIN10; |
| 830 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 844 #else |
| 831 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), | 845 const bool set_corners = true; |
| 832 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); | 846 #endif |
| 833 frame_background_->SetCornerImages( | 847 |
| 834 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), | 848 if (set_corners) { |
| 835 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), | 849 const ui::ThemeProvider* tp = GetThemeProvider(); |
| 836 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), | 850 frame_background_->SetSideImages( |
| 837 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); | 851 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
| 852 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
| 853 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), |
| 854 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); |
| 855 |
| 856 frame_background_->SetCornerImages( |
| 857 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), |
| 858 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), |
| 859 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), |
| 860 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); |
| 861 } |
| 862 |
| 838 frame_background_->PaintRestored(canvas, this); | 863 frame_background_->PaintRestored(canvas, this); |
| 839 | 864 |
| 840 // Note: When we don't have a toolbar, we need to draw some kind of bottom | 865 // Note: When we don't have a toolbar, we need to draw some kind of bottom |
| 841 // edge here. Because the App Window graphics we use for this have an | 866 // edge here. Because the App Window graphics we use for this have an |
| 842 // attached client edge and their sizing algorithm is a little involved, we do | 867 // attached client edge and their sizing algorithm is a little involved, we do |
| 843 // all this in PaintRestoredClientEdge(). | 868 // all this in PaintRestoredClientEdge(). |
| 844 } | 869 } |
| 845 | 870 |
| 846 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder( | 871 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder( |
| 847 gfx::Canvas* canvas) const { | 872 gfx::Canvas* canvas) const { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 gfx::Rect side(x, y, kClientEdgeThickness, h); | 1085 gfx::Rect side(x, y, kClientEdgeThickness, h); |
| 1061 canvas->FillRect(side, color); | 1086 canvas->FillRect(side, color); |
| 1062 if (draw_bottom) { | 1087 if (draw_bottom) { |
| 1063 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), | 1088 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), |
| 1064 kClientEdgeThickness), | 1089 kClientEdgeThickness), |
| 1065 color); | 1090 color); |
| 1066 } | 1091 } |
| 1067 side.Offset(w + kClientEdgeThickness, 0); | 1092 side.Offset(w + kClientEdgeThickness, 0); |
| 1068 canvas->FillRect(side, color); | 1093 canvas->FillRect(side, color); |
| 1069 } | 1094 } |
| OLD | NEW |