| 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 if (source != root) | 616 if (source != root) |
| 617 source->ConvertPointForAncestor(root, point); | 617 source->ConvertPointForAncestor(root, point); |
| 618 } | 618 } |
| 619 | 619 |
| 620 if (target != root) | 620 if (target != root) |
| 621 target->ConvertPointFromAncestor(root, point); | 621 target->ConvertPointFromAncestor(root, point); |
| 622 | 622 |
| 623 // API defines NULL |source| as returning the point in screen coordinates. | 623 // API defines NULL |source| as returning the point in screen coordinates. |
| 624 if (!source) { | 624 if (!source) { |
| 625 *point = point->Subtract( | 625 *point = point->Subtract( |
| 626 root->GetWidget()->GetClientAreaBoundsInScreen().origin()); | 626 root->GetWidget()->GetClientAreaBoundsInScreen().DistanceFromOrigin()); |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 | 629 |
| 630 // static | 630 // static |
| 631 void View::ConvertPointToWidget(const View* src, gfx::Point* p) { | 631 void View::ConvertPointToWidget(const View* src, gfx::Point* p) { |
| 632 DCHECK(src); | 632 DCHECK(src); |
| 633 DCHECK(p); | 633 DCHECK(p); |
| 634 | 634 |
| 635 src->ConvertPointForAncestor(NULL, p); | 635 src->ConvertPointForAncestor(NULL, p); |
| 636 } | 636 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 666 if (!widget) | 666 if (!widget) |
| 667 return; | 667 return; |
| 668 const gfx::Rect r = widget->GetClientAreaBoundsInScreen(); | 668 const gfx::Rect r = widget->GetClientAreaBoundsInScreen(); |
| 669 p->Offset(-r.x(), -r.y()); | 669 p->Offset(-r.x(), -r.y()); |
| 670 views::View::ConvertPointFromWidget(dst, p); | 670 views::View::ConvertPointFromWidget(dst, p); |
| 671 } | 671 } |
| 672 | 672 |
| 673 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { | 673 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { |
| 674 gfx::Rect x_rect = rect; | 674 gfx::Rect x_rect = rect; |
| 675 GetTransform().TransformRect(&x_rect); | 675 GetTransform().TransformRect(&x_rect); |
| 676 x_rect.Offset(GetMirroredPosition()); | 676 x_rect.Offset(GetMirroredPosition().DistanceFromOrigin()); |
| 677 return x_rect; | 677 return x_rect; |
| 678 } | 678 } |
| 679 | 679 |
| 680 gfx::Rect View::ConvertRectToWidget(const gfx::Rect& rect) const { | 680 gfx::Rect View::ConvertRectToWidget(const gfx::Rect& rect) const { |
| 681 gfx::Rect x_rect = rect; | 681 gfx::Rect x_rect = rect; |
| 682 for (const View* v = this; v; v = v->parent_) | 682 for (const View* v = this; v; v = v->parent_) |
| 683 x_rect = v->ConvertRectToParent(x_rect); | 683 x_rect = v->ConvertRectToParent(x_rect); |
| 684 return x_rect; | 684 return x_rect; |
| 685 } | 685 } |
| 686 | 686 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 717 // we paint our view in its mirrored position if need be. | 717 // we paint our view in its mirrored position if need be. |
| 718 gfx::Rect clip_rect = bounds(); | 718 gfx::Rect clip_rect = bounds(); |
| 719 clip_rect.Inset(clip_insets_); | 719 clip_rect.Inset(clip_insets_); |
| 720 if (parent_) | 720 if (parent_) |
| 721 clip_rect.set_x(parent_->GetMirroredXForRect(clip_rect)); | 721 clip_rect.set_x(parent_->GetMirroredXForRect(clip_rect)); |
| 722 if (!canvas->ClipRect(clip_rect)) | 722 if (!canvas->ClipRect(clip_rect)) |
| 723 return; | 723 return; |
| 724 | 724 |
| 725 // Non-empty clip, translate the graphics such that 0,0 corresponds to | 725 // Non-empty clip, translate the graphics such that 0,0 corresponds to |
| 726 // where this view is located (related to its parent). | 726 // where this view is located (related to its parent). |
| 727 canvas->Translate(GetMirroredPosition()); | 727 canvas->Translate(GetMirroredPosition().DistanceFromOrigin()); |
| 728 canvas->Transform(GetTransform()); | 728 canvas->Transform(GetTransform()); |
| 729 | 729 |
| 730 PaintCommon(canvas); | 730 PaintCommon(canvas); |
| 731 } | 731 } |
| 732 | 732 |
| 733 ui::ThemeProvider* View::GetThemeProvider() const { | 733 ui::ThemeProvider* View::GetThemeProvider() const { |
| 734 const Widget* widget = GetWidget(); | 734 const Widget* widget = GetWidget(); |
| 735 return widget ? widget->GetThemeProvider() : NULL; | 735 return widget ? widget->GetThemeProvider() : NULL; |
| 736 } | 736 } |
| 737 | 737 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 return; | 1519 return; |
| 1520 | 1520 |
| 1521 { | 1521 { |
| 1522 // If the View we are about to paint requested the canvas to be flipped, we | 1522 // If the View we are about to paint requested the canvas to be flipped, we |
| 1523 // should change the transform appropriately. | 1523 // should change the transform appropriately. |
| 1524 // The canvas mirroring is undone once the View is done painting so that we | 1524 // The canvas mirroring is undone once the View is done painting so that we |
| 1525 // don't pass the canvas with the mirrored transform to Views that didn't | 1525 // don't pass the canvas with the mirrored transform to Views that didn't |
| 1526 // request the canvas to be flipped. | 1526 // request the canvas to be flipped. |
| 1527 ScopedCanvas scoped(canvas); | 1527 ScopedCanvas scoped(canvas); |
| 1528 if (FlipCanvasOnPaintForRTLUI()) { | 1528 if (FlipCanvasOnPaintForRTLUI()) { |
| 1529 canvas->Translate(gfx::Point(width(), 0)); | 1529 canvas->Translate(gfx::Vector2d(width(), 0)); |
| 1530 canvas->Scale(-1, 1); | 1530 canvas->Scale(-1, 1); |
| 1531 } | 1531 } |
| 1532 | 1532 |
| 1533 OnPaint(canvas); | 1533 OnPaint(canvas); |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 PaintChildren(canvas); | 1536 PaintChildren(canvas); |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 // Tree operations ------------------------------------------------------------- | 1539 // Tree operations ------------------------------------------------------------- |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 gfx::Point widget_location(event.location()); | 2128 gfx::Point widget_location(event.location()); |
| 2129 ConvertPointToWidget(this, &widget_location); | 2129 ConvertPointToWidget(this, &widget_location); |
| 2130 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2130 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); |
| 2131 return true; | 2131 return true; |
| 2132 #else | 2132 #else |
| 2133 return false; | 2133 return false; |
| 2134 #endif // !defined(OS_MACOSX) | 2134 #endif // !defined(OS_MACOSX) |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 } // namespace views | 2137 } // namespace views |
| OLD | NEW |