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

Side by Side Diff: ui/views/controls/scrollbar/cocoa_scroll_bar.h

Issue 2454323002: MacViews: Reveal scrollbars when resting on the trackpad. (Closed)
Patch Set: fix compile Created 4 years, 1 month 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 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;
33 void ObserveScrollEvent(const ui::ScrollEvent& event) override;
31 34
32 // ViewsScrollbarBridgeDelegate: 35 // ViewsScrollbarBridgeDelegate:
33 void OnScrollerStyleChanged() override; 36 void OnScrollerStyleChanged() override;
34 37
35 // View: 38 // View:
36 bool OnMousePressed(const ui::MouseEvent& event) override; 39 bool OnMousePressed(const ui::MouseEvent& event) override;
37 void OnMouseReleased(const ui::MouseEvent& event) override; 40 void OnMouseReleased(const ui::MouseEvent& event) override;
38 void OnMouseEntered(const ui::MouseEvent& event) override; 41 void OnMouseEntered(const ui::MouseEvent& event) override;
39 void OnMouseExited(const ui::MouseEvent& event) override; 42 void OnMouseExited(const ui::MouseEvent& event) override;
40 43
(...skipping 17 matching lines...) Expand all
58 // ScrollBar: 61 // ScrollBar:
59 int GetLayoutSize() const override; 62 int GetLayoutSize() const override;
60 int GetContentOverlapSize() const override; 63 int GetContentOverlapSize() const override;
61 64
62 // View: 65 // View:
63 void Layout() override; 66 void Layout() override;
64 gfx::Size GetPreferredSize() const override; 67 gfx::Size GetPreferredSize() const override;
65 void OnPaint(gfx::Canvas* canvas) override; 68 void OnPaint(gfx::Canvas* canvas) override;
66 69
67 private: 70 private:
71 friend class BaseScrollBar; // For BaseScrollBar::GetHideTimerForTest().
72
68 // Methods to change the visibility of the scrollbar. 73 // Methods to change the visibility of the scrollbar.
69 void ShowScrollbar(); 74 void ShowScrollbar();
70 void HideScrollbar(); 75 void HideScrollbar();
71 76
72 // Returns true if the scrollbar is in a hover or pressed state. 77 // Returns true if the scrollbar is in a hover or pressed state.
73 bool IsHoverOrPressedState() const; 78 bool IsHoverOrPressedState() const;
74 79
75 // Updates the thickness of the scrollbar according to the current state of 80 // Updates the thickness of the scrollbar according to the current state of
76 // the expand animation. 81 // the expand animation.
77 void UpdateScrollbarThickness(); 82 void UpdateScrollbarThickness();
(...skipping 15 matching lines...) Expand all
93 NSScrollerStyle scroller_style_; 98 NSScrollerStyle scroller_style_;
94 99
95 // Timer that will start the scrollbar's hiding animation when it reaches 0. 100 // Timer that will start the scrollbar's hiding animation when it reaches 0.
96 base::Timer hide_scrollbar_timer_; 101 base::Timer hide_scrollbar_timer_;
97 102
98 // Slide animation that animates the thickness of an overlay scrollbar. 103 // Slide animation that animates the thickness of an overlay scrollbar.
99 // The animation expands the scrollbar as the showing animation and shrinks 104 // The animation expands the scrollbar as the showing animation and shrinks
100 // the scrollbar as the hiding animation. 105 // the scrollbar as the hiding animation.
101 gfx::SlideAnimation thickness_animation_; 106 gfx::SlideAnimation thickness_animation_;
102 107
108 // The scroll offset from the last adjustment to the scroll bar.
spqchan 2016/11/14 23:27:58 "scroll bar" -> "scrollbar
tapted 2016/11/15 12:22:23 Done.
109 int last_contents_scroll_offset_;
110
103 // True when the scrollbar is expanded. 111 // True when the scrollbar is expanded.
104 bool is_expanded_; 112 bool is_expanded_;
105 113
106 // True when the scrolltrack should be drawn. 114 // True when the scrolltrack should be drawn.
107 bool has_scrolltrack_; 115 bool has_scrolltrack_;
108 116
109 // True when the scrollbar has started dragging since it was last shown. 117 // 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. 118 // This is set to false when we begin to hide the scrollbar.
111 bool did_start_dragging_; 119 bool did_start_dragging_;
112 120
113 // The bridge for NSScroller. 121 // The bridge for NSScroller.
114 base::scoped_nsobject<ViewsScrollbarBridge> bridge_; 122 base::scoped_nsobject<ViewsScrollbarBridge> bridge_;
115 123
116 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar); 124 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar);
117 }; 125 };
118 126
119 } // namespace views 127 } // namespace views
120 128
121 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ 129 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698