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

Side by Side Diff: views/layout/center_layout.cc

Issue 7610011: Update Sad Tab help text and link. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix message centering. Created 9 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "views/layout/center_layout.h"
6
7 #include "base/logging.h"
8
9 namespace views {
10
11 ////////////////////////////////////////////////////////////////////////////////
12 // CenterLayout, public:
13
14 CenterLayout::CenterLayout() {
15 }
16
17 CenterLayout::~CenterLayout() {
18 }
19
20 ////////////////////////////////////////////////////////////////////////////////
21 // CenterLayout, LayoutManager implementation:
22
23 void CenterLayout::Layout(View* host) {
24 if (!host->has_children())
25 return;
26
27 DCHECK_EQ(1, host->child_count());
28 View* child = host->child_at(0);
29 gfx::Size size(child->GetPreferredSize());
30 gfx::Rect child_area(host->GetLocalBounds());
31 child_area.Inset(host->GetInsets());
32 size.set_width(std::min(size.width(), child_area.width()));
33 int child_height = child->GetHeightForWidth(size.width());
34 size.set_height(std::min(child_height, child_area.height()));
35 gfx::Point origin((child_area.width() - size.width()) / 2,
36 (child_area.height() - size.height()) / 2);
37 child->SetBoundsRect(gfx::Rect(origin, size));
38 }
39
40 gfx::Size CenterLayout::GetPreferredSize(View* host) {
41 if (!host->has_children())
42 return gfx::Size();
43
44 DCHECK_EQ(1, host->child_count());
45 return host->child_at(0)->GetPreferredSize();
46 }
47
48 int CenterLayout::GetPreferredHeightForWidth(View* host, int width) {
49 if (!host->has_children())
50 LayoutManager::GetPreferredHeightForWidth(host, width);
51
52 DCHECK_EQ(1, host->child_count());
53 return host->child_at(0)->GetHeightForWidth(width);
54 }
55
56 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698