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

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

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "app/theme_provider.h"
10 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
11 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/themes/browser_theme_provider.h" 12 #include "chrome/browser/themes/browser_theme_provider.h"
14 #include "chrome/browser/ui/views/frame/browser_frame.h" 13 #include "chrome/browser/ui/views/frame/browser_frame.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 14 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/tabs/tab_strip.h" 15 #include "chrome/browser/ui/views/tabs/tab_strip.h"
17 #include "chrome/browser/ui/views/toolbar_view.h" 16 #include "chrome/browser/ui/views/toolbar_view.h"
18 #include "gfx/canvas_skia.h" 17 #include "gfx/canvas_skia.h"
19 #include "gfx/font.h" 18 #include "gfx/font.h"
20 #include "gfx/path.h" 19 #include "gfx/path.h"
21 #include "grit/app_resources.h" 20 #include "grit/app_resources.h"
22 #include "grit/chromium_strings.h" 21 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "ui/base/theme_provider.h"
25 #include "views/controls/button/image_button.h" 25 #include "views/controls/button/image_button.h"
26 #include "views/controls/image_view.h" 26 #include "views/controls/image_view.h"
27 #include "views/widget/root_view.h" 27 #include "views/widget/root_view.h"
28 #include "views/window/window.h" 28 #include "views/window/window.h"
29 #include "views/window/window_resources.h" 29 #include "views/window/window_resources.h"
30 #include "views/window/window_shape.h" 30 #include "views/window/window_shape.h"
31 31
32 #if defined(OS_LINUX) 32 #if defined(OS_LINUX)
33 #include "views/window/hit_test.h" 33 #include "views/window/hit_test.h"
34 #endif 34 #endif
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 minimize_button_(new views::ImageButton(this))), 100 minimize_button_(new views::ImageButton(this))),
101 ALLOW_THIS_IN_INITIALIZER_LIST( 101 ALLOW_THIS_IN_INITIALIZER_LIST(
102 maximize_button_(new views::ImageButton(this))), 102 maximize_button_(new views::ImageButton(this))),
103 ALLOW_THIS_IN_INITIALIZER_LIST( 103 ALLOW_THIS_IN_INITIALIZER_LIST(
104 restore_button_(new views::ImageButton(this))), 104 restore_button_(new views::ImageButton(this))),
105 ALLOW_THIS_IN_INITIALIZER_LIST( 105 ALLOW_THIS_IN_INITIALIZER_LIST(
106 close_button_(new views::ImageButton(this))), 106 close_button_(new views::ImageButton(this))),
107 window_icon_(NULL), 107 window_icon_(NULL),
108 frame_(frame), 108 frame_(frame),
109 browser_view_(browser_view) { 109 browser_view_(browser_view) {
110 ThemeProvider* tp = frame_->GetThemeProviderForFrame(); 110 ui::ThemeProvider* tp = frame_->GetThemeProviderForFrame();
111 SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); 111 SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND);
112 SkBitmap* background = 112 SkBitmap* background =
113 tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND); 113 tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND);
114 minimize_button_->SetImage(views::CustomButton::BS_NORMAL, 114 minimize_button_->SetImage(views::CustomButton::BS_NORMAL,
115 tp->GetBitmapNamed(IDR_MINIMIZE)); 115 tp->GetBitmapNamed(IDR_MINIMIZE));
116 minimize_button_->SetImage(views::CustomButton::BS_HOT, 116 minimize_button_->SetImage(views::CustomButton::BS_HOT,
117 tp->GetBitmapNamed(IDR_MINIMIZE_H)); 117 tp->GetBitmapNamed(IDR_MINIMIZE_H));
118 minimize_button_->SetImage(views::CustomButton::BS_PUSHED, 118 minimize_button_->SetImage(views::CustomButton::BS_PUSHED,
119 tp->GetBitmapNamed(IDR_MINIMIZE_P)); 119 tp->GetBitmapNamed(IDR_MINIMIZE_P));
120 if (browser_view_->IsBrowserTypeNormal()) { 120 if (browser_view_->IsBrowserTypeNormal()) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; 534 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2;
535 } else { 535 } else {
536 // For "browser mode" windows, we use the native positioning, which is just 536 // For "browser mode" windows, we use the native positioning, which is just
537 // below the top frame border. 537 // below the top frame border.
538 y = frame_thickness; 538 y = frame_thickness;
539 } 539 }
540 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); 540 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size);
541 } 541 }
542 542
543 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 543 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
544 ThemeProvider* tp = GetThemeProvider(); 544 ui::ThemeProvider* tp = GetThemeProvider();
545 545
546 SkBitmap* top_left_corner = tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER); 546 SkBitmap* top_left_corner = tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER);
547 SkBitmap* top_right_corner = 547 SkBitmap* top_right_corner =
548 tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER); 548 tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER);
549 SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER); 549 SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER);
550 SkBitmap* right_edge = tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE); 550 SkBitmap* right_edge = tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE);
551 SkBitmap* left_edge = tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE); 551 SkBitmap* left_edge = tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE);
552 SkBitmap* bottom_left_corner = 552 SkBitmap* bottom_left_corner =
553 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); 553 tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER);
554 SkBitmap* bottom_right_corner = 554 SkBitmap* bottom_right_corner =
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 canvas->DrawBitmapInt(*bottom_left_corner, 0, 652 canvas->DrawBitmapInt(*bottom_left_corner, 0,
653 height() - bottom_left_corner->height()); 653 height() - bottom_left_corner->height());
654 654
655 // Left. 655 // Left.
656 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(), 656 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(),
657 height() - top_left_height - bottom_left_corner->height()); 657 height() - top_left_height - bottom_left_corner->height());
658 } 658 }
659 659
660 660
661 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 661 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
662 ThemeProvider* tp = GetThemeProvider(); 662 ui::ThemeProvider* tp = GetThemeProvider();
663 views::Window* window = frame_->GetWindow(); 663 views::Window* window = frame_->GetWindow();
664 664
665 // Window frame mode and color 665 // Window frame mode and color
666 SkBitmap* theme_frame; 666 SkBitmap* theme_frame;
667 // Never theme app and popup windows. 667 // Never theme app and popup windows.
668 if (!browser_view_->IsBrowserTypeNormal()) { 668 if (!browser_view_->IsBrowserTypeNormal()) {
669 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 669 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
670 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ? 670 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ?
671 IDR_FRAME : IDR_FRAME_INACTIVE); 671 IDR_FRAME : IDR_FRAME_INACTIVE);
672 } else if (!browser_view_->IsOffTheRecord()) { 672 } else if (!browser_view_->IsOffTheRecord()) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 y = toolbar_bounds.y(); 745 y = toolbar_bounds.y();
746 h = toolbar_bounds.bottom(); 746 h = toolbar_bounds.bottom();
747 } 747 }
748 748
749 // Gross hack: We split the toolbar images into two pieces, since sometimes 749 // Gross hack: We split the toolbar images into two pieces, since sometimes
750 // (popup mode) the toolbar isn't tall enough to show the whole image. The 750 // (popup mode) the toolbar isn't tall enough to show the whole image. The
751 // split happens between the top shadow section and the bottom gradient 751 // split happens between the top shadow section and the bottom gradient
752 // section so that we never break the gradient. 752 // section so that we never break the gradient.
753 int split_point = kFrameShadowThickness * 2; 753 int split_point = kFrameShadowThickness * 2;
754 int bottom_y = y + split_point; 754 int bottom_y = y + split_point;
755 ThemeProvider* tp = GetThemeProvider(); 755 ui::ThemeProvider* tp = GetThemeProvider();
756 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); 756 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
757 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; 757 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point;
758 758
759 // Split our canvas out so we can mask out the corners of the toolbar 759 // Split our canvas out so we can mask out the corners of the toolbar
760 // without masking out the frame. 760 // without masking out the frame.
761 canvas->SaveLayerAlpha( 761 canvas->SaveLayerAlpha(
762 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, 762 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3,
763 h)); 763 h));
764 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 764 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
765 765
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 // Bias the rounding to select a region that's lower rather than higher, 850 // Bias the rounding to select a region that's lower rather than higher,
851 // as the shadows at the image top mean the apparent center is below the 851 // as the shadows at the image top mean the apparent center is below the
852 // real center. 852 // real center.
853 ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h, 853 ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h,
854 otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false); 854 otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false);
855 855
856 canvas->Restore(); 856 canvas->Restore();
857 } 857 }
858 858
859 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 859 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
860 ThemeProvider* tp = GetThemeProvider(); 860 ui::ThemeProvider* tp = GetThemeProvider();
861 int client_area_top = frame_->GetWindow()->GetClientView()->y(); 861 int client_area_top = frame_->GetWindow()->GetClientView()->y();
862 int image_top = client_area_top; 862 int image_top = client_area_top;
863 863
864 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); 864 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
865 SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); 865 SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
866 866
867 if (browser_view_->IsToolbarVisible()) { 867 if (browser_view_->IsToolbarVisible()) {
868 // The client edge images always start below the toolbar corner images. The 868 // The client edge images always start below the toolbar corner images. The
869 // client edge filled rects start there or at the bottom of the tooolbar, 869 // client edge filled rects start there or at the bottom of the tooolbar,
870 // whichever is shorter. 870 // whichever is shorter.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1063
1064 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, 1064 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
1065 int height) const { 1065 int height) const {
1066 int top_height = NonClientTopBorderHeight(false, false); 1066 int top_height = NonClientTopBorderHeight(false, false);
1067 int border_thickness = NonClientBorderThickness(); 1067 int border_thickness = NonClientBorderThickness();
1068 return gfx::Rect(border_thickness, top_height, 1068 return gfx::Rect(border_thickness, top_height,
1069 std::max(0, width - (2 * border_thickness)), 1069 std::max(0, width - (2 * border_thickness)),
1070 std::max(0, height - GetReservedHeight() - 1070 std::max(0, height - GetReservedHeight() -
1071 top_height - border_thickness)); 1071 top_height - border_thickness));
1072 } 1072 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/glass_browser_frame_view.cc ('k') | chrome/browser/ui/views/js_modal_dialog_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698