OLD | NEW |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 85 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
86 virtual const char* GetClassName() const OVERRIDE; | 86 virtual const char* GetClassName() const OVERRIDE; |
87 | 87 |
88 // ScrollBarController overrides: | 88 // ScrollBarController overrides: |
89 virtual void ScrollToPosition(ScrollBar* source, int position) OVERRIDE; | 89 virtual void ScrollToPosition(ScrollBar* source, int position) OVERRIDE; |
90 virtual int GetScrollIncrement(ScrollBar* source, | 90 virtual int GetScrollIncrement(ScrollBar* source, |
91 bool is_page, | 91 bool is_page, |
92 bool is_positive) OVERRIDE; | 92 bool is_positive) OVERRIDE; |
93 | 93 |
94 private: | 94 private: |
| 95 FRIEND_TEST_ALL_PREFIXES(ScrollViewTest, CornerViewVisibility); |
95 class Viewport; | 96 class Viewport; |
96 | 97 |
97 // Used internally by SetHeader() and SetContents() to reset the view. Sets | 98 // Used internally by SetHeader() and SetContents() to reset the view. Sets |
98 // |member| to |new_view|. If |new_view| is non-null it is added to |parent|. | 99 // |member| to |new_view|. If |new_view| is non-null it is added to |parent|. |
99 void SetHeaderOrContents(View* parent, View* new_view, View** member); | 100 void SetHeaderOrContents(View* parent, View* new_view, View** member); |
100 | 101 |
101 // Scrolls the minimum amount necessary to make the specified rectangle | 102 // Scrolls the minimum amount necessary to make the specified rectangle |
102 // visible, in the coordinates of the contents view. The specified rectangle | 103 // visible, in the coordinates of the contents view. The specified rectangle |
103 // is constrained by the bounds of the contents view. This has no effect if | 104 // is constrained by the bounds of the contents view. This has no effect if |
104 // the contents have not been set. | 105 // the contents have not been set. |
105 void ScrollContentsRegionToBeVisible(const gfx::Rect& rect); | 106 void ScrollContentsRegionToBeVisible(const gfx::Rect& rect); |
106 | 107 |
107 // Computes the visibility of both scrollbars, taking in account the view port | 108 // Computes the visibility of both scrollbars, taking in account the view port |
108 // and content sizes. | 109 // and content sizes. |
109 void ComputeScrollBarsVisibility(const gfx::Size& viewport_size, | 110 void ComputeScrollBarsVisibility(const gfx::Size& viewport_size, |
110 const gfx::Size& content_size, | 111 const gfx::Size& content_size, |
111 bool* horiz_is_shown, | 112 bool* horiz_is_shown, |
112 bool* vert_is_shown) const; | 113 bool* vert_is_shown) const; |
113 | 114 |
114 // Shows or hides the scrollbar/resize_corner based on the value of | 115 // Shows or hides the scrollbar/corner_view based on the value of |
115 // |should_show|. | 116 // |should_show|. |
116 void SetControlVisibility(View* control, bool should_show); | 117 void SetControlVisibility(View* control, bool should_show); |
117 | 118 |
118 // Update the scrollbars positions given viewport and content sizes. | 119 // Update the scrollbars positions given viewport and content sizes. |
119 void UpdateScrollBarPositions(); | 120 void UpdateScrollBarPositions(); |
120 | 121 |
121 // The current contents and its viewport. |contents_| is contained in | 122 // The current contents and its viewport. |contents_| is contained in |
122 // |contents_viewport_|. | 123 // |contents_viewport_|. |
123 View* contents_; | 124 View* contents_; |
124 View* contents_viewport_; | 125 View* contents_viewport_; |
125 | 126 |
126 // The current header and its viewport. |header_| is contained in | 127 // The current header and its viewport. |header_| is contained in |
127 // |header_viewport_|. | 128 // |header_viewport_|. |
128 View* header_; | 129 View* header_; |
129 View* header_viewport_; | 130 View* header_viewport_; |
130 | 131 |
131 // Horizontal scrollbar. | 132 // Horizontal scrollbar. |
132 ScrollBar* horiz_sb_; | 133 ScrollBar* horiz_sb_; |
133 | 134 |
134 // Vertical scrollbar. | 135 // Vertical scrollbar. |
135 ScrollBar* vert_sb_; | 136 ScrollBar* vert_sb_; |
136 | 137 |
137 // Resize corner. | 138 // Corner view. |
138 View* resize_corner_; | 139 View* corner_view_; |
139 | 140 |
140 // The min and max height for the bounded scroll view. These are negative | 141 // The min and max height for the bounded scroll view. These are negative |
141 // values if the view is not bounded. | 142 // values if the view is not bounded. |
142 int min_height_; | 143 int min_height_; |
143 int max_height_; | 144 int max_height_; |
144 | 145 |
145 // If true, never show the horizontal scrollbar (even if the contents is wider | 146 // If true, never show the horizontal scrollbar (even if the contents is wider |
146 // than the viewport). | 147 // than the viewport). |
147 bool hide_horizontal_scrollbar_; | 148 bool hide_horizontal_scrollbar_; |
148 | 149 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 private: | 216 private: |
216 int top_margin_; | 217 int top_margin_; |
217 int row_height_; | 218 int row_height_; |
218 | 219 |
219 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); | 220 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); |
220 }; | 221 }; |
221 | 222 |
222 } // namespace views | 223 } // namespace views |
223 | 224 |
224 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ | 225 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ |
OLD | NEW |