Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 1460483003: Fix opaque frame app mode windows to have correct toolbar/content separator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 430 }
431 431
432 bool OpaqueBrowserFrameView::IsFullscreen() const { 432 bool OpaqueBrowserFrameView::IsFullscreen() const {
433 return frame()->IsFullscreen(); 433 return frame()->IsFullscreen();
434 } 434 }
435 435
436 bool OpaqueBrowserFrameView::IsTabStripVisible() const { 436 bool OpaqueBrowserFrameView::IsTabStripVisible() const {
437 return browser_view()->IsTabStripVisible(); 437 return browser_view()->IsTabStripVisible();
438 } 438 }
439 439
440 bool OpaqueBrowserFrameView::IsToolbarVisible() const {
441 return browser_view()->IsToolbarVisible() &&
442 !browser_view()->toolbar()->GetPreferredSize().IsEmpty();
443 }
444
440 int OpaqueBrowserFrameView::GetTabStripHeight() const { 445 int OpaqueBrowserFrameView::GetTabStripHeight() const {
441 return browser_view()->GetTabStripHeight(); 446 return browser_view()->GetTabStripHeight();
442 } 447 }
443 448
444 gfx::Size OpaqueBrowserFrameView::GetTabstripPreferredSize() const { 449 gfx::Size OpaqueBrowserFrameView::GetTabstripPreferredSize() const {
445 gfx::Size s = browser_view()->tabstrip()->GetPreferredSize(); 450 gfx::Size s = browser_view()->tabstrip()->GetPreferredSize();
446 return s; 451 return s;
447 } 452 }
448 453
449 /////////////////////////////////////////////////////////////////////////////// 454 ///////////////////////////////////////////////////////////////////////////////
(...skipping 10 matching lines...) Expand all
460 PaintRestoredFrameBorder(canvas); 465 PaintRestoredFrameBorder(canvas);
461 466
462 // The window icon and title are painted by their respective views. 467 // The window icon and title are painted by their respective views.
463 /* TODO(pkasting): If this window is active, we should also draw a drop 468 /* TODO(pkasting): If this window is active, we should also draw a drop
464 * shadow on the title. This is tricky, because we don't want to hardcode a 469 * shadow on the title. This is tricky, because we don't want to hardcode a
465 * shadow color (since we want to work with various themes), but we can't 470 * shadow color (since we want to work with various themes), but we can't
466 * alpha-blend either (since the Windows text APIs don't really do this). 471 * alpha-blend either (since the Windows text APIs don't really do this).
467 * So we'd need to sample the background color at the right location and 472 * So we'd need to sample the background color at the right location and
468 * synthesize a good shadow color. */ 473 * synthesize a good shadow color. */
469 474
470 if (browser_view()->IsToolbarVisible()) 475 if (IsToolbarVisible())
471 PaintToolbarBackground(canvas); 476 PaintToolbarBackground(canvas);
472 if (!layout_->IsTitleBarCondensed()) 477 PaintClientEdge(canvas);
473 PaintRestoredClientEdge(canvas);
474 } 478 }
475 479
476 // BrowserNonClientFrameView: 480 // BrowserNonClientFrameView:
477 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { 481 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const {
478 // Theme app and popup windows if |platform_observer_| wants it. 482 // Theme app and popup windows if |platform_observer_| wants it.
479 return browser_view()->IsBrowserTypeNormal() || 483 return browser_view()->IsBrowserTypeNormal() ||
480 platform_observer_->IsUsingSystemTheme(); 484 platform_observer_->IsUsingSystemTheme();
481 } 485 }
482 486
483 void OpaqueBrowserFrameView::UpdateNewAvatarButtonImpl() { 487 void OpaqueBrowserFrameView::UpdateNewAvatarButtonImpl() {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 toolbar_bounds.Inset(kClientEdgeThickness, 0); 741 toolbar_bounds.Inset(kClientEdgeThickness, 0);
738 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, 742 BrowserView::Paint1pxHorizontalLine(canvas, separator_color,
739 toolbar_bounds); 743 toolbar_bounds);
740 } else { 744 } else {
741 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, 745 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness,
742 kClientEdgeThickness, 0); 746 kClientEdgeThickness, 0);
743 canvas->FillRect(toolbar_bounds, separator_color); 747 canvas->FillRect(toolbar_bounds, separator_color);
744 } 748 }
745 } 749 }
746 750
747 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 751 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) {
748 ui::ThemeProvider* tp = GetThemeProvider(); 752 ui::ThemeProvider* tp = GetThemeProvider();
749 int y = frame()->client_view()->y(); 753 int y = frame()->client_view()->y();
750 754
751 gfx::Rect client_bounds = 755 gfx::Rect client_bounds =
752 layout_->CalculateClientAreaBounds(width(), height()); 756 layout_->CalculateClientAreaBounds(width(), height());
753 const int x = client_bounds.x(); 757 const int x = client_bounds.x();
754 const int w = client_bounds.width(); 758 const int w = client_bounds.width();
755 const int right = client_bounds.right(); 759 const int right = client_bounds.right();
756 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); 760 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR);
757 761
758 if (browser_view()->IsToolbarVisible()) { 762 if (IsToolbarVisible()) {
759 // The client edge images start below the toolbar. 763 // The client edge images start below the toolbar.
760 y += browser_view()->GetToolbarBounds().bottom(); 764 y += browser_view()->GetToolbarBounds().bottom();
761 } else if (!browser_view()->IsTabStripVisible()) { 765 } else {
762 // The toolbar isn't going to draw a client edge for us, so draw one 766 // The toolbar isn't going to draw a top edge for us, so draw one ourselves.
763 // ourselves.
764 gfx::ImageSkia* top_left = tp->GetImageSkiaNamed(IDR_APP_TOP_LEFT); 767 gfx::ImageSkia* top_left = tp->GetImageSkiaNamed(IDR_APP_TOP_LEFT);
765 const int img_w = top_left->width(); 768 const int img_w = top_left->width();
766 const int height = top_left->height(); 769 const int height = top_left->height();
767 const int top_y = y - height; 770 const int top_y = y - height;
768 canvas->DrawImageInt(*top_left, 0, 0, img_w, height, x - img_w, top_y, 771 canvas->DrawImageInt(*top_left, 0, 0, img_w, height, x - img_w, top_y,
769 img_w, height, false); 772 img_w, height, false);
770 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER), 0, 0, x, 773 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_APP_TOP_CENTER), 0, 0, x,
771 top_y, w, height); 774 top_y, w, height);
772 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_APP_TOP_RIGHT), 0, 0, img_w, 775 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_APP_TOP_RIGHT), 0, 0, img_w,
773 height, right, top_y, img_w, height, false); 776 height, right, top_y, img_w, height, false);
774 client_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness, 777 client_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness,
775 -kClientEdgeThickness, client_bounds.height()); 778 -kClientEdgeThickness, client_bounds.height());
776 canvas->FillRect(client_bounds, toolbar_color); 779 canvas->FillRect(client_bounds, toolbar_color);
777 } 780 }
778 781
782 // In maximized mode, the only edge to draw is the top one, so we're done.
783 if (layout_->IsTitleBarCondensed())
784 return;
785
779 const int bottom = std::max(y, height() - NonClientBorderThickness()); 786 const int bottom = std::max(y, height() - NonClientBorderThickness());
780 int height = bottom - y; 787 int height = bottom - y;
781 788
782 // Draw the client edge images. 789 // Draw the client edge images.
783 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); 790 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
784 const int img_w = right_image->width(); 791 const int img_w = right_image->width();
785 canvas->TileImageInt(*right_image, right, y, img_w, height); 792 canvas->TileImageInt(*right_image, right, y, img_w, height);
786 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), 793 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
787 right, bottom); 794 right, bottom);
788 gfx::ImageSkia* bottom_image = 795 gfx::ImageSkia* bottom_image =
789 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); 796 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
790 canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height()); 797 canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height());
791 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER), 798 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER),
792 x - img_w, bottom); 799 x - img_w, bottom);
793 gfx::ImageSkia* left_image = tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE); 800 gfx::ImageSkia* left_image = tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE);
794 canvas->TileImageInt(*left_image, x - img_w, y, img_w, height); 801 canvas->TileImageInt(*left_image, x - img_w, y, img_w, height);
795 802
796 // Draw the toolbar color so that the client edges show the right color even 803 // Draw the toolbar color so that the client edges show the right color even
797 // where not covered by the toolbar image. NOTE: We do this after drawing the 804 // where not covered by the toolbar image. NOTE: We do this after drawing the
798 // images because the images are meant to alpha-blend atop the frame whereas 805 // images because the images are meant to alpha-blend atop the frame whereas
799 // these rects are meant to be fully opaque, without anything overlaid. 806 // these rects are meant to be fully opaque, without anything overlaid.
800 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, 807 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness,
801 bottom + kClientEdgeThickness - y); 808 bottom + kClientEdgeThickness - y);
802 canvas->FillRect(side, toolbar_color); 809 canvas->FillRect(side, toolbar_color);
803 canvas->FillRect(gfx::Rect(x, bottom, w, kClientEdgeThickness), 810 canvas->FillRect(gfx::Rect(x, bottom, w, kClientEdgeThickness),
804 toolbar_color); 811 toolbar_color);
805 side.set_x(right); 812 side.set_x(right);
806 canvas->FillRect(side, toolbar_color); 813 canvas->FillRect(side, toolbar_color);
807 } 814 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698