OLD | NEW |
---|---|
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 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" | 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 SetFrameAvoidingMouse([window_ frame], location); | 345 SetFrameAvoidingMouse([window_ frame], location); |
346 } | 346 } |
347 | 347 |
348 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { | 348 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { |
349 UpdateSizeAndPosition(); | 349 UpdateSizeAndPosition(); |
350 } | 350 } |
351 | 351 |
352 void StatusBubbleMac::Create() { | 352 void StatusBubbleMac::Create() { |
353 DCHECK(!window_); | 353 DCHECK(!window_); |
354 | 354 |
355 window_ = [[NSWindow alloc] initWithContentRect:NSZeroRect | 355 window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) |
356 styleMask:NSBorderlessWindowMask | 356 styleMask:NSBorderlessWindowMask |
357 backing:NSBackingStoreBuffered | 357 backing:NSBackingStoreBuffered |
358 defer:YES]; | 358 defer:YES]; |
359 [window_ setMovableByWindowBackground:NO]; | 359 [window_ setMovableByWindowBackground:NO]; |
360 [window_ setBackgroundColor:[NSColor clearColor]]; | 360 [window_ setBackgroundColor:[NSColor clearColor]]; |
361 [window_ setLevel:NSNormalWindowLevel]; | 361 [window_ setLevel:NSNormalWindowLevel]; |
362 [window_ setOpaque:NO]; | 362 [window_ setOpaque:NO]; |
363 [window_ setHasShadow:NO]; | 363 [window_ setHasShadow:NO]; |
364 | 364 |
365 // We do not need to worry about the bubble outliving |parent_| because our | 365 // We do not need to worry about the bubble outliving |parent_| because our |
366 // teardown sequence in BWC guarantees that |parent_| outlives the status | 366 // teardown sequence in BWC guarantees that |parent_| outlives the status |
367 // bubble and that the StatusBubble is torn down completely prior to the | 367 // bubble and that the StatusBubble is torn down completely prior to the |
368 // window going away. | 368 // window going away. |
369 scoped_nsobject<BubbleView> view( | 369 scoped_nsobject<BubbleView> view( |
370 [[BubbleView alloc] initWithFrame:NSZeroRect themeProvider:parent_]); | 370 [[BubbleView alloc] initWithFrame:NSMakeRect(0, 0, 1, 1) |
sail
2011/06/10 01:04:24
Are you sure we need this? I create zero rect view
Avi (use Gerrit)
2011/06/10 01:20:27
Zero-rect views are fine. I wanted to change this
| |
371 themeProvider:parent_]); | |
371 [window_ setContentView:view]; | 372 [window_ setContentView:view]; |
372 | 373 |
373 [window_ setAlphaValue:0.0]; | 374 [window_ setAlphaValue:0.0]; |
374 | 375 |
375 // Set a delegate for the fade-in and fade-out transitions to be notified | 376 // Set a delegate for the fade-in and fade-out transitions to be notified |
376 // when fades are complete. The ownership model is for window_ to own | 377 // when fades are complete. The ownership model is for window_ to own |
377 // animation_dictionary, which owns animation, which owns | 378 // animation_dictionary, which owns animation, which owns |
378 // animation_delegate. | 379 // animation_delegate. |
379 CAAnimation* animation = [[window_ animationForKey:kFadeAnimationKey] copy]; | 380 CAAnimation* animation = [[window_ animationForKey:kFadeAnimationKey] copy]; |
380 [animation autorelease]; | 381 [animation autorelease]; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 SetState(kBubbleHidden); | 430 SetState(kBubbleHidden); |
430 } | 431 } |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
434 void StatusBubbleMac::SetState(StatusBubbleState state) { | 435 void StatusBubbleMac::SetState(StatusBubbleState state) { |
435 if (state == state_) | 436 if (state == state_) |
436 return; | 437 return; |
437 | 438 |
438 if (state == kBubbleHidden) | 439 if (state == kBubbleHidden) |
439 [window_ setFrame:NSZeroRect display:YES]; | 440 [window_ setFrame:NSMakeRect(0, 0, 1, 1) display:YES]; |
sail
2011/06/10 01:04:24
will this be visible?
Avi (use Gerrit)
2011/06/10 01:20:27
No, I checked. The bubble's faded to zero opacity
| |
440 | 441 |
441 if ([delegate_ respondsToSelector:@selector(statusBubbleWillEnterState:)]) | 442 if ([delegate_ respondsToSelector:@selector(statusBubbleWillEnterState:)]) |
442 [delegate_ statusBubbleWillEnterState:state]; | 443 [delegate_ statusBubbleWillEnterState:state]; |
443 | 444 |
444 state_ = state; | 445 state_ = state; |
445 } | 446 } |
446 | 447 |
447 void StatusBubbleMac::Fade(bool show) { | 448 void StatusBubbleMac::Fade(bool show) { |
448 DCHECK([NSThread isMainThread]); | 449 DCHECK([NSThread isMainThread]); |
449 | 450 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 | 684 |
684 if (expanded_width) { | 685 if (expanded_width) { |
685 size.width = screenRect.size.width; | 686 size.width = screenRect.size.width; |
686 } else { | 687 } else { |
687 size.width = kWindowWidthPercent * screenRect.size.width; | 688 size.width = kWindowWidthPercent * screenRect.size.width; |
688 } | 689 } |
689 | 690 |
690 screenRect.size = size; | 691 screenRect.size = size; |
691 return screenRect; | 692 return screenRect; |
692 } | 693 } |
OLD | NEW |