| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 10 #include "ash/frame/default_header_painter.h" | 10 #include "ash/frame/default_header_painter.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return gfx::Rect(); | 159 return gfx::Rect(); |
| 160 | 160 |
| 161 // When the tab strip is painted in the immersive fullscreen light bar style, | 161 // When the tab strip is painted in the immersive fullscreen light bar style, |
| 162 // the caption buttons and the avatar button are not visible. However, their | 162 // the caption buttons and the avatar button are not visible. However, their |
| 163 // bounds are still used to compute the tab strip bounds so that the tabs have | 163 // bounds are still used to compute the tab strip bounds so that the tabs have |
| 164 // the same horizontal position when the tab strip is painted in the immersive | 164 // the same horizontal position when the tab strip is painted in the immersive |
| 165 // light bar style as when the top-of-window views are revealed. | 165 // light bar style as when the top-of-window views are revealed. |
| 166 int left_inset = GetTabStripLeftInset(); | 166 int left_inset = GetTabStripLeftInset(); |
| 167 int right_inset = GetTabStripRightInset(); | 167 int right_inset = GetTabStripRightInset(); |
| 168 return gfx::Rect(left_inset, | 168 return gfx::Rect(left_inset, |
| 169 GetTopInset(), | 169 GetTopInset(false), |
| 170 std::max(0, width() - left_inset - right_inset), | 170 std::max(0, width() - left_inset - right_inset), |
| 171 tabstrip->GetPreferredSize().height()); | 171 tabstrip->GetPreferredSize().height()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 int BrowserNonClientFrameViewAsh::GetTopInset() const { | 174 int BrowserNonClientFrameViewAsh::GetTopInset(bool restored) const { |
| 175 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) | 175 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) |
| 176 return 0; | 176 return 0; |
| 177 | 177 |
| 178 if (browser_view()->IsTabStripVisible()) { | 178 if (browser_view()->IsTabStripVisible()) { |
| 179 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? | 179 return ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) ? |
| 180 kTabstripTopSpacingShort : kTabstripTopSpacingTall; | 180 kTabstripTopSpacingShort : kTabstripTopSpacingTall; |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) | 183 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) |
| 184 return header_painter_->GetHeaderHeight(); | 184 return header_painter_->GetHeaderHeight(); |
| 185 | 185 |
| 186 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); | 186 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); |
| 187 | 187 |
| 188 // The toolbar partially overlaps the caption buttons. | 188 // The toolbar partially overlaps the caption buttons. |
| 189 if (browser_view()->IsToolbarVisible()) | 189 if (browser_view()->IsToolbarVisible()) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 325 } |
| 326 | 326 |
| 327 void BrowserNonClientFrameViewAsh::Layout() { | 327 void BrowserNonClientFrameViewAsh::Layout() { |
| 328 // The header must be laid out before computing |painted_height| because the | 328 // The header must be laid out before computing |painted_height| because the |
| 329 // computation of |painted_height| for app and popup windows depends on the | 329 // computation of |painted_height| for app and popup windows depends on the |
| 330 // position of the window controls. | 330 // position of the window controls. |
| 331 header_painter_->LayoutHeader(); | 331 header_painter_->LayoutHeader(); |
| 332 | 332 |
| 333 int painted_height = 0; | 333 int painted_height = 0; |
| 334 if (browser_view()->IsTabStripVisible()) { | 334 if (browser_view()->IsTabStripVisible()) { |
| 335 painted_height = GetTopInset() + | 335 painted_height = GetTopInset(false) + |
| 336 browser_view()->tabstrip()->GetPreferredSize().height(); | 336 browser_view()->tabstrip()->GetPreferredSize().height(); |
| 337 } else if (browser_view()->IsToolbarVisible()) { | 337 } else if (browser_view()->IsToolbarVisible()) { |
| 338 // Paint the header so that it overlaps with the top few pixels of the | 338 // Paint the header so that it overlaps with the top few pixels of the |
| 339 // toolbar because the top few pixels of the toolbar are not opaque. | 339 // toolbar because the top few pixels of the toolbar are not opaque. |
| 340 painted_height = GetTopInset() + kFrameShadowThickness * 2; | 340 painted_height = GetTopInset(false) + kFrameShadowThickness * 2; |
| 341 } else { | 341 } else { |
| 342 painted_height = GetTopInset(); | 342 painted_height = GetTopInset(false); |
| 343 } | 343 } |
| 344 header_painter_->SetHeaderHeightForPainting(painted_height); | 344 header_painter_->SetHeaderHeightForPainting(painted_height); |
| 345 | 345 |
| 346 if (avatar_button()) { | 346 if (avatar_button()) { |
| 347 LayoutAvatar(); | 347 LayoutAvatar(); |
| 348 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right()); | 348 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right()); |
| 349 } | 349 } |
| 350 #if defined(FRAME_AVATAR_BUTTON) | 350 #if defined(FRAME_AVATAR_BUTTON) |
| 351 if (new_avatar_button()) | 351 if (new_avatar_button()) |
| 352 LayoutNewStyleAvatar(); | 352 LayoutNewStyleAvatar(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 rect_in_tabstrip_coords_f); | 484 rect_in_tabstrip_coords_f); |
| 485 | 485 |
| 486 if (rect_in_tabstrip_coords.y() > tabstrip->height()) | 486 if (rect_in_tabstrip_coords.y() > tabstrip->height()) |
| 487 return false; | 487 return false; |
| 488 | 488 |
| 489 return !tabstrip->HitTestRect(rect_in_tabstrip_coords) || | 489 return !tabstrip->HitTestRect(rect_in_tabstrip_coords) || |
| 490 tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); | 490 tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 491 } | 491 } |
| 492 | 492 |
| 493 // Claim |rect| if it is above the top of the topmost view in the client area. | 493 // Claim |rect| if it is above the top of the topmost view in the client area. |
| 494 return rect.y() < GetTopInset(); | 494 return rect.y() < GetTopInset(false); |
| 495 } | 495 } |
| 496 | 496 |
| 497 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { | 497 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { |
| 498 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); | 498 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); |
| 499 const int avatar_right = avatar_button() ? | 499 const int avatar_right = avatar_button() ? |
| 500 (insets.left() + browser_view()->GetOTRAvatarIcon().width()) : 0; | 500 (insets.left() + browser_view()->GetOTRAvatarIcon().width()) : 0; |
| 501 return avatar_right + insets.right(); | 501 return avatar_right + insets.right(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { | 504 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 540 } |
| 541 | 541 |
| 542 void BrowserNonClientFrameViewAsh::LayoutAvatar() { | 542 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
| 543 DCHECK(avatar_button()); | 543 DCHECK(avatar_button()); |
| 544 #if !defined(OS_CHROMEOS) | 544 #if !defined(OS_CHROMEOS) |
| 545 // ChromeOS shows avatar on V1 app. | 545 // ChromeOS shows avatar on V1 app. |
| 546 DCHECK(browser_view()->IsTabStripVisible()); | 546 DCHECK(browser_view()->IsTabStripVisible()); |
| 547 #endif | 547 #endif |
| 548 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 548 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 549 gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); | 549 gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); |
| 550 int avatar_bottom = GetTopInset() + browser_view()->GetTabStripHeight() - | 550 int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - |
| 551 avatar_insets.bottom(); | 551 avatar_insets.bottom(); |
| 552 int avatar_y = avatar_bottom - incognito_icon.height(); | 552 int avatar_y = avatar_bottom - incognito_icon.height(); |
| 553 if (!ui::MaterialDesignController::IsModeMaterial() && | 553 if (!ui::MaterialDesignController::IsModeMaterial() && |
| 554 browser_view()->IsTabStripVisible() && | 554 browser_view()->IsTabStripVisible() && |
| 555 (frame()->IsMaximized() || frame()->IsFullscreen())) { | 555 (frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 556 avatar_y = GetTopInset() + kContentShadowHeight; | 556 avatar_y = GetTopInset(false) + kContentShadowHeight; |
| 557 } | 557 } |
| 558 | 558 |
| 559 // Hide the incognito icon in immersive fullscreen when the tab light bar is | 559 // Hide the incognito icon in immersive fullscreen when the tab light bar is |
| 560 // visible because the header is too short for the icognito icon to be | 560 // visible because the header is too short for the icognito icon to be |
| 561 // recognizable. | 561 // recognizable. |
| 562 bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); | 562 bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); |
| 563 int avatar_height = avatar_visible ? avatar_bottom - avatar_y : 0; | 563 int avatar_height = avatar_visible ? avatar_bottom - avatar_y : 0; |
| 564 | 564 |
| 565 gfx::Rect avatar_bounds(avatar_insets.left(), avatar_y, | 565 gfx::Rect avatar_bounds(avatar_insets.left(), avatar_y, |
| 566 incognito_icon.width(), avatar_height); | 566 incognito_icon.width(), avatar_height); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 if (ui::MaterialDesignController::IsModeMaterial()) { | 624 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 625 // Paint the main toolbar image. Since this image is also used to draw the | 625 // Paint the main toolbar image. Since this image is also used to draw the |
| 626 // tab background, we must use the tab strip offset to compute the image | 626 // tab background, we must use the tab strip offset to compute the image |
| 627 // source y position. If you have to debug this code use an image editor | 627 // source y position. If you have to debug this code use an image editor |
| 628 // to paint a diagonal line through the toolbar image and ensure it lines up | 628 // to paint a diagonal line through the toolbar image and ensure it lines up |
| 629 // across the tab and toolbar. | 629 // across the tab and toolbar. |
| 630 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 630 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 631 canvas->TileImageInt( | 631 canvas->TileImageInt( |
| 632 *theme_toolbar, | 632 *theme_toolbar, |
| 633 x + GetThemeBackgroundXInset(), | 633 x + GetThemeBackgroundXInset(), |
| 634 y - GetTopInset(), | 634 y - GetTopInset(false), |
| 635 x, y, | 635 x, y, |
| 636 w, theme_toolbar->height()); | 636 w, theme_toolbar->height()); |
| 637 | 637 |
| 638 // Draw the content/toolbar separator. | 638 // Draw the content/toolbar separator. |
| 639 toolbar_bounds.Inset(kClientEdgeThickness, 0); | 639 toolbar_bounds.Inset(kClientEdgeThickness, 0); |
| 640 BrowserView::Paint1pxHorizontalLine( | 640 BrowserView::Paint1pxHorizontalLine( |
| 641 canvas, | 641 canvas, |
| 642 ThemeProperties::GetDefaultColor( | 642 ThemeProperties::GetDefaultColor( |
| 643 ThemeProperties::COLOR_TOOLBAR_SEPARATOR), | 643 ThemeProperties::COLOR_TOOLBAR_SEPARATOR), |
| 644 toolbar_bounds); | 644 toolbar_bounds); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 658 | 658 |
| 659 // Paint the main toolbar image. Since this image is also used to draw the | 659 // Paint the main toolbar image. Since this image is also used to draw the |
| 660 // tab background, we must use the tab strip offset to compute the image | 660 // tab background, we must use the tab strip offset to compute the image |
| 661 // source y position. If you have to debug this code use an image editor | 661 // source y position. If you have to debug this code use an image editor |
| 662 // to paint a diagonal line through the toolbar image and ensure it lines up | 662 // to paint a diagonal line through the toolbar image and ensure it lines up |
| 663 // across the tab and toolbar. | 663 // across the tab and toolbar. |
| 664 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 664 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 665 canvas->TileImageInt( | 665 canvas->TileImageInt( |
| 666 *theme_toolbar, | 666 *theme_toolbar, |
| 667 x + GetThemeBackgroundXInset(), | 667 x + GetThemeBackgroundXInset(), |
| 668 bottom_y - GetTopInset(), | 668 bottom_y - GetTopInset(false), |
| 669 x, bottom_y, | 669 x, bottom_y, |
| 670 w, theme_toolbar->height()); | 670 w, theme_toolbar->height()); |
| 671 | 671 |
| 672 // The pre-material design content area line has a shadow that extends a | 672 // The pre-material design content area line has a shadow that extends a |
| 673 // couple of pixels above the toolbar bounds. | 673 // couple of pixels above the toolbar bounds. |
| 674 const int kContentShadowHeight = 2; | 674 const int kContentShadowHeight = 2; |
| 675 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); | 675 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); |
| 676 canvas->TileImageInt(*toolbar_top, | 676 canvas->TileImageInt(*toolbar_top, |
| 677 0, 0, | 677 0, 0, |
| 678 x, y - kContentShadowHeight, | 678 x, y - kContentShadowHeight, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 | 707 |
| 708 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 708 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 709 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); | 709 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
| 710 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 710 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 711 width(), kClientEdgeThickness), | 711 width(), kClientEdgeThickness), |
| 712 ThemeProperties::GetDefaultColor( | 712 ThemeProperties::GetDefaultColor( |
| 713 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 713 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 714 } | 714 } |
| OLD | NEW |