OLD | NEW |
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/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 GlassBrowserFrameView::~GlassBrowserFrameView() { | 95 GlassBrowserFrameView::~GlassBrowserFrameView() { |
96 } | 96 } |
97 | 97 |
98 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
99 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 99 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
100 | 100 |
101 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 101 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
102 views::View* tabstrip) const { | 102 views::View* tabstrip) const { |
103 int minimize_button_offset = | 103 int minimize_button_offset = |
104 std::min(frame()->GetMinimizeButtonOffset(), width()); | 104 std::min(frame()->GetMinimizeButtonOffset(), width()); |
105 int tabstrip_x = browser_view()->ShouldShowAvatar() ? | 105 int tabstrip_x = NonClientBorderThickness() + kTabStripIndent; |
106 (avatar_bounds_.right() + kAvatarRightSpacing) : | 106 if (browser_view()->ShouldShowAvatar()) { |
107 NonClientBorderThickness() + kTabStripIndent; | 107 // Space between the right edge of the avatar label and the tabstrip. |
108 if (avatar_label()) { | 108 // Note: Setting this < -2 makes the first tab draw over the avatar label. |
109 tabstrip_x += avatar_label()->bounds().width() + | 109 const int kAvatarLabelRightSpacing = -2; |
110 views::kRelatedControlHorizontalSpacing; | 110 if (avatar_label() && avatar_label()->bounds().width()) |
| 111 tabstrip_x = avatar_label()->bounds().right() + kAvatarLabelRightSpacing; |
| 112 else |
| 113 tabstrip_x = avatar_bounds_.right() + kAvatarRightSpacing; |
111 } | 114 } |
112 // In RTL languages, we have moved an avatar icon left by the size of window | 115 // In RTL languages, we have moved an avatar icon left by the size of window |
113 // controls to prevent it from being rendered over them. So, we use its x | 116 // controls to prevent it from being rendered over them. So, we use its x |
114 // position to move this tab strip left when maximized. Also, we can render | 117 // position to move this tab strip left when maximized. Also, we can render |
115 // a tab strip until the left end of this window without considering the size | 118 // a tab strip until the left end of this window without considering the size |
116 // of window controls in RTL languages. | 119 // of window controls in RTL languages. |
117 if (base::i18n::IsRTL()) { | 120 if (base::i18n::IsRTL()) { |
118 if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized()) | 121 if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized()) |
119 tabstrip_x += avatar_bounds_.x(); | 122 tabstrip_x += avatar_bounds_.x(); |
120 minimize_button_offset = width(); | 123 minimize_button_offset = width(); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 252 } |
250 | 253 |
251 void GlassBrowserFrameView::Layout() { | 254 void GlassBrowserFrameView::Layout() { |
252 LayoutAvatar(); | 255 LayoutAvatar(); |
253 LayoutClientView(); | 256 LayoutClientView(); |
254 } | 257 } |
255 | 258 |
256 bool GlassBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { | 259 bool GlassBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { |
257 return (avatar_button() && | 260 return (avatar_button() && |
258 avatar_button()->GetMirroredBounds().Intersects(rect)) || | 261 avatar_button()->GetMirroredBounds().Intersects(rect)) || |
| 262 (avatar_label() && |
| 263 avatar_label()->GetMirroredBounds().Intersects(rect)) || |
259 !frame()->client_view()->bounds().Intersects(rect); | 264 !frame()->client_view()->bounds().Intersects(rect); |
260 } | 265 } |
261 | 266 |
262 /////////////////////////////////////////////////////////////////////////////// | 267 /////////////////////////////////////////////////////////////////////////////// |
263 // GlassBrowserFrameView, private: | 268 // GlassBrowserFrameView, private: |
264 | 269 |
265 int GlassBrowserFrameView::FrameBorderThickness() const { | 270 int GlassBrowserFrameView::FrameBorderThickness() const { |
266 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? | 271 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? |
267 0 : GetSystemMetrics(SM_CXSIZEFRAME); | 272 0 : GetSystemMetrics(SM_CXSIZEFRAME); |
268 } | 273 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 428 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
424 int avatar_y = frame()->IsMaximized() ? | 429 int avatar_y = frame()->IsMaximized() ? |
425 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : | 430 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : |
426 avatar_restored_y; | 431 avatar_restored_y; |
427 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(), | 432 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(), |
428 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 433 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
429 if (avatar_button()) | 434 if (avatar_button()) |
430 avatar_button()->SetBoundsRect(avatar_bounds_); | 435 avatar_button()->SetBoundsRect(avatar_bounds_); |
431 | 436 |
432 if (avatar_label()) { | 437 if (avatar_label()) { |
433 gfx::Size size = avatar_label()->GetPreferredSize(); | 438 // Space between the bottom of the avatar and the bottom of the avatar |
434 int label_height = std::min(avatar_bounds_.height(), size.height()); | 439 // label. |
| 440 const int kAvatarLabelBottomSpacing = 3; |
| 441 // Space between the frame border and the left edge of the avatar label. |
| 442 const int kAvatarLabelLeftSpacing = -2; |
| 443 gfx::Size label_size = avatar_label()->GetPreferredSize(); |
435 gfx::Rect label_bounds( | 444 gfx::Rect label_bounds( |
436 avatar_bounds_.right() + views::kRelatedControlHorizontalSpacing, | 445 NonClientBorderThickness() + kAvatarLabelLeftSpacing, |
437 avatar_y + (avatar_bounds_.height() - label_height) / 2, | 446 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
438 size.width(), | 447 label_size.width(), |
439 browser_view()->ShouldShowAvatar() ? size.height() : 0); | 448 browser_view()->ShouldShowAvatar() ? label_size.height() : 0); |
440 avatar_label()->SetBoundsRect(label_bounds); | 449 avatar_label()->SetBoundsRect(label_bounds); |
441 } | 450 } |
442 } | 451 } |
443 | 452 |
444 void GlassBrowserFrameView::LayoutClientView() { | 453 void GlassBrowserFrameView::LayoutClientView() { |
445 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 454 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
446 } | 455 } |
447 | 456 |
448 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const { | 457 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const { |
449 if (!browser_view()->IsTabStripVisible()) | 458 if (!browser_view()->IsTabStripVisible()) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 static bool initialized = false; | 538 static bool initialized = false; |
530 if (!initialized) { | 539 if (!initialized) { |
531 for (int i = 0; i < kThrobberIconCount; ++i) { | 540 for (int i = 0; i < kThrobberIconCount; ++i) { |
532 throbber_icons_[i] = | 541 throbber_icons_[i] = |
533 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 542 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
534 DCHECK(throbber_icons_[i]); | 543 DCHECK(throbber_icons_[i]); |
535 } | 544 } |
536 initialized = true; | 545 initialized = true; |
537 } | 546 } |
538 } | 547 } |
OLD | NEW |