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

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

Issue 1680613002: Adding momentum/overscroll to views:: ScrollViews Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Tableview layout. aaaand I think we are done 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/views/cocoa/bridged_content_view.mm ('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 {
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;
98 class Viewport; 107 class Viewport;
99 108
100 // Used internally by SetHeader() and SetContents() to reset the view. Sets 109 // 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|. 110 // |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); 111 void SetHeaderOrContents(View* parent, View* new_view, View** member);
103 112
104 // Scrolls the minimum amount necessary to make the specified rectangle 113 // Scrolls the minimum amount necessary to make the specified rectangle
105 // visible, in the coordinates of the contents view. The specified rectangle 114 // 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 115 // is constrained by the bounds of the contents view. This has no effect if
107 // the contents have not been set. 116 // the contents have not been set.
108 void ScrollContentsRegionToBeVisible(const gfx::Rect& rect); 117 void ScrollContentsRegionToBeVisible(const gfx::Rect& rect);
109 118
110 // Computes the visibility of both scrollbars, taking in account the view port 119 // Computes the visibility of both scrollbars, taking in account the view port
111 // and content sizes. 120 // and content sizes.
112 void ComputeScrollBarsVisibility(const gfx::Size& viewport_size, 121 void ComputeScrollBarsVisibility(const gfx::Size& viewport_size,
113 const gfx::Size& content_size, 122 const gfx::Size& content_size,
114 bool* horiz_is_shown, 123 bool* horiz_is_shown,
115 bool* vert_is_shown) const; 124 bool* vert_is_shown) const;
116 125
117 // Shows or hides the scrollbar/corner_view based on the value of 126 // Shows or hides the scrollbar/corner_view based on the value of
118 // |should_show|. 127 // |should_show|.
119 void SetControlVisibility(View* control, bool should_show); 128 void SetControlVisibility(View* control, bool should_show);
120 129
121 // Update the scrollbars positions given viewport and content sizes. 130 // Update the scrollbars positions given viewport and content sizes.
122 void UpdateScrollBarPositions(); 131 void UpdateScrollBarPositions();
123 132
124 // The current contents and its viewport. |contents_| is contained in 133 // Gets and sets the current scroll offset.
125 // |contents_viewport_|. 134 gfx::ScrollOffset CurrentOffset() const;
135 void ScrollToOffset(const gfx::ScrollOffset& offset);
136
137 // Callback entrypoint when hosted layers are scrolled by the compositor.
138 void OnLayerScrolled();
139
140 // The current contents and its viewport. |contents_| is contained in the
141 // layer-backed |contents_container_| which guarantees it is at least as high
142 // and wide as the |contents_viewport_|, which does the clipping.
126 View* contents_; 143 View* contents_;
144 View* contents_container_;
127 View* contents_viewport_; 145 View* contents_viewport_;
128 146
129 // The current header and its viewport. |header_| is contained in 147 // The current header and its viewport. |header_| is contained in
130 // |header_viewport_|. 148 // |header_viewport_|.
131 View* header_; 149 View* header_;
132 View* header_viewport_; 150 View* header_viewport_;
133 151
134 // Horizontal scrollbar. 152 // Horizontal scrollbar.
135 ScrollBar* horiz_sb_; 153 ScrollBar* horiz_sb_;
136 154
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 private: 236 private:
219 int top_margin_; 237 int top_margin_;
220 int row_height_; 238 int row_height_;
221 239
222 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); 240 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper);
223 }; 241 };
224 242
225 } // namespace views 243 } // namespace views
226 244
227 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 245 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698