| OLD | NEW |
| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 return gfx::ToEnclosingRect(views_vis_bounds); | 415 return gfx::ToEnclosingRect(views_vis_bounds); |
| 416 } | 416 } |
| 417 | 417 |
| 418 gfx::Rect View::GetBoundsInScreen() const { | 418 gfx::Rect View::GetBoundsInScreen() const { |
| 419 gfx::Point origin; | 419 gfx::Point origin; |
| 420 View::ConvertPointToScreen(this, &origin); | 420 View::ConvertPointToScreen(this, &origin); |
| 421 return gfx::Rect(origin, size()); | 421 return gfx::Rect(origin, size()); |
| 422 } | 422 } |
| 423 | 423 |
| 424 gfx::Size View::GetPreferredSize() const { | 424 gfx::Size View::GetPreferredSize() const { |
| 425 if (preferred_size_) |
| 426 return *preferred_size_; |
| 425 if (layout_manager_.get()) | 427 if (layout_manager_.get()) |
| 426 return layout_manager_->GetPreferredSize(this); | 428 return layout_manager_->GetPreferredSize(this); |
| 427 return gfx::Size(); | 429 return CalculatePreferredSize(); |
| 428 } | 430 } |
| 429 | 431 |
| 430 int View::GetBaseline() const { | 432 int View::GetBaseline() const { |
| 431 return -1; | 433 return -1; |
| 432 } | 434 } |
| 433 | 435 |
| 434 void View::SizeToPreferredSize() { | 436 void View::SizeToPreferredSize() { |
| 435 gfx::Size prefsize = GetPreferredSize(); | 437 gfx::Size prefsize = GetPreferredSize(); |
| 436 if ((prefsize.width() != width()) || (prefsize.height() != height())) | 438 if ((prefsize.width() != width()) || (prefsize.height() != height())) |
| 437 SetBounds(x(), y(), prefsize.width(), prefsize.height()); | 439 SetBounds(x(), y(), prefsize.width(), prefsize.height()); |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 | 1472 |
| 1471 bool View::HasObserver(const ViewObserver* observer) const { | 1473 bool View::HasObserver(const ViewObserver* observer) const { |
| 1472 return observers_.HasObserver(observer); | 1474 return observers_.HasObserver(observer); |
| 1473 } | 1475 } |
| 1474 | 1476 |
| 1475 //////////////////////////////////////////////////////////////////////////////// | 1477 //////////////////////////////////////////////////////////////////////////////// |
| 1476 // View, protected: | 1478 // View, protected: |
| 1477 | 1479 |
| 1478 // Size and disposition -------------------------------------------------------- | 1480 // Size and disposition -------------------------------------------------------- |
| 1479 | 1481 |
| 1482 gfx::Size View::CalculatePreferredSize() const { |
| 1483 return gfx::Size(); |
| 1484 } |
| 1485 |
| 1480 void View::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1486 void View::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1481 } | 1487 } |
| 1482 | 1488 |
| 1483 void View::PreferredSizeChanged() { | 1489 void View::PreferredSizeChanged() { |
| 1484 InvalidateLayout(); | 1490 InvalidateLayout(); |
| 1485 if (parent_) | 1491 if (parent_) |
| 1486 parent_->ChildPreferredSizeChanged(this); | 1492 parent_->ChildPreferredSizeChanged(this); |
| 1487 } | 1493 } |
| 1488 | 1494 |
| 1489 bool View::GetNeedsNotificationWhenVisibleBoundsChange() const { | 1495 bool View::GetNeedsNotificationWhenVisibleBoundsChange() const { |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2664 // Message the RootView to do the drag and drop. That way if we're removed | 2670 // Message the RootView to do the drag and drop. That way if we're removed |
| 2665 // the RootView can detect it and avoid calling us back. | 2671 // the RootView can detect it and avoid calling us back. |
| 2666 gfx::Point widget_location(event.location()); | 2672 gfx::Point widget_location(event.location()); |
| 2667 ConvertPointToWidget(this, &widget_location); | 2673 ConvertPointToWidget(this, &widget_location); |
| 2668 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2674 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2669 // WARNING: we may have been deleted. | 2675 // WARNING: we may have been deleted. |
| 2670 return true; | 2676 return true; |
| 2671 } | 2677 } |
| 2672 | 2678 |
| 2673 } // namespace views | 2679 } // namespace views |
| OLD | NEW |