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

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

Issue 2066583004: mash: Move most files in //ash/system/tray to //ash/common/system/tray (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trayupdatemove
Patch Set: rebase Created 4 years, 6 months 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
« no previous file with comments | « ash/system/tray/fixed_sized_scroll_view.h ('k') | ash/system/tray/hover_highlight_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/system/tray/fixed_sized_scroll_view.h"
6
7 namespace ash {
8
9 FixedSizedScrollView::FixedSizedScrollView() {
10 set_notify_enter_exit_on_child(true);
11 }
12
13 FixedSizedScrollView::~FixedSizedScrollView() {
14 }
15
16 void FixedSizedScrollView::SetContentsView(views::View* view) {
17 SetContents(view);
18 view->SetBoundsRect(gfx::Rect(view->GetPreferredSize()));
19 }
20
21 void FixedSizedScrollView::SetFixedSize(const gfx::Size& size) {
22 if (fixed_size_ == size)
23 return;
24 fixed_size_ = size;
25 PreferredSizeChanged();
26 }
27
28 gfx::Size FixedSizedScrollView::GetPreferredSize() const {
29 gfx::Size size = fixed_size_.IsEmpty() ?
30 contents()->GetPreferredSize() : fixed_size_;
31 gfx::Insets insets = GetInsets();
32 size.Enlarge(insets.width(), insets.height());
33 return size;
34 }
35
36 void FixedSizedScrollView::Layout() {
37 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize());
38 bounds.set_width(std::max(0, width() - GetScrollBarWidth()));
39 // Keep the origin of the contents unchanged so that the list will not scroll
40 // away from the current visible region user is viewing. ScrollView::Layout()
41 // will make sure the contents line up with its viewport properly if
42 // the contents moves out of the viewport region.
43 bounds.set_origin(contents()->bounds().origin());
44 contents()->SetBoundsRect(bounds);
45
46 views::ScrollView::Layout();
47 if (!vertical_scroll_bar()->visible()) {
48 gfx::Rect bounds = contents()->bounds();
49 bounds.set_width(bounds.width() + GetScrollBarWidth());
50 contents()->SetBoundsRect(bounds);
51 }
52 }
53
54 void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
55 gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize());
56 bounds.set_width(std::max(0, width() - GetScrollBarWidth()));
57 contents()->SetBoundsRect(bounds);
58 }
59
60 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/fixed_sized_scroll_view.h ('k') | ash/system/tray/hover_highlight_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698