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

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

Issue 8772060: Refactor window frame painting into a window background class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final cleanup of PaintRestored Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 10 #include "base/command_line.h"
(...skipping 21 matching lines...) Expand all
32 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/base/theme_provider.h" 34 #include "ui/base/theme_provider.h"
35 #include "ui/gfx/canvas_skia.h" 35 #include "ui/gfx/canvas_skia.h"
36 #include "ui/gfx/font.h" 36 #include "ui/gfx/font.h"
37 #include "ui/gfx/image/image.h" 37 #include "ui/gfx/image/image.h"
38 #include "ui/gfx/path.h" 38 #include "ui/gfx/path.h"
39 #include "ui/views/controls/button/image_button.h" 39 #include "ui/views/controls/button/image_button.h"
40 #include "ui/views/controls/image_view.h" 40 #include "ui/views/controls/image_view.h"
41 #include "ui/views/widget/root_view.h" 41 #include "ui/views/widget/root_view.h"
42 #include "ui/views/window/frame_background.h"
42 #include "ui/views/window/window_shape.h" 43 #include "ui/views/window/window_shape.h"
43 44
44 #if defined(USE_VIRTUAL_KEYBOARD) 45 #if defined(USE_VIRTUAL_KEYBOARD)
45 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" 46 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h"
46 #endif 47 #endif
47 48
48 namespace { 49 namespace {
49 // The frame border is only visible in restored mode and is hardcoded to 4 px on 50 // The frame border is only visible in restored mode and is hardcoded to 4 px on
50 // each side regardless of the system window border size. 51 // each side regardless of the system window border size.
51 const int kFrameBorderThickness = 4; 52 const int kFrameBorderThickness = 4;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 BrowserView* browser_view) 119 BrowserView* browser_view)
119 : BrowserNonClientFrameView(frame, browser_view), 120 : BrowserNonClientFrameView(frame, browser_view),
120 ALLOW_THIS_IN_INITIALIZER_LIST( 121 ALLOW_THIS_IN_INITIALIZER_LIST(
121 minimize_button_(new views::ImageButton(this))), 122 minimize_button_(new views::ImageButton(this))),
122 ALLOW_THIS_IN_INITIALIZER_LIST( 123 ALLOW_THIS_IN_INITIALIZER_LIST(
123 maximize_button_(new views::ImageButton(this))), 124 maximize_button_(new views::ImageButton(this))),
124 ALLOW_THIS_IN_INITIALIZER_LIST( 125 ALLOW_THIS_IN_INITIALIZER_LIST(
125 restore_button_(new views::ImageButton(this))), 126 restore_button_(new views::ImageButton(this))),
126 ALLOW_THIS_IN_INITIALIZER_LIST( 127 ALLOW_THIS_IN_INITIALIZER_LIST(
127 close_button_(new views::ImageButton(this))), 128 close_button_(new views::ImageButton(this))),
128 window_icon_(NULL) { 129 window_icon_(NULL),
130 frame_background_(new views::FrameBackground()) {
129 ui::ThemeProvider* tp = frame->GetThemeProvider(); 131 ui::ThemeProvider* tp = frame->GetThemeProvider();
130 SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND); 132 SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND);
131 SkBitmap* background = 133 SkBitmap* background =
132 tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND); 134 tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND);
133 minimize_button_->SetImage(views::CustomButton::BS_NORMAL, 135 minimize_button_->SetImage(views::CustomButton::BS_NORMAL,
134 tp->GetBitmapNamed(IDR_MINIMIZE)); 136 tp->GetBitmapNamed(IDR_MINIMIZE));
135 minimize_button_->SetImage(views::CustomButton::BS_HOT, 137 minimize_button_->SetImage(views::CustomButton::BS_HOT,
136 tp->GetBitmapNamed(IDR_MINIMIZE_H)); 138 tp->GetBitmapNamed(IDR_MINIMIZE_H));
137 minimize_button_->SetImage(views::CustomButton::BS_PUSHED, 139 minimize_button_->SetImage(views::CustomButton::BS_PUSHED,
138 tp->GetBitmapNamed(IDR_MINIMIZE_P)); 140 tp->GetBitmapNamed(IDR_MINIMIZE_P));
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; 571 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2;
570 } else { 572 } else {
571 // For "browser mode" windows, we use the native positioning, which is just 573 // For "browser mode" windows, we use the native positioning, which is just
572 // below the top frame border. 574 // below the top frame border.
573 y = frame_thickness; 575 y = frame_thickness;
574 } 576 }
575 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); 577 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size);
576 } 578 }
577 579
578 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 580 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
581 frame_background_->set_frame_color(GetFrameColor());
582 frame_background_->set_theme_bitmap(GetFrameBitmap());
583 frame_background_->set_theme_overlay_bitmap(GetFrameOverlayBitmap());
584 frame_background_->set_top_area_height(GetTopAreaHeight());
585
579 ui::ThemeProvider* tp = GetThemeProvider(); 586 ui::ThemeProvider* tp = GetThemeProvider();
580 587 frame_background_->SetSideImages(
588 tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE),
589 tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER),
590 tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE),
591 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER));
581 #if defined(USE_AURA) 592 #if defined(USE_AURA)
582 // TODO(jamescook): Remove this when Aura defaults to its own window frame, 593 // TODO(jamescook): Remove this when Aura defaults to its own window frame,
583 // BrowserNonClientFrameViewAura. Until then, use custom square corners to 594 // BrowserNonClientFrameViewAura. Until then, use custom square corners to
584 // avoid performance penalties associated with transparent layers. 595 // avoid performance penalties associated with transparent layers.
585 SkBitmap* top_left_corner = tp->GetBitmapNamed(IDR_AURA_WINDOW_TOP_LEFT); 596 frame_background_->SetCornerImages(
586 SkBitmap* top_right_corner = tp->GetBitmapNamed(IDR_AURA_WINDOW_TOP_RIGHT); 597 tp->GetBitmapNamed(IDR_AURA_WINDOW_TOP_LEFT),
587 SkBitmap* bottom_left_corner = 598 tp->GetBitmapNamed(IDR_AURA_WINDOW_TOP_RIGHT),
588 tp->GetBitmapNamed(IDR_AURA_WINDOW_BOTTOM_LEFT); 599 tp->GetBitmapNamed(IDR_AURA_WINDOW_BOTTOM_LEFT),
589 SkBitmap* bottom_right_corner = 600 tp->GetBitmapNamed(IDR_AURA_WINDOW_BOTTOM_RIGHT));
590 tp->GetBitmapNamed(IDR_AURA_WINDOW_BOTTOM_RIGHT);
591 #else 601 #else
592 SkBitmap* top_left_corner = tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER); 602 frame_background_->SetCornerImages(
593 SkBitmap* top_right_corner = tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER); 603 tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER),
594 SkBitmap* bottom_left_corner = 604 tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER),
595 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); 605 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER),
596 SkBitmap* bottom_right_corner = 606 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER));
597 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER);
598 #endif 607 #endif
599 SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER); 608 frame_background_->PaintRestored(canvas, this);
600 SkBitmap* right_edge = tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE);
601 SkBitmap* left_edge = tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE);
602 SkBitmap* bottom_edge = tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER);
603 609
604 // Fill with the frame color first so we have a constant background for
605 // areas not covered by the theme image.
606 SkBitmap* theme_frame = GetFrameBitmap();
607 int top_area_height = theme_frame->height();
608 if (browser_view()->IsTabStripVisible()) {
609 top_area_height = std::max(top_area_height,
610 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
611 }
612 SkColor frame_color = GetFrameColor();
613 canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height));
614
615 int remaining_height = height() - top_area_height;
616 if (remaining_height > 0) {
617 // Now fill down the sides.
618 canvas->FillRect(frame_color,
619 gfx::Rect(0, top_area_height, left_edge->width(),
620 remaining_height));
621 canvas->FillRect(frame_color,
622 gfx::Rect(width() - right_edge->width(),
623 top_area_height, right_edge->width(),
624 remaining_height));
625 int center_width = width() - left_edge->width() - right_edge->width();
626 if (center_width > 0) {
627 // Now fill the bottom area.
628 canvas->FillRect(frame_color,
629 gfx::Rect(left_edge->width(),
630 height() - bottom_edge->height(),
631 center_width, bottom_edge->height()));
632 }
633 }
634
635 // Draw the theme frame.
636 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height());
637
638 // Draw the theme frame overlay.
639 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
640 browser_view()->IsBrowserTypeNormal() &&
641 !browser_view()->IsOffTheRecord()) {
642 canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ?
643 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0);
644 }
645
646 // Top.
647 int top_left_height = std::min(top_left_corner->height(),
648 height() - bottom_left_corner->height());
649 canvas->DrawBitmapInt(*top_left_corner, 0, 0, top_left_corner->width(),
650 top_left_height, 0, 0, top_left_corner->width(), top_left_height, false);
651 canvas->TileImageInt(*top_edge, top_left_corner->width(), 0,
652 width() - top_left_corner->width() - top_right_corner->width(),
653 top_edge->height());
654 int top_right_height = std::min(top_right_corner->height(),
655 height() - bottom_right_corner->height());
656 canvas->DrawBitmapInt(*top_right_corner, 0, 0, top_right_corner->width(),
657 top_right_height, width() - top_right_corner->width(), 0,
658 top_right_corner->width(), top_right_height, false);
659 // Note: When we don't have a toolbar, we need to draw some kind of bottom 610 // Note: When we don't have a toolbar, we need to draw some kind of bottom
660 // edge here. Because the App Window graphics we use for this have an 611 // edge here. Because the App Window graphics we use for this have an
661 // attached client edge and their sizing algorithm is a little involved, we do 612 // attached client edge and their sizing algorithm is a little involved, we do
662 // all this in PaintRestoredClientEdge(). 613 // all this in PaintRestoredClientEdge().
663
664 // Right.
665 canvas->TileImageInt(*right_edge, width() - right_edge->width(),
666 top_right_height, right_edge->width(),
667 height() - top_right_height - bottom_right_corner->height());
668
669 // Bottom.
670 canvas->DrawBitmapInt(*bottom_right_corner,
671 width() - bottom_right_corner->width(),
672 height() - bottom_right_corner->height());
673 canvas->TileImageInt(*bottom_edge, bottom_left_corner->width(),
674 height() - bottom_edge->height(),
675 width() - bottom_left_corner->width() - bottom_right_corner->width(),
676 bottom_edge->height());
677 canvas->DrawBitmapInt(*bottom_left_corner, 0,
678 height() - bottom_left_corner->height());
679
680 // Left.
681 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(),
682 height() - top_left_height - bottom_left_corner->height());
683 } 614 }
684 615
685 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 616 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
686 ui::ThemeProvider* tp = GetThemeProvider(); 617 frame_background_->set_frame_color(GetFrameColor());
618 frame_background_->set_theme_bitmap(GetFrameBitmap());
619 frame_background_->set_theme_overlay_bitmap(GetFrameOverlayBitmap());
620 frame_background_->set_top_area_height(GetTopAreaHeight());
687 621
688 // Allow customization of these attributes. 622 // Allow customization of these attributes.
689 SkBitmap* left = NULL; 623 SkBitmap* left = NULL;
690 SkBitmap* right = NULL; 624 SkBitmap* right = NULL;
691 int top_offset = 0; 625 int top_offset = 0;
692 ModifyMaximizedFramePainting(&top_offset, &left, &right); 626 ModifyMaximizedFramePainting(&top_offset, &left, &right);
627 frame_background_->SetMaximizedCorners(left, right, top_offset);
693 628
694 // We will be painting from top_offset to top_offset + theme_frame_height. If 629 // Theme frame must be aligned with the tabstrip as if we were
695 // this is less than GetBoundsForTabStrip.bottom, we need to paint the frame
696 // color.
697 SkBitmap* theme_frame = GetFrameBitmap();
698 int theme_frame_bottom = top_offset + theme_frame->height();
699 int top_area_height =
700 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom();
701 if (top_area_height > theme_frame_bottom) {
702 SkColor frame_color = GetFrameColor();
703 canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height));
704 }
705
706 // Draw the theme frame. It must be aligned with the tabstrip as if we were
707 // in restored mode. Note that the top of the tabstrip is 630 // in restored mode. Note that the top of the tabstrip is
708 // kTabstripTopShadowThickness px off the top of the screen. 631 // kTabstripTopShadowThickness px off the top of the screen.
709 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + 632 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) +
710 kTabstripTopShadowThickness); 633 kTabstripTopShadowThickness);
711 int left_offset = 0, right_offset = 0; 634 frame_background_->set_theme_background_y(theme_background_y);
712 635
713 if (left || right) { 636 frame_background_->PaintMaximized(canvas, this);
714 // If we have either a left or right we should have both.
715 DCHECK(left && right);
716 left_offset = left->width();
717 right_offset = right->width();
718 canvas->DrawBitmapInt(*left, 0, 0);
719 canvas->DrawBitmapInt(*right, width() - right_offset, 0);
720 }
721 637
722 canvas->TileImageInt(*theme_frame, 638 // TODO(jamescook): Migrate this into FrameBackground.
723 left_offset,
724 top_offset,
725 width() - (left_offset + right_offset),
726 theme_frame->height());
727 // Draw the theme frame overlay
728 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
729 browser_view()->IsBrowserTypeNormal() &&
730 !browser_view()->IsOffTheRecord()) {
731 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
732 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
733 canvas->DrawBitmapInt(*theme_overlay, 0, theme_background_y);
734 }
735
736 if (!browser_view()->IsToolbarVisible()) { 639 if (!browser_view()->IsToolbarVisible()) {
737 // There's no toolbar to edge the frame border, so we need to draw a bottom 640 // There's no toolbar to edge the frame border, so we need to draw a bottom
738 // edge. The graphic we use for this has a built in client edge, so we clip 641 // edge. The graphic we use for this has a built in client edge, so we clip
739 // it off the bottom. 642 // it off the bottom.
740 SkBitmap* top_center = 643 SkBitmap* top_center =
741 tp->GetBitmapNamed(IDR_APP_TOP_CENTER); 644 GetThemeProvider()->GetBitmapNamed(IDR_APP_TOP_CENTER);
742 int edge_height = top_center->height() - kClientEdgeThickness; 645 int edge_height = top_center->height() - kClientEdgeThickness;
743 canvas->TileImageInt(*top_center, 0, 646 canvas->TileImageInt(*top_center, 0,
744 frame()->client_view()->y() - edge_height, width(), edge_height); 647 frame()->client_view()->y() - edge_height, width(), edge_height);
745 } 648 }
746 } 649 }
747 650
748 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { 651 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
749 // The window icon is painted by the TabIconView. 652 // The window icon is painted by the TabIconView.
750 views::WidgetDelegate* delegate = frame()->widget_delegate(); 653 views::WidgetDelegate* delegate = frame()->widget_delegate();
751 if (!delegate) { 654 if (!delegate) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 gfx::Rect(client_area_bounds.x(), client_area_bottom, 855 gfx::Rect(client_area_bounds.x(), client_area_bottom,
953 client_area_bounds.width(), kClientEdgeThickness)); 856 client_area_bounds.width(), kClientEdgeThickness));
954 canvas->FillRect( 857 canvas->FillRect(
955 toolbar_color, 858 toolbar_color,
956 gfx::Rect(client_area_bounds.right(), 859 gfx::Rect(client_area_bounds.right(),
957 client_area_top, 860 client_area_top,
958 kClientEdgeThickness, 861 kClientEdgeThickness,
959 client_area_bottom + kClientEdgeThickness - client_area_top)); 862 client_area_bottom + kClientEdgeThickness - client_area_top));
960 } 863 }
961 864
865 SkColor OpaqueBrowserFrameView::GetFrameColor() const {
866 bool is_incognito = browser_view()->IsOffTheRecord();
867 if (browser_view()->IsBrowserTypeNormal()) {
868 if (ShouldPaintAsActive()) {
869 return GetThemeProvider()->GetColor(is_incognito ?
870 ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME);
871 }
872 return GetThemeProvider()->GetColor(is_incognito ?
873 ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE :
874 ThemeService::COLOR_FRAME_INACTIVE);
875 }
876 // Never theme app and popup windows.
877 if (ShouldPaintAsActive()) {
878 return is_incognito ?
879 ResourceBundle::frame_color_incognito : ResourceBundle::frame_color;
880 }
881 return is_incognito ?
882 ResourceBundle::frame_color_incognito_inactive :
883 ResourceBundle::frame_color_inactive;
884 }
885
962 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { 886 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const {
963 bool is_incognito = browser_view()->IsOffTheRecord(); 887 bool is_incognito = browser_view()->IsOffTheRecord();
964 int resource_id; 888 int resource_id;
965 if (browser_view()->IsBrowserTypeNormal()) { 889 if (browser_view()->IsBrowserTypeNormal()) {
966 if (ShouldPaintAsActive()) { 890 if (ShouldPaintAsActive()) {
967 resource_id = is_incognito ? 891 resource_id = is_incognito ?
968 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; 892 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
969 } else { 893 } else {
970 resource_id = is_incognito ? 894 resource_id = is_incognito ?
971 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; 895 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
972 } 896 }
973 return GetThemeProvider()->GetBitmapNamed(resource_id); 897 return GetThemeProvider()->GetBitmapNamed(resource_id);
974 } 898 }
975 // Never theme app and popup windows. 899 // Never theme app and popup windows.
976 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 900 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
977 if (ShouldPaintAsActive()) { 901 if (ShouldPaintAsActive()) {
978 resource_id = is_incognito ? 902 resource_id = is_incognito ?
979 IDR_THEME_FRAME_INCOGNITO : IDR_FRAME; 903 IDR_THEME_FRAME_INCOGNITO : IDR_FRAME;
980 } else { 904 } else {
981 resource_id = is_incognito ? 905 resource_id = is_incognito ?
982 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; 906 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
983 } 907 }
984 return rb.GetBitmapNamed(resource_id); 908 return rb.GetBitmapNamed(resource_id);
985 } 909 }
986 910
987 SkColor OpaqueBrowserFrameView::GetFrameColor() const { 911 SkBitmap* OpaqueBrowserFrameView::GetFrameOverlayBitmap() const {
988 bool is_incognito = browser_view()->IsOffTheRecord(); 912 ui::ThemeProvider* tp = GetThemeProvider();
989 if (browser_view()->IsBrowserTypeNormal()) { 913 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
990 if (ShouldPaintAsActive()) { 914 browser_view()->IsBrowserTypeNormal() &&
991 return GetThemeProvider()->GetColor(is_incognito ? 915 !browser_view()->IsOffTheRecord()) {
992 ThemeService::COLOR_FRAME_INCOGNITO : ThemeService::COLOR_FRAME); 916 return tp->GetBitmapNamed(ShouldPaintAsActive() ?
993 } 917 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
994 return GetThemeProvider()->GetColor(is_incognito ?
995 ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE :
996 ThemeService::COLOR_FRAME_INACTIVE);
997 } 918 }
998 // Never theme app and popup windows. 919 return NULL;
999 if (ShouldPaintAsActive()) { 920 }
1000 return is_incognito ? 921
1001 ResourceBundle::frame_color_incognito : ResourceBundle::frame_color; 922 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
923 SkBitmap* frame_bitmap = GetFrameBitmap();
924 int top_area_height = frame_bitmap->height();
925 if (browser_view()->IsTabStripVisible()) {
926 top_area_height = std::max(top_area_height,
927 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
1002 } 928 }
1003 return is_incognito ? 929 return top_area_height;
1004 ResourceBundle::frame_color_incognito_inactive :
1005 ResourceBundle::frame_color_inactive;
1006 } 930 }
1007 931
1008 void OpaqueBrowserFrameView::LayoutWindowControls() { 932 void OpaqueBrowserFrameView::LayoutWindowControls() {
1009 bool is_maximized = frame()->IsMaximized(); 933 bool is_maximized = frame()->IsMaximized();
1010 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 934 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
1011 views::ImageButton::ALIGN_BOTTOM); 935 views::ImageButton::ALIGN_BOTTOM);
1012 int caption_y = CaptionButtonY(false); 936 int caption_y = CaptionButtonY(false);
1013 // There should always be the same number of non-shadow pixels visible to the 937 // There should always be the same number of non-shadow pixels visible to the
1014 // side of the caption buttons. In maximized mode we extend the rightmost 938 // side of the caption buttons. In maximized mode we extend the rightmost
1015 // button to the screen corner to obey Fitts' Law. 939 // button to the screen corner to obey Fitts' Law.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1056
1133 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, 1057 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
1134 int height) const { 1058 int height) const {
1135 int top_height = NonClientTopBorderHeight(false); 1059 int top_height = NonClientTopBorderHeight(false);
1136 int border_thickness = NonClientBorderThickness(); 1060 int border_thickness = NonClientBorderThickness();
1137 return gfx::Rect(border_thickness, top_height, 1061 return gfx::Rect(border_thickness, top_height,
1138 std::max(0, width - (2 * border_thickness)), 1062 std::max(0, width - (2 * border_thickness)),
1139 std::max(0, height - GetReservedHeight() - 1063 std::max(0, height - GetReservedHeight() -
1140 top_height - border_thickness)); 1064 top_height - border_thickness));
1141 } 1065 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view.h ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698