| 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 28 matching lines...) Expand all Loading... |
| 39 public: | 39 public: |
| 40 static const char kViewClassName[]; | 40 static const char kViewClassName[]; |
| 41 | 41 |
| 42 ScrollView(); | 42 ScrollView(); |
| 43 | 43 |
| 44 ~ScrollView() override; | 44 ~ScrollView() override; |
| 45 | 45 |
| 46 // Creates a ScrollView with a theme specific border. | 46 // Creates a ScrollView with a theme specific border. |
| 47 static ScrollView* CreateScrollViewWithBorder(); | 47 static ScrollView* CreateScrollViewWithBorder(); |
| 48 | 48 |
| 49 // Returns the ScrollView for which |contents| is its contents, or null if | |
| 50 // |contents| is not in a ScrollView. | |
| 51 static ScrollView* GetScrollViewForContents(View* contents); | |
| 52 | |
| 53 // Set the contents. Any previous contents will be deleted. The contents | 49 // Set the contents. Any previous contents will be deleted. The contents |
| 54 // is the view that needs to scroll. | 50 // is the view that needs to scroll. |
| 55 void SetContents(View* a_view); | 51 void SetContents(View* a_view); |
| 56 const View* contents() const { return contents_; } | 52 const View* contents() const { return contents_; } |
| 57 View* contents() { return contents_; } | 53 View* contents() { return contents_; } |
| 58 | 54 |
| 59 // Sets the header, deleting the previous header. | 55 // Sets the header, deleting the previous header. |
| 60 void SetHeader(View* header); | 56 void SetHeader(View* header); |
| 61 | 57 |
| 62 // Sets the background color. The default is white when scrolling with layers, | 58 // Sets the background color. The default is white when scrolling with layers, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 85 | 81 |
| 86 // Returns the horizontal/vertical scrollbar. This may return NULL. | 82 // Returns the horizontal/vertical scrollbar. This may return NULL. |
| 87 const ScrollBar* horizontal_scroll_bar() const { return horiz_sb_; } | 83 const ScrollBar* horizontal_scroll_bar() const { return horiz_sb_; } |
| 88 const ScrollBar* vertical_scroll_bar() const { return vert_sb_; } | 84 const ScrollBar* vertical_scroll_bar() const { return vert_sb_; } |
| 89 | 85 |
| 90 // Customize the scrollbar design. ScrollView takes the ownership of the | 86 // Customize the scrollbar design. ScrollView takes the ownership of the |
| 91 // specified ScrollBar. |horiz_sb| and |vert_sb| cannot be NULL. | 87 // specified ScrollBar. |horiz_sb| and |vert_sb| cannot be NULL. |
| 92 void SetHorizontalScrollBar(ScrollBar* horiz_sb); | 88 void SetHorizontalScrollBar(ScrollBar* horiz_sb); |
| 93 void SetVerticalScrollBar(ScrollBar* vert_sb); | 89 void SetVerticalScrollBar(ScrollBar* vert_sb); |
| 94 | 90 |
| 95 // Sets whether this ScrollView has a focus indicator or not. | 91 // Sets whether this ScrollView has a focus ring or not. |
| 96 void SetHasFocusIndicator(bool has_focus_indicator); | 92 void SetHasFocusRing(bool has_focus_ring); |
| 97 | 93 |
| 98 // View overrides: | 94 // View overrides: |
| 99 gfx::Size GetPreferredSize() const override; | 95 gfx::Size GetPreferredSize() const override; |
| 100 int GetHeightForWidth(int width) const override; | 96 int GetHeightForWidth(int width) const override; |
| 101 void Layout() override; | 97 void Layout() override; |
| 102 bool OnKeyPressed(const ui::KeyEvent& event) override; | 98 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 103 bool OnMouseWheel(const ui::MouseWheelEvent& e) override; | 99 bool OnMouseWheel(const ui::MouseWheelEvent& e) override; |
| 104 void OnScrollEvent(ui::ScrollEvent* event) override; | 100 void OnScrollEvent(ui::ScrollEvent* event) override; |
| 105 void OnGestureEvent(ui::GestureEvent* event) override; | 101 void OnGestureEvent(ui::GestureEvent* event) override; |
| 106 const char* GetClassName() const override; | 102 const char* GetClassName() const override; |
| 107 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | |
| 108 | 103 |
| 109 // ScrollBarController overrides: | 104 // ScrollBarController overrides: |
| 110 void ScrollToPosition(ScrollBar* source, int position) override; | 105 void ScrollToPosition(ScrollBar* source, int position) override; |
| 111 int GetScrollIncrement(ScrollBar* source, | 106 int GetScrollIncrement(ScrollBar* source, |
| 112 bool is_page, | 107 bool is_page, |
| 113 bool is_positive) override; | 108 bool is_positive) override; |
| 114 | 109 |
| 115 // TODO(djacobo): Remove this method when http://crbug.com/656198 is closed. | 110 // TODO(djacobo): Remove this method when http://crbug.com/656198 is closed. |
| 116 // Force |contents_viewport_| to enable a Layer(). | 111 // Force |contents_viewport_| to enable a Layer(). |
| 117 void EnableViewPortLayer(); | 112 void EnableViewPortLayer(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 147 |
| 153 // Whether the ScrollView scrolls using ui::Layer APIs. | 148 // Whether the ScrollView scrolls using ui::Layer APIs. |
| 154 bool ScrollsWithLayers() const; | 149 bool ScrollsWithLayers() const; |
| 155 | 150 |
| 156 // Callback entrypoint when hosted Layers are scrolled by the Compositor. | 151 // Callback entrypoint when hosted Layers are scrolled by the Compositor. |
| 157 void OnLayerScrolled(const gfx::ScrollOffset& offset); | 152 void OnLayerScrolled(const gfx::ScrollOffset& offset); |
| 158 | 153 |
| 159 // Horizontally scrolls the header (if any) to match the contents. | 154 // Horizontally scrolls the header (if any) to match the contents. |
| 160 void ScrollHeader(); | 155 void ScrollHeader(); |
| 161 | 156 |
| 162 void AddBorder(); | |
| 163 void UpdateBorder(); | |
| 164 | |
| 165 // The current contents and its viewport. |contents_| is contained in | 157 // The current contents and its viewport. |contents_| is contained in |
| 166 // |contents_viewport_|. | 158 // |contents_viewport_|. |
| 167 View* contents_; | 159 View* contents_; |
| 168 View* contents_viewport_; | 160 View* contents_viewport_; |
| 169 | 161 |
| 170 // The current header and its viewport. |header_| is contained in | 162 // The current header and its viewport. |header_| is contained in |
| 171 // |header_viewport_|. | 163 // |header_viewport_|. |
| 172 View* header_; | 164 View* header_; |
| 173 View* header_viewport_; | 165 View* header_viewport_; |
| 174 | 166 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 187 int max_height_; | 179 int max_height_; |
| 188 | 180 |
| 189 // The background color given to the viewport (for overscroll), and to the | 181 // The background color given to the viewport (for overscroll), and to the |
| 190 // contents when scrolling with layers. | 182 // contents when scrolling with layers. |
| 191 SkColor background_color_; | 183 SkColor background_color_; |
| 192 | 184 |
| 193 // 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 |
| 194 // than the viewport). | 186 // than the viewport). |
| 195 bool hide_horizontal_scrollbar_; | 187 bool hide_horizontal_scrollbar_; |
| 196 | 188 |
| 197 // In Harmony, the indicator is a focus ring. Pre-Harmony, the indicator is a | |
| 198 // different border painter. | |
| 199 bool draw_focus_indicator_ = false; | |
| 200 | |
| 201 // Only needed for pre-Harmony. Remove when Harmony is default. | |
| 202 bool draw_border_ = false; | |
| 203 | |
| 204 // Focus ring, if one is installed. | 189 // Focus ring, if one is installed. |
| 205 View* focus_ring_ = nullptr; | 190 View* focus_ring_ = nullptr; |
| 206 | 191 |
| 207 DISALLOW_COPY_AND_ASSIGN(ScrollView); | 192 DISALLOW_COPY_AND_ASSIGN(ScrollView); |
| 208 }; | 193 }; |
| 209 | 194 |
| 210 // VariableRowHeightScrollHelper is intended for views that contain rows of | 195 // VariableRowHeightScrollHelper is intended for views that contain rows of |
| 211 // varying height. To use a VariableRowHeightScrollHelper create one supplying | 196 // varying height. To use a VariableRowHeightScrollHelper create one supplying |
| 212 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement | 197 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement |
| 213 // to the helper. VariableRowHeightScrollHelper calls back to the | 198 // to the helper. VariableRowHeightScrollHelper calls back to the |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 private: | 258 private: |
| 274 int top_margin_; | 259 int top_margin_; |
| 275 int row_height_; | 260 int row_height_; |
| 276 | 261 |
| 277 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); | 262 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); |
| 278 }; | 263 }; |
| 279 | 264 |
| 280 } // namespace views | 265 } // namespace views |
| 281 | 266 |
| 282 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ | 267 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ |
| OLD | NEW |