| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ | 5 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ |
| 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ | 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "ui/compositor/layer_animation_observer.h" | 10 #include "ui/compositor/layer_animation_observer.h" |
| 11 #include "ui/gfx/animation/slide_animation.h" | 11 #include "ui/gfx/animation/slide_animation.h" |
| 12 #import "ui/views/cocoa/views_scrollbar_bridge.h" | 12 #import "ui/views/cocoa/views_scrollbar_bridge.h" |
| 13 #include "ui/views/controls/scrollbar/base_scroll_bar.h" | 13 #include "ui/views/controls/scrollbar/base_scroll_bar.h" |
| 14 #include "ui/views/views_export.h" | 14 #include "ui/views/views_export.h" |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 | 17 |
| 18 class CocoaScrollBarThumb; | 18 class CocoaScrollBarThumb; |
| 19 | 19 |
| 20 // The transparent scrollbar for Mac which overlays its contents. | 20 // The transparent scrollbar for Mac which overlays its contents. |
| 21 class VIEWS_EXPORT CocoaScrollBar : public BaseScrollBar, | 21 class VIEWS_EXPORT CocoaScrollBar : public BaseScrollBar, |
| 22 public ViewsScrollbarBridgeDelegate, | 22 public ViewsScrollbarBridgeDelegate, |
| 23 public ui::ImplicitAnimationObserver, | 23 public ui::ImplicitAnimationObserver, |
| 24 public gfx::AnimationDelegate { | 24 public gfx::AnimationDelegate { |
| 25 public: | 25 public: |
| 26 explicit CocoaScrollBar(bool horizontal); | 26 explicit CocoaScrollBar(bool horizontal); |
| 27 ~CocoaScrollBar() override; | 27 ~CocoaScrollBar() override; |
| 28 | 28 |
| 29 // BaseScrollBar: | 29 // ScrollBar: |
| 30 void ScrollToPosition(int position) override; | 30 void Update(int viewport_size, |
| 31 int content_size, |
| 32 int contents_scroll_offset) override; |
| 31 | 33 |
| 32 // ViewsScrollbarBridgeDelegate: | 34 // ViewsScrollbarBridgeDelegate: |
| 33 void OnScrollerStyleChanged() override; | 35 void OnScrollerStyleChanged() override; |
| 34 | 36 |
| 35 // View: | 37 // View: |
| 36 bool OnMousePressed(const ui::MouseEvent& event) override; | 38 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 37 void OnMouseReleased(const ui::MouseEvent& event) override; | 39 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 38 void OnMouseEntered(const ui::MouseEvent& event) override; | 40 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 39 void OnMouseExited(const ui::MouseEvent& event) override; | 41 void OnMouseExited(const ui::MouseEvent& event) override; |
| 40 | 42 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 NSScrollerStyle scroller_style_; | 95 NSScrollerStyle scroller_style_; |
| 94 | 96 |
| 95 // Timer that will start the scrollbar's hiding animation when it reaches 0. | 97 // Timer that will start the scrollbar's hiding animation when it reaches 0. |
| 96 base::Timer hide_scrollbar_timer_; | 98 base::Timer hide_scrollbar_timer_; |
| 97 | 99 |
| 98 // Slide animation that animates the thickness of an overlay scrollbar. | 100 // Slide animation that animates the thickness of an overlay scrollbar. |
| 99 // The animation expands the scrollbar as the showing animation and shrinks | 101 // The animation expands the scrollbar as the showing animation and shrinks |
| 100 // the scrollbar as the hiding animation. | 102 // the scrollbar as the hiding animation. |
| 101 gfx::SlideAnimation thickness_animation_; | 103 gfx::SlideAnimation thickness_animation_; |
| 102 | 104 |
| 105 // The scroll offset from the last adjustment to the scroll bar. |
| 106 int last_contents_scroll_offset_; |
| 107 |
| 103 // True when the scrollbar is expanded. | 108 // True when the scrollbar is expanded. |
| 104 bool is_expanded_; | 109 bool is_expanded_; |
| 105 | 110 |
| 106 // True when the scrolltrack should be drawn. | 111 // True when the scrolltrack should be drawn. |
| 107 bool has_scrolltrack_; | 112 bool has_scrolltrack_; |
| 108 | 113 |
| 109 // True when the scrollbar has started dragging since it was last shown. | 114 // True when the scrollbar has started dragging since it was last shown. |
| 110 // This is set to false when we begin to hide the scrollbar. | 115 // This is set to false when we begin to hide the scrollbar. |
| 111 bool did_start_dragging_; | 116 bool did_start_dragging_; |
| 112 | 117 |
| 113 // The bridge for NSScroller. | 118 // The bridge for NSScroller. |
| 114 base::scoped_nsobject<ViewsScrollbarBridge> bridge_; | 119 base::scoped_nsobject<ViewsScrollbarBridge> bridge_; |
| 115 | 120 |
| 116 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar); | 121 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 } // namespace views | 124 } // namespace views |
| 120 | 125 |
| 121 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ | 126 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ |
| OLD | NEW |