| 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/browser_theme_provider.h" | 9 #include "chrome/browser/themes/browser_theme_provider.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_frame.h" | 10 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 browser_view_->height()); | 208 browser_view_->height()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 211 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
| 212 (otr_avatar_bounds_.right() + kOTRSideSpacing) : | 212 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
| 213 NonClientBorderThickness() + kTabStripIndent; | 213 NonClientBorderThickness() + kTabStripIndent; |
| 214 | 214 |
| 215 int tabstrip_width = minimize_button_->x() - tabstrip_x - | 215 int tabstrip_width = minimize_button_->x() - tabstrip_x - |
| 216 (frame_->GetWindow()->IsMaximized() ? | 216 (frame_->GetWindow()->IsMaximized() ? |
| 217 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 217 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
| 218 int tabstrip_height = 0; |
| 219 if (tabstrip) |
| 220 tabstrip_height = tabstrip->GetPreferredSize().height(); |
| 218 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | 221 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), |
| 219 std::max(0, tabstrip_width), | 222 std::max(0, tabstrip_width), tabstrip_height); |
| 220 tabstrip->GetPreferredSize().height()); | |
| 221 } | 223 } |
| 222 | 224 |
| 223 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( | 225 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
| 224 bool restored) const { | 226 bool restored) const { |
| 225 return NonClientTopBorderHeight(restored, true) + ((!restored && | 227 return NonClientTopBorderHeight(restored, true) + ((!restored && |
| 226 (frame_->GetWindow()->IsMaximized() || | 228 (frame_->GetWindow()->IsMaximized() || |
| 227 frame_->GetWindow()->IsFullscreen())) ? | 229 frame_->GetWindow()->IsFullscreen())) ? |
| 228 0 : kNonClientRestoredExtraThickness); | 230 0 : kNonClientRestoredExtraThickness); |
| 229 } | 231 } |
| 230 | 232 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 382 } |
| 381 | 383 |
| 382 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { | 384 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { |
| 383 // If the point is outside the bounds of the client area, claim it. | 385 // If the point is outside the bounds of the client area, claim it. |
| 384 bool in_nonclient = NonClientFrameView::HitTest(l); | 386 bool in_nonclient = NonClientFrameView::HitTest(l); |
| 385 if (in_nonclient) | 387 if (in_nonclient) |
| 386 return in_nonclient; | 388 return in_nonclient; |
| 387 | 389 |
| 388 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. | 390 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. |
| 389 bool vertical_tabs = browser_view_->UseVerticalTabs(); | 391 bool vertical_tabs = browser_view_->UseVerticalTabs(); |
| 390 gfx::Rect tabstrip_bounds = browser_view_->tabstrip()->bounds(); | 392 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); |
| 391 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 393 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
| 392 View::ConvertPointToView(frame_->GetWindow()->client_view(), | 394 View::ConvertPointToView(frame_->GetWindow()->client_view(), |
| 393 this, &tabstrip_origin); | 395 this, &tabstrip_origin); |
| 394 tabstrip_bounds.set_origin(tabstrip_origin); | 396 tabstrip_bounds.set_origin(tabstrip_origin); |
| 395 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || | 397 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || |
| 396 (vertical_tabs && l.x() > tabstrip_bounds.right())) { | 398 (vertical_tabs && l.x() > tabstrip_bounds.right())) { |
| 397 return false; | 399 return false; |
| 398 } | 400 } |
| 399 | 401 |
| 400 // We convert from our parent's coordinates since we assume we fill its bounds | 402 // We convert from our parent's coordinates since we assume we fill its bounds |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { | 442 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { |
| 441 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); | 443 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); |
| 442 if (!delegate) { | 444 if (!delegate) { |
| 443 LOG(WARNING) << "delegate is NULL, returning safe default."; | 445 LOG(WARNING) << "delegate is NULL, returning safe default."; |
| 444 return SkBitmap(); | 446 return SkBitmap(); |
| 445 } | 447 } |
| 446 return delegate->GetWindowIcon(); | 448 return delegate->GetWindowIcon(); |
| 447 } | 449 } |
| 448 | 450 |
| 449 /////////////////////////////////////////////////////////////////////////////// | 451 /////////////////////////////////////////////////////////////////////////////// |
| 452 // OpaqueBrowserFrameView, protected: |
| 453 |
| 454 void OpaqueBrowserFrameView::LayoutOTRAvatar() { |
| 455 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 456 int otr_bottom, otr_restored_y; |
| 457 if (browser_view_->UseVerticalTabs()) { |
| 458 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing; |
| 459 otr_restored_y = kFrameShadowThickness; |
| 460 } else { |
| 461 otr_bottom = GetHorizontalTabStripVerticalOffset(false) + |
| 462 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; |
| 463 otr_restored_y = otr_bottom - otr_avatar_icon.height(); |
| 464 } |
| 465 int otr_y = frame_->GetWindow()->IsMaximized() ? |
| 466 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) : |
| 467 otr_restored_y; |
| 468 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, |
| 469 otr_y, otr_avatar_icon.width(), |
| 470 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); |
| 471 } |
| 472 |
| 473 /////////////////////////////////////////////////////////////////////////////// |
| 450 // OpaqueBrowserFrameView, private: | 474 // OpaqueBrowserFrameView, private: |
| 451 | 475 |
| 452 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { | 476 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { |
| 453 views::Window* window = frame_->GetWindow(); | 477 views::Window* window = frame_->GetWindow(); |
| 454 return (!restored && (window->IsMaximized() || window->IsFullscreen())) ? | 478 return (!restored && (window->IsMaximized() || window->IsFullscreen())) ? |
| 455 0 : kFrameBorderThickness; | 479 0 : kFrameBorderThickness; |
| 456 } | 480 } |
| 457 | 481 |
| 458 int OpaqueBrowserFrameView::TopResizeHeight() const { | 482 int OpaqueBrowserFrameView::TopResizeHeight() const { |
| 459 return FrameBorderThickness(false) - kTopResizeAdjust; | 483 return FrameBorderThickness(false) - kTopResizeAdjust; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 // vertical midline rather than below. This compensates for how the icon is | 1063 // vertical midline rather than below. This compensates for how the icon is |
| 1040 // already biased downwards (see IconBounds()) and helps prevent descenders | 1064 // already biased downwards (see IconBounds()) and helps prevent descenders |
| 1041 // on the title from overlapping the 3D edge at the bottom of the titlebar. | 1065 // on the title from overlapping the 3D edge at the bottom of the titlebar. |
| 1042 title_bounds_.SetRect(title_x, | 1066 title_bounds_.SetRect(title_x, |
| 1043 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 1067 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
| 1044 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), | 1068 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), |
| 1045 title_height); | 1069 title_height); |
| 1046 } | 1070 } |
| 1047 } | 1071 } |
| 1048 | 1072 |
| 1049 void OpaqueBrowserFrameView::LayoutOTRAvatar() { | |
| 1050 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | |
| 1051 int otr_bottom, otr_restored_y; | |
| 1052 if (browser_view_->UseVerticalTabs()) { | |
| 1053 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing; | |
| 1054 otr_restored_y = kFrameShadowThickness; | |
| 1055 } else { | |
| 1056 otr_bottom = GetHorizontalTabStripVerticalOffset(false) + | |
| 1057 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; | |
| 1058 otr_restored_y = otr_bottom - otr_avatar_icon.height(); | |
| 1059 } | |
| 1060 int otr_y = frame_->GetWindow()->IsMaximized() ? | |
| 1061 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) : | |
| 1062 otr_restored_y; | |
| 1063 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, | |
| 1064 otr_y, otr_avatar_icon.width(), | |
| 1065 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); | |
| 1066 } | |
| 1067 | |
| 1068 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1073 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1069 int height) const { | 1074 int height) const { |
| 1070 int top_height = NonClientTopBorderHeight(false, false); | 1075 int top_height = NonClientTopBorderHeight(false, false); |
| 1071 int border_thickness = NonClientBorderThickness(); | 1076 int border_thickness = NonClientBorderThickness(); |
| 1072 return gfx::Rect(border_thickness, top_height, | 1077 return gfx::Rect(border_thickness, top_height, |
| 1073 std::max(0, width - (2 * border_thickness)), | 1078 std::max(0, width - (2 * border_thickness)), |
| 1074 std::max(0, height - GetReservedHeight() - | 1079 std::max(0, height - GetReservedHeight() - |
| 1075 top_height - border_thickness)); | 1080 top_height - border_thickness)); |
| 1076 } | 1081 } |
| OLD | NEW |