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 // The outside edge of the avatar label should be just outside that of the |
439 // the avatar menu button. Therefore we use the |leading_button_start_| | 441 // avatar menu button. |
440 // value directly. | 442 int avatar_label_x = avatar_on_right ? |
443 host->width() - trailing_button_start_ - label_size.width() : | |
Peter Kasting
2014/01/16 21:46:17
Nit: Consider parens around this subexpression
Adrian Kuegel
2014/01/17 09:42:17
Done.
| |
444 leading_button_start_; | |
441 gfx::Rect label_bounds( | 445 gfx::Rect label_bounds( |
442 leading_button_start_, | 446 avatar_label_x, |
443 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), | 447 avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(), |
444 label_size.width(), | 448 label_size.width(), |
445 delegate_->ShouldShowAvatar() ? label_size.height() : 0); | 449 delegate_->ShouldShowAvatar() ? label_size.height() : 0); |
446 avatar_label_->SetBoundsRect(label_bounds); | 450 avatar_label_->SetBoundsRect(label_bounds); |
447 edge_offset = label_size.width(); | 451 edge_offset = label_size.width(); |
448 } else { | 452 } else { |
449 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); | 453 edge_offset = kAvatarOuterSpacing + incognito_icon.width(); |
450 } | 454 } |
451 if (avatar_on_right) | 455 if (avatar_on_right) |
452 trailing_button_start_ += edge_offset; | 456 trailing_button_start_ += edge_offset; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 window_icon_ = view; | 623 window_icon_ = view; |
620 break; | 624 break; |
621 case VIEW_ID_WINDOW_TITLE: | 625 case VIEW_ID_WINDOW_TITLE: |
622 if (view) { | 626 if (view) { |
623 DCHECK_EQ(std::string(views::Label::kViewClassName), | 627 DCHECK_EQ(std::string(views::Label::kViewClassName), |
624 view->GetClassName()); | 628 view->GetClassName()); |
625 } | 629 } |
626 window_title_ = static_cast<views::Label*>(view); | 630 window_title_ = static_cast<views::Label*>(view); |
627 break; | 631 break; |
628 case VIEW_ID_AVATAR_LABEL: | 632 case VIEW_ID_AVATAR_LABEL: |
629 avatar_label_ = view; | 633 avatar_label_ = static_cast<AvatarLabel*>(view); |
630 break; | 634 break; |
631 case VIEW_ID_AVATAR_BUTTON: | 635 case VIEW_ID_AVATAR_BUTTON: |
632 if (view) { | 636 if (view) { |
633 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), | 637 DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName), |
634 view->GetClassName()); | 638 view->GetClassName()); |
635 } | 639 } |
636 avatar_button_ = static_cast<AvatarMenuButton*>(view); | 640 avatar_button_ = static_cast<AvatarMenuButton*>(view); |
637 break; | 641 break; |
638 case VIEW_ID_NEW_AVATAR_BUTTON: | 642 case VIEW_ID_NEW_AVATAR_BUTTON: |
639 new_avatar_button_ = view; | 643 new_avatar_button_ = view; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 | 687 |
684 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 688 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
685 views::View* view) { | 689 views::View* view) { |
686 SetView(view->id(), view); | 690 SetView(view->id(), view); |
687 } | 691 } |
688 | 692 |
689 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 693 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
690 views::View* view) { | 694 views::View* view) { |
691 SetView(view->id(), NULL); | 695 SetView(view->id(), NULL); |
692 } | 696 } |
OLD | NEW |