| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #import "chrome/browser/ui/cocoa/view_id_util.h" | 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 owner:self | 115 owner:self |
| 116 userInfo:nil]); | 116 userInfo:nil]); |
| 117 [self addTrackingArea:trackingArea_.get()]; | 117 [self addTrackingArea:trackingArea_.get()]; |
| 118 } else if (trackingArea_.get()) { | 118 } else if (trackingArea_.get()) { |
| 119 [self removeTrackingArea:trackingArea_.get()]; | 119 [self removeTrackingArea:trackingArea_.get()]; |
| 120 [trackingArea_.get() clearOwner]; | 120 [trackingArea_.get() clearOwner]; |
| 121 trackingArea_.reset(nil); | 121 trackingArea_.reset(nil); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 - (BOOL)trackingEnabled { |
| 126 return trackingArea_.get() != nullptr; |
| 127 } |
| 128 |
| 125 - (void)keyDown:(NSEvent*)theEvent { | 129 - (void)keyDown:(NSEvent*)theEvent { |
| 126 // If this is the overflow container, we handle three key events: left, right, | 130 // If this is the overflow container, we handle three key events: left, right, |
| 127 // and space. Left and right navigate the actions within the container, and | 131 // and space. Left and right navigate the actions within the container, and |
| 128 // space activates the current one. We have to handle this ourselves, because | 132 // space activates the current one. We have to handle this ourselves, because |
| 129 // Cocoa doesn't treat custom views with subviews in menu items differently | 133 // Cocoa doesn't treat custom views with subviews in menu items differently |
| 130 // than any other menu item, so it would otherwise be impossible to navigate | 134 // than any other menu item, so it would otherwise be impossible to navigate |
| 131 // to a particular action from the keyboard. | 135 // to a particular action from the keyboard. |
| 132 ui::KeyboardCode key = ui::KeyboardCodeFromNSEvent(theEvent); | 136 ui::KeyboardCode key = ui::KeyboardCodeFromNSEvent(theEvent); |
| 133 BOOL shouldProcess = isOverflow_ && | 137 BOOL shouldProcess = isOverflow_ && |
| 134 (key == ui::VKEY_RIGHT || key == ui::VKEY_LEFT || key == ui::VKEY_SPACE); | 138 (key == ui::VKEY_RIGHT || key == ui::VKEY_LEFT || key == ui::VKEY_SPACE); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 172 |
| 169 - (void)setHighlight:(scoped_ptr<ui::NinePartImageIds>)highlight { | 173 - (void)setHighlight:(scoped_ptr<ui::NinePartImageIds>)highlight { |
| 170 if (highlight || highlight_) { | 174 if (highlight || highlight_) { |
| 171 highlight_ = std::move(highlight); | 175 highlight_ = std::move(highlight); |
| 172 // We don't allow resizing when the container is highlighting. | 176 // We don't allow resizing when the container is highlighting. |
| 173 resizable_ = highlight.get() == nullptr; | 177 resizable_ = highlight.get() == nullptr; |
| 174 [self setNeedsDisplay:YES]; | 178 [self setNeedsDisplay:YES]; |
| 175 } | 179 } |
| 176 } | 180 } |
| 177 | 181 |
| 182 - (BOOL)isHighlighting { |
| 183 return highlight_.get() != nullptr; |
| 184 } |
| 185 |
| 178 - (void)setIsOverflow:(BOOL)isOverflow { | 186 - (void)setIsOverflow:(BOOL)isOverflow { |
| 179 if (isOverflow_ != isOverflow) { | 187 if (isOverflow_ != isOverflow) { |
| 180 isOverflow_ = isOverflow; | 188 isOverflow_ = isOverflow; |
| 181 resizable_ = !isOverflow_; | 189 resizable_ = !isOverflow_; |
| 182 [self setNeedsDisplay:YES]; | 190 [self setNeedsDisplay:YES]; |
| 183 } | 191 } |
| 184 } | 192 } |
| 185 | 193 |
| 186 - (void)resetCursorRects { | 194 - (void)resetCursorRects { |
| 187 [self addCursorRect:grippyRect_ cursor:[self appropriateCursorForGrippy]]; | 195 [self addCursorRect:grippyRect_ cursor:[self appropriateCursorForGrippy]]; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 retVal = [NSCursor resizeLeftRightCursor]; | 371 retVal = [NSCursor resizeLeftRightCursor]; |
| 364 } | 372 } |
| 365 return retVal; | 373 return retVal; |
| 366 } | 374 } |
| 367 | 375 |
| 368 - (CGFloat)maxAllowedWidth { | 376 - (CGFloat)maxAllowedWidth { |
| 369 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; | 377 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; |
| 370 } | 378 } |
| 371 | 379 |
| 372 @end | 380 @end |
| OLD | NEW |