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 #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" |
| 12 #include "ui/base/cocoa/appkit_utils.h" |
11 | 13 |
12 NSString* const kBrowserActionGrippyDragStartedNotification = | 14 NSString* const kBrowserActionGrippyDragStartedNotification = |
13 @"BrowserActionGrippyDragStartedNotification"; | 15 @"BrowserActionGrippyDragStartedNotification"; |
14 NSString* const kBrowserActionGrippyDraggingNotification = | 16 NSString* const kBrowserActionGrippyDraggingNotification = |
15 @"BrowserActionGrippyDraggingNotification"; | 17 @"BrowserActionGrippyDraggingNotification"; |
16 NSString* const kBrowserActionGrippyDragFinishedNotification = | 18 NSString* const kBrowserActionGrippyDragFinishedNotification = |
17 @"BrowserActionGrippyDragFinishedNotification"; | 19 @"BrowserActionGrippyDragFinishedNotification"; |
18 NSString* const kBrowserActionsContainerWillAnimate = | 20 NSString* const kBrowserActionsContainerWillAnimate = |
19 @"BrowserActionsContainerWillAnimate"; | 21 @"BrowserActionsContainerWillAnimate"; |
20 NSString* const kBrowserActionsContainerMouseEntered = | 22 NSString* const kBrowserActionsContainerMouseEntered = |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 66 } |
65 return self; | 67 return self; |
66 } | 68 } |
67 | 69 |
68 - (void)dealloc { | 70 - (void)dealloc { |
69 if (trackingArea_.get()) | 71 if (trackingArea_.get()) |
70 [self removeTrackingArea:trackingArea_.get()]; | 72 [self removeTrackingArea:trackingArea_.get()]; |
71 [super dealloc]; | 73 [super dealloc]; |
72 } | 74 } |
73 | 75 |
| 76 - (void)drawRect:(NSRect)rect { |
| 77 [super drawRect:rect]; |
| 78 if (isHighlighting_) { |
| 79 ui::NinePartImageIds imageIds = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); |
| 80 ui::DrawNinePartImage( |
| 81 [self bounds], imageIds, NSCompositeSourceOver, 1.0, true); |
| 82 } |
| 83 } |
| 84 |
74 - (void)setTrackingEnabled:(BOOL)enabled { | 85 - (void)setTrackingEnabled:(BOOL)enabled { |
75 if (enabled) { | 86 if (enabled) { |
76 trackingArea_.reset( | 87 trackingArea_.reset( |
77 [[CrTrackingArea alloc] initWithRect:NSZeroRect | 88 [[CrTrackingArea alloc] initWithRect:NSZeroRect |
78 options:NSTrackingMouseEnteredAndExited | | 89 options:NSTrackingMouseEnteredAndExited | |
79 NSTrackingActiveInActiveApp | | 90 NSTrackingActiveInActiveApp | |
80 NSTrackingInVisibleRect | 91 NSTrackingInVisibleRect |
81 owner:self | 92 owner:self |
82 userInfo:nil]); | 93 userInfo:nil]); |
83 [self addTrackingArea:trackingArea_.get()]; | 94 [self addTrackingArea:trackingArea_.get()]; |
84 } else if (trackingArea_.get()) { | 95 } else if (trackingArea_.get()) { |
85 [self removeTrackingArea:trackingArea_.get()]; | 96 [self removeTrackingArea:trackingArea_.get()]; |
86 [trackingArea_.get() clearOwner]; | 97 [trackingArea_.get() clearOwner]; |
87 trackingArea_.reset(nil); | 98 trackingArea_.reset(nil); |
88 } | 99 } |
89 } | 100 } |
90 | 101 |
| 102 - (void)setIsHighlighting:(BOOL)isHighlighting { |
| 103 if (isHighlighting != isHighlighting_) { |
| 104 isHighlighting_ = isHighlighting; |
| 105 [self setNeedsDisplay:YES]; |
| 106 } |
| 107 } |
| 108 |
91 - (void)setResizable:(BOOL)resizable { | 109 - (void)setResizable:(BOOL)resizable { |
92 if (resizable == resizable_) | 110 if (resizable == resizable_) |
93 return; | 111 return; |
94 resizable_ = resizable; | 112 resizable_ = resizable; |
95 [self setNeedsDisplay:YES]; | 113 [self setNeedsDisplay:YES]; |
96 } | 114 } |
97 | 115 |
98 - (BOOL)isResizable { | 116 - (BOOL)isResizable { |
99 return resizable_; | 117 return resizable_; |
100 } | 118 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 retVal = [NSCursor resizeLeftRightCursor]; | 275 retVal = [NSCursor resizeLeftRightCursor]; |
258 } | 276 } |
259 return retVal; | 277 return retVal; |
260 } | 278 } |
261 | 279 |
262 - (CGFloat)maxAllowedWidth { | 280 - (CGFloat)maxAllowedWidth { |
263 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; | 281 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; |
264 } | 282 } |
265 | 283 |
266 @end | 284 @end |
OLD | NEW |