OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_layout.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/profiles/profiles_state.h" | 8 #include "chrome/browser/profiles/profiles_state.h" |
9 #include "chrome/browser/ui/views/profiles/avatar_label.h" | 9 #include "chrome/browser/ui/views/profiles/avatar_label.h" |
10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 11 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
12 #include "components/signin/core/common/profile_management_switches.h" | 13 #include "components/signin/core/common/profile_management_switches.h" |
13 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
14 #include "ui/views/controls/button/image_button.h" | 15 #include "ui/views/controls/button/image_button.h" |
15 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Besides the frame border, there's another 9 px of empty space atop the | 20 // Besides the frame border, there's another 9 px of empty space atop the |
20 // window in restored mode, to use to drag the window around. | 21 // window in restored mode, to use to drag the window around. |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 frame_thickness + kIconLeftSpacing, frame_thickness, size, size); | 376 frame_thickness + kIconLeftSpacing, frame_thickness, size, size); |
376 } | 377 } |
377 } | 378 } |
378 } | 379 } |
379 | 380 |
380 void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) { | 381 void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) { |
381 DCHECK(switches::IsNewAvatarMenu()); | 382 DCHECK(switches::IsNewAvatarMenu()); |
382 if (!new_avatar_button_) | 383 if (!new_avatar_button_) |
383 return; | 384 return; |
384 | 385 |
385 gfx::Size label_size = new_avatar_button_->GetPreferredSize(); | 386 int button_width = new_avatar_button_->GetPreferredSize().width(); |
386 int button_size_with_offset = kNewAvatarButtonOffset + label_size.width(); | 387 int button_width_with_offset = button_width + kNewAvatarButtonOffset; |
387 | 388 |
388 int button_x = host->width() - trailing_button_start_ - | 389 int button_x = |
389 button_size_with_offset; | 390 host->width() - trailing_button_start_ - button_width_with_offset; |
390 int button_y = CaptionButtonY(!IsTitleBarCondensed()); | 391 int button_y = CaptionButtonY(!IsTitleBarCondensed()); |
391 | 392 |
392 trailing_button_start_ += button_size_with_offset; | 393 minimum_size_for_buttons_ += button_width_with_offset; |
393 minimum_size_for_buttons_ += button_size_with_offset; | 394 trailing_button_start_ += button_width_with_offset; |
| 395 |
| 396 // In non-maximized mode, allow the new tab button to completely slide under |
| 397 // the avatar button. |
| 398 if (!IsTitleBarCondensed()) { |
| 399 trailing_button_start_ -= |
| 400 TabStrip::kNewTabButtonAssetWidth + kNewTabCaptionNormalSpacing; |
| 401 } |
394 | 402 |
395 // Do not include the 1px padding that is added for the caption buttons. | 403 // Do not include the 1px padding that is added for the caption buttons. |
396 new_avatar_button_->SetBounds(button_x, | 404 new_avatar_button_->SetBounds( |
397 button_y, | 405 button_x, button_y, button_width, kCaptionButtonHeightWithPadding - 1); |
398 label_size.width(), | |
399 kCaptionButtonHeightWithPadding - 1); | |
400 } | 406 } |
401 | 407 |
402 void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) { | 408 void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) { |
403 // Even though the avatar is used for both incognito and profiles we always | 409 // Even though the avatar is used for both incognito and profiles we always |
404 // use the incognito icon to layout the avatar button. The profile icon | 410 // use the incognito icon to layout the avatar button. The profile icon |
405 // can be customized so we can't depend on its size to perform layout. | 411 // can be customized so we can't depend on its size to perform layout. |
406 gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon(); | 412 gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon(); |
407 | 413 |
408 bool avatar_on_right = ShouldAvatarBeOnRight(); | 414 bool avatar_on_right = ShouldAvatarBeOnRight(); |
409 int avatar_bottom = GetTabStripInsetsTop(false) + | 415 int avatar_bottom = GetTabStripInsetsTop(false) + |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 688 |
683 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 689 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
684 views::View* view) { | 690 views::View* view) { |
685 SetView(view->id(), view); | 691 SetView(view->id(), view); |
686 } | 692 } |
687 | 693 |
688 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 694 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
689 views::View* view) { | 695 views::View* view) { |
690 SetView(view->id(), NULL); | 696 SetView(view->id(), NULL); |
691 } | 697 } |
OLD | NEW |