Chromium Code Reviews| 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 "chrome/browser/profiles/profiles_state.h" | 7 #include "chrome/browser/profiles/profiles_state.h" |
| 8 #include "chrome/browser/ui/views/avatar_label.h" | |
| 8 #include "chrome/browser/ui/views/avatar_menu_button.h" | 9 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 9 #include "chrome/common/profile_management_switches.h" | 10 #include "chrome/common/profile_management_switches.h" |
| 10 #include "ui/gfx/font.h" | 11 #include "ui/gfx/font.h" |
| 11 #include "ui/views/controls/button/image_button.h" | 12 #include "ui/views/controls/button/image_button.h" |
| 12 #include "ui/views/controls/label.h" | 13 #include "ui/views/controls/label.h" |
| 13 | 14 |
| 14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 15 #include "win8/util/win8_util.h" | 16 #include "win8/util/win8_util.h" |
| 16 #endif // OS_WIN | 17 #endif // OS_WIN |
| 17 | 18 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 avatar_x, | 425 avatar_x, |
| 425 avatar_y, | 426 avatar_y, |
| 426 incognito_icon.width(), | 427 incognito_icon.width(), |
| 427 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 428 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
| 428 if (avatar_button_) { | 429 if (avatar_button_) { |
| 429 avatar_button_->set_button_on_right(avatar_on_right); | 430 avatar_button_->set_button_on_right(avatar_on_right); |
| 430 avatar_button_->SetBoundsRect(avatar_bounds_); | 431 avatar_button_->SetBoundsRect(avatar_bounds_); |
| 431 | 432 |
| 432 int edge_offset; | 433 int edge_offset; |
| 433 if (avatar_label_) { | 434 if (avatar_label_) { |
| 435 avatar_label_->SetLabelOnRight(avatar_on_right); | |
| 434 // Space between the bottom of the avatar and the bottom of the avatar | 436 // Space between the bottom of the avatar and the bottom of the avatar |
| 435 // label. | 437 // label. |
| 436 const int kAvatarLabelBottomSpacing = 3; | 438 const int kAvatarLabelBottomSpacing = 3; |
| 437 gfx::Size label_size = avatar_label_->GetPreferredSize(); | 439 gfx::Size label_size = avatar_label_->GetPreferredSize(); |
| 438 // The x-position of the avatar label should be slightly to the left of | 440 // If the avatar is displayed on the left, the x-position of the avatar |
| 439 // the avatar menu button. Therefore we use the |leading_button_start_| | 441 // label should be slightly to the left of the avatar menu button. |
| 440 // value directly. | 442 // Therefore we use the |leading_button_start_| value directly. |
| 443 // Otherwise if the avatar is displayed on the right, the right end of the | |
| 444 // avatar label should be slightly to the right of the avatar menu button. | |
|
Peter Kasting
2014/01/15 02:06:26
Nit: This whole comment can just be:
The outside
Adrian Kuegel
2014/01/15 16:24:51
Done.
| |
| 445 int avatar_label_x = avatar_on_right ? | |
| 446 host->width() - trailing_button_start_ - label_size.width() : | |
| 447 leading_button_start_; | |
| 441 gfx::Rect label_bounds( | 448 gfx::Rect label_bounds( |
| 442 leading_button_start_, | 449 avatar_label_x, |
| 443 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), | 450 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
| 444 label_size.width(), | 451 label_size.width(), |
| 445 delegate_->ShouldShowAvatar() ? label_size.height() : 0); | 452 delegate_->ShouldShowAvatar() ? label_size.height() : 0); |
| 446 avatar_label_->SetBoundsRect(label_bounds); | 453 avatar_label_->SetBoundsRect(label_bounds); |
| 447 edge_offset = label_size.width(); | 454 edge_offset = label_size.width(); |
| 448 } else { | 455 } else { |
| 449 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); | 456 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); |
| 450 } | 457 } |
| 451 if (avatar_on_right) | 458 if (avatar_on_right) |
| 452 trailing_button_start_ += edge_offset; | 459 trailing_button_start_ += edge_offset; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 | 590 |
| 584 void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) { | 591 void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) { |
| 585 // Why do things this way instead of having an Init() method, where we're | 592 // Why do things this way instead of having an Init() method, where we're |
| 586 // passed the views we'll handle? Because OpaqueBrowserFrameView doesn't own | 593 // passed the views we'll handle? Because OpaqueBrowserFrameView doesn't own |
| 587 // all the views which are part of it. The avatar stuff, for example, will be | 594 // all the views which are part of it. The avatar stuff, for example, will be |
| 588 // added and removed by the base class of OpaqueBrowserFrameView. | 595 // added and removed by the base class of OpaqueBrowserFrameView. |
| 589 switch (id) { | 596 switch (id) { |
| 590 case VIEW_ID_MINIMIZE_BUTTON: | 597 case VIEW_ID_MINIMIZE_BUTTON: |
| 591 if (view) { | 598 if (view) { |
| 592 DCHECK_EQ(std::string(views::ImageButton::kViewClassName), | 599 DCHECK_EQ(std::string(views::ImageButton::kViewClassName), |
| 593 view->GetClassName()); | 600 view->GetClassName()); |
|
Peter Kasting
2014/01/15 02:06:26
As alluded to in the other file: I don't really se
Adrian Kuegel
2014/01/15 16:24:51
I filed a bug for that and removed the DCHECK for
| |
| 594 } | 601 } |
| 595 minimize_button_ = static_cast<views::ImageButton*>(view); | 602 minimize_button_ = static_cast<views::ImageButton*>(view); |
| 596 break; | 603 break; |
| 597 case VIEW_ID_MAXIMIZE_BUTTON: | 604 case VIEW_ID_MAXIMIZE_BUTTON: |
| 598 if (view) { | 605 if (view) { |
| 599 DCHECK_EQ(std::string(views::ImageButton::kViewClassName), | 606 DCHECK_EQ(std::string(views::ImageButton::kViewClassName), |
| 600 view->GetClassName()); | 607 view->GetClassName()); |
| 601 } | 608 } |
| 602 maximize_button_ = static_cast<views::ImageButton*>(view); | 609 maximize_button_ = static_cast<views::ImageButton*>(view); |
| 603 break; | 610 break; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 619 window_icon_ = view; | 626 window_icon_ = view; |
| 620 break; | 627 break; |
| 621 case VIEW_ID_WINDOW_TITLE: | 628 case VIEW_ID_WINDOW_TITLE: |
| 622 if (view) { | 629 if (view) { |
| 623 DCHECK_EQ(std::string(views::Label::kViewClassName), | 630 DCHECK_EQ(std::string(views::Label::kViewClassName), |
| 624 view->GetClassName()); | 631 view->GetClassName()); |
| 625 } | 632 } |
| 626 window_title_ = static_cast<views::Label*>(view); | 633 window_title_ = static_cast<views::Label*>(view); |
| 627 break; | 634 break; |
| 628 case VIEW_ID_AVATAR_LABEL: | 635 case VIEW_ID_AVATAR_LABEL: |
| 629 avatar_label_ = view; | 636 if (view) { |
| 637 DCHECK_EQ(std::string(AvatarLabel::kViewClassName), | |
| 638 view->GetClassName()); | |
| 639 } | |
| 640 avatar_label_ = static_cast<AvatarLabel*>(view); | |
| 630 break; | 641 break; |
| 631 case VIEW_ID_AVATAR_BUTTON: | 642 case VIEW_ID_AVATAR_BUTTON: |
| 632 if (view) { | 643 if (view) { |
| 633 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), | 644 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), |
| 634 view->GetClassName()); | 645 view->GetClassName()); |
| 635 } | 646 } |
| 636 avatar_button_ = static_cast<AvatarMenuButton*>(view); | 647 avatar_button_ = static_cast<AvatarMenuButton*>(view); |
| 637 break; | 648 break; |
| 638 case VIEW_ID_NEW_AVATAR_BUTTON: | 649 case VIEW_ID_NEW_AVATAR_BUTTON: |
| 639 new_avatar_button_ = view; | 650 new_avatar_button_ = view; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 | 694 |
| 684 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 695 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
| 685 views::View* view) { | 696 views::View* view) { |
| 686 SetView(view->id(), view); | 697 SetView(view->id(), view); |
| 687 } | 698 } |
| 688 | 699 |
| 689 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 700 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
| 690 views::View* view) { | 701 views::View* view) { |
| 691 SetView(view->id(), NULL); | 702 SetView(view->id(), NULL); |
| 692 } | 703 } |
| OLD | NEW |