| 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/avatar_label.h" |
| 9 #include "chrome/browser/ui/views/avatar_menu_button.h" | 10 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/profile_management_switches.h" | 12 #include "chrome/common/profile_management_switches.h" |
| 12 #include "ui/gfx/font.h" | 13 #include "ui/gfx/font.h" |
| 13 #include "ui/views/controls/button/image_button.h" | 14 #include "ui/views/controls/button/image_button.h" |
| 14 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 15 | 16 |
| 16 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 17 #include "win8/util/win8_util.h" | 18 #include "win8/util/win8_util.h" |
| 18 #endif // OS_WIN | 19 #endif // OS_WIN |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 avatar_x, | 440 avatar_x, |
| 440 avatar_y, | 441 avatar_y, |
| 441 incognito_icon.width(), | 442 incognito_icon.width(), |
| 442 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 443 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
| 443 if (avatar_button_) { | 444 if (avatar_button_) { |
| 444 avatar_button_->set_button_on_right(avatar_on_right); | 445 avatar_button_->set_button_on_right(avatar_on_right); |
| 445 avatar_button_->SetBoundsRect(avatar_bounds_); | 446 avatar_button_->SetBoundsRect(avatar_bounds_); |
| 446 | 447 |
| 447 int edge_offset; | 448 int edge_offset; |
| 448 if (avatar_label_) { | 449 if (avatar_label_) { |
| 450 avatar_label_->SetLabelOnRight(avatar_on_right); |
| 449 // Space between the bottom of the avatar and the bottom of the avatar | 451 // Space between the bottom of the avatar and the bottom of the avatar |
| 450 // label. | 452 // label. |
| 451 const int kAvatarLabelBottomSpacing = 3; | 453 const int kAvatarLabelBottomSpacing = 3; |
| 452 gfx::Size label_size = avatar_label_->GetPreferredSize(); | 454 gfx::Size label_size = avatar_label_->GetPreferredSize(); |
| 453 // The x-position of the avatar label should be slightly to the left of | 455 // The outside edge of the avatar label should be just outside that of the |
| 454 // the avatar menu button. Therefore we use the |leading_button_start_| | 456 // avatar menu button. |
| 455 // value directly. | 457 int avatar_label_x = avatar_on_right ? |
| 458 (host->width() - trailing_button_start_ - label_size.width()) : |
| 459 leading_button_start_; |
| 456 gfx::Rect label_bounds( | 460 gfx::Rect label_bounds( |
| 457 leading_button_start_, | 461 avatar_label_x, |
| 458 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), | 462 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
| 459 label_size.width(), | 463 label_size.width(), |
| 460 delegate_->ShouldShowAvatar() ? label_size.height() : 0); | 464 delegate_->ShouldShowAvatar() ? label_size.height() : 0); |
| 461 avatar_label_->SetBoundsRect(label_bounds); | 465 avatar_label_->SetBoundsRect(label_bounds); |
| 462 edge_offset = label_size.width(); | 466 edge_offset = label_size.width(); |
| 463 } else { | 467 } else { |
| 464 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); | 468 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); |
| 465 } | 469 } |
| 466 if (avatar_on_right) | 470 if (avatar_on_right) |
| 467 trailing_button_start_ += edge_offset; | 471 trailing_button_start_ += edge_offset; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 window_icon_ = view; | 638 window_icon_ = view; |
| 635 break; | 639 break; |
| 636 case VIEW_ID_WINDOW_TITLE: | 640 case VIEW_ID_WINDOW_TITLE: |
| 637 if (view) { | 641 if (view) { |
| 638 DCHECK_EQ(std::string(views::Label::kViewClassName), | 642 DCHECK_EQ(std::string(views::Label::kViewClassName), |
| 639 view->GetClassName()); | 643 view->GetClassName()); |
| 640 } | 644 } |
| 641 window_title_ = static_cast<views::Label*>(view); | 645 window_title_ = static_cast<views::Label*>(view); |
| 642 break; | 646 break; |
| 643 case VIEW_ID_AVATAR_LABEL: | 647 case VIEW_ID_AVATAR_LABEL: |
| 644 avatar_label_ = view; | 648 avatar_label_ = static_cast<AvatarLabel*>(view); |
| 645 break; | 649 break; |
| 646 case VIEW_ID_AVATAR_BUTTON: | 650 case VIEW_ID_AVATAR_BUTTON: |
| 647 if (view) { | 651 if (view) { |
| 648 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), | 652 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), |
| 649 view->GetClassName()); | 653 view->GetClassName()); |
| 650 } | 654 } |
| 651 avatar_button_ = static_cast<AvatarMenuButton*>(view); | 655 avatar_button_ = static_cast<AvatarMenuButton*>(view); |
| 652 break; | 656 break; |
| 653 case VIEW_ID_NEW_AVATAR_BUTTON: | 657 case VIEW_ID_NEW_AVATAR_BUTTON: |
| 654 new_avatar_button_ = view; | 658 new_avatar_button_ = view; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 | 702 |
| 699 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 703 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
| 700 views::View* view) { | 704 views::View* view) { |
| 701 SetView(view->id(), view); | 705 SetView(view->id(), view); |
| 702 } | 706 } |
| 703 | 707 |
| 704 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 708 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
| 705 views::View* view) { | 709 views::View* view) { |
| 706 SetView(view->id(), NULL); | 710 SetView(view->id(), NULL); |
| 707 } | 711 } |
| OLD | NEW |