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

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

Issue 10384178: ash: Make sure all the sub-popups retain the same height as the main popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/tray_details_view.h ('k') | ash/system/tray/tray_item_more.cc » ('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 (c) 2012 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/tray_details_view.h"
6
7 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_views.h"
9 #include "ui/views/background.h"
10 #include "ui/views/controls/scroll_view.h"
11 #include "ui/views/layout/box_layout.h"
12 #include "ui/views/layout/grid_layout.h"
13
14 namespace ash {
15 namespace internal {
16
17 TrayDetailsView::TrayDetailsView()
18 : footer_(NULL),
19 scroller_(NULL),
20 scroll_content_(NULL) {
21 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
22 0, 0, 0));
23 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
24 }
25
26 TrayDetailsView::~TrayDetailsView() {
27 }
28
29 void TrayDetailsView::CreateSpecialRow(int string_id,
30 ViewClickListener* listener) {
31 DCHECK(!footer_);
32 footer_ = new SpecialPopupRow();
33 footer_->SetTextLabel(string_id, listener);
34 AddChildViewAt(footer_, child_count());
35 }
36
37 void TrayDetailsView::CreateScrollableList() {
38 DCHECK(!scroller_);
39 scroll_content_ = new views::View;
40 scroll_content_->SetLayoutManager(new views::BoxLayout(
41 views::BoxLayout::kVertical, 0, 0, 1));
42 scroller_ = new FixedSizedScrollView;
43 scroller_->SetContentsView(scroll_content_);
44 AddChildView(scroller_);
45 }
46
47 void TrayDetailsView::Reset() {
48 RemoveAllChildViews(true);
49 footer_ = NULL;
50 scroller_ = NULL;
51 scroll_content_ = NULL;
52 }
53
54 void TrayDetailsView::Layout() {
55 if (!scroller_ || !footer_ || bounds().IsEmpty()) {
56 views::View::Layout();
57 return;
58 }
59
60 scroller_->set_fixed_size(gfx::Size());
61 gfx::Size size = GetPreferredSize();
62 if (size.height() < height()) {
63 // The available size is larger than the requested size. In this case, do
64 // the normal layout, then make sure the footer element is bottom aligned.
65 views::View::Layout();
66 gfx::Rect fbounds = footer_->bounds();
67 fbounds.set_y(height() - footer_->height());
68 footer_->SetBoundsRect(fbounds);
69 } else {
70 // The available size is smaller than the requested size. Squeeze the
71 // scroller so that everything fits in the available size, and then do the
72 // normal layout.
73 gfx::Size scroller_size = scroll_content_->GetPreferredSize();
74 scroller_->set_fixed_size(gfx::Size(
75 width() + scroller_->GetScrollBarWidth(),
76 scroller_size.height() - (size.height() - height())));
77 views::View::Layout();
78 }
79 }
80
81 } // namespace internal
82 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_details_view.h ('k') | ash/system/tray/tray_item_more.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698