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

Side by Side Diff: ui/views/controls/scroll_view.h

Issue 2189583004: [not for review - epic CL] Adding Elastic+Momentum+Layered scrolling to views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined rebase Created 4 years, 4 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SCROLL_VIEW_H_ 5 #ifndef UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
6 #define UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 6 #define UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "ui/views/controls/scrollbar/scroll_bar.h" 13 #include "ui/views/controls/scrollbar/scroll_bar.h"
14 14
15 namespace gfx {
16 class ScrollOffset;
17 }
18
15 namespace views { 19 namespace views {
20 namespace test {
21 class ScrollViewTestApi;
22 }
16 23
17 ///////////////////////////////////////////////////////////////////////////// 24 /////////////////////////////////////////////////////////////////////////////
18 // 25 //
19 // ScrollView class 26 // ScrollView class
20 // 27 //
21 // A ScrollView is used to make any View scrollable. The view is added to 28 // A ScrollView is used to make any View scrollable. The view is added to
22 // a viewport which takes care of clipping. 29 // a viewport which takes care of clipping.
23 // 30 //
24 // In this current implementation both horizontal and vertical scrollbars are 31 // In this current implementation both horizontal and vertical scrollbars are
25 // added as needed. 32 // added as needed.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void SetVerticalScrollBar(ScrollBar* vert_sb); 84 void SetVerticalScrollBar(ScrollBar* vert_sb);
78 85
79 // View overrides: 86 // View overrides:
80 gfx::Size GetPreferredSize() const override; 87 gfx::Size GetPreferredSize() const override;
81 int GetHeightForWidth(int width) const override; 88 int GetHeightForWidth(int width) const override;
82 void Layout() override; 89 void Layout() override;
83 bool OnKeyPressed(const ui::KeyEvent& event) override; 90 bool OnKeyPressed(const ui::KeyEvent& event) override;
84 bool OnMouseWheel(const ui::MouseWheelEvent& e) override; 91 bool OnMouseWheel(const ui::MouseWheelEvent& e) override;
85 void OnMouseEntered(const ui::MouseEvent& event) override; 92 void OnMouseEntered(const ui::MouseEvent& event) override;
86 void OnMouseExited(const ui::MouseEvent& event) override; 93 void OnMouseExited(const ui::MouseEvent& event) override;
94 void OnScrollEvent(ui::ScrollEvent* event) override;
87 void OnGestureEvent(ui::GestureEvent* event) override; 95 void OnGestureEvent(ui::GestureEvent* event) override;
88 const char* GetClassName() const override; 96 const char* GetClassName() const override;
97 ScrollView* EnclosingScrollView() override;
89 98
90 // ScrollBarController overrides: 99 // ScrollBarController overrides:
91 void ScrollToPosition(ScrollBar* source, int position) override; 100 void ScrollToPosition(ScrollBar* source, int position) override;
92 int GetScrollIncrement(ScrollBar* source, 101 int GetScrollIncrement(ScrollBar* source,
93 bool is_page, 102 bool is_page,
94 bool is_positive) override; 103 bool is_positive) override;
95 104
96 private: 105 private:
97 FRIEND_TEST_ALL_PREFIXES(ScrollViewTest, CornerViewVisibility); 106 friend class test::ScrollViewTestApi;
107
98 class Viewport; 108 class Viewport;
99 109
100 // Used internally by SetHeader() and SetContents() to reset the view. Sets 110 // Used internally by SetHeader() and SetContents() to reset the view. Sets
101 // |member| to |new_view|. If |new_view| is non-null it is added to |parent|. 111 // |member| to |new_view|. If |new_view| is non-null it is added to |parent|.
102 void SetHeaderOrContents(View* parent, View* new_view, View** member); 112 void SetHeaderOrContents(View* parent, View* new_view, View** member);
103 113
104 // Scrolls the minimum amount necessary to make the specified rectangle 114 // Scrolls the minimum amount necessary to make the specified rectangle
105 // visible, in the coordinates of the contents view. The specified rectangle 115 // visible, in the coordinates of the contents view. The specified rectangle
106 // is constrained by the bounds of the contents view. This has no effect if 116 // is constrained by the bounds of the contents view. This has no effect if
107 // the contents have not been set. 117 // the contents have not been set.
108 void ScrollContentsRegionToBeVisible(const gfx::Rect& rect); 118 void ScrollContentsRegionToBeVisible(const gfx::Rect& rect);
109 119
110 // Computes the visibility of both scrollbars, taking in account the view port 120 // Computes the visibility of both scrollbars, taking in account the view port
111 // and content sizes. 121 // and content sizes.
112 void ComputeScrollBarsVisibility(const gfx::Size& viewport_size, 122 void ComputeScrollBarsVisibility(const gfx::Size& viewport_size,
113 const gfx::Size& content_size, 123 const gfx::Size& content_size,
114 bool* horiz_is_shown, 124 bool* horiz_is_shown,
115 bool* vert_is_shown) const; 125 bool* vert_is_shown) const;
116 126
117 // Shows or hides the scrollbar/corner_view based on the value of 127 // Shows or hides the scrollbar/corner_view based on the value of
118 // |should_show|. 128 // |should_show|.
119 void SetControlVisibility(View* control, bool should_show); 129 void SetControlVisibility(View* control, bool should_show);
120 130
121 // Update the scrollbars positions given viewport and content sizes. 131 // Update the scrollbars positions given viewport and content sizes.
122 void UpdateScrollBarPositions(); 132 void UpdateScrollBarPositions();
123 133
124 // The current contents and its viewport. |contents_| is contained in 134 // Gets and sets the current scroll offset.
125 // |contents_viewport_|. 135 gfx::ScrollOffset CurrentOffset() const;
136 void ScrollToOffset(const gfx::ScrollOffset& offset);
137
138 // Callback entrypoint when hosted layers are scrolled by the compositor.
139 void OnLayerScrolled();
140
141 // Horizontally scroll the header (if any) to match the contents.
142 void ScrollHeader();
143
144 // The current contents and its viewport. |contents_| is contained in the
145 // layer-backed |contents_container_| which guarantees it is at least as high
146 // and wide as the |contents_viewport_|, which does the clipping.
126 View* contents_; 147 View* contents_;
148 View* contents_container_;
127 View* contents_viewport_; 149 View* contents_viewport_;
128 150
129 // The current header and its viewport. |header_| is contained in 151 // The current header and its viewport. |header_| is contained in
130 // |header_viewport_|. 152 // |header_viewport_|.
131 View* header_; 153 View* header_;
132 View* header_viewport_; 154 View* header_viewport_;
133 155
134 // Horizontal scrollbar. 156 // Horizontal scrollbar.
135 ScrollBar* horiz_sb_; 157 ScrollBar* horiz_sb_;
136 158
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 private: 240 private:
219 int top_margin_; 241 int top_margin_;
220 int row_height_; 242 int row_height_;
221 243
222 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); 244 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper);
223 }; 245 };
224 246
225 } // namespace views 247 } // namespace views
226 248
227 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 249 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698