| 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/panels/panel_window_controller_cocoa.h" | 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #import "chrome/browser/ui/cocoa/event_utils.h" | 21 #import "chrome/browser/ui/cocoa/event_utils.h" |
| 22 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 22 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 23 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 23 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 24 #import "chrome/browser/ui/cocoa/menu_controller.h" | 24 #import "chrome/browser/ui/cocoa/menu_controller.h" |
| 25 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" | 25 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" |
| 26 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" | 26 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" |
| 27 #include "chrome/browser/ui/panels/panel.h" | 27 #include "chrome/browser/ui/panels/panel.h" |
| 28 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 28 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 29 #include "chrome/browser/ui/panels/panel_manager.h" | 29 #include "chrome/browser/ui/panels/panel_manager.h" |
| 30 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" | 30 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" |
| 31 #include "chrome/browser/ui/panels/panel_slide_animation.h" |
| 31 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 32 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
| 32 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 33 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 33 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
| 34 #include "content/browser/renderer_host/render_widget_host_view.h" | 35 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 35 #include "content/browser/tab_contents/tab_contents.h" | 36 #include "content/browser/tab_contents/tab_contents.h" |
| 36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 37 #include "grit/ui_resources.h" | 38 #include "grit/ui_resources.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/image/image.h" | 40 #include "ui/gfx/image/image.h" |
| 40 #include "ui/gfx/mac/nsimage_cache.h" | 41 #include "ui/gfx/mac/nsimage_cache.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 469 } |
| 469 } | 470 } |
| 470 [boundsAnimation_ setDuration: duration]; | 471 [boundsAnimation_ setDuration: duration]; |
| 471 [boundsAnimation_ setFrameRate:0.0]; | 472 [boundsAnimation_ setFrameRate:0.0]; |
| 472 [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking]; | 473 [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking]; |
| 473 [boundsAnimation_ startAnimation]; | 474 [boundsAnimation_ startAnimation]; |
| 474 } | 475 } |
| 475 | 476 |
| 476 - (float)animation:(NSAnimation*)animation | 477 - (float)animation:(NSAnimation*)animation |
| 477 valueForProgress:(NSAnimationProgress)progress { | 478 valueForProgress:(NSAnimationProgress)progress { |
| 478 if (!playingMinimizeAnimation_) { | 479 return PanelSlideAnimation::ComputeAnimationValue( |
| 479 // Cubic easing out. | 480 progress, playingMinimizeAnimation_, animationStopToShowTitlebarOnly_); |
| 480 float value = 1.0 - progress; | |
| 481 return 1.0 - value * value * value; | |
| 482 } | |
| 483 | |
| 484 // Minimize animation: | |
| 485 // 1. Quickly (0 -> 0.15) make only titlebar visible. | |
| 486 // 2. Stay a little bit (0.15->0.6) in place, just showing titlebar. | |
| 487 // 3. Slowly minimize to thin strip (0.6->1.0) | |
| 488 const float kAnimationStopAfterQuickDecrease = 0.15; | |
| 489 const float kAnimationStopAfterShowingTitlebar = 0.6; | |
| 490 float value; | |
| 491 if (progress <= kAnimationStopAfterQuickDecrease) { | |
| 492 value = progress * animationStopToShowTitlebarOnly_ / | |
| 493 kAnimationStopAfterQuickDecrease; | |
| 494 } else if (progress <= kAnimationStopAfterShowingTitlebar) { | |
| 495 value = animationStopToShowTitlebarOnly_; | |
| 496 } else { | |
| 497 value = animationStopToShowTitlebarOnly_ + | |
| 498 (progress - kAnimationStopAfterShowingTitlebar) * | |
| 499 (1.0 - animationStopToShowTitlebarOnly_) / | |
| 500 (1.0 - kAnimationStopAfterShowingTitlebar); | |
| 501 } | |
| 502 return value; | |
| 503 } | 481 } |
| 504 | 482 |
| 505 - (void)animationDidEnd:(NSAnimation*)animation { | 483 - (void)animationDidEnd:(NSAnimation*)animation { |
| 506 playingMinimizeAnimation_ = NO; | 484 playingMinimizeAnimation_ = NO; |
| 507 if (windowShim_->panel()->expansion_state() == Panel::EXPANDED) | 485 if (windowShim_->panel()->expansion_state() == Panel::EXPANDED) |
| 508 [self enableTabContentsViewAutosizing]; | 486 [self enableTabContentsViewAutosizing]; |
| 509 | 487 |
| 510 content::NotificationService::current()->Notify( | 488 content::NotificationService::current()->Notify( |
| 511 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 489 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 512 content::Source<Panel>(windowShim_->panel()), | 490 content::Source<Panel>(windowShim_->panel()), |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 - (BOOL)canBecomeKeyWindow { | 597 - (BOOL)canBecomeKeyWindow { |
| 620 // Panel can only gain focus if it is expanded. Minimized panels do not | 598 // Panel can only gain focus if it is expanded. Minimized panels do not |
| 621 // participate in Cmd-~ rotation. | 599 // participate in Cmd-~ rotation. |
| 622 // TODO(dimich): If it will be ever desired to expand/focus the Panel on | 600 // TODO(dimich): If it will be ever desired to expand/focus the Panel on |
| 623 // keyboard navigation or via main menu, the care should be taken to avoid | 601 // keyboard navigation or via main menu, the care should be taken to avoid |
| 624 // cases when minimized Panel is getting keyboard input, invisibly. | 602 // cases when minimized Panel is getting keyboard input, invisibly. |
| 625 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; | 603 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; |
| 626 } | 604 } |
| 627 | 605 |
| 628 @end | 606 @end |
| OLD | NEW |