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 #include "ui/views/controls/scroll_view.h" | 5 #include "ui/views/controls/scroll_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
9 #include "ui/native_theme/native_theme.h" | 9 #include "ui/native_theme/native_theme.h" |
10 #include "ui/views/border.h" | 10 #include "ui/views/border.h" |
11 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 11 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
12 #include "ui/views/widget/root_view.h" | 12 #include "ui/views/widget/root_view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 const char ScrollView::kViewClassName[] = "ScrollView"; | 16 const char ScrollView::kViewClassName[] = "ScrollView"; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Subclass of ScrollView that resets the border when the theme changes. | 20 // Subclass of ScrollView that resets the border when the theme changes. |
21 class ScrollViewWithBorder : public views::ScrollView { | 21 class ScrollViewWithBorder : public views::ScrollView { |
22 public: | 22 public: |
23 ScrollViewWithBorder() { | 23 ScrollViewWithBorder() {} |
24 SetThemeSpecificState(); | |
25 } | |
26 | 24 |
27 // View overrides; | 25 // View overrides; |
28 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE { | 26 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE { |
29 SetThemeSpecificState(); | 27 SetBorder(Border::CreateSolidBorder( |
| 28 1, |
| 29 theme->GetSystemColor(ui::NativeTheme::kColorId_UnfocusedBorderColor))); |
30 } | 30 } |
31 | 31 |
32 private: | 32 private: |
33 void SetThemeSpecificState() { | |
34 SetBorder(Border::CreateSolidBorder( | |
35 1, | |
36 GetNativeTheme()->GetSystemColor( | |
37 ui::NativeTheme::kColorId_UnfocusedBorderColor))); | |
38 } | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(ScrollViewWithBorder); | 33 DISALLOW_COPY_AND_ASSIGN(ScrollViewWithBorder); |
41 }; | 34 }; |
42 | 35 |
43 // Returns the position for the view so that it isn't scrolled off the visible | 36 // Returns the position for the view so that it isn't scrolled off the visible |
44 // region. | 37 // region. |
45 int CheckScrollBounds(int viewport_size, int content_size, int current_pos) { | 38 int CheckScrollBounds(int viewport_size, int content_size, int current_pos) { |
46 int max = std::max(content_size - viewport_size, 0); | 39 int max = std::max(content_size - viewport_size, 0); |
47 if (current_pos < 0) | 40 if (current_pos < 0) |
48 return 0; | 41 return 0; |
49 if (current_pos > max) | 42 if (current_pos > max) |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 621 |
629 VariableRowHeightScrollHelper::RowInfo | 622 VariableRowHeightScrollHelper::RowInfo |
630 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 623 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
631 if (y < top_margin_) | 624 if (y < top_margin_) |
632 return RowInfo(0, top_margin_); | 625 return RowInfo(0, top_margin_); |
633 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 626 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
634 row_height_); | 627 row_height_); |
635 } | 628 } |
636 | 629 |
637 } // namespace views | 630 } // namespace views |
OLD | NEW |