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/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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 /////////////////////////////////////////////////////////////////////////////// | 229 /////////////////////////////////////////////////////////////////////////////// |
230 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: | 230 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
231 | 231 |
232 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( | 232 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( |
233 views::View* tabstrip) const { | 233 views::View* tabstrip) const { |
234 if (!tabstrip) | 234 if (!tabstrip) |
235 return gfx::Rect(); | 235 return gfx::Rect(); |
236 | 236 |
237 gfx::Rect bounds = GetBoundsForTabStripAndAvatarArea(tabstrip); | 237 gfx::Rect bounds = GetBoundsForTabStripAndAvatarArea(tabstrip); |
238 int space_left_of_tabstrip = browser_view()->ShouldShowAvatar() ? | 238 int space_left_of_tabstrip = kTabStripIndent; |
239 (kAvatarLeftSpacing + avatar_bounds_.width() + kAvatarRightSpacing) : | 239 if (browser_view()->ShouldShowAvatar()) { |
240 kTabStripIndent; | 240 if (avatar_label() && avatar_label()->bounds().width()) { |
241 if (avatar_label() && avatar_label()->bounds().width()) { | 241 // Space between the right edge of the avatar label and the tabstrip. |
242 space_left_of_tabstrip += views::kRelatedControlHorizontalSpacing + | 242 const int kAvatarLabelRightSpacing = -10; |
243 avatar_label()->bounds().width(); | 243 space_left_of_tabstrip = |
| 244 avatar_label()->bounds().right() + kAvatarLabelRightSpacing; |
| 245 } else { |
| 246 space_left_of_tabstrip = |
| 247 kAvatarLeftSpacing + avatar_bounds_.width() + kAvatarRightSpacing; |
| 248 } |
244 } | 249 } |
245 bounds.Inset(space_left_of_tabstrip, 0, 0, 0); | 250 bounds.Inset(space_left_of_tabstrip, 0, 0, 0); |
246 return bounds; | 251 return bounds; |
247 } | 252 } |
248 | 253 |
249 BrowserNonClientFrameView::TabStripInsets | 254 BrowserNonClientFrameView::TabStripInsets |
250 OpaqueBrowserFrameView::GetTabStripInsets(bool restored) const { | 255 OpaqueBrowserFrameView::GetTabStripInsets(bool restored) const { |
251 int top = NonClientTopBorderHeight(restored) + ((!restored && | 256 int top = NonClientTopBorderHeight(restored) + ((!restored && |
252 (!frame()->ShouldLeaveOffsetNearTopBorder() || | 257 (!frame()->ShouldLeaveOffsetNearTopBorder() || |
253 frame()->IsFullscreen())) ? | 258 frame()->IsFullscreen())) ? |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 int avatar_y = frame()->IsMaximized() ? | 1028 int avatar_y = frame()->IsMaximized() ? |
1024 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : | 1029 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : |
1025 avatar_restored_y; | 1030 avatar_restored_y; |
1026 avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing, | 1031 avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing, |
1027 avatar_y, incognito_icon.width(), | 1032 avatar_y, incognito_icon.width(), |
1028 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 1033 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
1029 if (avatar_button()) | 1034 if (avatar_button()) |
1030 avatar_button()->SetBoundsRect(avatar_bounds_); | 1035 avatar_button()->SetBoundsRect(avatar_bounds_); |
1031 | 1036 |
1032 if (avatar_label()) { | 1037 if (avatar_label()) { |
1033 gfx::Size size = avatar_label()->GetPreferredSize(); | 1038 // Space between the bottom of the avatar and the bottom of the avatar |
1034 int label_height = std::min(avatar_bounds_.height(), size.height()); | 1039 // label. |
| 1040 const int kAvatarLabelBottomSpacing = 3; |
| 1041 // Space between the frame border and the left edge of the avatar label. |
| 1042 const int kAvatarLabelLeftSpacing = -1; |
| 1043 gfx::Size label_size = avatar_label()->GetPreferredSize(); |
1035 gfx::Rect label_bounds( | 1044 gfx::Rect label_bounds( |
1036 avatar_bounds_.right() + views::kRelatedControlHorizontalSpacing, | 1045 FrameBorderThickness(false) + kAvatarLabelLeftSpacing, |
1037 avatar_y + (avatar_bounds_.height() - label_height) / 2, | 1046 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
1038 size.width(), | 1047 label_size.width(), |
1039 browser_view()->ShouldShowAvatar() ? size.height() : 0); | 1048 browser_view()->ShouldShowAvatar() ? label_size.height() : 0); |
1040 avatar_label()->SetBoundsRect(label_bounds); | 1049 avatar_label()->SetBoundsRect(label_bounds); |
1041 } | 1050 } |
1042 } | 1051 } |
1043 | 1052 |
1044 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1053 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1045 int height) const { | 1054 int height) const { |
1046 int top_height = NonClientTopBorderHeight(false); | 1055 int top_height = NonClientTopBorderHeight(false); |
1047 int border_thickness = NonClientBorderThickness(); | 1056 int border_thickness = NonClientBorderThickness(); |
1048 return gfx::Rect(border_thickness, top_height, | 1057 return gfx::Rect(border_thickness, top_height, |
1049 std::max(0, width - (2 * border_thickness)), | 1058 std::max(0, width - (2 * border_thickness)), |
1050 std::max(0, height - GetReservedHeight() - | 1059 std::max(0, height - GetReservedHeight() - |
1051 top_height - border_thickness)); | 1060 top_height - border_thickness)); |
1052 } | 1061 } |
OLD | NEW |