Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_frame.h" | 10 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // In maximized mode, where the New Tab button and the caption buttons are at | 83 // In maximized mode, where the New Tab button and the caption buttons are at |
| 84 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 84 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
| 85 // looking too cluttered. | 85 // looking too cluttered. |
| 86 const int kNewTabCaptionMaximizedSpacing = 16; | 86 const int kNewTabCaptionMaximizedSpacing = 16; |
| 87 // How far to indent the tabstrip from the left side of the screen when there | 87 // How far to indent the tabstrip from the left side of the screen when there |
| 88 // is no OTR icon. | 88 // is no OTR icon. |
| 89 const int kTabStripIndent = 1; | 89 const int kTabStripIndent = 1; |
| 90 // Inset from the top of the toolbar/tabstrip to the shadow. Used only for | 90 // Inset from the top of the toolbar/tabstrip to the shadow. Used only for |
| 91 // vertical tabs. | 91 // vertical tabs. |
| 92 const int kVerticalTabBorderInset = 3; | 92 const int kVerticalTabBorderInset = 3; |
| 93 | |
| 94 // Converts |bounds| from |src|'s coordinate system to |dst|, and checks if | |
| 95 // |pt| is contained within. | |
| 96 bool ConvertedContainsCheck(gfx::Rect bounds, const views::View* src, | |
| 97 const views::View* dst, const gfx::Point& pt) { | |
| 98 DCHECK(src); | |
| 99 DCHECK(dst); | |
| 100 gfx::Point origin(bounds.origin()); | |
| 101 views::View::ConvertPointToView(src, dst, &origin); | |
| 102 bounds.set_origin(origin); | |
| 103 return bounds.Contains(pt); | |
| 104 } | |
| 105 | |
| 93 } | 106 } |
| 94 | 107 |
| 95 /////////////////////////////////////////////////////////////////////////////// | 108 /////////////////////////////////////////////////////////////////////////////// |
| 96 // OpaqueBrowserFrameView, public: | 109 // OpaqueBrowserFrameView, public: |
| 97 | 110 |
| 98 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, | 111 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, |
| 99 BrowserView* browser_view) | 112 BrowserView* browser_view) |
| 100 : BrowserNonClientFrameView(), | 113 : BrowserNonClientFrameView(), |
| 101 ALLOW_THIS_IN_INITIALIZER_LIST( | 114 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 102 minimize_button_(new views::ImageButton(this))), | 115 minimize_button_(new views::ImageButton(this))), |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 398 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
| 386 views::Window* window = frame_->GetWindow(); | 399 views::Window* window = frame_->GetWindow(); |
| 387 if (window->IsFullscreen()) | 400 if (window->IsFullscreen()) |
| 388 return; // Nothing is visible, so don't bother to paint. | 401 return; // Nothing is visible, so don't bother to paint. |
| 389 | 402 |
| 390 if (window->IsMaximized()) | 403 if (window->IsMaximized()) |
| 391 PaintMaximizedFrameBorder(canvas); | 404 PaintMaximizedFrameBorder(canvas); |
| 392 else | 405 else |
| 393 PaintRestoredFrameBorder(canvas); | 406 PaintRestoredFrameBorder(canvas); |
| 394 PaintTitleBar(canvas); | 407 PaintTitleBar(canvas); |
| 395 if (browser_view_->IsToolbarVisible()) | 408 if (browser_view_->IsToolbarVisible() || |
| 409 browser_view_->UseCompactNavigationBar()) | |
| 396 PaintToolbarBackground(canvas); | 410 PaintToolbarBackground(canvas); |
| 397 if (browser_view_->ShouldShowOffTheRecordAvatar()) | 411 if (browser_view_->ShouldShowOffTheRecordAvatar()) |
| 398 PaintOTRAvatar(canvas); | 412 PaintOTRAvatar(canvas); |
| 399 if (!window->IsMaximized()) | 413 if (!window->IsMaximized()) |
| 400 PaintRestoredClientEdge(canvas); | 414 PaintRestoredClientEdge(canvas); |
| 401 } | 415 } |
| 402 | 416 |
| 403 void OpaqueBrowserFrameView::Layout() { | 417 void OpaqueBrowserFrameView::Layout() { |
| 404 LayoutWindowControls(); | 418 LayoutWindowControls(); |
| 405 LayoutTitleBar(); | 419 LayoutTitleBar(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 418 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); | 432 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); |
| 419 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 433 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
| 420 View::ConvertPointToView(frame_->GetWindow()->client_view(), | 434 View::ConvertPointToView(frame_->GetWindow()->client_view(), |
| 421 this, &tabstrip_origin); | 435 this, &tabstrip_origin); |
| 422 tabstrip_bounds.set_origin(tabstrip_origin); | 436 tabstrip_bounds.set_origin(tabstrip_origin); |
| 423 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || | 437 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || |
| 424 (vertical_tabs && l.x() > tabstrip_bounds.right())) { | 438 (vertical_tabs && l.x() > tabstrip_bounds.right())) { |
| 425 return false; | 439 return false; |
| 426 } | 440 } |
| 427 | 441 |
| 442 // Claim it only if we're also not in the compact navigation buttons. | |
| 443 if (browser_view_->UseCompactNavigationBar()) { | |
|
sky
2011/05/03 18:38:32
Did you need to do anything in glass_browser_frame
SteveT
2011/05/06 18:48:43
No - it turns out GlassBrowserFrameView's HitTest
| |
| 444 if (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(), | |
| 445 frame_->GetWindow()->client_view(), | |
| 446 static_cast<const View*>(this), | |
| 447 l)) { | |
| 448 return false; | |
| 449 } | |
| 450 if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(), | |
| 451 frame_->GetWindow()->client_view(), | |
| 452 static_cast<const View*>(this), | |
| 453 l)) { | |
| 454 return false; | |
| 455 } | |
| 456 } | |
| 457 | |
| 428 // We convert from our parent's coordinates since we assume we fill its bounds | 458 // We convert from our parent's coordinates since we assume we fill its bounds |
| 429 // completely. We need to do this since we're not a parent of the tabstrip, | 459 // completely. We need to do this since we're not a parent of the tabstrip, |
| 430 // meaning ConvertPointToView would otherwise return something bogus. | 460 // meaning ConvertPointToView would otherwise return something bogus. |
| 431 gfx::Point browser_view_point(l); | 461 gfx::Point browser_view_point(l); |
| 432 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); | 462 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); |
| 433 return browser_view_->IsPositionInWindowCaption(browser_view_point); | 463 return browser_view_->IsPositionInWindowCaption(browser_view_point); |
| 434 } | 464 } |
| 435 | 465 |
| 436 void OpaqueBrowserFrameView::GetAccessibleState( | 466 void OpaqueBrowserFrameView::GetAccessibleState( |
| 437 ui::AccessibleViewState* state) { | 467 ui::AccessibleViewState* state) { |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 } | 921 } |
| 892 | 922 |
| 893 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 923 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
| 894 ui::ThemeProvider* tp = GetThemeProvider(); | 924 ui::ThemeProvider* tp = GetThemeProvider(); |
| 895 int client_area_top = frame_->GetWindow()->client_view()->y(); | 925 int client_area_top = frame_->GetWindow()->client_view()->y(); |
| 896 int image_top = client_area_top; | 926 int image_top = client_area_top; |
| 897 | 927 |
| 898 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 928 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 899 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 929 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
| 900 | 930 |
| 901 if (browser_view_->IsToolbarVisible()) { | 931 if (browser_view_->IsToolbarVisible() || |
| 932 browser_view_->UseCompactNavigationBar()) { | |
| 902 // The client edge images always start below the toolbar corner images. The | 933 // The client edge images always start below the toolbar corner images. The |
| 903 // client edge filled rects start there or at the bottom of the tooolbar, | 934 // client edge filled rects start there or at the bottom of the toolbar, |
| 904 // whichever is shorter. | 935 // whichever is shorter. |
| 905 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 936 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 906 image_top += toolbar_bounds.y() + | 937 image_top += toolbar_bounds.y() + |
| 907 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); | 938 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
| 908 client_area_top = std::min(image_top, | 939 client_area_top = std::min(image_top, |
| 909 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); | 940 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); |
| 910 if (browser_view_->UseVerticalTabs()) { | 941 if (browser_view_->UseVerticalTabs()) { |
| 911 client_area_top -= kVerticalTabBorderInset; | 942 client_area_top -= kVerticalTabBorderInset; |
| 912 image_top -= kVerticalTabBorderInset; | 943 image_top -= kVerticalTabBorderInset; |
| 913 } | 944 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 | 1128 |
| 1098 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1129 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1099 int height) const { | 1130 int height) const { |
| 1100 int top_height = NonClientTopBorderHeight(false, false); | 1131 int top_height = NonClientTopBorderHeight(false, false); |
| 1101 int border_thickness = NonClientBorderThickness(); | 1132 int border_thickness = NonClientBorderThickness(); |
| 1102 return gfx::Rect(border_thickness, top_height, | 1133 return gfx::Rect(border_thickness, top_height, |
| 1103 std::max(0, width - (2 * border_thickness)), | 1134 std::max(0, width - (2 * border_thickness)), |
| 1104 std::max(0, height - GetReservedHeight() - | 1135 std::max(0, height - GetReservedHeight() - |
| 1105 top_height - border_thickness)); | 1136 top_height - border_thickness)); |
| 1106 } | 1137 } |
| OLD | NEW |