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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 [showHideAnimation_.release() autorelease]; | 444 [showHideAnimation_.release() autorelease]; |
445 } else if (animation == moveAnimation_.get()) { | 445 } else if (animation == moveAnimation_.get()) { |
446 [moveAnimation_.release() autorelease]; | 446 [moveAnimation_.release() autorelease]; |
447 } else { | 447 } else { |
448 NOTREACHED(); | 448 NOTREACHED(); |
449 } | 449 } |
450 | 450 |
451 // If the find bar is not visible, make it actually hidden, so it'll no longer | 451 // If the find bar is not visible, make it actually hidden, so it'll no longer |
452 // respond to key events. | 452 // respond to key events. |
453 [[self view] setHidden:![self isFindBarVisible]]; | 453 [[self view] setHidden:![self isFindBarVisible]]; |
454 [[self browserWindowController] onFindBarVisibilityChanged]; | |
455 } | 454 } |
456 | 455 |
457 - (gfx::Point)findBarWindowPosition { | 456 - (gfx::Point)findBarWindowPosition { |
458 gfx::Rect viewRect(NSRectToCGRect([[self view] frame])); | 457 gfx::Rect viewRect(NSRectToCGRect([[self view] frame])); |
459 // Convert Cocoa coordinates (Y growing up) to Y growing down. | 458 // Convert Cocoa coordinates (Y growing up) to Y growing down. |
460 // Offset from |maxY_|, which represents the content view's top, instead | 459 // Offset from |maxY_|, which represents the content view's top, instead |
461 // of from the superview, which represents the whole browser window. | 460 // of from the superview, which represents the whole browser window. |
462 viewRect.set_y(maxY_ - viewRect.bottom()); | 461 viewRect.set_y(maxY_ - viewRect.bottom()); |
463 return viewRect.origin(); | 462 return viewRect.origin(); |
464 } | 463 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 duration:(float)duration { | 499 duration:(float)duration { |
501 // Save the current frame. | 500 // Save the current frame. |
502 NSRect startFrame = [findBarView_ frame]; | 501 NSRect startFrame = [findBarView_ frame]; |
503 | 502 |
504 // Stop any existing animations. | 503 // Stop any existing animations. |
505 [showHideAnimation_ stopAnimation]; | 504 [showHideAnimation_ stopAnimation]; |
506 | 505 |
507 if (!animate) { | 506 if (!animate) { |
508 [findBarView_ setFrame:endFrame]; | 507 [findBarView_ setFrame:endFrame]; |
509 [[self view] setHidden:![self isFindBarVisible]]; | 508 [[self view] setHidden:![self isFindBarVisible]]; |
510 [[self browserWindowController] onFindBarVisibilityChanged]; | |
511 showHideAnimation_.reset(nil); | 509 showHideAnimation_.reset(nil); |
512 return; | 510 return; |
513 } | 511 } |
514 | 512 |
515 // If animating, ensure that the find bar is not hidden. Hidden status will be | 513 // If animating, ensure that the find bar is not hidden. Hidden status will be |
516 // updated at the end of the animation. | 514 // updated at the end of the animation. |
517 [[self view] setHidden:NO]; | 515 [[self view] setHidden:NO]; |
518 //[[self browserWindowController] onFindBarVisibilityChanged]; | |
519 | 516 |
520 // Reset the frame to what was saved above. | 517 // Reset the frame to what was saved above. |
521 [findBarView_ setFrame:startFrame]; | 518 [findBarView_ setFrame:startFrame]; |
522 | 519 |
523 [[self browserWindowController] onFindBarVisibilityChanged]; | |
524 | |
525 showHideAnimation_.reset([self createAnimationForView:findBarView_ | 520 showHideAnimation_.reset([self createAnimationForView:findBarView_ |
526 toFrame:endFrame | 521 toFrame:endFrame |
527 duration:duration]); | 522 duration:duration]); |
528 } | 523 } |
529 | 524 |
530 - (float)findBarHorizontalPosition { | 525 - (float)findBarHorizontalPosition { |
531 // Get the rect of the FindBar. | 526 // Get the rect of the FindBar. |
532 NSView* view = [self view]; | 527 NSView* view = [self view]; |
533 NSRect frame = [view frame]; | 528 NSRect frame = [view frame]; |
534 gfx::Rect viewRect(NSRectToCGRect(frame)); | 529 gfx::Rect viewRect(NSRectToCGRect(frame)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 616 } |
622 | 617 |
623 - (BrowserWindowController*)browserWindowController { | 618 - (BrowserWindowController*)browserWindowController { |
624 if (!browser_) | 619 if (!browser_) |
625 return nil; | 620 return nil; |
626 return [BrowserWindowController | 621 return [BrowserWindowController |
627 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; | 622 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; |
628 } | 623 } |
629 | 624 |
630 @end | 625 @end |
OLD | NEW |