OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/common/system/tray/fixed_sized_scroll_view.h" | 5 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
8 | 8 |
9 namespace ash { | 9 namespace ash { |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void FixedSizedScrollView::Layout() { | 55 void FixedSizedScrollView::Layout() { |
56 if (UseMd()) | 56 if (UseMd()) |
57 return views::ScrollView::Layout(); | 57 return views::ScrollView::Layout(); |
58 | 58 |
59 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); | 59 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); |
60 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth())); | 60 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth())); |
61 // Keep the origin of the contents unchanged so that the list will not scroll | 61 // Keep the origin of the contents unchanged so that the list will not scroll |
62 // away from the current visible region user is viewing. ScrollView::Layout() | 62 // away from the current visible region user is viewing. ScrollView::Layout() |
63 // will make sure the contents line up with its viewport properly if | 63 // will make sure the contents line up with its viewport properly if |
64 // the contents moves out of the viewport region. | 64 // the contents moves out of the viewport region. |
65 bounds.set_origin(contents()->bounds().origin()); | 65 bounds.set_origin(contents()->origin()); |
66 contents()->SetBoundsRect(bounds); | 66 contents()->SetBoundsRect(bounds); |
67 | 67 |
68 views::ScrollView::Layout(); | 68 views::ScrollView::Layout(); |
69 if (!vertical_scroll_bar()->visible()) { | 69 if (!vertical_scroll_bar()->visible()) { |
70 gfx::Rect bounds = contents()->bounds(); | 70 gfx::Rect bounds = contents()->bounds(); |
71 bounds.set_width(bounds.width() + GetScrollBarLayoutWidth()); | 71 bounds.set_width(bounds.width() + GetScrollBarLayoutWidth()); |
72 contents()->SetBoundsRect(bounds); | 72 contents()->SetBoundsRect(bounds); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 76 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
77 if (UseMd()) | 77 if (UseMd()) |
78 return; | 78 return; |
79 | 79 |
80 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); | 80 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); |
81 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth())); | 81 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth())); |
82 contents()->SetBoundsRect(bounds); | 82 contents()->SetBoundsRect(bounds); |
83 } | 83 } |
84 | 84 |
85 } // namespace ash | 85 } // namespace ash |
OLD | NEW |