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

Unified Diff: trunk/src/ui/app_list/cocoa/current_user_menu_item_view.mm

Issue 17059002: Revert 206237 "Menu for the OSX app launcher, HoverImageMenuButt..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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: trunk/src/ui/app_list/cocoa/current_user_menu_item_view.mm
===================================================================
--- trunk/src/ui/app_list/cocoa/current_user_menu_item_view.mm (revision 206373)
+++ trunk/src/ui/app_list/cocoa/current_user_menu_item_view.mm (working copy)
@@ -1,85 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ui/app_list/cocoa/current_user_menu_item_view.h"
-
-#include "base/logging.h"
-#include "base/memory/scoped_nsobject.h"
-#include "base/strings/sys_string_conversions.h"
-#include "grit/ui_resources.h"
-#include "ui/app_list/app_list_view_delegate.h"
-#include "ui/base/resource/resource_bundle.h"
-
-namespace {
-
-// Padding on the left of the indicator icon.
-const CGFloat kMenuLeftMargin = 3;
-
-}
-
-@interface CurrentUserMenuItemView ()
-
-// Adds a text label in the custom view in the menu showing the current user.
-- (NSTextField*)addLabelWithFrame:(NSPoint)origin
- labelText:(const string16&)labelText;
-
-@end
-
-@implementation CurrentUserMenuItemView
-
-- (id)initWithDelegate:(app_list::AppListViewDelegate*)delegate {
- DCHECK(delegate);
- if ((self = [super initWithFrame:NSZeroRect])) {
- NSImage* userImage = ui::ResourceBundle::GetSharedInstance().
- GetNativeImageNamed(IDR_APP_LIST_USER_INDICATOR).AsNSImage();
- NSRect imageRect = NSMakeRect(kMenuLeftMargin, 0, 0, 0);
- imageRect.size = [userImage size];
- scoped_nsobject<NSImageView> userImageView(
- [[NSImageView alloc] initWithFrame:imageRect]);
- [userImageView setImage:userImage];
- [self addSubview:userImageView];
-
- NSPoint labelOrigin = NSMakePoint(NSMaxX(imageRect), 0);
- NSTextField* userField =
- [self addLabelWithFrame:labelOrigin
- labelText:delegate->GetCurrentUserName()];
-
- labelOrigin.y = NSMaxY([userField frame]);
- NSTextField* emailField =
- [self addLabelWithFrame:labelOrigin
- labelText:delegate->GetCurrentUserEmail()];
- [emailField setTextColor:[NSColor disabledControlTextColor]];
-
- // Size the container view to fit the longest label.
- NSRect labelFrame = [emailField frame];
- if (NSWidth([userField frame]) > NSWidth(labelFrame))
- labelFrame.size.width = NSWidth([userField frame]);
- [self setFrameSize:NSMakeSize(
- NSMaxX(labelFrame) + NSMaxX(imageRect),
- NSMaxY(labelFrame))];
- }
- return self;
-}
-
-- (NSTextField*)addLabelWithFrame:(NSPoint)origin
- labelText:(const string16&)labelText {
- NSRect labelFrame = NSZeroRect;
- labelFrame.origin = origin;
- scoped_nsobject<NSTextField> label(
- [[NSTextField alloc] initWithFrame:labelFrame]);
- [label setStringValue:base::SysUTF16ToNSString(labelText)];
- [label setEditable:NO];
- [label setBordered:NO];
- [label setDrawsBackground:NO];
- [label setFont:[NSFont menuFontOfSize:0]];
- [label sizeToFit];
- [self addSubview:label];
- return label.autorelease();
-}
-
-- (BOOL)isFlipped {
- return YES;
-}
-
-@end
« no previous file with comments | « trunk/src/ui/app_list/cocoa/current_user_menu_item_view.h ('k') | trunk/src/ui/base/cocoa/controls/hover_image_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698