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

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

Issue 1624773002: Clean up frame code a bit: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync, fix compile Created 4 years, 11 months 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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 return false; 567 return false;
568 568
569 // Do not show caption buttons if the window manager is forcefully providing a 569 // Do not show caption buttons if the window manager is forcefully providing a
570 // title bar (e.g., in Ubuntu Unity, if the window is maximized). 570 // title bar (e.g., in Ubuntu Unity, if the window is maximized).
571 if (!views::ViewsDelegate::GetInstance()) 571 if (!views::ViewsDelegate::GetInstance())
572 return true; 572 return true;
573 return !views::ViewsDelegate::GetInstance()->WindowManagerProvidesTitleBar( 573 return !views::ViewsDelegate::GetInstance()->WindowManagerProvidesTitleBar(
574 IsMaximized()); 574 IsMaximized());
575 } 575 }
576 576
577 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 577 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(
578 gfx::Canvas* canvas) const {
578 frame_background_->set_frame_color(GetFrameColor()); 579 frame_background_->set_frame_color(GetFrameColor());
579 frame_background_->set_theme_image(GetFrameImage()); 580 frame_background_->set_theme_image(GetFrameImage());
580 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); 581 frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
581 frame_background_->set_top_area_height(GetTopAreaHeight()); 582 frame_background_->set_top_area_height(GetTopAreaHeight());
582 583
583 const ui::ThemeProvider* tp = GetThemeProvider(); 584 const ui::ThemeProvider* tp = GetThemeProvider();
584 frame_background_->SetSideImages( 585 frame_background_->SetSideImages(
585 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), 586 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE),
586 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), 587 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER),
587 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), 588 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE),
588 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); 589 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER));
589 frame_background_->SetCornerImages( 590 frame_background_->SetCornerImages(
590 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), 591 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER),
591 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), 592 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER),
592 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), 593 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER),
593 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); 594 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER));
594 frame_background_->PaintRestored(canvas, this); 595 frame_background_->PaintRestored(canvas, this);
595 596
596 // Note: When we don't have a toolbar, we need to draw some kind of bottom 597 // Note: When we don't have a toolbar, we need to draw some kind of bottom
597 // edge here. Because the App Window graphics we use for this have an 598 // edge here. Because the App Window graphics we use for this have an
598 // attached client edge and their sizing algorithm is a little involved, we do 599 // attached client edge and their sizing algorithm is a little involved, we do
599 // all this in PaintRestoredClientEdge(). 600 // all this in PaintRestoredClientEdge().
600 } 601 }
601 602
602 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 603 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(
604 gfx::Canvas* canvas) const {
603 frame_background_->set_frame_color(GetFrameColor()); 605 frame_background_->set_frame_color(GetFrameColor());
604 frame_background_->set_theme_image(GetFrameImage()); 606 frame_background_->set_theme_image(GetFrameImage());
605 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); 607 frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
606 frame_background_->set_top_area_height(GetTopAreaHeight()); 608 frame_background_->set_top_area_height(GetTopAreaHeight());
607 frame_background_->set_maximized_top_inset( 609 frame_background_->set_maximized_top_inset(
608 GetTopInset(true) - GetTopInset(false)); 610 GetTopInset(true) - GetTopInset(false));
609 frame_background_->PaintMaximized(canvas, this); 611 frame_background_->PaintMaximized(canvas, this);
610 } 612 }
611 613
612 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { 614 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const {
613 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 615 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
614 if (toolbar_bounds.IsEmpty()) 616 if (toolbar_bounds.IsEmpty())
615 return; 617 return;
616 gfx::Point toolbar_origin(toolbar_bounds.origin()); 618 gfx::Point toolbar_origin(toolbar_bounds.origin());
617 ConvertPointToTarget(browser_view(), this, &toolbar_origin); 619 ConvertPointToTarget(browser_view(), this, &toolbar_origin);
618 toolbar_bounds.set_origin(toolbar_origin); 620 toolbar_bounds.set_origin(toolbar_origin);
619 const int h = toolbar_bounds.height(); 621 const int h = toolbar_bounds.height();
620 const bool md = ui::MaterialDesignController::IsModeMaterial(); 622 const bool md = ui::MaterialDesignController::IsModeMaterial();
621 const ui::ThemeProvider* tp = GetThemeProvider(); 623 const ui::ThemeProvider* tp = GetThemeProvider();
622 const SkColor separator_color = 624 const SkColor separator_color =
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, 709 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness,
708 kClientEdgeThickness, 0); 710 kClientEdgeThickness, 0);
709 if (md) { 711 if (md) {
710 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, 712 BrowserView::Paint1pxHorizontalLine(canvas, separator_color,
711 toolbar_bounds, true); 713 toolbar_bounds, true);
712 } else { 714 } else {
713 canvas->FillRect(toolbar_bounds, separator_color); 715 canvas->FillRect(toolbar_bounds, separator_color);
714 } 716 }
715 } 717 }
716 718
717 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) { 719 void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const {
718 gfx::Rect client_bounds = 720 gfx::Rect client_bounds =
719 layout_->CalculateClientAreaBounds(width(), height()); 721 layout_->CalculateClientAreaBounds(width(), height());
720 const int x = client_bounds.x(); 722 const int x = client_bounds.x();
721 int y = client_bounds.y(); 723 int y = client_bounds.y();
722 const int w = client_bounds.width(); 724 const int w = client_bounds.width();
723 const int right = client_bounds.right(); 725 const int right = client_bounds.right();
724 const bool normal_mode = browser_view()->IsTabStripVisible(); 726 const bool normal_mode = browser_view()->IsTabStripVisible();
725 const bool md = ui::MaterialDesignController::IsModeMaterial(); 727 const bool md = ui::MaterialDesignController::IsModeMaterial();
726 const ui::ThemeProvider* tp = GetThemeProvider(); 728 const ui::ThemeProvider* tp = GetThemeProvider();
727 const SkColor toolbar_color = 729 const SkColor toolbar_color =
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 SkColor color, 814 SkColor color,
813 gfx::Canvas* canvas) const { 815 gfx::Canvas* canvas) const {
814 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, 816 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness,
815 bottom + kClientEdgeThickness - y); 817 bottom + kClientEdgeThickness - y);
816 canvas->FillRect(side, color); 818 canvas->FillRect(side, color);
817 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), 819 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness),
818 color); 820 color);
819 side.set_x(right); 821 side.set_x(right);
820 canvas->FillRect(side, color); 822 canvas->FillRect(side, color);
821 } 823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698