| 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 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" | |
| 9 | 8 |
| 10 namespace ash { | 9 namespace ash { |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 | 12 |
| 14 bool UseMd() { | 13 bool UseMd() { |
| 15 return MaterialDesignController::IsSystemTrayMenuMaterial(); | 14 return MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 16 } | 15 } |
| 17 | 16 |
| 18 } // namespace | 17 } // namespace |
| 19 | 18 |
| 20 FixedSizedScrollView::FixedSizedScrollView() { | 19 FixedSizedScrollView::FixedSizedScrollView() { |
| 21 set_notify_enter_exit_on_child(true); | 20 set_notify_enter_exit_on_child(true); |
| 22 if (UseMd()) { | |
| 23 SetVerticalScrollBar(new views::OverlayScrollBar(false)); | |
| 24 SetHorizontalScrollBar(new views::OverlayScrollBar(true)); | |
| 25 } | |
| 26 } | 21 } |
| 27 | 22 |
| 28 FixedSizedScrollView::~FixedSizedScrollView() {} | 23 FixedSizedScrollView::~FixedSizedScrollView() {} |
| 29 | 24 |
| 30 void FixedSizedScrollView::SetContentsView(views::View* view) { | 25 void FixedSizedScrollView::SetContentsView(views::View* view) { |
| 31 SetContents(view); | 26 SetContents(view); |
| 32 if (!UseMd()) | 27 if (!UseMd()) |
| 33 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize())); | 28 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize())); |
| 34 } | 29 } |
| 35 | 30 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 76 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 82 if (UseMd()) | 77 if (UseMd()) |
| 83 return; | 78 return; |
| 84 | 79 |
| 85 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); | 80 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); |
| 86 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth())); | 81 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth())); |
| 87 contents()->SetBoundsRect(bounds); | 82 contents()->SetBoundsRect(bounds); |
| 88 } | 83 } |
| 89 | 84 |
| 90 } // namespace ash | 85 } // namespace ash |
| OLD | NEW |