OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/cocoa/scroll_view_with_no_scrollbars.h" | 5 #include "ui/app_list/cocoa/scroll_view_with_no_scrollbars.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 | 9 |
10 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 10 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
11 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 11 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
12 | 12 |
13 enum { | 13 enum { |
14 NSEventPhaseNone = 0, | 14 NSEventPhaseNone = 0, |
15 NSEventPhaseBegan = 0x1 << 0, | 15 NSEventPhaseBegan = 0x1 << 0, |
16 NSEventPhaseStationary = 0x1 << 1, | 16 NSEventPhaseStationary = 0x1 << 1, |
17 NSEventPhaseChanged = 0x1 << 2, | 17 NSEventPhaseChanged = 0x1 << 2, |
18 NSEventPhaseEnded = 0x1 << 3, | 18 NSEventPhaseEnded = 0x1 << 3, |
(...skipping 26 matching lines...) Expand all Loading... |
45 | 45 |
46 @implementation ScrollViewWithNoScrollbars | 46 @implementation ScrollViewWithNoScrollbars |
47 | 47 |
48 @synthesize delegate = delegate_; | 48 @synthesize delegate = delegate_; |
49 | 49 |
50 - (id)initWithFrame:(NSRect)frame { | 50 - (id)initWithFrame:(NSRect)frame { |
51 if ((self = [super initWithFrame:frame])) { | 51 if ((self = [super initWithFrame:frame])) { |
52 [self setHasHorizontalScroller:base::mac::IsOSLionOrLater()]; | 52 [self setHasHorizontalScroller:base::mac::IsOSLionOrLater()]; |
53 NSRect horizontalScrollerRect = [self bounds]; | 53 NSRect horizontalScrollerRect = [self bounds]; |
54 horizontalScrollerRect.size.height = 0; | 54 horizontalScrollerRect.size.height = 0; |
55 scoped_nsobject<InvisibleScroller> horizontalScroller( | 55 base::scoped_nsobject<InvisibleScroller> horizontalScroller( |
56 [[InvisibleScroller alloc] initWithFrame:horizontalScrollerRect]); | 56 [[InvisibleScroller alloc] initWithFrame:horizontalScrollerRect]); |
57 [self setHorizontalScroller:horizontalScroller]; | 57 [self setHorizontalScroller:horizontalScroller]; |
58 } | 58 } |
59 return self; | 59 return self; |
60 } | 60 } |
61 | 61 |
62 - (void)endGestureWithEvent:(NSEvent*)event { | 62 - (void)endGestureWithEvent:(NSEvent*)event { |
63 [super endGestureWithEvent:event]; | 63 [super endGestureWithEvent:event]; |
64 if (!base::mac::IsOSLionOrLater()) | 64 if (!base::mac::IsOSLionOrLater()) |
65 [delegate_ userScrolling:NO]; | 65 [delegate_ userScrolling:NO]; |
66 } | 66 } |
67 | 67 |
68 - (void)scrollWheel:(NSEvent*)event { | 68 - (void)scrollWheel:(NSEvent*)event { |
69 [super scrollWheel:event]; | 69 [super scrollWheel:event]; |
70 if (![event respondsToSelector:@selector(momentumPhase)]) | 70 if (![event respondsToSelector:@selector(momentumPhase)]) |
71 return; | 71 return; |
72 | 72 |
73 BOOL scrollComplete = [event momentumPhase] == NSEventPhaseEnded || | 73 BOOL scrollComplete = [event momentumPhase] == NSEventPhaseEnded || |
74 ([event momentumPhase] == NSEventPhaseNone && | 74 ([event momentumPhase] == NSEventPhaseNone && |
75 [event phase] == NSEventPhaseEnded); | 75 [event phase] == NSEventPhaseEnded); |
76 | 76 |
77 [delegate_ userScrolling:!scrollComplete]; | 77 [delegate_ userScrolling:!scrollComplete]; |
78 } | 78 } |
79 | 79 |
80 @end | 80 @end |
OLD | NEW |