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

Side by Side Diff: chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm

Issue 8528052: Fix up fullscreen exit bubble messages to suggest Esc instead of F11 where appropriate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: strings Created 9 years, 1 month 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/fullscreen_exit_bubble.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/logging.h" // for NOTREACHED() 7 #include "base/logging.h" // for NOTREACHED()
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
15 #include "chrome/browser/ui/cocoa/event_utils.h" 15 #include "chrome/browser/ui/cocoa/event_utils.h"
16 #import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h" 16 #import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h"
17 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" 17 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h"
18 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 18 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
19 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 19 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
20 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" 20 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "grit/ui_strings.h"
22 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 23 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 24 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
24 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 25 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
25 #include "ui/base/models/accelerator_cocoa.h" 26 #include "ui/base/models/accelerator_cocoa.h"
27 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/l10n/l10n_util_mac.h" 28 #include "ui/base/l10n/l10n_util_mac.h"
27 29
28 30
29 namespace { 31 namespace {
30 const int kBubbleOffsetY = 10; 32 const int kBubbleOffsetY = 10;
31 const float kInitialDelay = 3.8; 33 const float kInitialDelay = 3.8;
32 const float kHideDuration = 0.7; 34 const float kHideDuration = 0.7;
33 } // namespace 35 } // namespace
34 36
35 @interface OneClickHyperlinkTextView : HyperlinkTextView 37 @interface OneClickHyperlinkTextView : HyperlinkTextView
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 fullscreen_bubble::GetDenyButtonTextForType(bubbleType))]; 161 fullscreen_bubble::GetDenyButtonTextForType(bubbleType))];
160 [self showButtons:YES]; 162 [self showButtons:YES];
161 163
162 // Reenable mouse events if they were disabled previously. 164 // Reenable mouse events if they were disabled previously.
163 [[self window] setIgnoresMouseEvents:NO]; 165 [[self window] setIgnoresMouseEvents:NO];
164 } else { 166 } else {
165 [self showButtons:NO]; 167 [self showButtons:NO];
166 // Only button-less bubbles auto-hide. 168 // Only button-less bubbles auto-hide.
167 [self hideSoon]; 169 [self hideSoon];
168 } 170 }
171 // TODO(jeremya): show "Press Esc to exit" instead of a link on mouselock.
169 172
170 // Relayout. A bit jumpy, but functional. 173 // Relayout. A bit jumpy, but functional.
171 [tweaker_ tweakUI:[self window]]; 174 [tweaker_ tweakUI:[self window]];
172 NSRect windowFrame = [owner_ window].frame; 175 NSRect windowFrame = [owner_ window].frame;
173 [self positionInWindowAtTop:NSHeight(windowFrame) width:NSWidth(windowFrame)]; 176 [self positionInWindowAtTop:NSHeight(windowFrame) width:NSWidth(windowFrame)];
174 } 177 }
175 178
176 // Called when someone clicks on the embedded link. 179 // Called when someone clicks on the embedded link.
177 - (BOOL) textView:(NSTextView*)textView 180 - (BOOL) textView:(NSTextView*)textView
178 clickedOnLink:(id)link 181 clickedOnLink:(id)link
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 exitLabel_.reset([[OneClickHyperlinkTextView alloc] 233 exitLabel_.reset([[OneClickHyperlinkTextView alloc]
231 initWithFrame:[exitLabelPlaceholder_ frame]]); 234 initWithFrame:[exitLabelPlaceholder_ frame]]);
232 [exitLabel_.get() setAutoresizingMask: 235 [exitLabel_.get() setAutoresizingMask:
233 [exitLabelPlaceholder_ autoresizingMask]]; 236 [exitLabelPlaceholder_ autoresizingMask]];
234 [exitLabel_.get() setHidden:[exitLabelPlaceholder_ isHidden]]; 237 [exitLabel_.get() setHidden:[exitLabelPlaceholder_ isHidden]];
235 [[exitLabelPlaceholder_ superview] 238 [[exitLabelPlaceholder_ superview]
236 replaceSubview:exitLabelPlaceholder_ with:exitLabel_.get()]; 239 replaceSubview:exitLabelPlaceholder_ with:exitLabel_.get()];
237 exitLabelPlaceholder_ = nil; // Now released. 240 exitLabelPlaceholder_ = nil; // Now released.
238 [exitLabel_.get() setDelegate:self]; 241 [exitLabel_.get() setDelegate:self];
239 242
240 NSString *message = l10n_util::GetNSStringF(IDS_EXIT_FULLSCREEN_MODE, 243 NSString *exit_link_text = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE);
Nico 2011/11/15 05:22:02 Space after *, not before. Variables in ObjC calle
jeremya 2011/11/15 05:29:13 Done.
241 base::SysNSStringToUTF16([[self class] keyCommandString])); 244 NSString *accelerator_text = [@" " stringByAppendingString:
245 l10n_util::GetNSStringF(IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
246 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY))];
242 247
243 NSFont* font = [NSFont systemFontOfSize: 248 NSFont* font = [NSFont systemFontOfSize:
244 [NSFont systemFontSizeForControlSize:NSRegularControlSize]]; 249 [NSFont systemFontSizeForControlSize:NSRegularControlSize]];
245 [(HyperlinkTextView*)exitLabel_.get() 250 [(HyperlinkTextView*)exitLabel_.get()
246 setMessageAndLink:@"" 251 setMessageAndLink:accelerator_text
247 withLink:message 252 withLink:exit_link_text
248 atOffset:0 253 atOffset:0
249 font:font 254 font:font
250 messageColor:[NSColor blackColor] 255 messageColor:[NSColor blackColor]
251 linkColor:[NSColor blueColor]]; 256 linkColor:[NSColor blueColor]];
252 [exitLabel_.get() setAlignment:NSRightTextAlignment]; 257 [exitLabel_.get() setAlignment:NSRightTextAlignment];
253 258
254 NSRect labelFrame = [exitLabel_ frame]; 259 NSRect labelFrame = [exitLabel_ frame];
255 260
256 // NSTextView's sizeToFit: method seems to enjoy wrapping lines. Temporarily 261 // NSTextView's sizeToFit: method seems to enjoy wrapping lines. Temporarily
257 // set the size large to force it not to. 262 // set the size large to force it not to.
258 NSRect windowFrame = [[self window] frame]; 263 NSRect windowFrame = [[self window] frame];
259 [exitLabel_ setFrameSize:windowFrame.size]; 264 [exitLabel_ setFrameSize:windowFrame.size];
260 NSLayoutManager* layoutManager = [exitLabel_ layoutManager]; 265 NSLayoutManager* layoutManager = [exitLabel_ layoutManager];
261 NSTextContainer* textContainer = [exitLabel_ textContainer]; 266 NSTextContainer* textContainer = [exitLabel_ textContainer];
262 [layoutManager ensureLayoutForTextContainer:textContainer]; 267 [layoutManager ensureLayoutForTextContainer:textContainer];
263 NSRect textFrame = [layoutManager usedRectForTextContainer:textContainer]; 268 NSRect textFrame = [layoutManager usedRectForTextContainer:textContainer];
264 269
270 textFrame.size.width = ceil(textFrame.size.width);
Nico 2011/11/15 05:22:02 NSWidth() on the right
jeremya 2011/11/15 05:29:13 Done.
265 labelFrame.origin.x += NSWidth(labelFrame) - NSWidth(textFrame); 271 labelFrame.origin.x += NSWidth(labelFrame) - NSWidth(textFrame);
266 labelFrame.size = textFrame.size; 272 labelFrame.size = textFrame.size;
267 [exitLabel_ setFrame:labelFrame]; 273 [exitLabel_ setFrame:labelFrame];
268 } 274 }
269 275
270 // This looks at the Main Menu and determines what the user has set as the 276 // This looks at the Main Menu and determines what the user has set as the
271 // key combination for quit. It then gets the modifiers and builds an object 277 // key combination for quit. It then gets the modifiers and builds an object
272 // to hold the data. 278 // to hold the data.
273 + (ui::AcceleratorCocoa)acceleratorForToggleFullscreen { 279 + (ui::AcceleratorCocoa)acceleratorForToggleFullscreen {
274 NSMenu* mainMenu = [NSApp mainMenu]; 280 NSMenu* mainMenu = [NSApp mainMenu];
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 - (void)hideSoon { 323 - (void)hideSoon {
318 hideTimer_.reset( 324 hideTimer_.reset(
319 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay 325 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay
320 target:self 326 target:self
321 selector:@selector(hideTimerFired:) 327 selector:@selector(hideTimerFired:)
322 userInfo:nil 328 userInfo:nil
323 repeats:NO] retain]); 329 repeats:NO] retain]);
324 } 330 }
325 331
326 @end 332 @end
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/fullscreen_exit_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698