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

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

Issue 2188133002: Scroll with Layers in views::ScrollView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-ScrollTrack
Patch Set: bugref, scale_delta DCHECK + comment 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
« no previous file with comments | « ui/events/blink/input_handler_proxy_unittest.cc ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
16 namespace test { 20 namespace test {
17 class ScrollViewTestApi; 21 class ScrollViewTestApi;
18 } 22 }
19 23
20 ///////////////////////////////////////////////////////////////////////////// 24 /////////////////////////////////////////////////////////////////////////////
21 // 25 //
22 // ScrollView class 26 // ScrollView class
23 // 27 //
24 // 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
(...skipping 19 matching lines...) Expand all
44 48
45 // Set the contents. Any previous contents will be deleted. The contents 49 // Set the contents. Any previous contents will be deleted. The contents
46 // is the view that needs to scroll. 50 // is the view that needs to scroll.
47 void SetContents(View* a_view); 51 void SetContents(View* a_view);
48 const View* contents() const { return contents_; } 52 const View* contents() const { return contents_; }
49 View* contents() { return contents_; } 53 View* contents() { return contents_; }
50 54
51 // Sets the header, deleting the previous header. 55 // Sets the header, deleting the previous header.
52 void SetHeader(View* header); 56 void SetHeader(View* header);
53 57
58 // Sets the background color. The default is white when scrolling with layers,
59 // otherwise transparent. An opaque color when scrolling with layers ensures
60 // fonts can be drawn with subpixel antialiasing.
61 void SetBackgroundColor(SkColor color);
62
54 // Returns the visible region of the content View. 63 // Returns the visible region of the content View.
55 gfx::Rect GetVisibleRect() const; 64 gfx::Rect GetVisibleRect() const;
56 65
57 void set_hide_horizontal_scrollbar(bool visible) { 66 void set_hide_horizontal_scrollbar(bool visible) {
58 hide_horizontal_scrollbar_ = visible; 67 hide_horizontal_scrollbar_ = visible;
59 } 68 }
60 69
61 // Turns this scroll view into a bounded scroll view, with a fixed height. 70 // Turns this scroll view into a bounded scroll view, with a fixed height.
62 // By default, a ScrollView will stretch to fill its outer container. 71 // By default, a ScrollView will stretch to fill its outer container.
63 void ClipHeightTo(int min_height, int max_height); 72 void ClipHeightTo(int min_height, int max_height);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 bool* horiz_is_shown, 127 bool* horiz_is_shown,
119 bool* vert_is_shown) const; 128 bool* vert_is_shown) const;
120 129
121 // Shows or hides the scrollbar/corner_view based on the value of 130 // Shows or hides the scrollbar/corner_view based on the value of
122 // |should_show|. 131 // |should_show|.
123 void SetControlVisibility(View* control, bool should_show); 132 void SetControlVisibility(View* control, bool should_show);
124 133
125 // Update the scrollbars positions given viewport and content sizes. 134 // Update the scrollbars positions given viewport and content sizes.
126 void UpdateScrollBarPositions(); 135 void UpdateScrollBarPositions();
127 136
137 // Helpers to get and set the current scroll offset (either from the ui::Layer
138 // or from the |contents_| origin offset).
139 gfx::ScrollOffset CurrentOffset() const;
140 void ScrollToOffset(const gfx::ScrollOffset& offset);
141
142 // Whether the ScrollView scrolls using ui::Layer APIs.
143 bool ScrollsWithLayers() const;
144
145 // Callback entrypoint when hosted Layers are scrolled by the Compositor.
146 void OnLayerScrolled();
147
148 // Horizontally scrolls the header (if any) to match the contents.
149 void ScrollHeader();
150
128 // The current contents and its viewport. |contents_| is contained in 151 // The current contents and its viewport. |contents_| is contained in
129 // |contents_viewport_|. 152 // |contents_viewport_|.
130 View* contents_; 153 View* contents_;
131 View* contents_viewport_; 154 View* contents_viewport_;
132 155
133 // The current header and its viewport. |header_| is contained in 156 // The current header and its viewport. |header_| is contained in
134 // |header_viewport_|. 157 // |header_viewport_|.
135 View* header_; 158 View* header_;
136 View* header_viewport_; 159 View* header_viewport_;
137 160
138 // Horizontal scrollbar. 161 // Horizontal scrollbar.
139 ScrollBar* horiz_sb_; 162 ScrollBar* horiz_sb_;
140 163
141 // Vertical scrollbar. 164 // Vertical scrollbar.
142 ScrollBar* vert_sb_; 165 ScrollBar* vert_sb_;
143 166
144 // Corner view. 167 // Corner view.
145 View* corner_view_; 168 View* corner_view_;
146 169
147 // The min and max height for the bounded scroll view. These are negative 170 // The min and max height for the bounded scroll view. These are negative
148 // values if the view is not bounded. 171 // values if the view is not bounded.
149 int min_height_; 172 int min_height_;
150 int max_height_; 173 int max_height_;
151 174
175 // The background color given to the viewport (for overscroll), and to the
176 // contents when scrolling with layers.
177 SkColor background_color_;
178
152 // If true, never show the horizontal scrollbar (even if the contents is wider 179 // If true, never show the horizontal scrollbar (even if the contents is wider
153 // than the viewport). 180 // than the viewport).
154 bool hide_horizontal_scrollbar_; 181 bool hide_horizontal_scrollbar_;
155 182
156 DISALLOW_COPY_AND_ASSIGN(ScrollView); 183 DISALLOW_COPY_AND_ASSIGN(ScrollView);
157 }; 184 };
158 185
159 // VariableRowHeightScrollHelper is intended for views that contain rows of 186 // VariableRowHeightScrollHelper is intended for views that contain rows of
160 // varying height. To use a VariableRowHeightScrollHelper create one supplying 187 // varying height. To use a VariableRowHeightScrollHelper create one supplying
161 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement 188 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 private: 249 private:
223 int top_margin_; 250 int top_margin_;
224 int row_height_; 251 int row_height_;
225 252
226 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); 253 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper);
227 }; 254 };
228 255
229 } // namespace views 256 } // namespace views
230 257
231 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 258 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
OLDNEW
« no previous file with comments | « ui/events/blink/input_handler_proxy_unittest.cc ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698