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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm

Issue 1105713002: [Extension Toolbar] Slide out overflowed actions for popups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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
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 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #import "chrome/browser/ui/cocoa/view_id_util.h" 10 #import "chrome/browser/ui/cocoa/view_id_util.h"
11 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
12 #include "ui/base/cocoa/appkit_utils.h" 12 #include "ui/base/cocoa/appkit_utils.h"
13 13
14 NSString* const kBrowserActionGrippyDragStartedNotification = 14 NSString* const kBrowserActionGrippyDragStartedNotification =
15 @"BrowserActionGrippyDragStartedNotification"; 15 @"BrowserActionGrippyDragStartedNotification";
16 NSString* const kBrowserActionGrippyDraggingNotification = 16 NSString* const kBrowserActionGrippyDraggingNotification =
17 @"BrowserActionGrippyDraggingNotification"; 17 @"BrowserActionGrippyDraggingNotification";
18 NSString* const kBrowserActionGrippyDragFinishedNotification = 18 NSString* const kBrowserActionGrippyDragFinishedNotification =
19 @"BrowserActionGrippyDragFinishedNotification"; 19 @"BrowserActionGrippyDragFinishedNotification";
20 NSString* const kBrowserActionsContainerWillAnimate = 20 NSString* const kBrowserActionsContainerWillAnimate =
21 @"BrowserActionsContainerWillAnimate"; 21 @"BrowserActionsContainerWillAnimate";
22 NSString* const kBrowserActionsContainerMouseEntered = 22 NSString* const kBrowserActionsContainerMouseEntered =
23 @"BrowserActionsContainerMouseEntered"; 23 @"BrowserActionsContainerMouseEntered";
24 NSString* const kBrowserActionsContainerAnimationEnded =
25 @"BrowserActionsContainerAnimationEnded";
24 NSString* const kTranslationWithDelta = 26 NSString* const kTranslationWithDelta =
25 @"TranslationWithDelta"; 27 @"TranslationWithDelta";
26 28
27 namespace { 29 namespace {
28 const CGFloat kAnimationDuration = 0.2; 30 const CGFloat kAnimationDuration = 0.2;
29 const CGFloat kGrippyWidth = 3.0; 31 const CGFloat kGrippyWidth = 3.0;
30 const CGFloat kMinimumContainerWidth = 3.0; 32 const CGFloat kMinimumContainerWidth = 3.0;
31 } // namespace 33 } // namespace
32 34
35 @interface ContainerAnimationHelper : NSObject<NSAnimationDelegate> {
36 BrowserActionsContainerView* container_;
37 }
38
39 - (id)initWithContainer:(BrowserActionsContainerView*)container;
40
41 - (void)animationDidEnd:(NSAnimation*)animation;
42 - (void)animationDidStop:(NSAnimation*)animation;
43
44 - (void)notifyAnimationEnded;
45
46 @end
47
48 @implementation ContainerAnimationHelper
49
50 - (id)initWithContainer:(BrowserActionsContainerView*)container {
51 if ((self = [super init])) {
52 container_ = container;
53 }
54 return self;
55 }
56
57 - (void)animationDidEnd:(NSAnimation*)animation {
58 [self performSelector:@selector(notifyAnimationEnded)
59 withObject:self
60 afterDelay:0];
61 }
62
63 - (void)animationDidStop:(NSAnimation*)animation {
64 [self performSelector:@selector(notifyAnimationEnded)
65 withObject:self
66 afterDelay:0];
67 }
68
69 - (void)notifyAnimationEnded {
70 [[NSNotificationCenter defaultCenter]
71 postNotificationName:kBrowserActionsContainerAnimationEnded
72 object:container_];
73 }
74
75 @end
76
77
33 @interface BrowserActionsContainerView(Private) 78 @interface BrowserActionsContainerView(Private)
34 // Returns the cursor that should be shown when hovering over the grippy based 79 // Returns the cursor that should be shown when hovering over the grippy based
35 // on |canDragLeft_| and |canDragRight_|. 80 // on |canDragLeft_| and |canDragRight_|.
36 - (NSCursor*)appropriateCursorForGrippy; 81 - (NSCursor*)appropriateCursorForGrippy;
37 82
38 // Returns the maximum allowed size for the container. 83 // Returns the maximum allowed size for the container.
39 - (CGFloat)maxAllowedWidth; 84 - (CGFloat)maxAllowedWidth;
40 @end 85 @end
41 86
42 @implementation BrowserActionsContainerView 87 @implementation BrowserActionsContainerView
43 88
44 @synthesize canDragLeft = canDragLeft_; 89 @synthesize canDragLeft = canDragLeft_;
45 @synthesize canDragRight = canDragRight_; 90 @synthesize canDragRight = canDragRight_;
46 @synthesize grippyPinned = grippyPinned_; 91 @synthesize grippyPinned = grippyPinned_;
47 @synthesize maxDesiredWidth = maxDesiredWidth_; 92 @synthesize maxDesiredWidth = maxDesiredWidth_;
48 @synthesize userIsResizing = userIsResizing_; 93 @synthesize userIsResizing = userIsResizing_;
49 @synthesize delegate = delegate_; 94 @synthesize delegate = delegate_;
50 95
51 #pragma mark - 96 #pragma mark -
52 #pragma mark Overridden Class Functions 97 #pragma mark Overridden Class Functions
53 98
54 - (id)initWithFrame:(NSRect)frameRect { 99 - (id)initWithFrame:(NSRect)frameRect {
55 if ((self = [super initWithFrame:frameRect])) { 100 if ((self = [super initWithFrame:frameRect])) {
56 grippyRect_ = NSMakeRect(0.0, 0.0, kGrippyWidth, NSHeight([self bounds])); 101 grippyRect_ = NSMakeRect(0.0, 0.0, kGrippyWidth, NSHeight([self bounds]));
57 canDragLeft_ = YES; 102 canDragLeft_ = YES;
58 canDragRight_ = YES; 103 canDragRight_ = YES;
59 resizable_ = YES; 104 resizable_ = YES;
60 105
106 animationHelper_.reset(
107 [[ContainerAnimationHelper alloc] initWithContainer:self]);
61 resizeAnimation_.reset([[NSViewAnimation alloc] init]); 108 resizeAnimation_.reset([[NSViewAnimation alloc] init]);
62 [resizeAnimation_ setDuration:kAnimationDuration]; 109 [resizeAnimation_ setDuration:kAnimationDuration];
63 [resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; 110 [resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
111 [resizeAnimation_ setDelegate:animationHelper_.get()];
64 112
65 [self setHidden:YES]; 113 [self setHidden:YES];
66 } 114 }
67 return self; 115 return self;
68 } 116 }
69 117
70 - (void)dealloc { 118 - (void)dealloc {
71 if (trackingArea_.get()) 119 if (trackingArea_.get())
72 [self removeTrackingArea:trackingArea_.get()]; 120 [self removeTrackingArea:trackingArea_.get()];
73 [super dealloc]; 121 [super dealloc];
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 retVal = [NSCursor resizeLeftRightCursor]; 323 retVal = [NSCursor resizeLeftRightCursor];
276 } 324 }
277 return retVal; 325 return retVal;
278 } 326 }
279 327
280 - (CGFloat)maxAllowedWidth { 328 - (CGFloat)maxAllowedWidth {
281 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; 329 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX;
282 } 330 }
283 331
284 @end 332 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698