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

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

Issue 2512583002: Remove *RowHeightScrollHelper from scroll_view.h/cc (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | 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"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // If true, never show the horizontal scrollbar (even if the contents is wider 185 // If true, never show the horizontal scrollbar (even if the contents is wider
186 // than the viewport). 186 // than the viewport).
187 bool hide_horizontal_scrollbar_; 187 bool hide_horizontal_scrollbar_;
188 188
189 // Focus ring, if one is installed. 189 // Focus ring, if one is installed.
190 View* focus_ring_ = nullptr; 190 View* focus_ring_ = nullptr;
191 191
192 DISALLOW_COPY_AND_ASSIGN(ScrollView); 192 DISALLOW_COPY_AND_ASSIGN(ScrollView);
193 }; 193 };
194 194
195 // VariableRowHeightScrollHelper is intended for views that contain rows of
196 // varying height. To use a VariableRowHeightScrollHelper create one supplying
197 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement
198 // to the helper. VariableRowHeightScrollHelper calls back to the
199 // Controller to determine row boundaries.
200 class VariableRowHeightScrollHelper {
201 public:
202 // The origin and height of a row.
203 struct RowInfo {
204 RowInfo(int origin, int height) : origin(origin), height(height) {}
205
206 // Origin of the row.
207 int origin;
208
209 // Height of the row.
210 int height;
211 };
212
213 // Used to determine row boundaries.
214 class Controller {
215 public:
216 // Returns the origin and size of the row at the specified location.
217 virtual VariableRowHeightScrollHelper::RowInfo GetRowInfo(int y) = 0;
218 };
219
220 // Creates a new VariableRowHeightScrollHelper. Controller is
221 // NOT deleted by this VariableRowHeightScrollHelper.
222 explicit VariableRowHeightScrollHelper(Controller* controller);
223 virtual ~VariableRowHeightScrollHelper();
224
225 // Delegate the View methods of the same name to these. The scroll amount is
226 // determined by querying the Controller for the appropriate row to scroll
227 // to.
228 int GetPageScrollIncrement(ScrollView* scroll_view,
229 bool is_horizontal, bool is_positive);
230 int GetLineScrollIncrement(ScrollView* scroll_view,
231 bool is_horizontal, bool is_positive);
232
233 protected:
234 // Returns the row information for the row at the specified location. This
235 // calls through to the method of the same name on the controller.
236 virtual RowInfo GetRowInfo(int y);
237
238 private:
239 Controller* controller_;
240
241 DISALLOW_COPY_AND_ASSIGN(VariableRowHeightScrollHelper);
242 };
243
244 // FixedRowHeightScrollHelper is intended for views that contain fixed height
245 // height rows. To use a FixedRowHeightScrollHelper delegate
246 // GetPageScrollIncrement and GetLineScrollIncrement to it.
247 class FixedRowHeightScrollHelper : public VariableRowHeightScrollHelper {
248 public:
249 // Creates a FixedRowHeightScrollHelper. top_margin gives the distance from
250 // the top of the view to the first row, and may be 0. row_height gives the
251 // height of each row.
252 FixedRowHeightScrollHelper(int top_margin, int row_height);
253
254 protected:
255 // Calculates the bounds of the row from the top margin and row height.
256 RowInfo GetRowInfo(int y) override;
257
258 private:
259 int top_margin_;
260 int row_height_;
261
262 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper);
263 };
264
265 } // namespace views 195 } // namespace views
266 196
267 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 197 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698