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

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: rebase Created 7 years, 9 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 setAllowedAnimations:info_bubble::kAnimateNone];
101 if (self = [super initWithWindow:window 104 if (self = [super initWithWindow:window
102 parentWindow:parent 105 parentWindow:parent
103 anchoredAt:point]) { 106 anchoredAt:point]) {
104 profile_ = profile; 107 profile_ = profile;
105 model_.reset(model.release()); 108 model_.reset(model.release());
106 109
107 [[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge]; 110 [[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge];
108 [[self bubble] setArrowLocation:info_bubble::kNoArrow]; 111 [[self bubble] setArrowLocation:info_bubble::kNoArrow];
112 ui::NativeTheme* nativeTheme = ui::NativeTheme::instance();
109 [[self bubble] setBackgroundColor: 113 [[self bubble] setBackgroundColor:
110 [NSColor colorWithDeviceWhite:(251.0f/255.0f) 114 gfx::SkColorToCalibratedNSColor(nativeTheme->GetSystemColor(
111 alpha:1.0]]; 115 ui::NativeTheme::kColorId_DialogBackground))];
112 [self performLayout]; 116 [self performLayout];
113 } 117 }
114 return self; 118 return self;
115 } 119 }
116 120
117 - (ActionBoxMenuModel*)model { 121 - (ActionBoxMenuModel*)model {
118 return model_.get(); 122 return model_.get();
119 } 123 }
120 124
121 - (NSMutableArray*)items { 125 - (NSMutableArray*)items {
(...skipping 29 matching lines...) Expand all
151 CGFloat yOffset = kVerticalPadding; 155 CGFloat yOffset = kVerticalPadding;
152 156
153 // Keep track of a potential separator to resize it when we know the width. 157 // Keep track of a potential separator to resize it when we know the width.
154 scoped_nsobject<NSBox> separatorView; 158 scoped_nsobject<NSBox> separatorView;
155 159
156 // Loop over the items in reverse, constructing the menu items. 160 // Loop over the items in reverse, constructing the menu items.
157 CGFloat width = kBubbleMinWidth; 161 CGFloat width = kBubbleMinWidth;
158 CGFloat minX = NSMinX([contentView bounds]); 162 CGFloat minX = NSMinX([contentView bounds]);
159 for (int i = model_->GetItemCount() - 1; i >= 0; --i) { 163 for (int i = model_->GetItemCount() - 1; i >= 0; --i) {
160 if (model_->GetTypeAt(i) == ui::MenuModel::TYPE_SEPARATOR) { 164 if (model_->GetTypeAt(i) == ui::MenuModel::TYPE_SEPARATOR) {
165 const CGFloat kSeparatorHeight = 1.0;
Scott Hess - ex-Googler 2013/02/27 15:22:10 Is this the same on hidpi? I'd say "probably", bu
sail 2013/02/27 18:48:18 Yea this is correct in hidpi mode. For example, th
161 // Only supports one separator. 166 // Only supports one separator.
162 DCHECK(!separatorView); 167 DCHECK(!separatorView);
163 yOffset += kVerticalPadding; 168 yOffset += kVerticalPadding + kSeparatorHeight;
164 separatorView.reset([[NSBox alloc] 169 separatorView.reset([[NSBox alloc]
165 initWithFrame:NSMakeRect(0, yOffset, width, 1)]); 170 initWithFrame:NSMakeRect(0, yOffset, width, kSeparatorHeight)]);
166 [separatorView setBorderType:NSNoBorder];
167 [separatorView setBoxType:NSBoxCustom]; 171 [separatorView setBoxType:NSBoxCustom];
168 [separatorView setFillColor:[NSColor grayColor]]; 172 ui::NativeTheme* nativeTheme = ui::NativeTheme::instance();
173 [separatorView setBorderColor:
174 gfx::SkColorToCalibratedNSColor(nativeTheme->GetSystemColor(
175 ui::NativeTheme::kColorId_MenuSeparatorColor))];
169 [contentView addSubview:separatorView]; 176 [contentView addSubview:separatorView];
170 yOffset += kVerticalPadding; 177 yOffset += kVerticalPadding;
171 } else { 178 } else {
172 // Create the item controller. Autorelease it because it will be owned 179 // Create the item controller. Autorelease it because it will be owned
173 // by the |items_| array. 180 // by the |items_| array.
174 scoped_nsobject<ActionBoxMenuItemController> itemController( 181 scoped_nsobject<ActionBoxMenuItemController> itemController(
175 [[ActionBoxMenuItemController alloc] 182 [[ActionBoxMenuItemController alloc]
176 initWithModelIndex:i 183 initWithModelIndex:i
177 menuController:self 184 menuController:self
178 profile:profile_]); 185 profile:profile_]);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 [viewController_ highlightForEvent:theEvent]; 396 [viewController_ highlightForEvent:theEvent];
390 } 397 }
391 398
392 - (void)mouseExited:(NSEvent*)theEvent { 399 - (void)mouseExited:(NSEvent*)theEvent {
393 [viewController_ highlightForEvent:theEvent]; 400 [viewController_ highlightForEvent:theEvent];
394 } 401 }
395 402
396 - (void)drawRect:(NSRect)dirtyRect { 403 - (void)drawRect:(NSRect)dirtyRect {
397 NSColor* backgroundColor = nil; 404 NSColor* backgroundColor = nil;
398 if ([viewController_ isHighlighted]) { 405 if ([viewController_ isHighlighted]) {
399 backgroundColor = [NSColor colorWithDeviceWhite:0.0 alpha:kSelectionAlpha]; 406 ui::NativeTheme* nativeTheme = ui::NativeTheme::instance();
407 backgroundColor = gfx::SkColorToCalibratedNSColor(
408 nativeTheme->GetSystemColor(
409 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor));
Scott Hess - ex-Googler 2013/02/27 15:22:10 This wad of code seems like it's just dying for a
sail 2013/02/27 18:48:18 Done.
400 } else { 410 } else {
401 backgroundColor = [NSColor clearColor]; 411 backgroundColor = [NSColor clearColor];
402 } 412 }
403 413
404 [backgroundColor set]; 414 [backgroundColor set];
405 [NSBezierPath fillRect:[self bounds]]; 415 [NSBezierPath fillRect:[self bounds]];
406 } 416 }
407 417
408 // Make sure the element is focusable for accessibility. 418 // Make sure the element is focusable for accessibility.
409 - (BOOL)canBecomeKeyView { 419 - (BOOL)canBecomeKeyView {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 - (void)accessibilityPerformAction:(NSString*)action { 454 - (void)accessibilityPerformAction:(NSString*)action {
445 if ([action isEqual:NSAccessibilityPressAction]) { 455 if ([action isEqual:NSAccessibilityPressAction]) {
446 [viewController_ itemSelected:self]; 456 [viewController_ itemSelected:self];
447 return; 457 return;
448 } 458 }
449 459
450 [super accessibilityPerformAction:action]; 460 [super accessibilityPerformAction:action];
451 } 461 }
452 462
453 @end 463 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698