| 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 #include "ui/views/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 border_->GetInsets(&insets); | 318 border_->GetInsets(&insets); |
| 319 return insets; | 319 return insets; |
| 320 } | 320 } |
| 321 | 321 |
| 322 gfx::Rect View::GetVisibleBounds() const { | 322 gfx::Rect View::GetVisibleBounds() const { |
| 323 if (!IsDrawn()) | 323 if (!IsDrawn()) |
| 324 return gfx::Rect(); | 324 return gfx::Rect(); |
| 325 gfx::Rect vis_bounds(GetLocalBounds()); | 325 gfx::Rect vis_bounds(GetLocalBounds()); |
| 326 gfx::Rect ancestor_bounds; | 326 gfx::Rect ancestor_bounds; |
| 327 const View* view = this; | 327 const View* view = this; |
| 328 ui::Transform transform; | 328 gfx::Transform transform; |
| 329 | 329 |
| 330 while (view != NULL && !vis_bounds.IsEmpty()) { | 330 while (view != NULL && !vis_bounds.IsEmpty()) { |
| 331 transform.ConcatTransform(view->GetTransform()); | 331 transform.ConcatTransform(view->GetTransform()); |
| 332 transform.ConcatTranslate(static_cast<float>(view->GetMirroredX()), | 332 transform.ConcatTranslate(static_cast<float>(view->GetMirroredX()), |
| 333 static_cast<float>(view->y())); | 333 static_cast<float>(view->y())); |
| 334 | 334 |
| 335 vis_bounds = view->ConvertRectToParent(vis_bounds); | 335 vis_bounds = view->ConvertRectToParent(vis_bounds); |
| 336 const View* ancestor = view->parent_; | 336 const View* ancestor = view->parent_; |
| 337 if (ancestor != NULL) { | 337 if (ancestor != NULL) { |
| 338 ancestor_bounds.SetRect(0, 0, ancestor->width(), ancestor->height()); | 338 ancestor_bounds.SetRect(0, 0, ancestor->width(), ancestor->height()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 OnEnabledChanged(); | 419 OnEnabledChanged(); |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 void View::OnEnabledChanged() { | 423 void View::OnEnabledChanged() { |
| 424 SchedulePaint(); | 424 SchedulePaint(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 // Transformations ------------------------------------------------------------- | 427 // Transformations ------------------------------------------------------------- |
| 428 | 428 |
| 429 const ui::Transform& View::GetTransform() const { | 429 const gfx::Transform& View::GetTransform() const { |
| 430 static const ui::Transform* no_op = new ui::Transform; | 430 static const gfx::Transform* no_op = new gfx::Transform; |
| 431 return layer() ? layer()->transform() : *no_op; | 431 return layer() ? layer()->transform() : *no_op; |
| 432 } | 432 } |
| 433 | 433 |
| 434 void View::SetTransform(const ui::Transform& transform) { | 434 void View::SetTransform(const gfx::Transform& transform) { |
| 435 if (!transform.HasChange()) { | 435 if (!transform.HasChange()) { |
| 436 if (layer()) { | 436 if (layer()) { |
| 437 layer()->SetTransform(transform); | 437 layer()->SetTransform(transform); |
| 438 if (!paint_to_layer_) | 438 if (!paint_to_layer_) |
| 439 DestroyLayer(); | 439 DestroyLayer(); |
| 440 } else { | 440 } else { |
| 441 // Nothing. | 441 // Nothing. |
| 442 } | 442 } |
| 443 } else { | 443 } else { |
| 444 if (!layer()) | 444 if (!layer()) |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 descendants_to_notify_.reset(); | 1758 descendants_to_notify_.reset(); |
| 1759 } | 1759 } |
| 1760 | 1760 |
| 1761 void View::SetLayerBounds(const gfx::Rect& bounds) { | 1761 void View::SetLayerBounds(const gfx::Rect& bounds) { |
| 1762 layer()->SetBounds(bounds); | 1762 layer()->SetBounds(bounds); |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 // Transformations ------------------------------------------------------------- | 1765 // Transformations ------------------------------------------------------------- |
| 1766 | 1766 |
| 1767 bool View::GetTransformRelativeTo(const View* ancestor, | 1767 bool View::GetTransformRelativeTo(const View* ancestor, |
| 1768 ui::Transform* transform) const { | 1768 gfx::Transform* transform) const { |
| 1769 const View* p = this; | 1769 const View* p = this; |
| 1770 | 1770 |
| 1771 while (p && p != ancestor) { | 1771 while (p && p != ancestor) { |
| 1772 transform->ConcatTransform(p->GetTransform()); | 1772 transform->ConcatTransform(p->GetTransform()); |
| 1773 transform->ConcatTranslate(static_cast<float>(p->GetMirroredX()), | 1773 transform->ConcatTranslate(static_cast<float>(p->GetMirroredX()), |
| 1774 static_cast<float>(p->y())); | 1774 static_cast<float>(p->y())); |
| 1775 | 1775 |
| 1776 p = p->parent_; | 1776 p = p->parent_; |
| 1777 } | 1777 } |
| 1778 | 1778 |
| 1779 return p == ancestor; | 1779 return p == ancestor; |
| 1780 } | 1780 } |
| 1781 | 1781 |
| 1782 // Coordinate conversion ------------------------------------------------------- | 1782 // Coordinate conversion ------------------------------------------------------- |
| 1783 | 1783 |
| 1784 bool View::ConvertPointForAncestor(const View* ancestor, | 1784 bool View::ConvertPointForAncestor(const View* ancestor, |
| 1785 gfx::Point* point) const { | 1785 gfx::Point* point) const { |
| 1786 ui::Transform trans; | 1786 gfx::Transform trans; |
| 1787 // TODO(sad): Have some way of caching the transformation results. | 1787 // TODO(sad): Have some way of caching the transformation results. |
| 1788 bool result = GetTransformRelativeTo(ancestor, &trans); | 1788 bool result = GetTransformRelativeTo(ancestor, &trans); |
| 1789 gfx::Point3f p(*point); | 1789 gfx::Point3f p(*point); |
| 1790 trans.TransformPoint(p); | 1790 trans.TransformPoint(p); |
| 1791 *point = p.AsPoint(); | 1791 *point = p.AsPoint(); |
| 1792 return result; | 1792 return result; |
| 1793 } | 1793 } |
| 1794 | 1794 |
| 1795 bool View::ConvertPointFromAncestor(const View* ancestor, | 1795 bool View::ConvertPointFromAncestor(const View* ancestor, |
| 1796 gfx::Point* point) const { | 1796 gfx::Point* point) const { |
| 1797 ui::Transform trans; | 1797 gfx::Transform trans; |
| 1798 bool result = GetTransformRelativeTo(ancestor, &trans); | 1798 bool result = GetTransformRelativeTo(ancestor, &trans); |
| 1799 gfx::Point3f p(*point); | 1799 gfx::Point3f p(*point); |
| 1800 trans.TransformPointReverse(p); | 1800 trans.TransformPointReverse(p); |
| 1801 *point = p.AsPoint(); | 1801 *point = p.AsPoint(); |
| 1802 return result; | 1802 return result; |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 // Accelerated painting -------------------------------------------------------- | 1805 // Accelerated painting -------------------------------------------------------- |
| 1806 | 1806 |
| 1807 void View::CreateLayer() { | 1807 void View::CreateLayer() { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 gfx::Point widget_location(event.location()); | 2122 gfx::Point widget_location(event.location()); |
| 2123 ConvertPointToWidget(this, &widget_location); | 2123 ConvertPointToWidget(this, &widget_location); |
| 2124 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2124 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); |
| 2125 return true; | 2125 return true; |
| 2126 #else | 2126 #else |
| 2127 return false; | 2127 return false; |
| 2128 #endif // !defined(OS_MACOSX) | 2128 #endif // !defined(OS_MACOSX) |
| 2129 } | 2129 } |
| 2130 | 2130 |
| 2131 } // namespace views | 2131 } // namespace views |
| OLD | NEW |