Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: ash/common/system/tray/fixed_sized_scroll_view.cc

Issue 2555213004: Improving the appearance of overlay scrollbars (Closed)
Patch Set: attempt to fix mac Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 8 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
9 9
10 namespace ash { 10 namespace ash {
11 11
12 namespace { 12 namespace {
13 13
14 bool UseMd() { 14 bool UseMd() {
15 return MaterialDesignController::IsSystemTrayMenuMaterial(); 15 return MaterialDesignController::IsSystemTrayMenuMaterial();
16 } 16 }
17 17
18 } // namespace 18 } // namespace
19 19
20 FixedSizedScrollView::FixedSizedScrollView() { 20 FixedSizedScrollView::FixedSizedScrollView() {
21 set_notify_enter_exit_on_child(true); 21 set_notify_enter_exit_on_child(true);
22 if (UseMd()) 22 if (UseMd()) {
23 SetVerticalScrollBar(new views::OverlayScrollBar(false)); 23 SetVerticalScrollBar(new views::OverlayScrollBar(false));
24 SetHorizontalScrollBar(new views::OverlayScrollBar(true));
25 }
24 } 26 }
25 27
26 FixedSizedScrollView::~FixedSizedScrollView() {} 28 FixedSizedScrollView::~FixedSizedScrollView() {}
27 29
28 void FixedSizedScrollView::SetContentsView(views::View* view) { 30 void FixedSizedScrollView::SetContentsView(views::View* view) {
29 SetContents(view); 31 SetContents(view);
30 if (!UseMd()) 32 if (!UseMd())
31 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize())); 33 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize()));
32 } 34 }
33 35
(...skipping 19 matching lines...) Expand all
53 gfx::Insets insets = GetInsets(); 55 gfx::Insets insets = GetInsets();
54 size.Enlarge(insets.width(), insets.height()); 56 size.Enlarge(insets.width(), insets.height());
55 return size; 57 return size;
56 } 58 }
57 59
58 void FixedSizedScrollView::Layout() { 60 void FixedSizedScrollView::Layout() {
59 if (UseMd()) 61 if (UseMd())
60 return views::ScrollView::Layout(); 62 return views::ScrollView::Layout();
61 63
62 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); 64 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize());
63 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); 65 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth()));
64 // Keep the origin of the contents unchanged so that the list will not scroll 66 // Keep the origin of the contents unchanged so that the list will not scroll
65 // away from the current visible region user is viewing. ScrollView::Layout() 67 // away from the current visible region user is viewing. ScrollView::Layout()
66 // will make sure the contents line up with its viewport properly if 68 // will make sure the contents line up with its viewport properly if
67 // the contents moves out of the viewport region. 69 // the contents moves out of the viewport region.
68 bounds.set_origin(contents()->bounds().origin()); 70 bounds.set_origin(contents()->bounds().origin());
69 contents()->SetBoundsRect(bounds); 71 contents()->SetBoundsRect(bounds);
70 72
71 views::ScrollView::Layout(); 73 views::ScrollView::Layout();
72 if (!vertical_scroll_bar()->visible()) { 74 if (!vertical_scroll_bar()->visible()) {
73 gfx::Rect bounds = contents()->bounds(); 75 gfx::Rect bounds = contents()->bounds();
74 bounds.set_width(bounds.width() + GetScrollBarWidth()); 76 bounds.set_width(bounds.width() + GetScrollBarLayoutWidth());
75 contents()->SetBoundsRect(bounds); 77 contents()->SetBoundsRect(bounds);
76 } 78 }
77 } 79 }
78 80
79 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 81 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
80 if (UseMd()) 82 if (UseMd())
81 return; 83 return;
82 84
83 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); 85 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize());
84 bounds.set_width(std::max(0, width() - GetScrollBarWidth())); 86 bounds.set_width(std::max(0, width() - GetScrollBarLayoutWidth()));
85 contents()->SetBoundsRect(bounds); 87 contents()->SetBoundsRect(bounds);
86 } 88 }
87 89
88 } // namespace ash 90 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/tray/tray_details_view.cc » ('j') | ui/views/controls/scroll_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698