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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.mm

Issue 12315069: Mac: Update zoom bubble UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller. h" 5 #import "chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller. h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "chrome/browser/extensions/extension_icon_image.h" 11 #include "chrome/browser/extensions/extension_icon_image.h"
12 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 12 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
13 #import "chrome/browser/ui/cocoa/event_utils.h" 13 #import "chrome/browser/ui/cocoa/event_utils.h"
14 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
15 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 15 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
16 #include "chrome/browser/ui/toolbar/action_box_menu_model.h" 16 #include "chrome/browser/ui/toolbar/action_box_menu_model.h"
17 #include "chrome/common/extensions/api/extension_action/action_info.h" 17 #include "chrome/common/extensions/api/extension_action/action_info.h"
18 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 #include "skia/ext/skia_utils_mac.h"
22 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 23 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
23 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/image/image_skia_util_mac.h" 26 #include "ui/gfx/image/image_skia_util_mac.h"
27 #include "ui/native_theme/native_theme.h"
26 28
27 @interface ActionBoxMenuBubbleController (Private) 29 @interface ActionBoxMenuBubbleController (Private)
28 - (id)highlightedItem; 30 - (id)highlightedItem;
29 - (void)keyDown:(NSEvent*)theEvent; 31 - (void)keyDown:(NSEvent*)theEvent;
30 - (void)moveDown:(id)sender; 32 - (void)moveDown:(id)sender;
31 - (void)moveUp:(id)sender; 33 - (void)moveUp:(id)sender;
32 - (void)highlightNextItemByDelta:(NSInteger)delta; 34 - (void)highlightNextItemByDelta:(NSInteger)delta;
33 - (void)highlightItem:(ActionBoxMenuItemController*)newItem; 35 - (void)highlightItem:(ActionBoxMenuItemController*)newItem;
34 @end 36 @end
35 37
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 anchoredAt:(NSPoint)point 93 anchoredAt:(NSPoint)point
92 profile:(Profile*)profile { 94 profile:(Profile*)profile {
93 // Use an arbitrary height because it will reflect the size of the content. 95 // Use an arbitrary height because it will reflect the size of the content.
94 NSRect contentRect = NSMakeRect(0, 0, kBubbleMinWidth, 150); 96 NSRect contentRect = NSMakeRect(0, 0, kBubbleMinWidth, 150);
95 // Create an empty window into which content is placed. 97 // Create an empty window into which content is placed.
96 scoped_nsobject<InfoBubbleWindow> window( 98 scoped_nsobject<InfoBubbleWindow> window(
97 [[InfoBubbleWindow alloc] initWithContentRect:contentRect 99 [[InfoBubbleWindow alloc] initWithContentRect:contentRect
98 styleMask:NSBorderlessWindowMask 100 styleMask:NSBorderlessWindowMask
99 backing:NSBackingStoreBuffered 101 backing:NSBackingStoreBuffered
100 defer:NO]); 102 defer:NO]);
103 [window setEnableAnimations:NO];
104 [window setDelayOnClose:NO];
101 if (self = [super initWithWindow:window 105 if (self = [super initWithWindow:window
102 parentWindow:parent 106 parentWindow:parent
103 anchoredAt:point]) { 107 anchoredAt:point]) {
104 profile_ = profile; 108 profile_ = profile;
105 model_.reset(model.release()); 109 model_.reset(model.release());
106 110
107 [[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge]; 111 [[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge];
108 [[self bubble] setArrowLocation:info_bubble::kNoArrow]; 112 [[self bubble] setArrowLocation:info_bubble::kNoArrow];
113 ui::NativeTheme *nativeTheme = ui::NativeTheme::instance();
Robert Sesek 2013/02/26 23:15:16 nit: asterisk placement
sail 2013/02/27 00:35:34 Done.
109 [[self bubble] setBackgroundColor: 114 [[self bubble] setBackgroundColor:
110 [NSColor colorWithDeviceWhite:(251.0f/255.0f) 115 gfx::SkColorToCalibratedNSColor(nativeTheme->GetSystemColor(
111 alpha:1.0]]; 116 ui::NativeTheme::kColorId_DialogBackground))];
112 [self performLayout]; 117 [self performLayout];
113 } 118 }
114 return self; 119 return self;
115 } 120 }
116 121
117 - (ActionBoxMenuModel*)model { 122 - (ActionBoxMenuModel*)model {
118 return model_.get(); 123 return model_.get();
119 } 124 }
120 125
121 - (NSMutableArray*)items { 126 - (NSMutableArray*)items {
(...skipping 29 matching lines...) Expand all
151 CGFloat yOffset = kVerticalPadding; 156 CGFloat yOffset = kVerticalPadding;
152 157
153 // Keep track of a potential separator to resize it when we know the width. 158 // Keep track of a potential separator to resize it when we know the width.
154 scoped_nsobject<NSBox> separatorView; 159 scoped_nsobject<NSBox> separatorView;
155 160
156 // Loop over the items in reverse, constructing the menu items. 161 // Loop over the items in reverse, constructing the menu items.
157 CGFloat width = kBubbleMinWidth; 162 CGFloat width = kBubbleMinWidth;
158 CGFloat minX = NSMinX([contentView bounds]); 163 CGFloat minX = NSMinX([contentView bounds]);
159 for (int i = model_->GetItemCount() - 1; i >= 0; --i) { 164 for (int i = model_->GetItemCount() - 1; i >= 0; --i) {
160 if (model_->GetTypeAt(i) == ui::MenuModel::TYPE_SEPARATOR) { 165 if (model_->GetTypeAt(i) == ui::MenuModel::TYPE_SEPARATOR) {
166 const CGFloat kSeparatorHeight = 1.0;
161 // Only supports one separator. 167 // Only supports one separator.
162 DCHECK(!separatorView); 168 DCHECK(!separatorView);
163 yOffset += kVerticalPadding; 169 yOffset += kVerticalPadding + kSeparatorHeight;
164 separatorView.reset([[NSBox alloc] 170 separatorView.reset([[NSBox alloc]
165 initWithFrame:NSMakeRect(0, yOffset, width, 1)]); 171 initWithFrame:NSMakeRect(0, yOffset, width, kSeparatorHeight)]);
166 [separatorView setBorderType:NSNoBorder];
167 [separatorView setBoxType:NSBoxCustom]; 172 [separatorView setBoxType:NSBoxCustom];
168 [separatorView setFillColor:[NSColor grayColor]]; 173 ui::NativeTheme *nativeTheme = ui::NativeTheme::instance();
174 [separatorView setBorderColor:
175 gfx::SkColorToCalibratedNSColor(nativeTheme->GetSystemColor(
176 ui::NativeTheme::kColorId_MenuSeparatorColor))];
169 [contentView addSubview:separatorView]; 177 [contentView addSubview:separatorView];
170 yOffset += kVerticalPadding; 178 yOffset += kVerticalPadding;
171 } else { 179 } else {
172 // Create the item controller. Autorelease it because it will be owned 180 // Create the item controller. Autorelease it because it will be owned
173 // by the |items_| array. 181 // by the |items_| array.
174 scoped_nsobject<ActionBoxMenuItemController> itemController( 182 scoped_nsobject<ActionBoxMenuItemController> itemController(
175 [[ActionBoxMenuItemController alloc] 183 [[ActionBoxMenuItemController alloc]
176 initWithModelIndex:i 184 initWithModelIndex:i
177 menuController:self 185 menuController:self
178 profile:profile_]); 186 profile:profile_]);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 [viewController_ highlightForEvent:theEvent]; 397 [viewController_ highlightForEvent:theEvent];
390 } 398 }
391 399
392 - (void)mouseExited:(NSEvent*)theEvent { 400 - (void)mouseExited:(NSEvent*)theEvent {
393 [viewController_ highlightForEvent:theEvent]; 401 [viewController_ highlightForEvent:theEvent];
394 } 402 }
395 403
396 - (void)drawRect:(NSRect)dirtyRect { 404 - (void)drawRect:(NSRect)dirtyRect {
397 NSColor* backgroundColor = nil; 405 NSColor* backgroundColor = nil;
398 if ([viewController_ isHighlighted]) { 406 if ([viewController_ isHighlighted]) {
399 backgroundColor = [NSColor colorWithDeviceWhite:0.0 alpha:kSelectionAlpha]; 407 ui::NativeTheme *nativeTheme = ui::NativeTheme::instance();
408 backgroundColor = gfx::SkColorToCalibratedNSColor(
409 nativeTheme->GetSystemColor(
410 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor));
400 } else { 411 } else {
401 backgroundColor = [NSColor clearColor]; 412 backgroundColor = [NSColor clearColor];
402 } 413 }
403 414
404 [backgroundColor set]; 415 [backgroundColor set];
405 [NSBezierPath fillRect:[self bounds]]; 416 [NSBezierPath fillRect:[self bounds]];
406 } 417 }
407 418
408 // Make sure the element is focusable for accessibility. 419 // Make sure the element is focusable for accessibility.
409 - (BOOL)canBecomeKeyView { 420 - (BOOL)canBecomeKeyView {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 - (void)accessibilityPerformAction:(NSString*)action { 455 - (void)accessibilityPerformAction:(NSString*)action {
445 if ([action isEqual:NSAccessibilityPressAction]) { 456 if ([action isEqual:NSAccessibilityPressAction]) {
446 [viewController_ itemSelected:self]; 457 [viewController_ itemSelected:self];
447 return; 458 return;
448 } 459 }
449 460
450 [super accessibilityPerformAction:action]; 461 [super accessibilityPerformAction:action];
451 } 462 }
452 463
453 @end 464 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698