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

Side by Side Diff: ui/views/controls/single_split_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 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 | « ui/views/controls/single_split_view.h ('k') | ui/views/controls/single_split_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "ui/views/controls/single_split_view.h" 5 #include "ui/views/controls/single_split_view.h"
6 6
7 #include "skia/ext/skia_utils_win.h" 7 #include "skia/ext/skia_utils_win.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/cursor/cursor.h" 9 #include "ui/base/cursor/cursor.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 const char* SingleSplitView::GetClassName() const { 59 const char* SingleSplitView::GetClassName() const {
60 return kViewClassName; 60 return kViewClassName;
61 } 61 }
62 62
63 void SingleSplitView::GetAccessibleState(ui::AXViewState* state) { 63 void SingleSplitView::GetAccessibleState(ui::AXViewState* state) {
64 state->role = ui::AX_ROLE_GROUP; 64 state->role = ui::AX_ROLE_GROUP;
65 state->name = accessible_name_; 65 state->name = accessible_name_;
66 } 66 }
67 67
68 gfx::Size SingleSplitView::GetPreferredSize() { 68 gfx::Size SingleSplitView::GetPreferredSize() const {
69 int width = 0; 69 int width = 0;
70 int height = 0; 70 int height = 0;
71 for (int i = 0; i < 2 && i < child_count(); ++i) { 71 for (int i = 0; i < 2 && i < child_count(); ++i) {
72 View* view = child_at(i); 72 const View* view = child_at(i);
73 gfx::Size pref = view->GetPreferredSize(); 73 gfx::Size pref = view->GetPreferredSize();
74 if (is_horizontal_) { 74 if (is_horizontal_) {
75 width += pref.width(); 75 width += pref.width();
76 height = std::max(height, pref.height()); 76 height = std::max(height, pref.height());
77 } else { 77 } else {
78 width = std::max(width, pref.width()); 78 width = std::max(width, pref.width());
79 height += pref.height(); 79 height += pref.height();
80 } 80 }
81 } 81 }
82 if (is_horizontal_) 82 if (is_horizontal_)
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 const gfx::Rect& bounds) const { 244 const gfx::Rect& bounds) const {
245 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); 245 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height());
246 if (divider_offset < 0) 246 if (divider_offset < 0)
247 // primary_axis_size may < GetDividerSize during initial layout. 247 // primary_axis_size may < GetDividerSize during initial layout.
248 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); 248 return std::max(0, (primary_axis_size - GetDividerSize()) / 2);
249 return std::min(divider_offset, 249 return std::min(divider_offset,
250 std::max(primary_axis_size - GetDividerSize(), 0)); 250 std::max(primary_axis_size - GetDividerSize(), 0));
251 } 251 }
252 252
253 } // namespace views 253 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/single_split_view.h ('k') | ui/views/controls/single_split_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698