Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 8574068: Mac Panels interaction with Dock modifications. (step 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 22 matching lines...) Expand all
33 #include "chrome/common/chrome_notification_types.h" 33 #include "chrome/common/chrome_notification_types.h"
34 #include "content/browser/renderer_host/render_widget_host_view.h" 34 #include "content/browser/renderer_host/render_widget_host_view.h"
35 #include "content/browser/tab_contents/tab_contents.h" 35 #include "content/browser/tab_contents/tab_contents.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "grit/ui_resources.h" 37 #include "grit/ui_resources.h"
38 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/gfx/image/image.h" 39 #include "ui/gfx/image/image.h"
40 #include "ui/gfx/mac/nsimage_cache.h" 40 #include "ui/gfx/mac/nsimage_cache.h"
41 41
42 const int kMinimumWindowSize = 1; 42 const int kMinimumWindowSize = 1;
43 const double kBoundsChangeAnimationDuration = 0.18; // Seconds. 43 const double kBoundsChangeAnimationSpeed = 1000; // Pixels per second.
jennb 2011/11/17 23:45:40 Prefer units in var name. kBoundsAnimationPixelsPe
Dmitry Titov 2011/11/18 00:15:11 Done.
44 const double kBoundsChangeAnimationMaxDuration = 0.18; // Seconds.
44 45
45 // Replicate specific 10.6 SDK declarations for building with prior SDKs. 46 // Replicate specific 10.6 SDK declarations for building with prior SDKs.
46 #if !defined(MAC_OS_X_VERSION_10_6) || \ 47 #if !defined(MAC_OS_X_VERSION_10_6) || \
47 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 48 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
48 49
49 enum { 50 enum {
50 NSWindowCollectionBehaviorParticipatesInCycle = 1 << 5 51 NSWindowCollectionBehaviorParticipatesInCycle = 1 << 5
51 }; 52 };
52 53
53 #endif // MAC_OS_X_VERSION_10_6 54 #endif // MAC_OS_X_VERSION_10_6
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return [BrowserWindowUtils themePatternPhaseFor:windowView withTabStrip:nil]; 105 return [BrowserWindowUtils themePatternPhaseFor:windowView withTabStrip:nil];
105 } 106 }
106 107
107 - (void)awakeFromNib { 108 - (void)awakeFromNib {
108 NSWindow* window = [self window]; 109 NSWindow* window = [self window];
109 110
110 DCHECK(window); 111 DCHECK(window);
111 DCHECK(titlebar_view_); 112 DCHECK(titlebar_view_);
112 DCHECK_EQ(self, [window delegate]); 113 DCHECK_EQ(self, [window delegate]);
113 114
114 // Using NSModalPanelWindowLevel (8) rather then NSStatusWindowLevel (25) 115 [window setLevel:NSStatusWindowLevel];
jennb 2011/11/17 23:45:40 I'm assuming the comment no longer applies because
Dmitry Titov 2011/11/18 00:15:11 It never actually applied because it was a copy-pa
115 // ensures notification balloons on top of regular windows, but below
116 // popup menus which are at NSPopUpMenuWindowLevel (101) and Spotlight
117 // drop-out, which is at NSStatusWindowLevel-2 (23) for OSX 10.6/7.
118 // See http://crbug.com/59878.
119 [window setLevel:NSModalPanelWindowLevel];
120 116
121 if (base::mac::IsOSSnowLeopardOrLater()) { 117 if (base::mac::IsOSSnowLeopardOrLater()) {
122 [window setCollectionBehavior: 118 [window setCollectionBehavior:
123 NSWindowCollectionBehaviorParticipatesInCycle]; 119 NSWindowCollectionBehaviorParticipatesInCycle];
124 } 120 }
125 121
126 [titlebar_view_ attach]; 122 [titlebar_view_ attach];
127 123
128 // Set initial size of the window to match the size of the panel to give 124 // Set initial size of the window to match the size of the panel to give
129 // the renderer the proper size to work with earlier, avoiding a resize 125 // the renderer the proper size to work with earlier, avoiding a resize
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 432
437 NSArray *animations = [NSArray arrayWithObjects:windowResize, nil]; 433 NSArray *animations = [NSArray arrayWithObjects:windowResize, nil];
438 434
439 // Terminate previous animation, if it is still playing. 435 // Terminate previous animation, if it is still playing.
440 [self terminateBoundsAnimation]; 436 [self terminateBoundsAnimation];
441 boundsAnimation_ = 437 boundsAnimation_ =
442 [[NSViewAnimation alloc] initWithViewAnimations:animations]; 438 [[NSViewAnimation alloc] initWithViewAnimations:animations];
443 [boundsAnimation_ setDelegate:self]; 439 [boundsAnimation_ setDelegate:self];
444 440
445 [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking]; 441 [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking];
446 [boundsAnimation_ setDuration: kBoundsChangeAnimationDuration]; 442
443 NSRect currentFrame = [[self window] frame];
444 // Compute duration. We use constant speed of animation, however if the change
445 // is too large, we clip the duration (effectively increasing speed) to
446 // limit total duration of animation. This helps to make 'big changes' take
447 // specific well-percieved time, while making smaller updates quicker, which
jennb 2011/11/17 23:45:40 perceived
jennb 2011/11/17 23:45:40 Did you mean slower instead of quicker? (I admit t
Dmitry Titov 2011/11/18 00:15:11 Done.
Dmitry Titov 2011/11/18 00:15:11 Re-worded, made shorter.
Dmitry Titov 2011/11/18 00:15:11 Done.
448 // is intuitively 'correct'.
449 // 'distance' is the max travel between 4 potentially traveling corners.
jennb 2011/11/17 23:45:40 extra space in line
Dmitry Titov 2011/11/18 00:15:11 Done.
450 double distanceX = std::max(abs(NSMinX(currentFrame) - NSMinX(frame)),
451 abs(NSMaxX(currentFrame) - NSMaxX(frame)));
452 double distanceY = std::max(abs(NSMinY(currentFrame) - NSMinY(frame)),
453 abs(NSMaxY(currentFrame) - NSMaxY(frame)));
454 double distance = std::max(distanceX, distanceY);
455 double duration = std::min(distance / kBoundsChangeAnimationSpeed,
456 kBoundsChangeAnimationMaxDuration);
457 [boundsAnimation_ setDuration: duration];
447 [boundsAnimation_ startAnimation]; 458 [boundsAnimation_ startAnimation];
448 } 459 }
449 460
450 - (void)animationDidEnd:(NSAnimation*)animation { 461 - (void)animationDidEnd:(NSAnimation*)animation {
451 if (windowShim_->panel()->expansion_state() == Panel::EXPANDED) 462 if (windowShim_->panel()->expansion_state() == Panel::EXPANDED)
452 [self enableTabContentsViewAutosizing]; 463 [self enableTabContentsViewAutosizing];
453 464
454 content::NotificationService::current()->Notify( 465 content::NotificationService::current()->Notify(
455 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 466 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
456 content::Source<Panel>(windowShim_->panel()), 467 content::Source<Panel>(windowShim_->panel()),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 - (BOOL)canBecomeKeyWindow { 569 - (BOOL)canBecomeKeyWindow {
559 // Panel can only gain focus if it is expanded. Minimized panels do not 570 // Panel can only gain focus if it is expanded. Minimized panels do not
560 // participate in Cmd-~ rotation. 571 // participate in Cmd-~ rotation.
561 // TODO(dimich): If it will be ever desired to expand/focus the Panel on 572 // TODO(dimich): If it will be ever desired to expand/focus the Panel on
562 // keyboard navigation or via main menu, the care should be taken to avoid 573 // keyboard navigation or via main menu, the care should be taken to avoid
563 // cases when minimized Panel is getting keyboard input, invisibly. 574 // cases when minimized Panel is getting keyboard input, invisibly.
564 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; 575 return windowShim_->panel()->expansion_state() == Panel::EXPANDED;
565 } 576 }
566 577
567 @end 578 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698