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

Side by Side Diff: ui/views/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/view.h ('k') | ui/views/widget/widget.h » ('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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // Partially visible pixels should be considered visible. 417 // Partially visible pixels should be considered visible.
418 return gfx::ToEnclosingRect(views_vis_bounds); 418 return gfx::ToEnclosingRect(views_vis_bounds);
419 } 419 }
420 420
421 gfx::Rect View::GetBoundsInScreen() const { 421 gfx::Rect View::GetBoundsInScreen() const {
422 gfx::Point origin; 422 gfx::Point origin;
423 View::ConvertPointToScreen(this, &origin); 423 View::ConvertPointToScreen(this, &origin);
424 return gfx::Rect(origin, size()); 424 return gfx::Rect(origin, size());
425 } 425 }
426 426
427 gfx::Size View::GetPreferredSize() { 427 gfx::Size View::GetPreferredSize() const {
428 if (layout_manager_.get()) 428 if (layout_manager_.get())
429 return layout_manager_->GetPreferredSize(this); 429 return layout_manager_->GetPreferredSize(this);
430 return gfx::Size(); 430 return gfx::Size();
431 } 431 }
432 432
433 int View::GetBaseline() const { 433 int View::GetBaseline() const {
434 return -1; 434 return -1;
435 } 435 }
436 436
437 void View::SizeToPreferredSize() { 437 void View::SizeToPreferredSize() {
438 gfx::Size prefsize = GetPreferredSize(); 438 gfx::Size prefsize = GetPreferredSize();
439 if ((prefsize.width() != width()) || (prefsize.height() != height())) 439 if ((prefsize.width() != width()) || (prefsize.height() != height()))
440 SetBounds(x(), y(), prefsize.width(), prefsize.height()); 440 SetBounds(x(), y(), prefsize.width(), prefsize.height());
441 } 441 }
442 442
443 gfx::Size View::GetMinimumSize() { 443 gfx::Size View::GetMinimumSize() const {
444 return GetPreferredSize(); 444 return GetPreferredSize();
445 } 445 }
446 446
447 gfx::Size View::GetMaximumSize() { 447 gfx::Size View::GetMaximumSize() {
448 return gfx::Size(); 448 return gfx::Size();
449 } 449 }
450 450
451 int View::GetHeightForWidth(int w) { 451 int View::GetHeightForWidth(int w) const {
452 if (layout_manager_.get()) 452 if (layout_manager_.get())
453 return layout_manager_->GetPreferredHeightForWidth(this, w); 453 return layout_manager_->GetPreferredHeightForWidth(this, w);
454 return GetPreferredSize().height(); 454 return GetPreferredSize().height();
455 } 455 }
456 456
457 void View::SetVisible(bool visible) { 457 void View::SetVisible(bool visible) {
458 if (visible != visible_) { 458 if (visible != visible_) {
459 // If the View is currently visible, schedule paint to refresh parent. 459 // If the View is currently visible, schedule paint to refresh parent.
460 // TODO(beng): not sure we should be doing this if we have a layer. 460 // TODO(beng): not sure we should be doing this if we have a layer.
461 if (visible_) 461 if (visible_)
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 // Message the RootView to do the drag and drop. That way if we're removed 2535 // Message the RootView to do the drag and drop. That way if we're removed
2536 // the RootView can detect it and avoid calling us back. 2536 // the RootView can detect it and avoid calling us back.
2537 gfx::Point widget_location(event.location()); 2537 gfx::Point widget_location(event.location());
2538 ConvertPointToWidget(this, &widget_location); 2538 ConvertPointToWidget(this, &widget_location);
2539 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2539 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2540 // WARNING: we may have been deleted. 2540 // WARNING: we may have been deleted.
2541 return true; 2541 return true;
2542 } 2542 }
2543 2543
2544 } // namespace views 2544 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698