Chromium Code Reviews| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 const int kResizeAreaCornerSize = 16; | 75 const int kResizeAreaCornerSize = 16; |
| 76 | 76 |
| 77 // The content left/right images have a shadow built into them. | 77 // The content left/right images have a shadow built into them. |
| 78 const int kContentEdgeShadowThickness = 2; | 78 const int kContentEdgeShadowThickness = 2; |
| 79 | 79 |
| 80 #if !defined(OS_WIN) | 80 #if !defined(OS_WIN) |
| 81 // The icon never shrinks below 16 px on a side. | 81 // The icon never shrinks below 16 px on a side. |
| 82 const int kIconMinimumSize = 16; | 82 const int kIconMinimumSize = 16; |
| 83 #endif | 83 #endif |
| 84 | 84 |
| 85 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 86 // The number of pixels to move the frame background image upwards when using | |
| 87 // the GTK+ theme and the titlebar is condensed. | |
| 88 const int kGTKThemeCondensedFrameTopInset = 15; | |
| 89 #endif | |
| 90 | |
| 91 } // namespace | 85 } // namespace |
| 92 | 86 |
| 93 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
| 94 // OpaqueBrowserFrameView, public: | 88 // OpaqueBrowserFrameView, public: |
| 95 | 89 |
| 96 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, | 90 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, |
| 97 BrowserView* browser_view) | 91 BrowserView* browser_view) |
| 98 : BrowserNonClientFrameView(frame, browser_view), | 92 : BrowserNonClientFrameView(frame, browser_view), |
| 99 layout_(new OpaqueBrowserFrameViewLayout(this)), | 93 layout_(new OpaqueBrowserFrameViewLayout(this)), |
| 100 minimize_button_(nullptr), | 94 minimize_button_(nullptr), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: | 157 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
| 164 | 158 |
| 165 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( | 159 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( |
| 166 views::View* tabstrip) const { | 160 views::View* tabstrip) const { |
| 167 if (!tabstrip) | 161 if (!tabstrip) |
| 168 return gfx::Rect(); | 162 return gfx::Rect(); |
| 169 | 163 |
| 170 return layout_->GetBoundsForTabStrip(tabstrip->GetPreferredSize(), width()); | 164 return layout_->GetBoundsForTabStrip(tabstrip->GetPreferredSize(), width()); |
| 171 } | 165 } |
| 172 | 166 |
| 173 int OpaqueBrowserFrameView::GetTopInset() const { | 167 int OpaqueBrowserFrameView::GetTopInset(bool restored) const { |
| 174 return browser_view()->IsTabStripVisible() ? | 168 return browser_view()->IsTabStripVisible() ? |
| 175 layout_->GetTabStripInsetsTop(false) : | 169 layout_->GetTabStripInsetsTop(restored) : |
| 176 layout_->NonClientTopBorderHeight(false); | 170 layout_->NonClientTopBorderHeight(restored); |
| 177 } | 171 } |
| 178 | 172 |
| 179 int OpaqueBrowserFrameView::GetThemeBackgroundXInset() const { | 173 int OpaqueBrowserFrameView::GetThemeBackgroundXInset() const { |
| 180 return 0; | 174 return 0; |
| 181 } | 175 } |
| 182 | 176 |
| 183 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { | 177 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { |
| 184 if (window_icon_) | 178 if (window_icon_) |
| 185 window_icon_->Update(); | 179 window_icon_->Update(); |
| 186 } | 180 } |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 // attached client edge and their sizing algorithm is a little involved, we do | 613 // attached client edge and their sizing algorithm is a little involved, we do |
| 620 // all this in PaintRestoredClientEdge(). | 614 // all this in PaintRestoredClientEdge(). |
| 621 } | 615 } |
| 622 | 616 |
| 623 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { | 617 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { |
| 624 ui::ThemeProvider* tp = GetThemeProvider(); | 618 ui::ThemeProvider* tp = GetThemeProvider(); |
| 625 frame_background_->set_frame_color(GetFrameColor()); | 619 frame_background_->set_frame_color(GetFrameColor()); |
| 626 frame_background_->set_theme_image(GetFrameImage()); | 620 frame_background_->set_theme_image(GetFrameImage()); |
| 627 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | 621 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
| 628 frame_background_->set_top_area_height(GetTopAreaHeight()); | 622 frame_background_->set_top_area_height(GetTopAreaHeight()); |
| 629 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 623 frame_background_->set_maximized_top_inset( |
| 630 // The window manager typically shows a gradient in the native title bar (when | 624 GetTopInset(true) - GetTopInset(false)); |
| 631 // the system title bar pref is set, or when maximized on Ubuntu). Hide the | |
| 632 // gradient in the tab strip (by shifting it up vertically) to avoid a | |
| 633 // double-gradient effect. | |
| 634 if (tp->UsingSystemTheme()) | |
| 635 frame_background_->set_maximized_top_inset(kGTKThemeCondensedFrameTopInset); | |
|
Peter Kasting
2015/11/05 21:15:27
Note that this is no longer necessary since the ne
| |
| 636 #endif | |
| 637 | 625 |
| 638 frame_background_->PaintMaximized(canvas, this); | 626 frame_background_->PaintMaximized(canvas, this); |
| 639 | 627 |
| 640 // TODO(jamescook): Migrate this into FrameBackground. | 628 // TODO(jamescook): Migrate this into FrameBackground. |
| 641 if (!browser_view()->IsToolbarVisible()) { | 629 if (!browser_view()->IsToolbarVisible()) { |
| 642 // There's no toolbar to edge the frame border, so we need to draw a bottom | 630 // There's no toolbar to edge the frame border, so we need to draw a bottom |
| 643 // edge. The graphic we use for this has a built in client edge, so we clip | 631 // edge. The graphic we use for this has a built in client edge, so we clip |
| 644 // it off the bottom. | 632 // it off the bottom. |
| 645 gfx::ImageSkia* top_center = tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER); | 633 gfx::ImageSkia* top_center = tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER); |
| 646 int edge_height = top_center->height() - kClientEdgeThickness; | 634 int edge_height = top_center->height() - kClientEdgeThickness; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 | 669 |
| 682 // Paint the bottom rect. | 670 // Paint the bottom rect. |
| 683 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), | 671 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), |
| 684 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); | 672 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 685 | 673 |
| 686 // Tile the toolbar image starting at the frame edge on the left and where the | 674 // Tile the toolbar image starting at the frame edge on the left and where the |
| 687 // horizontal tabstrip is (or would be) on the top. | 675 // horizontal tabstrip is (or would be) on the top. |
| 688 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 676 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 689 canvas->TileImageInt( | 677 canvas->TileImageInt( |
| 690 *theme_toolbar, x + GetThemeBackgroundXInset(), | 678 *theme_toolbar, x + GetThemeBackgroundXInset(), |
| 691 bottom_y - GetTopInset() + Tab::GetYOffsetForActiveTabBackground(), | 679 bottom_y - GetTopInset(false) + Tab::GetYOffsetForActiveTabBackground(), |
| 692 x, bottom_y, w, theme_toolbar->height()); | 680 x, bottom_y, w, theme_toolbar->height()); |
| 693 | 681 |
| 694 // Draw rounded corners for the tab. | 682 // Draw rounded corners for the tab. |
| 695 gfx::ImageSkia* toolbar_left_mask = | 683 gfx::ImageSkia* toolbar_left_mask = |
| 696 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); | 684 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); |
| 697 gfx::ImageSkia* toolbar_right_mask = | 685 gfx::ImageSkia* toolbar_right_mask = |
| 698 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); | 686 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); |
| 699 | 687 |
| 700 // We mask out the corners by using the DestinationIn transfer mode, | 688 // We mask out the corners by using the DestinationIn transfer mode, |
| 701 // which keeps the RGB pixels from the destination and the alpha from | 689 // which keeps the RGB pixels from the destination and the alpha from |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 client_area_bottom + kClientEdgeThickness - client_area_top), | 835 client_area_bottom + kClientEdgeThickness - client_area_top), |
| 848 toolbar_color); | 836 toolbar_color); |
| 849 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, | 837 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, |
| 850 client_area_bounds.width(), kClientEdgeThickness), | 838 client_area_bounds.width(), kClientEdgeThickness), |
| 851 toolbar_color); | 839 toolbar_color); |
| 852 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, | 840 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, |
| 853 kClientEdgeThickness, | 841 kClientEdgeThickness, |
| 854 client_area_bottom + kClientEdgeThickness - client_area_top), | 842 client_area_bottom + kClientEdgeThickness - client_area_top), |
| 855 toolbar_color); | 843 toolbar_color); |
| 856 } | 844 } |
| OLD | NEW |