OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/cocoa/app_list_view_controller.h" | 5 #import "ui/app_list/cocoa/app_list_view_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | |
14 #include "skia/ext/skia_utils_mac.h" | 15 #include "skia/ext/skia_utils_mac.h" |
15 #include "ui/app_list/app_list_constants.h" | 16 #include "ui/app_list/app_list_constants.h" |
16 #include "ui/app_list/app_list_model.h" | 17 #include "ui/app_list/app_list_model.h" |
17 #include "ui/app_list/app_list_view_delegate.h" | 18 #include "ui/app_list/app_list_view_delegate.h" |
18 #include "ui/app_list/app_list_view_delegate_observer.h" | 19 #include "ui/app_list/app_list_view_delegate_observer.h" |
19 #import "ui/app_list/cocoa/app_list_pager_view.h" | 20 #import "ui/app_list/cocoa/app_list_pager_view.h" |
20 #import "ui/app_list/cocoa/apps_grid_controller.h" | 21 #import "ui/app_list/cocoa/apps_grid_controller.h" |
21 #include "ui/app_list/search_box_model.h" | 22 #include "ui/app_list/search_box_model.h" |
22 #import "ui/base/cocoa/flipped_view.h" | 23 #import "ui/base/cocoa/flipped_view.h" |
24 #import "ui/gfx/image/image_skia_util_mac.h" | |
23 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 25 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 // The roundedness of the corners of the bubble. | 29 // The roundedness of the corners of the bubble. |
28 const CGFloat kBubbleCornerRadius = 3; | 30 const CGFloat kBubbleCornerRadius = 3; |
29 | 31 |
30 // Height of the pager. | 32 // Height of the pager. |
31 const CGFloat kPagerPreferredHeight = 57; | 33 const CGFloat kPagerPreferredHeight = 57; |
32 | 34 |
33 // Height of separator line drawn between the searchbox and grid view. | 35 // Height of separator line drawn between the searchbox and grid view. |
34 const CGFloat kTopSeparatorSize = 1; | 36 const CGFloat kTopSeparatorSize = 1; |
35 | 37 |
36 // Height of the search input. | 38 // Height of the search input. |
37 const CGFloat kSearchInputHeight = 48; | 39 const CGFloat kSearchInputHeight = 48; |
38 | 40 |
39 // Minimum margin on either side of the pager. If the pager grows beyond this, | 41 // Minimum margin on either side of the pager. If the pager grows beyond this, |
40 // the segment size is reduced. | 42 // the segment size is reduced. |
41 const CGFloat kMinPagerMargin = 40; | 43 const CGFloat kMinPagerMargin = 40; |
42 // Maximum width of a single segment. | 44 // Maximum width of a single segment. |
43 const CGFloat kMaxSegmentWidth = 80; | 45 const CGFloat kMaxSegmentWidth = 80; |
44 | 46 |
45 // Duration of the animation for sliding in and out search results. | 47 // Duration of the animation for sliding in and out search results. |
46 const NSTimeInterval kResultsAnimationDuration = 0.2; | 48 const NSTimeInterval kResultsAnimationDuration = 0.2; |
47 | 49 |
50 // Properties of the message rectangle, if it is shown. | |
51 const NSRect kMessageRect = {{12, 12}, {370, 91}}; | |
52 const CGFloat kMessageCornerRadius = 2; | |
53 const CGFloat kSpacingBelowMessageTitle = 6; | |
54 const SkColor kMessageBackgroundColor = SkColorSetRGB(0xFF, 0xFD, 0xE7); | |
55 const SkColor kMessageStrokeColor = SkColorSetARGB(0x3d, 0x00, 0x00, 0x00); | |
56 // The inset should be 16px, but NSTextView has its own inset of 3. | |
57 const CGFloat kMessageTextInset = 13; | |
58 | |
48 } // namespace | 59 } // namespace |
49 | 60 |
50 @interface BackgroundView : FlippedView; | 61 @interface BackgroundView : FlippedView; |
51 @end | 62 @end |
52 | 63 |
53 @implementation BackgroundView | 64 @implementation BackgroundView |
54 | 65 |
55 - (void)drawRect:(NSRect)dirtyRect { | 66 - (void)drawRect:(NSRect)dirtyRect { |
56 gfx::ScopedNSGraphicsContextSaveGState context; | 67 gfx::ScopedNSGraphicsContextSaveGState context; |
57 NSRect boundsRect = [self bounds]; | 68 NSRect boundsRect = [self bounds]; |
58 NSRect searchAreaRect = NSMakeRect(0, 0, | 69 NSRect searchAreaRect = NSMakeRect(0, 0, |
59 NSWidth(boundsRect), kSearchInputHeight); | 70 NSWidth(boundsRect), kSearchInputHeight); |
60 NSRect separatorRect = NSMakeRect(0, NSMaxY(searchAreaRect), | 71 NSRect separatorRect = NSMakeRect(0, NSMaxY(searchAreaRect), |
61 NSWidth(boundsRect), kTopSeparatorSize); | 72 NSWidth(boundsRect), kTopSeparatorSize); |
62 | 73 |
63 [[NSBezierPath bezierPathWithRoundedRect:boundsRect | 74 [[NSBezierPath bezierPathWithRoundedRect:boundsRect |
64 xRadius:kBubbleCornerRadius | 75 xRadius:kBubbleCornerRadius |
65 yRadius:kBubbleCornerRadius] addClip]; | 76 yRadius:kBubbleCornerRadius] addClip]; |
66 | 77 |
67 [skia::SkColorToSRGBNSColor(app_list::kContentsBackgroundColor) set]; | 78 [skia::SkColorToSRGBNSColor(app_list::kContentsBackgroundColor) set]; |
68 NSRectFill(boundsRect); | 79 NSRectFill(boundsRect); |
69 [skia::SkColorToSRGBNSColor(app_list::kSearchBoxBackground) set]; | 80 [skia::SkColorToSRGBNSColor(app_list::kSearchBoxBackground) set]; |
70 NSRectFill(searchAreaRect); | 81 NSRectFill(searchAreaRect); |
71 [skia::SkColorToSRGBNSColor(app_list::kTopSeparatorColor) set]; | 82 [skia::SkColorToSRGBNSColor(app_list::kTopSeparatorColor) set]; |
72 NSRectFill(separatorRect); | 83 NSRectFill(separatorRect); |
73 } | 84 } |
74 | 85 |
75 @end | 86 @end |
76 | 87 |
88 @interface MessageBackgroundView : FlippedView | |
89 @end | |
90 | |
91 @implementation MessageBackgroundView | |
92 | |
93 - (void)drawRect:(NSRect)dirtyRect { | |
94 NSRect boundsRect = [self bounds]; | |
95 gfx::ScopedNSGraphicsContextSaveGState context; | |
96 [[NSBezierPath bezierPathWithRoundedRect:boundsRect | |
97 xRadius:kMessageCornerRadius | |
98 yRadius:kMessageCornerRadius] addClip]; | |
99 | |
100 [skia::SkColorToSRGBNSColor(kMessageStrokeColor) set]; | |
101 NSRectFill(boundsRect); | |
102 | |
103 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(boundsRect, 1, 1) | |
104 xRadius:kMessageCornerRadius | |
105 yRadius:kMessageCornerRadius] addClip]; | |
106 [skia::SkColorToSRGBNSColor(kMessageBackgroundColor) set]; | |
107 NSRectFill(boundsRect); | |
108 } | |
109 | |
110 @end | |
111 | |
77 @interface AppListViewController () | 112 @interface AppListViewController () |
78 | 113 |
79 - (void)loadAndSetView; | 114 - (void)loadAndSetView; |
80 - (void)revealSearchResults:(BOOL)show; | 115 - (void)revealSearchResults:(BOOL)show; |
81 | 116 |
82 @end | 117 @end |
83 | 118 |
84 namespace app_list { | 119 namespace app_list { |
85 | 120 |
86 class AppListModelObserverBridge : public AppListViewDelegateObserver { | 121 class AppListModelObserverBridge : public AppListViewDelegateObserver { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 if (delegate_) { | 204 if (delegate_) { |
170 // Ensure the search box is cleared when switching profiles. | 205 // Ensure the search box is cleared when switching profiles. |
171 if ([self searchBoxModel]) | 206 if ([self searchBoxModel]) |
172 [self searchBoxModel]->SetText(base::string16()); | 207 [self searchBoxModel]->SetText(base::string16()); |
173 | 208 |
174 // First clean up, in reverse order. | 209 // First clean up, in reverse order. |
175 app_list_model_observer_bridge_.reset(); | 210 app_list_model_observer_bridge_.reset(); |
176 [appsSearchResultsController_ setDelegate:nil]; | 211 [appsSearchResultsController_ setDelegate:nil]; |
177 [appsSearchBoxController_ setDelegate:nil]; | 212 [appsSearchBoxController_ setDelegate:nil]; |
178 [appsGridController_ setDelegate:nil]; | 213 [appsGridController_ setDelegate:nil]; |
214 [messageText_ setDelegate:nil]; | |
179 } | 215 } |
180 delegate_ = newDelegate; | 216 delegate_ = newDelegate; |
181 if (delegate_) { | 217 if (delegate_) { |
182 [loadingIndicator_ stopAnimation:self]; | 218 [loadingIndicator_ stopAnimation:self]; |
183 } else { | 219 } else { |
184 [loadingIndicator_ startAnimation:self]; | 220 [loadingIndicator_ startAnimation:self]; |
185 return; | 221 return; |
186 } | 222 } |
187 | 223 |
188 [appsGridController_ setDelegate:delegate_]; | 224 [appsGridController_ setDelegate:delegate_]; |
189 [appsSearchBoxController_ setDelegate:self]; | 225 [appsSearchBoxController_ setDelegate:self]; |
190 [appsSearchResultsController_ setDelegate:self]; | 226 [appsSearchResultsController_ setDelegate:self]; |
191 app_list_model_observer_bridge_.reset( | 227 app_list_model_observer_bridge_.reset( |
192 new app_list::AppListModelObserverBridge(self)); | 228 new app_list::AppListModelObserverBridge(self)); |
193 [self onProfilesChanged]; | 229 [self onProfilesChanged]; |
230 | |
231 if (![AppsGridController hasFewerRows]) | |
Robert Sesek
2016/03/22 14:24:11
This is large enough to be its own method.
tapted
2016/03/23 00:27:22
Done.
| |
232 return; | |
233 | |
234 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
235 NSFont* messageFont = rb.GetFontWithDelta(0).GetNativeFont(); | |
236 NSFont* titleFont = rb.GetFontWithDelta(2).GetNativeFont(); | |
237 | |
238 base::string16 title = delegate_->GetMessageTitle(); | |
239 size_t messageBreak; | |
240 base::string16 messageFull = delegate_->GetMessageText(&messageBreak); | |
241 base::string16 shortcutName = delegate_->GetAppsShortcutName(); | |
242 base::string16 learnMore = delegate_->GetLearnMoreText(); | |
243 base::string16 learnMoreUrl = delegate_->GetLearnMoreLink(); | |
244 | |
245 base::string16 messagePre = messageFull.substr(0, messageBreak); | |
246 base::string16 messagePost = messageFull.substr(messageBreak); | |
247 | |
248 NSURL* linkURL = [NSURL URLWithString:base::SysUTF16ToNSString(learnMoreUrl)]; | |
249 gfx::ImageSkia* icon = delegate_->GetAppsIcon(); | |
250 | |
251 // Shift the baseline up so that the graphics align centered. 4 looks nice. It | |
252 // happens to be the image size minus the font size, but that's a coincidence. | |
253 const CGFloat kBaselineShift = 4; | |
254 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | |
255 [[NSMutableParagraphStyle alloc] init]); | |
256 [paragraphStyle setLineSpacing:kSpacingBelowMessageTitle + kBaselineShift]; | |
257 | |
258 NSNumber* baselineOffset = [NSNumber numberWithFloat:kBaselineShift]; | |
259 base::scoped_nsobject<NSMutableAttributedString> text( | |
260 [[NSMutableAttributedString alloc] | |
261 initWithString:base::SysUTF16ToNSString(title) | |
262 attributes:@{ | |
263 NSParagraphStyleAttributeName : paragraphStyle, | |
264 NSFontAttributeName : titleFont | |
265 }]); | |
266 | |
267 NSDictionary* defaultAttributes = @{ | |
268 NSFontAttributeName : messageFont, | |
269 NSBaselineOffsetAttributeName : baselineOffset | |
270 }; | |
271 | |
272 base::scoped_nsobject<NSAttributedString> lineBreak( | |
273 [[NSAttributedString alloc] initWithString:@"\n" | |
274 attributes:defaultAttributes]); | |
275 base::scoped_nsobject<NSAttributedString> space([[NSAttributedString alloc] | |
276 initWithString:@" " | |
277 attributes:defaultAttributes]); | |
278 base::scoped_nsobject<NSAttributedString> messagePreString( | |
279 [[NSAttributedString alloc] | |
280 initWithString:base::SysUTF16ToNSString(messagePre) | |
281 attributes:defaultAttributes]); | |
282 base::scoped_nsobject<NSAttributedString> messagePostString( | |
283 [[NSAttributedString alloc] | |
284 initWithString:base::SysUTF16ToNSString(messagePost) | |
285 attributes:defaultAttributes]); | |
286 | |
287 // NSNoUnderlineStyle is broken. | |
288 base::scoped_nsobject<NSAttributedString> learnMoreString( | |
289 [[NSAttributedString alloc] | |
290 initWithString:base::SysUTF16ToNSString(learnMore) | |
291 attributes:@{ | |
292 NSParagraphStyleAttributeName : paragraphStyle, | |
293 NSFontAttributeName : messageFont, | |
294 NSLinkAttributeName : linkURL, | |
295 NSBaselineOffsetAttributeName : baselineOffset, | |
296 NSUnderlineStyleAttributeName : | |
297 [NSNumber numberWithInt:NSNoUnderlineStyle] | |
298 }]); | |
299 base::scoped_nsobject<NSAttributedString> shortcutStringText( | |
300 [[NSAttributedString alloc] | |
301 initWithString:base::SysUTF16ToNSString(shortcutName) | |
302 attributes:defaultAttributes]); | |
303 base::scoped_nsobject<NSMutableAttributedString> shortcutString( | |
304 [[NSMutableAttributedString alloc] init]); | |
305 if (icon) { | |
306 NSImage* image = gfx::NSImageFromImageSkia(*icon); | |
307 // The image has a bunch of representations. Ensure the smallest is used. | |
308 // (Going smaller would make pixels all manky, so don't do that). | |
309 [image setSize:NSMakeSize(16, 16)]; | |
310 | |
311 base::scoped_nsobject<NSTextAttachmentCell> attachmentCell( | |
312 [[NSTextAttachmentCell alloc] initImageCell:image]); | |
313 base::scoped_nsobject<NSTextAttachment> attachment( | |
314 [[NSTextAttachment alloc] init]); | |
315 [attachment setAttachmentCell:attachmentCell]; | |
316 [shortcutString | |
317 appendAttributedString:[NSAttributedString | |
318 attributedStringWithAttachment:attachment]]; | |
319 [shortcutString appendAttributedString:space]; | |
320 } | |
321 [shortcutString appendAttributedString:shortcutStringText]; | |
322 | |
323 [text appendAttributedString:lineBreak]; | |
324 [text appendAttributedString:messagePreString]; | |
325 [text appendAttributedString:shortcutString]; | |
326 [text appendAttributedString:messagePostString]; | |
327 [text appendAttributedString:space]; | |
328 [text appendAttributedString:learnMoreString]; | |
329 | |
330 [[messageText_ textStorage] setAttributedString:text]; | |
331 [messageText_ sizeToFit]; | |
332 | |
333 // If the user scroller preference is to always show scrollbars, and the | |
334 // translated message is long, the scroll track may be present. This means | |
335 // text will be under the scroller. We only want vertical scrolling, but | |
336 // reducing the width puts the scroll track in a weird spot. So, increase the | |
337 // width of the scroll view to move the track into the padding towards the | |
338 // message background border, then reduce the width of the text view. The | |
339 // non-overlay scroller still looks kinda weird but hopefully not many will | |
340 // actually see it. | |
341 CGFloat overlap = | |
342 NSWidth([messageText_ bounds]) - [messageScrollView_ contentSize].width; | |
343 if (overlap > 0) { | |
344 NSRect rect = [messageScrollView_ frame]; | |
345 rect.size.width += kMessageTextInset - 2; | |
346 [messageScrollView_ setFrame:rect]; | |
347 overlap -= kMessageTextInset - 2; | |
348 DCHECK_GT(overlap, 0); | |
349 rect = [messageText_ frame]; | |
350 rect.size.width -= overlap; | |
351 [messageText_ setFrame:rect]; | |
352 [messageText_ sizeToFit]; | |
353 | |
354 // And after doing all that for some reason Cocoa scrolls to the bottom. So | |
355 // fix that. | |
356 [[messageScrollView_ documentView] scrollPoint:NSMakePoint(0, 0)]; | |
357 } | |
358 | |
359 [messageText_ setDelegate:self]; | |
194 } | 360 } |
195 | 361 |
196 -(void)loadAndSetView { | 362 -(void)loadAndSetView { |
197 pagerControl_.reset([[AppListPagerView alloc] init]); | 363 pagerControl_.reset([[AppListPagerView alloc] init]); |
198 [pagerControl_ setTarget:appsGridController_]; | 364 [pagerControl_ setTarget:appsGridController_]; |
199 [pagerControl_ setAction:@selector(onPagerClicked:)]; | 365 [pagerControl_ setAction:@selector(onPagerClicked:)]; |
200 | 366 |
201 NSRect gridFrame = [[appsGridController_ view] frame]; | 367 NSRect gridFrame = [[appsGridController_ view] frame]; |
202 NSRect contentsRect = NSMakeRect(0, kSearchInputHeight + kTopSeparatorSize, | 368 |
203 NSWidth(gridFrame), NSHeight(gridFrame) + kPagerPreferredHeight - | 369 base::scoped_nsobject<NSView> messageTextBackground; |
204 [AppsGridController scrollerPadding]); | 370 if ([AppsGridController hasFewerRows]) { |
371 messageTextBackground.reset( | |
372 [[MessageBackgroundView alloc] initWithFrame:kMessageRect]); | |
373 NSRect frameRect = | |
374 NSInsetRect(kMessageRect, kMessageTextInset, kMessageTextInset); | |
375 messageText_.reset([[NSTextView alloc] initWithFrame:frameRect]); | |
376 // Provide a solid background here (as well as the background) so that | |
377 // subpixel AA works. | |
378 [messageText_ | |
379 setBackgroundColor:skia::SkColorToSRGBNSColor(kMessageBackgroundColor)]; | |
380 [messageText_ setDrawsBackground:YES]; | |
381 [messageText_ setEditable:NO]; | |
382 // Ideally setSelectable:NO would also be set here, but that disables mouse | |
383 // events completely, breaking the "Learn more" link. Instead, selection is | |
384 // "disabled" via a delegate method which Apple's documentation suggests. In | |
385 // reality, selection still happens, it just disappears once the mouse is | |
386 // released. To avoid the selection appearing, also set selected text to | |
387 // have no special attributes. Sadly, the mouse cursor still displays an | |
388 // I-beam, but hacking cursor rectangles on the view so that the "Learn | |
389 // More" link is still correctly handled is too hard. | |
390 [messageText_ setSelectedTextAttributes:@{}]; | |
391 gridFrame.origin.y += NSMaxY([messageTextBackground frame]); | |
392 } | |
393 | |
394 [[appsGridController_ view] setFrame:gridFrame]; | |
395 | |
396 NSRect contentsRect = | |
397 NSMakeRect(0, kSearchInputHeight + kTopSeparatorSize, NSWidth(gridFrame), | |
398 NSMaxY(gridFrame) + kPagerPreferredHeight - | |
399 [AppsGridController scrollerPadding]); | |
205 | 400 |
206 contentsView_.reset([[FlippedView alloc] initWithFrame:contentsRect]); | 401 contentsView_.reset([[FlippedView alloc] initWithFrame:contentsRect]); |
207 | 402 |
208 // The contents view contains animations both from an NSCollectionView and the | 403 // The contents view contains animations both from an NSCollectionView and the |
209 // app list's own transitive drag layers. On Mavericks, the subviews need to | 404 // app list's own transitive drag layers. On Mavericks, the subviews need to |
210 // have access to a compositing layer they can share. Otherwise the compositor | 405 // have access to a compositing layer they can share. Otherwise the compositor |
211 // makes tearing artifacts. However, doing this on Mountain Lion or earler | 406 // makes tearing artifacts. However, doing this on Mountain Lion or earler |
212 // results in flickering whilst an item is installing. | 407 // results in flickering whilst an item is installing. |
213 if (base::mac::IsOSMavericksOrLater()) | 408 if (base::mac::IsOSMavericksOrLater()) |
214 [contentsView_ setWantsLayer:YES]; | 409 [contentsView_ setWantsLayer:YES]; |
(...skipping 14 matching lines...) Expand all Loading... | |
229 [[NSProgressIndicator alloc] initWithFrame:NSZeroRect]); | 424 [[NSProgressIndicator alloc] initWithFrame:NSZeroRect]); |
230 [loadingIndicator_ setStyle:NSProgressIndicatorSpinningStyle]; | 425 [loadingIndicator_ setStyle:NSProgressIndicatorSpinningStyle]; |
231 [loadingIndicator_ sizeToFit]; | 426 [loadingIndicator_ sizeToFit]; |
232 NSRect indicatorRect = [loadingIndicator_ frame]; | 427 NSRect indicatorRect = [loadingIndicator_ frame]; |
233 indicatorRect.origin.x = NSWidth(contentsRect) / 2 - NSMidX(indicatorRect); | 428 indicatorRect.origin.x = NSWidth(contentsRect) / 2 - NSMidX(indicatorRect); |
234 indicatorRect.origin.y = NSHeight(contentsRect) / 2 - NSMidY(indicatorRect); | 429 indicatorRect.origin.y = NSHeight(contentsRect) / 2 - NSMidY(indicatorRect); |
235 [loadingIndicator_ setFrame:indicatorRect]; | 430 [loadingIndicator_ setFrame:indicatorRect]; |
236 [loadingIndicator_ setDisplayedWhenStopped:NO]; | 431 [loadingIndicator_ setDisplayedWhenStopped:NO]; |
237 [loadingIndicator_ startAnimation:self]; | 432 [loadingIndicator_ startAnimation:self]; |
238 | 433 |
434 if (messageText_) { | |
435 [contentsView_ addSubview:messageTextBackground]; | |
436 | |
437 // Add a scroll view in case the translation is long and doesn't fit. Mac | |
438 // likes to hide scrollbars, so add to the height so the user can see part | |
439 // of the next line of text: just extend out into the padding towards the | |
440 // text background's border. Subtract at least 2: one for the border stroke | |
441 // and one for a bit of padding. | |
442 NSRect frameRect = [messageText_ frame]; | |
443 frameRect.size.height += kMessageTextInset - 2; | |
444 messageScrollView_.reset([[NSScrollView alloc] initWithFrame:frameRect]); | |
445 [messageScrollView_ setHasVerticalScroller:YES]; | |
446 [messageScrollView_ setAutohidesScrollers:YES]; | |
447 | |
448 // Now the message is going into an NSScrollView, origin should be 0, 0. | |
449 frameRect = [messageText_ frame]; | |
450 frameRect.origin = NSMakePoint(0, 0); | |
451 [messageText_ setFrame:frameRect]; | |
452 | |
453 [messageScrollView_ setDocumentView:messageText_]; | |
454 [contentsView_ addSubview:messageScrollView_]; | |
455 } | |
239 [contentsView_ addSubview:[appsGridController_ view]]; | 456 [contentsView_ addSubview:[appsGridController_ view]]; |
240 [contentsView_ addSubview:pagerControl_]; | 457 [contentsView_ addSubview:pagerControl_]; |
241 [contentsView_ addSubview:loadingIndicator_]; | 458 [contentsView_ addSubview:loadingIndicator_]; |
242 [backgroundView_ addSubview:contentsView_]; | 459 [backgroundView_ addSubview:contentsView_]; |
243 [backgroundView_ addSubview:[appsSearchResultsController_ view]]; | 460 [backgroundView_ addSubview:[appsSearchResultsController_ view]]; |
244 [backgroundView_ addSubview:[appsSearchBoxController_ view]]; | 461 [backgroundView_ addSubview:[appsSearchBoxController_ view]]; |
245 [containerView addSubview:backgroundView_]; | 462 [containerView addSubview:backgroundView_]; |
246 [self setView:containerView]; | 463 [self setView:containerView]; |
247 } | 464 } |
248 | 465 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 if (delegate_) { | 578 if (delegate_) { |
362 delegate_->OpenSearchResult( | 579 delegate_->OpenSearchResult( |
363 result, false /* auto_launch */, 0 /* event flags */); | 580 result, false /* auto_launch */, 0 /* event flags */); |
364 } | 581 } |
365 } | 582 } |
366 | 583 |
367 - (void)onProfilesChanged { | 584 - (void)onProfilesChanged { |
368 [appsSearchBoxController_ rebuildMenu]; | 585 [appsSearchBoxController_ rebuildMenu]; |
369 } | 586 } |
370 | 587 |
588 // NSTextViewDelegate implementation. | |
589 | |
590 - (BOOL)textView:(NSTextView*)textView | |
591 clickedOnLink:(id)link | |
592 atIndex:(NSUInteger)charIndex { | |
593 DCHECK(delegate_); | |
594 delegate_->OpenLearnMoreLink(); | |
595 return YES; | |
596 } | |
597 | |
598 - (NSArray*)textView:(NSTextView*)aTextView | |
599 willChangeSelectionFromCharacterRanges:(NSArray*)oldSelectedCharRanges | |
600 toCharacterRanges:(NSArray*)newSelectedCharRanges { | |
601 return oldSelectedCharRanges; | |
602 } | |
603 | |
371 @end | 604 @end |
OLD | NEW |