Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3785)

Unified Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc

Issue 127253004: Support displaying the avatar label on the right side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
index 982bdf38c8be2e9aec068f98824399bf94e03035..126620e0234b9bc085cb01dcfbcaf1e5bd67ae6c 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/ui/views/avatar_label.h"
#include "chrome/browser/ui/views/avatar_menu_button.h"
#include "chrome/common/profile_management_switches.h"
#include "ui/gfx/font.h"
@@ -431,15 +432,21 @@ void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) {
int edge_offset;
if (avatar_label_) {
+ avatar_label_->SetLabelOnRight(avatar_on_right);
// Space between the bottom of the avatar and the bottom of the avatar
// label.
const int kAvatarLabelBottomSpacing = 3;
gfx::Size label_size = avatar_label_->GetPreferredSize();
- // The x-position of the avatar label should be slightly to the left of
- // the avatar menu button. Therefore we use the |leading_button_start_|
- // value directly.
+ // If the avatar is displayed on the left, the x-position of the avatar
+ // label should be slightly to the left of the avatar menu button.
+ // Therefore we use the |leading_button_start_| value directly.
+ // Otherwise if the avatar is displayed on the right, the right end of the
+ // 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.
+ int avatar_label_x = avatar_on_right ?
+ host->width() - trailing_button_start_ - label_size.width() :
+ leading_button_start_;
gfx::Rect label_bounds(
- leading_button_start_,
+ avatar_label_x,
avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(),
label_size.width(),
delegate_->ShouldShowAvatar() ? label_size.height() : 0);
@@ -626,7 +633,11 @@ void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) {
window_title_ = static_cast<views::Label*>(view);
break;
case VIEW_ID_AVATAR_LABEL:
- avatar_label_ = view;
+ if (view) {
+ DCHECK_EQ(std::string(AvatarLabel::kViewClassName),
+ view->GetClassName());
+ }
+ avatar_label_ = static_cast<AvatarLabel*>(view);
break;
case VIEW_ID_AVATAR_BUTTON:
if (view) {

Powered by Google App Engine
This is Rietveld 408576698