OLD | NEW |
---|---|
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/download/download_shelf_controller.h" | 5 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 - (void)layoutItems:(BOOL)skipFirst; | 75 - (void)layoutItems:(BOOL)skipFirst; |
76 - (void)closed; | 76 - (void)closed; |
77 - (void)maybeAutoCloseAfterDelay; | 77 - (void)maybeAutoCloseAfterDelay; |
78 - (void)scheduleAutoClose; | 78 - (void)scheduleAutoClose; |
79 - (void)cancelAutoClose; | 79 - (void)cancelAutoClose; |
80 - (void)autoClose; | 80 - (void)autoClose; |
81 - (void)viewFrameDidChange:(NSNotification*)notification; | 81 - (void)viewFrameDidChange:(NSNotification*)notification; |
82 - (void)installTrackingArea; | 82 - (void)installTrackingArea; |
83 - (void)removeTrackingArea; | 83 - (void)removeTrackingArea; |
84 - (void)willEnterFullscreen; | 84 - (void)willEnterFullscreen; |
85 - (void)willLeaveFullscreen; | 85 - (void)didExitFullscreen; |
86 - (void)updateDownloadItemViews; | |
86 - (void)updateCloseButton; | 87 - (void)updateCloseButton; |
87 @end | 88 @end |
88 | 89 |
89 | 90 |
90 @implementation DownloadShelfController | 91 @implementation DownloadShelfController |
91 | 92 |
92 - (id)initWithBrowser:(Browser*)browser | 93 - (id)initWithBrowser:(Browser*)browser |
93 resizeDelegate:(id<ViewResizer>)resizeDelegate { | 94 resizeDelegate:(id<ViewResizer>)resizeDelegate { |
94 if ((self = [super initWithNibName:@"DownloadShelf" | 95 if ((self = [super initWithNibName:@"DownloadShelf" |
95 bundle:base::mac::FrameworkBundle()])) { | 96 bundle:base::mac::FrameworkBundle()])) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 [defaultCenter addObserver:self | 128 [defaultCenter addObserver:self |
128 selector:@selector(viewFrameDidChange:) | 129 selector:@selector(viewFrameDidChange:) |
129 name:NSViewFrameDidChangeNotification | 130 name:NSViewFrameDidChangeNotification |
130 object:[self view]]; | 131 object:[self view]]; |
131 | 132 |
132 [defaultCenter addObserver:self | 133 [defaultCenter addObserver:self |
133 selector:@selector(willEnterFullscreen) | 134 selector:@selector(willEnterFullscreen) |
134 name:NSWindowWillEnterFullScreenNotification | 135 name:NSWindowWillEnterFullScreenNotification |
135 object:nil]; | 136 object:nil]; |
136 [defaultCenter addObserver:self | 137 [defaultCenter addObserver:self |
137 selector:@selector(willLeaveFullscreen) | 138 selector:@selector(didExitFullscreen) |
138 name:NSWindowWillExitFullScreenNotification | 139 name:NSWindowDidExitFullScreenNotification |
139 object:nil]; | 140 object:nil]; |
140 [self installTrackingArea]; | 141 [self installTrackingArea]; |
141 } | 142 } |
142 | 143 |
143 - (void)dealloc { | 144 - (void)dealloc { |
144 [self browserWillBeDestroyed]; | 145 [self browserWillBeDestroyed]; |
145 [super dealloc]; | 146 [super dealloc]; |
146 } | 147 } |
147 | 148 |
148 - (void)browserWillBeDestroyed { | 149 - (void)browserWillBeDestroyed { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 [[self view] removeTrackingArea:trackingArea_.get()]; | 472 [[self view] removeTrackingArea:trackingArea_.get()]; |
472 trackingArea_.reset(nil); | 473 trackingArea_.reset(nil); |
473 } | 474 } |
474 } | 475 } |
475 | 476 |
476 - (void)willEnterFullscreen { | 477 - (void)willEnterFullscreen { |
477 isFullscreen_ = YES; | 478 isFullscreen_ = YES; |
478 [self updateCloseButton]; | 479 [self updateCloseButton]; |
479 } | 480 } |
480 | 481 |
481 - (void)willLeaveFullscreen { | 482 - (void)didExitFullscreen { |
482 isFullscreen_ = NO; | 483 isFullscreen_ = NO; |
483 [self updateCloseButton]; | 484 [self updateCloseButton]; |
485 [self updateDownloadItemViews]; | |
486 } | |
487 | |
488 - (void)updateDownloadItemViews { | |
489 for (DownloadItemController* controller in downloadItemControllers_.get()) | |
490 [controller updateViews]; | |
Robert Sesek
2016/07/12 23:33:13
Can you call [[controller view] setNeedsDisplay:YE
| |
484 } | 491 } |
485 | 492 |
486 - (void)updateCloseButton { | 493 - (void)updateCloseButton { |
487 if (!barIsVisible_) | 494 if (!barIsVisible_) |
488 return; | 495 return; |
489 | 496 |
490 NSRect selfBounds = [[self view] bounds]; | 497 NSRect selfBounds = [[self view] bounds]; |
491 NSRect hoverFrame = [hoverCloseButton_ frame]; | 498 NSRect hoverFrame = [hoverCloseButton_ frame]; |
492 NSRect bounds; | 499 NSRect bounds; |
493 | 500 |
494 if (isFullscreen_) { | 501 if (isFullscreen_) { |
495 bounds = NSMakeRect(NSMinX(hoverFrame), 0, | 502 bounds = NSMakeRect(NSMinX(hoverFrame), 0, |
496 selfBounds.size.width - NSMinX(hoverFrame), | 503 selfBounds.size.width - NSMinX(hoverFrame), |
497 selfBounds.size.height); | 504 selfBounds.size.height); |
498 } else { | 505 } else { |
499 bounds.origin.x = NSMinX(hoverFrame); | 506 bounds.origin.x = NSMinX(hoverFrame); |
500 bounds.origin.y = NSMidY(hoverFrame) - | 507 bounds.origin.y = NSMidY(hoverFrame) - |
501 kHoverCloseButtonDefaultSize.height / 2.0; | 508 kHoverCloseButtonDefaultSize.height / 2.0; |
502 bounds.size = kHoverCloseButtonDefaultSize; | 509 bounds.size = kHoverCloseButtonDefaultSize; |
503 } | 510 } |
504 | 511 |
505 // Set the tracking off to create a new tracking area for the control. | 512 // Set the tracking off to create a new tracking area for the control. |
506 // When changing the bounds/frame on a HoverButton, the tracking isn't updated | 513 // When changing the bounds/frame on a HoverButton, the tracking isn't updated |
507 // correctly, it needs to be turned off and back on. | 514 // correctly, it needs to be turned off and back on. |
508 [hoverCloseButton_ setTrackingEnabled:NO]; | 515 [hoverCloseButton_ setTrackingEnabled:NO]; |
509 [hoverCloseButton_ setFrame:bounds]; | 516 [hoverCloseButton_ setFrame:bounds]; |
510 [hoverCloseButton_ setTrackingEnabled:YES]; | 517 [hoverCloseButton_ setTrackingEnabled:YES]; |
511 } | 518 } |
512 @end | 519 @end |
OLD | NEW |